]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
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)
committerBjoern Jacke <bjacke@samba.org>
Wed, 15 Nov 2023 18:54:11 +0000 (18:54 +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>
source3/modules/nfs4_acls.c
source3/modules/nfs4_acls.h
source3/modules/vfs_gpfs.c

index 8471a7e6f768d92b9d76876e1738aec7956eaf40..08ea77df913ef4519880b073e59493bd9597de64 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 85b345e5eb95a8476fc173fa16bc08b9ac24d9fe..a8b4e38ff88c00c61285258f92c4f4a67de152a2 100644 (file)
@@ -1588,31 +1588,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)
 {
@@ -2548,7 +2523,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,