From cc0416f19b2dfdf95d8998ad1d645842e93c6082 Mon Sep 17 00:00:00 2001 From: Christof Schmitt Date: Thu, 9 Nov 2023 12:01:56 -0700 Subject: [PATCH] nfs4_acls: Implement fstat with DAC_CAP_OVERRIDE MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit AT_EMTPY_PATH does not exist on AIX. Address this by implementing an override for fstat. Implement the new override function in nfs4_acls.c since all stat functions with DAC_CAP_OVERRIDE will be moved there to allow reuse by other filesystems. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15507 Signed-off-by: Christof Schmitt Reviewed-by: Björn Jacke (cherry picked from commit 05f1ee1ae2d8439af0ac9baf64ebba1a3374ea83) --- source3/modules/nfs4_acls.c | 12 ++++++++++++ source3/modules/nfs4_acls.h | 3 +++ source3/modules/vfs_gpfs.c | 8 +++----- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c index 2daae990042..1107d628e9e 100644 --- a/source3/modules/nfs4_acls.c +++ b/source3/modules/nfs4_acls.c @@ -116,6 +116,18 @@ int smbacl4_get_vfs_params(struct connection_struct *conn, return 0; } +int fstat_with_cap_dac_override(int fd, SMB_STRUCT_STAT *sbuf, + bool fake_dir_create_times) +{ + int ret; + + set_effective_capability(DAC_OVERRIDE_CAPABILITY); + ret = sys_fstat(fd, sbuf, fake_dir_create_times); + drop_effective_capability(DAC_OVERRIDE_CAPABILITY); + + 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 c9fcf6d250b..096688b0dff 100644 --- a/source3/modules/nfs4_acls.h +++ b/source3/modules/nfs4_acls.h @@ -118,6 +118,9 @@ struct smbacl4_vfs_params { int smbacl4_get_vfs_params(struct connection_struct *conn, struct smbacl4_vfs_params *params); +int fstat_with_cap_dac_override(int fd, SMB_STRUCT_STAT *sbuf, + bool fake_dir_create_times); + 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 f15b7403236..058f93af285 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -1683,11 +1683,9 @@ static int vfs_gpfs_fstat(struct vfs_handle_struct *handle, DBG_DEBUG("fstat for %s failed with EACCES. Trying with " "CAP_DAC_OVERRIDE.\n", fsp->fsp_name->base_name); - ret = fstatat_with_cap_dac_override(fsp_get_pathref_fd(fsp), - "", - sbuf, - AT_EMPTY_PATH, - fake_dctime); + ret = fstat_with_cap_dac_override(fsp_get_pathref_fd(fsp), + sbuf, + fake_dctime); } return ret; -- 2.34.1