vfs_gpfs: Implement CAP_DAC_OVERRIDE for fstatat
authorChristof Schmitt <cs@samba.org>
Thu, 26 Oct 2023 22:51:02 +0000 (15:51 -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>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Wed Nov  8 18:42:13 UTC 2023 on atb-devel-224

(cherry picked from commit 963fc353e70b940f4009ca2764e966682400e2dc)

source3/modules/vfs_gpfs.c

index 568e11f1aac56e11b1c73563c1b6f1cb7f21fa98..e88ef817a36f97cdecf52cd48dec920bd0afb12a 100644 (file)
@@ -1708,6 +1708,31 @@ static int vfs_gpfs_lstat(struct vfs_handle_struct *handle,
        return ret;
 }
 
+static int vfs_gpfs_fstatat(struct vfs_handle_struct *handle,
+                           const struct files_struct *dirfsp,
+                           const struct smb_filename *smb_fname,
+                           SMB_STRUCT_STAT *sbuf,
+                           int flags)
+{
+       int ret;
+
+       ret = SMB_VFS_NEXT_FSTATAT(handle, dirfsp, smb_fname, sbuf, flags);
+       if (ret == -1 && errno == EACCES) {
+               bool fake_dctime =
+                       lp_fake_directory_create_times(SNUM(handle->conn));
+
+               DBG_DEBUG("fstatat for %s failed with EACCES. Trying with "
+                         "CAP_DAC_OVERRIDE.\n", dirfsp->fsp_name->base_name);
+               ret = fstatat_with_cap_dac_override(fsp_get_pathref_fd(dirfsp),
+                                                   smb_fname->base_name,
+                                                   sbuf,
+                                                   flags,
+                                                   fake_dctime);
+       }
+
+       return ret;
+}
+
 static int timespec_to_gpfs_time(
        struct timespec ts, gpfs_timestruc_t *gt, int idx, int *flags)
 {
@@ -2639,6 +2664,7 @@ static struct vfs_fn_pointers vfs_gpfs_fns = {
        .stat_fn = vfs_gpfs_stat,
        .fstat_fn = vfs_gpfs_fstat,
        .lstat_fn = vfs_gpfs_lstat,
+       .fstatat_fn = vfs_gpfs_fstatat,
        .fntimes_fn = vfs_gpfs_fntimes,
        .aio_force_fn = vfs_gpfs_aio_force,
        .sendfile_fn = vfs_gpfs_sendfile,