From ddef013da21baac182250e37bf65a5abb9834e6c Mon Sep 17 00:00:00 2001 From: Christof Schmitt Date: Thu, 26 Oct 2023 14:39:46 -0700 Subject: [PATCH] vfs_gpfs: Move fstatat with DAC_CAP_OVERRIDE to helper function Allow reuse of this code. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15507 Signed-off-by: Christof Schmitt Reviewed-by: Ralph Boehme (cherry picked from commit 95319351e37b8b968b798eee66c93852d9ad2d81) --- source3/modules/vfs_gpfs.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index f8ccbca1038..d9361fe906f 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -1594,6 +1594,25 @@ static NTSTATUS vfs_gpfs_fset_dos_attributes(struct vfs_handle_struct *handle, return NT_STATUS_OK; } +static int fstatat_with_cap_dac_override(int fd, + const char *pathname, + SMB_STRUCT_STAT *sbuf, + int flags, + bool fake_dir_create_times) +{ + int ret; + + set_effective_capability(DAC_OVERRIDE_CAPABILITY); + ret = sys_fstatat(fd, + pathname, + sbuf, + flags, + fake_dir_create_times); + drop_effective_capability(DAC_OVERRIDE_CAPABILITY); + + return ret; +} + static int stat_with_capability(struct vfs_handle_struct *handle, struct smb_filename *smb_fname, int flag) { @@ -1625,14 +1644,11 @@ static int stat_with_capability(struct vfs_handle_struct *handle, return -1; } - set_effective_capability(DAC_OVERRIDE_CAPABILITY); - ret = sys_fstatat(fd, - rel_name->base_name, - &smb_fname->st, - flag, - fake_dctime); - - drop_effective_capability(DAC_OVERRIDE_CAPABILITY); + ret = fstatat_with_cap_dac_override(fd, + rel_name->base_name, + &smb_fname->st, + flag, + fake_dctime); TALLOC_FREE(dir_name); close(fd); -- 2.47.2