Fix the erroneous masking of chmod requests via the UNIX extensions.
authorJeremy Allison <jra@samba.org>
Wed, 21 Aug 2013 19:03:25 +0000 (12:03 -0700)
committerKarolin Seeger <kseeger@samba.org>
Fri, 30 Aug 2013 08:26:13 +0000 (10:26 +0200)
Changed from switch statement to if, as "create mask", "force create mode"
are only applied to new files, not existing ones. "directory mask",
"force directory mode" are only applied to new directories, not existing
ones.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Simo Sorce <idra@samba.org>
(cherry picked from commit bd0156988b34feaf91c3046f7ec78f0833222395)

source3/smbd/trans2.c

index 61063d6cdc0b0a224e4fd0994508a8c1ed626ecb..bbaa84eb473bafbd5858402acae765b5c41a5632 100644 (file)
@@ -1452,20 +1452,22 @@ static NTSTATUS unix_perms_from_wire( connection_struct *conn,
        ret |= ((perms & UNIX_SET_UID ) ? S_ISUID : 0);
 #endif
 
-       switch (ptype) {
-       case PERM_NEW_FILE:
-       case PERM_EXISTING_FILE:
-               /* Apply mode mask */
+       if (ptype == PERM_NEW_FILE) {
+               /*
+                * "create mask"/"force create mode" are
+                * only applied to new files, not existing ones.
+                */
                ret &= lp_create_mask(SNUM(conn));
                /* Add in force bits */
                ret |= lp_force_create_mode(SNUM(conn));
-               break;
-       case PERM_NEW_DIR:
-       case PERM_EXISTING_DIR:
+       } else if (ptype == PERM_NEW_DIR) {
+               /*
+                * "directory mask"/"force directory mode" are
+                * only applied to new directories, not existing ones.
+                */
                ret &= lp_dir_mask(SNUM(conn));
                /* Add in force bits */
                ret |= lp_force_dir_mode(SNUM(conn));
-               break;
        }
 
        *ret_perms = ret;