s3: smbd: set_nt_acl(). Now we know we always have a valid file handle, always use...
authorJeremy Allison <jra@samba.org>
Tue, 8 Oct 2019 20:45:45 +0000 (13:45 -0700)
committerJeremy Allison <jra@samba.org>
Tue, 15 Oct 2019 18:46:36 +0000 (18:46 +0000)
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
source3/smbd/posix_acls.c

index e0df84bc3f04c372aa1711826053017c2be7aee9..23aa5b575a04e9b377e898f494d7c00c4e7ff216 100644 (file)
@@ -3578,15 +3578,16 @@ NTSTATUS posix_get_nt_acl(struct connection_struct *conn,
 NTSTATUS try_chown(files_struct *fsp, uid_t uid, gid_t gid)
 {
        NTSTATUS status;
+       int ret;
 
        if(!CAN_WRITE(fsp->conn)) {
                return NT_STATUS_MEDIA_WRITE_PROTECTED;
        }
 
        /* Case (1). */
-       status = vfs_chown_fsp(fsp, uid, gid);
-       if (NT_STATUS_IS_OK(status)) {
-               return status;
+       ret = SMB_VFS_FCHOWN(fsp, uid, gid);
+       if (ret == 0) {
+               return NT_STATUS_OK;
        }
 
        /* Case (2) / (3) */
@@ -3610,8 +3611,12 @@ NTSTATUS try_chown(files_struct *fsp, uid_t uid, gid_t gid)
                }
 
                if (has_take_ownership_priv || has_restore_priv) {
+                       status = NT_STATUS_OK;
                        become_root();
-                       status = vfs_chown_fsp(fsp, uid, gid);
+                       ret = SMB_VFS_FCHOWN(fsp, uid, gid);
+                       if (ret != 0) {
+                               status = map_nt_error_from_unix(errno);
+                       }
                        unbecome_root();
                        return status;
                }
@@ -3630,9 +3635,13 @@ NTSTATUS try_chown(files_struct *fsp, uid_t uid, gid_t gid)
                return NT_STATUS_INVALID_OWNER;
        }
 
+       status = NT_STATUS_OK;
        become_root();
        /* Keep the current file gid the same. */
-       status = vfs_chown_fsp(fsp, uid, (gid_t)-1);
+       ret = SMB_VFS_FCHOWN(fsp, uid, (gid_t)-1);
+       if (ret != 0) {
+               status = map_nt_error_from_unix(errno);
+       }
        unbecome_root();
 
        return status;