]> err.no Git - linux-2.6/commitdiff
[CIFS] CIFS should honour umask
authorSteve French <sfrench@us.ibm.com>
Fri, 8 Jun 2007 14:55:14 +0000 (14:55 +0000)
committerSteve French <sfrench@us.ibm.com>
Fri, 8 Jun 2007 14:55:14 +0000 (14:55 +0000)
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>
fs/cifs/dir.c
fs/cifs/inode.c

index f085db965788dbee306c1dc635c21002ac49bfad..8e86aaceb68a476b1bd349979db176f2c1467032 100644 (file)
@@ -208,7 +208,8 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
                /* If Open reported that we actually created a file
                then we now have to set the mode if possible */
                if ((cifs_sb->tcon->ses->capabilities & CAP_UNIX) &&
-                       (oplock & CIFS_CREATE_ACTION))
+                       (oplock & CIFS_CREATE_ACTION)) {
+                       mode &= ~current->fs->umask;
                        if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
                                CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode,
                                        (__u64)current->fsuid,
@@ -226,7 +227,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
                                        cifs_sb->mnt_cifs_flags &
                                                CIFS_MOUNT_MAP_SPECIAL_CHR);
                        }
-               else {
+               else {
                        /* BB implement mode setting via Windows security
                           descriptors e.g. */
                        /* CIFSSMBWinSetPerms(xid,pTcon,path,mode,-1,-1,nls);*/
@@ -336,6 +337,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode,
        if (full_path == NULL)
                rc = -ENOMEM;
        else if (pTcon->ses->capabilities & CAP_UNIX) {
+               mode &= ~current->fs->umask;
                if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
                        rc = CIFSSMBUnixSetPerms(xid, pTcon, full_path,
                                mode, (__u64)current->fsuid,
index 3e87dad3367c731c626ac951e764fb5277b170e6..f0ff12b3f398fcd09bae2f39934263b803bdb1e1 100644 (file)
@@ -986,7 +986,8 @@ mkdir_get_info:
                  * failed to get it from the server or was set bogus */ 
                if ((direntry->d_inode) && (direntry->d_inode->i_nlink < 2))
                                direntry->d_inode->i_nlink = 2; 
-               if (cifs_sb->tcon->ses->capabilities & CAP_UNIX)
+               if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) {
+                       mode &= ~current->fs->umask;
                        if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
                                CIFSSMBUnixSetPerms(xid, pTcon, full_path,
                                                    mode,
@@ -1004,7 +1005,7 @@ mkdir_get_info:
                                                    cifs_sb->mnt_cifs_flags & 
                                                    CIFS_MOUNT_MAP_SPECIAL_CHR);
                        }
-               else {
+               else {
                        /* BB to be implemented via Windows secrty descriptors
                           eg CIFSSMBWinSetPerms(xid, pTcon, full_path, mode,
                                                 -1, -1, local_nls); */