From f8a23d960e02f783119c2aef38a6e293ee548df3 Mon Sep 17 00:00:00 2001 From: Christof Schmitt Date: Thu, 9 Nov 2023 12:23:49 -0700 Subject: [PATCH] vfs_gpfs: Move vfs_gpfs_stat 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 by other file system modules. Also rename the function to the more generic name nfs4_acl_stat. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15507 Signed-off-by: Christof Schmitt Reviewed-by: Björn Jacke --- source3/modules/nfs4_acls.c | 14 ++++++++++++++ source3/modules/nfs4_acls.h | 3 +++ source3/modules/vfs_gpfs.c | 16 +--------------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c index e65c763dd68..efd9bf94c49 100644 --- a/source3/modules/nfs4_acls.c +++ b/source3/modules/nfs4_acls.c @@ -178,6 +178,20 @@ int stat_with_cap_dac_override(struct vfs_handle_struct *handle, return ret; } +int nfs4_acl_stat(struct vfs_handle_struct *handle, + struct smb_filename *smb_fname) +{ + int ret; + + ret = SMB_VFS_NEXT_STAT(handle, smb_fname); + if (ret == -1 && errno == EACCES) { + DEBUG(10, ("Trying stat with capability for %s\n", + smb_fname->base_name)); + ret = stat_with_cap_dac_override(handle, smb_fname, 0); + } + return ret; +} + int fstat_with_cap_dac_override(int fd, SMB_STRUCT_STAT *sbuf, bool fake_dir_create_times) { diff --git a/source3/modules/nfs4_acls.h b/source3/modules/nfs4_acls.h index 828e1da6c39..9de97e0f179 100644 --- a/source3/modules/nfs4_acls.h +++ b/source3/modules/nfs4_acls.h @@ -127,6 +127,9 @@ int fstatat_with_cap_dac_override(int fd, int stat_with_cap_dac_override(struct vfs_handle_struct *handle, struct smb_filename *smb_fname, int flag); +int nfs4_acl_stat(struct vfs_handle_struct *handle, + struct smb_filename *smb_fname); + int fstat_with_cap_dac_override(int fd, SMB_STRUCT_STAT *sbuf, bool fake_dir_create_times); diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index a6b7eca9830..ac177741f8a 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -1588,20 +1588,6 @@ static NTSTATUS vfs_gpfs_fset_dos_attributes(struct vfs_handle_struct *handle, return NT_STATUS_OK; } -static int vfs_gpfs_stat(struct vfs_handle_struct *handle, - struct smb_filename *smb_fname) -{ - int ret; - - ret = SMB_VFS_NEXT_STAT(handle, smb_fname); - if (ret == -1 && errno == EACCES) { - DEBUG(10, ("Trying stat with capability for %s\n", - smb_fname->base_name)); - ret = stat_with_cap_dac_override(handle, smb_fname, 0); - } - return ret; -} - static int vfs_gpfs_fstat(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_STAT *sbuf) @@ -2595,7 +2581,7 @@ static struct vfs_fn_pointers vfs_gpfs_fns = { .sys_acl_delete_def_fd_fn = gpfsacl_sys_acl_delete_def_fd, .fchmod_fn = vfs_gpfs_fchmod, .close_fn = vfs_gpfs_close, - .stat_fn = vfs_gpfs_stat, + .stat_fn = nfs4_acl_stat, .fstat_fn = vfs_gpfs_fstat, .lstat_fn = vfs_gpfs_lstat, .fstatat_fn = vfs_gpfs_fstatat, -- 2.47.3