The branch, master has been updated
       via  d1593a2 Fix the UNIX extensions CHOWN calls to use FCHOWN if 
available, else LCHOWN.
       via  f1ff97f Allow UNIX extensions client to act on open fsp instead of 
pathname if available.
       via  bd01569 Fix the erroneous masking of chmod requests via the UNIX 
extensions.
      from  7614278 smbd: Simplify dropbox special case in unix_convert

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit d1593a20f3a5ebf287477dfa8f5ab31dca3dd0c3
Author: Jeremy Allison <[email protected]>
Date:   Wed Aug 21 12:20:48 2013 -0700

    Fix the UNIX extensions CHOWN calls to use FCHOWN if available, else LCHOWN.
    
    UNIX extensions calls must never deref links.
    
    Signed-off-by: Jeremy Allison <[email protected]>
    Reviewed-by: Simo Sorce <[email protected]>
    
    Autobuild-User(master): Jeremy Allison <[email protected]>
    Autobuild-Date(master): Mon Aug 26 20:19:46 CEST 2013 on sn-devel-104

commit f1ff97fc022adaacaa23b7da250be6f7d51c6ac7
Author: Jeremy Allison <[email protected]>
Date:   Wed Aug 21 12:10:05 2013 -0700

    Allow UNIX extensions client to act on open fsp instead of pathname if 
available.
    
    Eliminates possible race condition on pathname op.
    
    Signed-off-by: Jeremy Allison <[email protected]>
    Reviewed-by: Simo Sorce <[email protected]>

commit bd0156988b34feaf91c3046f7ec78f0833222395
Author: Jeremy Allison <[email protected]>
Date:   Wed Aug 21 12:03:25 2013 -0700

    Fix the erroneous masking of chmod requests via the UNIX extensions.
    
    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 <[email protected]>
    Reviewed-by: Simo Sorce <[email protected]>

-----------------------------------------------------------------------

Summary of changes:
 source3/smbd/trans2.c |   53 +++++++++++++++++++++++++++++++++++-------------
 1 files changed, 38 insertions(+), 15 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index e7c0da1..b6cb3cc 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -1392,20 +1392,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;
@@ -7124,11 +7126,18 @@ static NTSTATUS 
smb_set_file_unix_basic(connection_struct *conn,
         */
 
        if (raw_unixmode != SMB_MODE_NO_CHANGE) {
+               int ret;
+
                DEBUG(10,("smb_set_file_unix_basic: SMB_SET_FILE_UNIX_BASIC "
                          "setting mode 0%o for file %s\n",
                          (unsigned int)unixmode,
                          smb_fname_str_dbg(smb_fname)));
-               if (SMB_VFS_CHMOD(conn, smb_fname->base_name, unixmode) != 0) {
+               if (fsp && fsp->fh->fd != -1) {
+                       ret = SMB_VFS_FCHMOD(fsp, unixmode);
+               } else {
+                       ret = SMB_VFS_CHMOD(conn, smb_fname->base_name, 
unixmode);
+               }
+               if (ret != 0) {
                        return map_nt_error_from_unix(errno);
                }
        }
@@ -7146,12 +7155,15 @@ static NTSTATUS 
smb_set_file_unix_basic(connection_struct *conn,
                          (unsigned int)set_owner,
                          smb_fname_str_dbg(smb_fname)));
 
-               if (S_ISLNK(sbuf.st_ex_mode)) {
+               if (fsp && fsp->fh->fd != -1) {
+                       ret = SMB_VFS_FCHOWN(fsp, set_owner, (gid_t)-1);
+               } else {
+                       /*
+                        * UNIX extensions calls must always operate
+                        * on symlinks.
+                        */
                        ret = SMB_VFS_LCHOWN(conn, smb_fname->base_name,
                                             set_owner, (gid_t)-1);
-               } else {
-                       ret = SMB_VFS_CHOWN(conn, smb_fname->base_name,
-                                           set_owner, (gid_t)-1);
                }
 
                if (ret != 0) {
@@ -7169,12 +7181,23 @@ static NTSTATUS 
smb_set_file_unix_basic(connection_struct *conn,
 
        if ((set_grp != (uid_t)SMB_GID_NO_CHANGE) &&
            (sbuf.st_ex_gid != set_grp)) {
+               int ret;
+
                DEBUG(10,("smb_set_file_unix_basic: SMB_SET_FILE_UNIX_BASIC "
                          "changing group %u for file %s\n",
                          (unsigned int)set_owner,
                          smb_fname_str_dbg(smb_fname)));
-               if (SMB_VFS_CHOWN(conn, smb_fname->base_name, (uid_t)-1,
-                                 set_grp) != 0) {
+               if (fsp && fsp->fh->fd != -1) {
+                       ret = SMB_VFS_FCHOWN(fsp, set_owner, (gid_t)-1);
+               } else {
+                       /*
+                        * UNIX extensions calls must always operate
+                        * on symlinks.
+                        */
+                       ret = SMB_VFS_LCHOWN(conn, smb_fname->base_name, 
(uid_t)-1,
+                                 set_grp);
+               }
+               if (ret != 0) {
                        status = map_nt_error_from_unix(errno);
                        if (delete_on_fail) {
                                SMB_VFS_UNLINK(conn, smb_fname);


-- 
Samba Shared Repository

Reply via email to