From 8ca3c4839fea0fc8985cc2d3af7802b6e954e2b5 Mon Sep 17 00:00:00 2001 From: Christof Schmitt Date: Thu, 9 Nov 2023 12:27:58 -0700 Subject: [PATCH] vfs_gpfs: Move vfs_gpfs_fstat to nfs4_acls.c and rename function MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Björn Jacke (cherry picked from commit f9301871c61b066c1ea464e6e9109bb2cde71598) --- source3/modules/nfs4_acls.c | 21 +++++++++++++++++++++ source3/modules/nfs4_acls.h | 4 ++++ source3/modules/vfs_gpfs.c | 23 +---------------------- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c index b643bd8bd7a..bf863f3227b 100644 --- a/source3/modules/nfs4_acls.c +++ b/source3/modules/nfs4_acls.c @@ -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 diff --git a/source3/modules/nfs4_acls.h b/source3/modules/nfs4_acls.h index 9de97e0f179..d1a585d7932 100644 --- a/source3/modules/nfs4_acls.h +++ b/source3/modules/nfs4_acls.h @@ -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 */ diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index 57a62406302..e20a8820eff 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -1594,27 +1594,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) { @@ -2584,7 +2563,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, -- 2.47.2