diff options
Diffstat (limited to 'fs/cifs/dir.c')
-rw-r--r-- | fs/cifs/dir.c | 67 |
1 files changed, 40 insertions, 27 deletions
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c index fb69c1fa85c9..e962e75e6f7b 100644 --- a/fs/cifs/dir.c +++ b/fs/cifs/dir.c | |||
@@ -226,23 +226,28 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode, | |||
226 | /* If Open reported that we actually created a file | 226 | /* If Open reported that we actually created a file |
227 | then we now have to set the mode if possible */ | 227 | then we now have to set the mode if possible */ |
228 | if ((pTcon->unix_ext) && (oplock & CIFS_CREATE_ACTION)) { | 228 | if ((pTcon->unix_ext) && (oplock & CIFS_CREATE_ACTION)) { |
229 | struct cifs_unix_set_info_args args = { | ||
230 | .mode = mode, | ||
231 | .ctime = NO_CHANGE_64, | ||
232 | .atime = NO_CHANGE_64, | ||
233 | .mtime = NO_CHANGE_64, | ||
234 | .device = 0, | ||
235 | }; | ||
236 | |||
229 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { | 237 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { |
230 | CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode, | 238 | args.uid = (__u64) current->fsuid; |
231 | (__u64)current->fsuid, | 239 | if (inode->i_mode & S_ISGID) |
232 | (__u64)current->fsgid, | 240 | args.gid = (__u64) inode->i_gid; |
233 | 0 /* dev */, | 241 | else |
234 | cifs_sb->local_nls, | 242 | args.gid = (__u64) current->fsgid; |
235 | cifs_sb->mnt_cifs_flags & | ||
236 | CIFS_MOUNT_MAP_SPECIAL_CHR); | ||
237 | } else { | 243 | } else { |
238 | CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode, | 244 | args.uid = NO_CHANGE_64; |
239 | (__u64)-1, | 245 | args.gid = NO_CHANGE_64; |
240 | (__u64)-1, | ||
241 | 0 /* dev */, | ||
242 | cifs_sb->local_nls, | ||
243 | cifs_sb->mnt_cifs_flags & | ||
244 | CIFS_MOUNT_MAP_SPECIAL_CHR); | ||
245 | } | 246 | } |
247 | CIFSSMBUnixSetInfo(xid, pTcon, full_path, &args, | ||
248 | cifs_sb->local_nls, | ||
249 | cifs_sb->mnt_cifs_flags & | ||
250 | CIFS_MOUNT_MAP_SPECIAL_CHR); | ||
246 | } else { | 251 | } else { |
247 | /* BB implement mode setting via Windows security | 252 | /* BB implement mode setting via Windows security |
248 | descriptors e.g. */ | 253 | descriptors e.g. */ |
@@ -267,7 +272,12 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode, | |||
267 | (cifs_sb->mnt_cifs_flags & | 272 | (cifs_sb->mnt_cifs_flags & |
268 | CIFS_MOUNT_SET_UID)) { | 273 | CIFS_MOUNT_SET_UID)) { |
269 | newinode->i_uid = current->fsuid; | 274 | newinode->i_uid = current->fsuid; |
270 | 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; | ||
271 | } | 281 | } |
272 | } | 282 | } |
273 | } | 283 | } |
@@ -357,21 +367,24 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode, | |||
357 | if (full_path == NULL) | 367 | if (full_path == NULL) |
358 | rc = -ENOMEM; | 368 | rc = -ENOMEM; |
359 | else if (pTcon->unix_ext) { | 369 | else if (pTcon->unix_ext) { |
360 | mode &= ~current->fs->umask; | 370 | struct cifs_unix_set_info_args args = { |
371 | .mode = mode & ~current->fs->umask, | ||
372 | .ctime = NO_CHANGE_64, | ||
373 | .atime = NO_CHANGE_64, | ||
374 | .mtime = NO_CHANGE_64, | ||
375 | .device = device_number, | ||
376 | }; | ||
361 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { | 377 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { |
362 | rc = CIFSSMBUnixSetPerms(xid, pTcon, full_path, | 378 | args.uid = (__u64) current->fsuid; |
363 | mode, (__u64)current->fsuid, | 379 | args.gid = (__u64) current->fsgid; |
364 | (__u64)current->fsgid, | ||
365 | device_number, cifs_sb->local_nls, | ||
366 | cifs_sb->mnt_cifs_flags & | ||
367 | CIFS_MOUNT_MAP_SPECIAL_CHR); | ||
368 | } else { | 380 | } else { |
369 | rc = CIFSSMBUnixSetPerms(xid, pTcon, | 381 | args.uid = NO_CHANGE_64; |
370 | full_path, mode, (__u64)-1, (__u64)-1, | 382 | args.gid = NO_CHANGE_64; |
371 | device_number, cifs_sb->local_nls, | ||
372 | cifs_sb->mnt_cifs_flags & | ||
373 | CIFS_MOUNT_MAP_SPECIAL_CHR); | ||
374 | } | 383 | } |
384 | rc = CIFSSMBUnixSetInfo(xid, pTcon, full_path, | ||
385 | &args, cifs_sb->local_nls, | ||
386 | cifs_sb->mnt_cifs_flags & | ||
387 | CIFS_MOUNT_MAP_SPECIAL_CHR); | ||
375 | 388 | ||
376 | if (!rc) { | 389 | if (!rc) { |
377 | rc = cifs_get_inode_info_unix(&newinode, full_path, | 390 | rc = cifs_get_inode_info_unix(&newinode, full_path, |