]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_gpfs: Move fstatat with DAC_CAP_OVERRIDE to helper function
authorChristof Schmitt <cs@samba.org>
Thu, 26 Oct 2023 21:39:46 +0000 (14:39 -0700)
committerRalph Boehme <slow@samba.org>
Wed, 8 Nov 2023 17:40:37 +0000 (17:40 +0000)
Allow reuse of this code.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15507

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/modules/vfs_gpfs.c

index 3d3d10905b484d3f01a3169462d1b7d1c90c9878..8f232b5b00d59b4ca24b5839965a15dd107fdcf9 100644 (file)
@@ -1588,6 +1588,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)
 {
@@ -1619,14 +1638,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);