vfs_gpfs: Move vfs_gpfs_fstatat to nfs4_acls.c and rename function
authorChristof Schmitt <cs@samba.org>
Thu, 9 Nov 2023 19:35:21 +0000 (12:35 -0700)
committerJule Anger <janger@samba.org>
Sat, 25 Nov 2023 18:27:15 +0000 (18:27 +0000)
All stat DAC_CAP_OVERRIDE code is being moved to nfs4_acls.c to allow
reuse. Move the vfs_gpfs_fstatat function and rename it to the more
generic name nfs4_acl_fstat.

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

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Björn Jacke <bjacke@samba.org>
(cherry picked from commit 5fd73e93af9d015c9e65a6d4d16229476a541cfc)

source3/modules/nfs4_acls.c
source3/modules/nfs4_acls.h
source3/modules/vfs_gpfs.c

index 83a5e034471c1d11d825e09e7c3923a48d30c063..7bb115c6ca8a25101f8ea2ed50f203a7dc7dd983 100644 (file)
@@ -240,6 +240,31 @@ int nfs4_acl_lstat(struct vfs_handle_struct *handle,
        return ret;
 }
 
+int nfs4_acl_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;
+}
+
 /************************************************
  Split the ACE flag mapping between nfs4 and Windows
  into two separate functions rather than trying to do
index ee97207387bf1067d0699fbda4b029d8c82bfe2b..1fafaafe76a26b4803c38d977b576d871a0da8de 100644 (file)
@@ -140,6 +140,12 @@ int nfs4_acl_fstat(struct vfs_handle_struct *handle,
 int nfs4_acl_lstat(struct vfs_handle_struct *handle,
                   struct smb_filename *smb_fname);
 
+int nfs4_acl_fstatat(struct vfs_handle_struct *handle,
+                    const struct files_struct *dirfsp,
+                    const struct smb_filename *smb_fname,
+                    SMB_STRUCT_STAT *sbuf,
+                    int flags);
+
 struct SMB4ACL_T *smb_create_smb4acl(TALLOC_CTX *mem_ctx);
 
 /* prop's contents are copied */
index 70294635f636da36b531283d0fe6fa9d2d86949e..a5339ab41d110c856fe487971f36ae91406d410b 100644 (file)
@@ -1594,31 +1594,6 @@ static NTSTATUS vfs_gpfs_fset_dos_attributes(struct vfs_handle_struct *handle,
        return NT_STATUS_OK;
 }
 
-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)
 {
@@ -2561,7 +2536,7 @@ static struct vfs_fn_pointers vfs_gpfs_fns = {
        .stat_fn = nfs4_acl_stat,
        .fstat_fn = nfs4_acl_fstat,
        .lstat_fn = nfs4_acl_lstat,
-       .fstatat_fn = vfs_gpfs_fstatat,
+       .fstatat_fn = nfs4_acl_fstatat,
        .fntimes_fn = vfs_gpfs_fntimes,
        .aio_force_fn = vfs_gpfs_aio_force,
        .sendfile_fn = vfs_gpfs_sendfile,