From: Björn Jacke Date: Mon, 20 Nov 2023 11:36:00 +0000 (+0100) Subject: dosmode: prefer capabilities over become_root X-Git-Tag: talloc-2.4.2~558 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=5e925f9755fad180863861157aa7548d83dd3fde;p=thirdparty%2Fsamba.git dosmode: prefer capabilities over become_root Signed-off-by: Bjoern Jacke Reviewed-by: Andrew Bartlett --- diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c index 5dfab65984a..6fbcac40d2e 100644 --- a/source3/smbd/dosmode.c +++ b/source3/smbd/dosmode.c @@ -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;