diff options
author | Jeff Layton <jlayton@redhat.com> | 2008-08-06 00:39:02 -0400 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2008-08-06 00:39:02 -0400 |
commit | 95089910933e10768cfef1ab0bab0c55b962aacb (patch) | |
tree | c80dd73d46196aff3e6c12a12bfb6b6f20aac08c /fs/cifs/dir.c | |
parent | 2dd2dfa060650118661422d4e666ac804c388751 (diff) |
[CIFS] cifs_mkdir and cifs_create should respect the setgid bit on parent dir
If a server supports unix extensions but does not support POSIX create
routines, then the client will create a new inode with a standard SMB
mkdir or create/open call and then will set the mode. When it does this,
it does not take the setgid bit on the parent directory into account.
This patch has CIFS flip on the setgid bit when the parent directory has
it. If the share is mounted with "setuids" then also change the group
owner to the gid of the parent.
This patch should apply cleanly on top of the setattr cleanup patches
that I sent a few weeks ago.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs/dir.c')
-rw-r--r-- | fs/cifs/dir.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c index 634cf330fe04..e962e75e6f7b 100644 --- a/fs/cifs/dir.c +++ b/fs/cifs/dir.c | |||
@@ -236,12 +236,14 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode, | |||
236 | 236 | ||
237 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { | 237 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { |
238 | args.uid = (__u64) current->fsuid; | 238 | args.uid = (__u64) current->fsuid; |
239 | args.gid = (__u64) current->fsgid; | 239 | if (inode->i_mode & S_ISGID) |
240 | args.gid = (__u64) inode->i_gid; | ||
241 | else | ||
242 | args.gid = (__u64) current->fsgid; | ||
240 | } else { | 243 | } else { |
241 | args.uid = NO_CHANGE_64; | 244 | args.uid = NO_CHANGE_64; |
242 | args.gid = NO_CHANGE_64; | 245 | args.gid = NO_CHANGE_64; |
243 | } | 246 | } |
244 | |||
245 | CIFSSMBUnixSetInfo(xid, pTcon, full_path, &args, | 247 | CIFSSMBUnixSetInfo(xid, pTcon, full_path, &args, |
246 | cifs_sb->local_nls, | 248 | cifs_sb->local_nls, |
247 | cifs_sb->mnt_cifs_flags & | 249 | cifs_sb->mnt_cifs_flags & |
@@ -270,7 +272,12 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode, | |||
270 | (cifs_sb->mnt_cifs_flags & | 272 | (cifs_sb->mnt_cifs_flags & |
271 | CIFS_MOUNT_SET_UID)) { | 273 | CIFS_MOUNT_SET_UID)) { |
272 | newinode->i_uid = current->fsuid; | 274 | newinode->i_uid = current->fsuid; |
273 | newinode->i_gid = current->fsgid; | 275 | if (inode->i_mode & S_ISGID) |
276 | newinode->i_gid = | ||
277 | inode->i_gid; | ||
278 | else | ||
279 | newinode->i_gid = | ||
280 | current->fsgid; | ||
274 | } | 281 | } |
275 | } | 282 | } |
276 | } | 283 | } |