smbd: Fix a typo in a few places
[samba.git] / source3 / modules / vfs_acl_common.c
index 692e776d10cd1f261c8c5ff76cfea507a6195a18..e04b672cf9ae7ddb2f561ba7f85217d49d9426c9 100644 (file)
@@ -738,10 +738,13 @@ static NTSTATUS set_underlying_acl(vfs_handle_struct *handle, files_struct *fsp,
        /* We got access denied here. If we're already root,
           or we didn't need to do a chown, or the fsp isn't
           open with WRITE_OWNER access, just return. */
-       if (get_current_uid(handle->conn) == 0 || !chown_needed ||
-           !(fsp->access_mask & SEC_STD_WRITE_OWNER)) {
+       if (get_current_uid(handle->conn) == 0 || !chown_needed) {
                return NT_STATUS_ACCESS_DENIED;
        }
+       status = check_any_access_fsp(fsp, SEC_STD_WRITE_OWNER);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
 
        /*
         * Only allow take-ownership, not give-ownership. That's the way Windows
@@ -761,9 +764,9 @@ static NTSTATUS set_underlying_acl(vfs_handle_struct *handle, files_struct *fsp,
 
        /* Ok, we failed to chown and we have
           SEC_STD_WRITE_OWNER access - override. */
-       set_effective_capability(DAC_OVERRIDE_CAPABILITY);
+       become_root();
        status = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd);
-       drop_effective_capability(DAC_OVERRIDE_CAPABILITY);
+       unbecome_root();
 
        return status;
 }
@@ -1069,7 +1072,7 @@ static int acl_common_remove_object(vfs_handle_struct *handle,
                goto out;
        }
 
-       set_effective_capability(DAC_OVERRIDE_CAPABILITY);
+       become_root();
        if (is_directory) {
                ret = SMB_VFS_NEXT_UNLINKAT(handle,
                                dirfsp,
@@ -1081,7 +1084,7 @@ static int acl_common_remove_object(vfs_handle_struct *handle,
                                smb_fname,
                                0);
        }
-       drop_effective_capability(DAC_OVERRIDE_CAPABILITY);
+       unbecome_root();
 
        if (ret == -1) {
                saved_errno = errno;