vfs_gpfs: Move vfs_gpfs_fstat to nfs4_acls.c and rename function
authorChristof Schmitt <cs@samba.org>
Thu, 9 Nov 2023 19:27:58 +0000 (12:27 -0700)
committerBjoern Jacke <bjacke@samba.org>
Wed, 15 Nov 2023 18:54:11 +0000 (18:54 +0000)
All stat DAC_CAP_OVERRIDE code is moving to nfs4_acls.c to allow reuse.
Move the vfs_gpfs_fstat function and rename 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 efd9bf94c4907a8e5d0d78af012a0afdaf145155..4f6c8ce4699ec36d00bbca4350ca6fb9a9b951a7 100644 (file)
@@ -204,6 +204,27 @@ int fstat_with_cap_dac_override(int fd, SMB_STRUCT_STAT *sbuf,
        return ret;
 }
 
+int nfs4_acl_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 = fstat_with_cap_dac_override(fsp_get_pathref_fd(fsp),
+                                                 sbuf,
+                                                 fake_dctime);
+       }
+
+       return ret;
+}
+
 /************************************************
  Split the ACE flag mapping between nfs4 and Windows
  into two separate functions rather than trying to do
index 9de97e0f17960435f904d599334b7356115b77d8..d1a585d7932d247157bba79ec7f1c00539cda31c 100644 (file)
@@ -133,6 +133,10 @@ int nfs4_acl_stat(struct vfs_handle_struct *handle,
 int fstat_with_cap_dac_override(int fd, SMB_STRUCT_STAT *sbuf,
                                bool fake_dir_create_times);
 
+int nfs4_acl_fstat(struct vfs_handle_struct *handle,
+                  struct files_struct *fsp,
+                  SMB_STRUCT_STAT *sbuf);
+
 struct SMB4ACL_T *smb_create_smb4acl(TALLOC_CTX *mem_ctx);
 
 /* prop's contents are copied */
index ac177741f8a015b901ca2c98df0426c068f85e72..aa25a76aecbebfb8cce3e75cce6d5176f1bef2f4 100644 (file)
@@ -1588,27 +1588,6 @@ static NTSTATUS vfs_gpfs_fset_dos_attributes(struct vfs_handle_struct *handle,
        return NT_STATUS_OK;
 }
 
-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 = fstat_with_cap_dac_override(fsp_get_pathref_fd(fsp),
-                                                 sbuf,
-                                                 fake_dctime);
-       }
-
-       return ret;
-}
-
 static int vfs_gpfs_lstat(struct vfs_handle_struct *handle,
                          struct smb_filename *smb_fname)
 {
@@ -2582,7 +2561,7 @@ static struct vfs_fn_pointers vfs_gpfs_fns = {
        .fchmod_fn = vfs_gpfs_fchmod,
        .close_fn = vfs_gpfs_close,
        .stat_fn = nfs4_acl_stat,
-       .fstat_fn = vfs_gpfs_fstat,
+       .fstat_fn = nfs4_acl_fstat,
        .lstat_fn = vfs_gpfs_lstat,
        .fstatat_fn = vfs_gpfs_fstatat,
        .fntimes_fn = vfs_gpfs_fntimes,