From: Christof Schmitt Date: Thu, 9 Nov 2023 19:35:21 +0000 (-0700) Subject: vfs_gpfs: Move vfs_gpfs_fstatat to nfs4_acls.c and rename function X-Git-Tag: samba-4.18.9~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3241127482dd8cbe6211ab4bd4bd865d98ee99e3;p=thirdparty%2Fsamba.git vfs_gpfs: Move vfs_gpfs_fstatat to nfs4_acls.c and rename function 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 Reviewed-by: Björn Jacke (cherry picked from commit 5fd73e93af9d015c9e65a6d4d16229476a541cfc) --- diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c index 83a5e034471..7bb115c6ca8 100644 --- a/source3/modules/nfs4_acls.c +++ b/source3/modules/nfs4_acls.c @@ -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 diff --git a/source3/modules/nfs4_acls.h b/source3/modules/nfs4_acls.h index ee97207387b..1fafaafe76a 100644 --- a/source3/modules/nfs4_acls.h +++ b/source3/modules/nfs4_acls.h @@ -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 */ diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index d7ed16d4df8..fc0fc0cef6e 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -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) { @@ -2550,7 +2525,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,