]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
nfs4_acls: Implement fstat with DAC_CAP_OVERRIDE
authorChristof Schmitt <cs@samba.org>
Thu, 9 Nov 2023 19:01:56 +0000 (12:01 -0700)
committerBjoern Jacke <bjacke@samba.org>
Wed, 15 Nov 2023 18:54:11 +0000 (18:54 +0000)
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 <cs@samba.org>
Reviewed-by: Björn Jacke <bjacke@samba.org>
source3/modules/nfs4_acls.c
source3/modules/nfs4_acls.h
source3/modules/vfs_gpfs.c

index 1e18ae3b1cff986d93f9d51c1cc2ec16b612c0af..9e9e05d4db3d95e9d0d6af37bfbaffc56f3e06b7 100644 (file)
@@ -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
index c9fcf6d250b5616550291dc0ea01e1fcd88a9e59..096688b0dff7aec4c505d99de08a05d7e80e3da1 100644 (file)
@@ -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 */
index 2f505a103b082fb509afaec51825671d838884fd..c353ecaf24f4a01eab4ab8a5d388d4c2c69dfcd9 100644 (file)
@@ -1677,11 +1677,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;