]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
dosmode: prefer capabilities over become_root
authorBjörn Jacke <bj@sernet.de>
Mon, 20 Nov 2023 11:36:00 +0000 (12:36 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 27 Nov 2023 01:12:40 +0000 (01:12 +0000)
Signed-off-by: Bjoern Jacke <bjacke@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/smbd/dosmode.c

index 5dfab65984af102af882a61a7cb84218e1b031b1..6fbcac40d2ec789efeb05de6f509c82ba272a6ad 100644 (file)
@@ -1035,9 +1035,9 @@ int file_set_dosmode(connection_struct *conn,
                return -1;
        }
 
-       become_root();
+       set_effective_capability(DAC_OVERRIDE_CAPABILITY);
        ret = SMB_VFS_FCHMOD(smb_fname->fsp, unixmode);
-       unbecome_root();
+       drop_effective_capability(DAC_OVERRIDE_CAPABILITY);
 
 done:
        if (!newfile) {
@@ -1205,9 +1205,9 @@ int file_ntimes(connection_struct *conn,
        /* Check if we have write access. */
        if (can_write_to_fsp(fsp)) {
                /* We are allowed to become root and change the filetime. */
-               become_root();
+               set_effective_capability(DAC_OVERRIDE_CAPABILITY);
                ret = SMB_VFS_FNTIMES(fsp, ft);
-               unbecome_root();
+               drop_effective_capability(DAC_OVERRIDE_CAPABILITY);
        }
 
        return ret;