]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_gpfs: Implement CAP_DAC_OVERRIDE for fstat
authorChristof Schmitt <cs@samba.org>
Thu, 26 Oct 2023 21:45:34 +0000 (14:45 -0700)
committerJule Anger <janger@samba.org>
Sat, 25 Nov 2023 18:28:13 +0000 (18:28 +0000)
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>
(cherry picked from commit cbdc16a7cfa225d1cf9109fafe85e9d14729700e)

source3/modules/vfs_gpfs.c

index d9361fe906faf49d319e8e8b1042f50f3c0ef359..568e11f1aac56e11b1c73563c1b6f1cb7f21fa98 100644 (file)
@@ -1670,6 +1670,29 @@ static int vfs_gpfs_stat(struct vfs_handle_struct *handle,
        return ret;
 }
 
+static int vfs_gpfs_fstat(struct vfs_handle_struct *handle,
+                         struct files_struct *fsp,
+                         SMB_STRUCT_STAT *sbuf)
+{
+       int ret;
+
+       ret = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
+       if (ret == -1 && errno == EACCES) {
+               bool fake_dctime =
+                       lp_fake_directory_create_times(SNUM(handle->conn));
+
+               DBG_DEBUG("fstat for %s failed with EACCES. Trying with "
+                         "CAP_DAC_OVERRIDE.\n", fsp->fsp_name->base_name);
+               ret = fstatat_with_cap_dac_override(fsp_get_pathref_fd(fsp),
+                                                   "",
+                                                   sbuf,
+                                                   AT_EMPTY_PATH,
+                                                   fake_dctime);
+       }
+
+       return ret;
+}
+
 static int vfs_gpfs_lstat(struct vfs_handle_struct *handle,
                          struct smb_filename *smb_fname)
 {
@@ -2614,6 +2637,7 @@ static struct vfs_fn_pointers vfs_gpfs_fns = {
        .fchmod_fn = vfs_gpfs_fchmod,
        .close_fn = vfs_gpfs_close,
        .stat_fn = vfs_gpfs_stat,
+       .fstat_fn = vfs_gpfs_fstat,
        .lstat_fn = vfs_gpfs_lstat,
        .fntimes_fn = vfs_gpfs_fntimes,
        .aio_force_fn = vfs_gpfs_aio_force,