Revert "open.c: prefer capabilities over become_root"
authorBjörn Jacke <bjacke@samba.org>
Mon, 25 Mar 2024 16:03:35 +0000 (17:03 +0100)
committerRalph Boehme <slow@samba.org>
Wed, 27 Mar 2024 09:40:34 +0000 (09:40 +0000)
This reverts commit b250f25fe407f9a6269b804382de4854501f2d86.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15583
Signed-off-by: Bjoern Jacke <bjacke@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/open.c

index ae47d130650270441b1a03e861bfaa39a28482c9..9512fb20c5981d50bf80645515c715554e5b6980 100644 (file)
@@ -999,11 +999,11 @@ static void change_file_owner_to_parent_fsp(struct files_struct *parent_fsp,
                 return;
        }
 
-       set_effective_capability(DAC_OVERRIDE_CAPABILITY);
+       become_root();
        ret = SMB_VFS_FCHOWN(fsp,
                             parent_fsp->fsp_name->st.st_ex_uid,
                             (gid_t)-1);
-       drop_effective_capability(DAC_OVERRIDE_CAPABILITY);
+       unbecome_root();
        if (ret == -1) {
                DBG_ERR("failed to fchown "
                        "file %s to parent directory uid %u. Error "
@@ -1036,11 +1036,11 @@ static NTSTATUS change_dir_owner_to_parent_fsp(struct files_struct *parent_fsp,
                return NT_STATUS_OK;
        }
 
-       set_effective_capability(DAC_OVERRIDE_CAPABILITY);
+       become_root();
        ret = SMB_VFS_FCHOWN(fsp,
                             parent_fsp->fsp_name->st.st_ex_uid,
                             (gid_t)-1);
-       drop_effective_capability(DAC_OVERRIDE_CAPABILITY);
+       unbecome_root();
        if (ret == -1) {
                status = map_nt_error_from_unix(errno);
                DBG_ERR("failed to chown "
@@ -5542,13 +5542,13 @@ static NTSTATUS inherit_new_acl(files_struct *dirfsp, files_struct *fsp)
 
        if (inherit_owner) {
                /* We need to be root to force this. */
-               set_effective_capability(DAC_OVERRIDE_CAPABILITY);
+               become_root();
        }
        status = SMB_VFS_FSET_NT_ACL(metadata_fsp(fsp),
                        security_info_sent,
                        psd);
        if (inherit_owner) {
-               drop_effective_capability(DAC_OVERRIDE_CAPABILITY);
+               unbecome_root();
        }
        TALLOC_FREE(frame);
        return status;