From: Christof Schmitt Date: Thu, 9 Nov 2023 19:30:27 +0000 (-0700) Subject: vfs_gpfs: Move vfs_gpfs_lstat to nfs4_acls.c and rename function X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=119586b19260b338d20c4f2caeb71717d16eeb20;p=metze%2Fsamba-autobuild-v4-19-test%2F.git vfs_gpfs: Move vfs_gpfs_lstat to nfs4_acls.c and rename function All stat CAP_DAC_OVERRIDE code is being moved to nf4_acls.c to allow reuse. Move the vfs_gpfs_lstat function and rename to the more generic name nfs4_acl_lstat. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15507 Signed-off-by: Christof Schmitt Reviewed-by: Björn Jacke (cherry picked from commit 2c1195678d34516744ba4f8b1c5582f4046cba35) --- diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c index bf863f3227b..83a5e034471 100644 --- a/source3/modules/nfs4_acls.c +++ b/source3/modules/nfs4_acls.c @@ -225,6 +225,21 @@ int nfs4_acl_fstat(struct vfs_handle_struct *handle, return ret; } +int nfs4_acl_lstat(struct vfs_handle_struct *handle, + struct smb_filename *smb_fname) +{ + int ret; + + ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname); + if (ret == -1 && errno == EACCES) { + DEBUG(10, ("Trying lstat with capability for %s\n", + smb_fname->base_name)); + ret = stat_with_cap_dac_override(handle, smb_fname, + AT_SYMLINK_NOFOLLOW); + } + 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 d1a585d7932..ee97207387b 100644 --- a/source3/modules/nfs4_acls.h +++ b/source3/modules/nfs4_acls.h @@ -137,6 +137,9 @@ int nfs4_acl_fstat(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_STAT *sbuf); +int nfs4_acl_lstat(struct vfs_handle_struct *handle, + struct smb_filename *smb_fname); + 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 3594643de95..70294635f63 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -1594,21 +1594,6 @@ static NTSTATUS vfs_gpfs_fset_dos_attributes(struct vfs_handle_struct *handle, return NT_STATUS_OK; } -static int vfs_gpfs_lstat(struct vfs_handle_struct *handle, - struct smb_filename *smb_fname) -{ - int ret; - - ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname); - if (ret == -1 && errno == EACCES) { - DEBUG(10, ("Trying lstat with capability for %s\n", - smb_fname->base_name)); - ret = stat_with_cap_dac_override(handle, smb_fname, - AT_SYMLINK_NOFOLLOW); - } - return ret; -} - static int vfs_gpfs_fstatat(struct vfs_handle_struct *handle, const struct files_struct *dirfsp, const struct smb_filename *smb_fname, @@ -2575,7 +2560,7 @@ static struct vfs_fn_pointers vfs_gpfs_fns = { .close_fn = vfs_gpfs_close, .stat_fn = nfs4_acl_stat, .fstat_fn = nfs4_acl_fstat, - .lstat_fn = vfs_gpfs_lstat, + .lstat_fn = nfs4_acl_lstat, .fstatat_fn = vfs_gpfs_fstatat, .fntimes_fn = vfs_gpfs_fntimes, .aio_force_fn = vfs_gpfs_aio_force,