aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs
diff options
context:
space:
mode:
authorSteve French <sfrench@us.ibm.com>2007-06-08 10:55:14 -0400
committerSteve French <sfrench@us.ibm.com>2007-06-08 10:55:14 -0400
commit3ce53fc4c57603d99c330a6ee2fe96d94f2d350f (patch)
tree54a5e999cc6044669139fb5e3a7cc0a1db31e86f /fs/cifs
parent100c1ddc98e070c1b595d6bad329fb57bc57313c (diff)
[CIFS] CIFS should honour umask
This patch makes CIFS honour a process' umask like other filesystems. Of course the server is still free to munge the permissions if it wants to; but the client will send the "right" permissions to begin with. A few caveats: 1) It only applies to filesystems that have CAP_UNIX (aka support unix extensions) 2) It applies the correct mode to the follow up CIFSSMBUnixSetPerms() after remote creation When mode to CIFS/NTFS ACL mapping is complete we can do the same thing for that case for servers which do not support the Unix Extensions. Signed-off-by: Matt Keenen <matt@opcode-solutions.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs')
-rw-r--r--fs/cifs/dir.c6
-rw-r--r--fs/cifs/inode.c5
2 files changed, 7 insertions, 4 deletions
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index f085db965788..8e86aaceb68a 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -208,7 +208,8 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
208 /* If Open reported that we actually created a file 208 /* If Open reported that we actually created a file
209 then we now have to set the mode if possible */ 209 then we now have to set the mode if possible */
210 if ((cifs_sb->tcon->ses->capabilities & CAP_UNIX) && 210 if ((cifs_sb->tcon->ses->capabilities & CAP_UNIX) &&
211 (oplock & CIFS_CREATE_ACTION)) 211 (oplock & CIFS_CREATE_ACTION)) {
212 mode &= ~current->fs->umask;
212 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { 213 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
213 CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode, 214 CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode,
214 (__u64)current->fsuid, 215 (__u64)current->fsuid,
@@ -226,7 +227,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
226 cifs_sb->mnt_cifs_flags & 227 cifs_sb->mnt_cifs_flags &
227 CIFS_MOUNT_MAP_SPECIAL_CHR); 228 CIFS_MOUNT_MAP_SPECIAL_CHR);
228 } 229 }
229 else { 230 } else {
230 /* BB implement mode setting via Windows security 231 /* BB implement mode setting via Windows security
231 descriptors e.g. */ 232 descriptors e.g. */
232 /* CIFSSMBWinSetPerms(xid,pTcon,path,mode,-1,-1,nls);*/ 233 /* CIFSSMBWinSetPerms(xid,pTcon,path,mode,-1,-1,nls);*/
@@ -336,6 +337,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode,
336 if (full_path == NULL) 337 if (full_path == NULL)
337 rc = -ENOMEM; 338 rc = -ENOMEM;
338 else if (pTcon->ses->capabilities & CAP_UNIX) { 339 else if (pTcon->ses->capabilities & CAP_UNIX) {
340 mode &= ~current->fs->umask;
339 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { 341 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
340 rc = CIFSSMBUnixSetPerms(xid, pTcon, full_path, 342 rc = CIFSSMBUnixSetPerms(xid, pTcon, full_path,
341 mode, (__u64)current->fsuid, 343 mode, (__u64)current->fsuid,
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 3e87dad3367c..f0ff12b3f398 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -986,7 +986,8 @@ mkdir_get_info:
986 * failed to get it from the server or was set bogus */ 986 * failed to get it from the server or was set bogus */
987 if ((direntry->d_inode) && (direntry->d_inode->i_nlink < 2)) 987 if ((direntry->d_inode) && (direntry->d_inode->i_nlink < 2))
988 direntry->d_inode->i_nlink = 2; 988 direntry->d_inode->i_nlink = 2;
989 if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) 989 if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) {
990 mode &= ~current->fs->umask;
990 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { 991 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
991 CIFSSMBUnixSetPerms(xid, pTcon, full_path, 992 CIFSSMBUnixSetPerms(xid, pTcon, full_path,
992 mode, 993 mode,
@@ -1004,7 +1005,7 @@ mkdir_get_info:
1004 cifs_sb->mnt_cifs_flags & 1005 cifs_sb->mnt_cifs_flags &
1005 CIFS_MOUNT_MAP_SPECIAL_CHR); 1006 CIFS_MOUNT_MAP_SPECIAL_CHR);
1006 } 1007 }
1007 else { 1008 } else {
1008 /* BB to be implemented via Windows secrty descriptors 1009 /* BB to be implemented via Windows secrty descriptors
1009 eg CIFSSMBWinSetPerms(xid, pTcon, full_path, mode, 1010 eg CIFSSMBWinSetPerms(xid, pTcon, full_path, mode,
1010 -1, -1, local_nls); */ 1011 -1, -1, local_nls); */