nfs4_acls: Implement fstat with DAC_CAP_OVERRIDE
authorChristof Schmitt <cs@samba.org>
Thu, 9 Nov 2023 19:01:56 +0000 (12:01 -0700)
committerJule Anger <janger@samba.org>
Sat, 25 Nov 2023 18:27:15 +0000 (18:27 +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>
(cherry picked from commit 05f1ee1ae2d8439af0ac9baf64ebba1a3374ea83)

source3/modules/nfs4_acls.c
source3/modules/nfs4_acls.h
source3/modules/vfs_gpfs.c

index 2daae9900428cf907e373af1fd06cc1333a135f3..1107d628e9e993795f75cb7f2f9d77209c768050 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 f15b7403236661ee3376ff6236b9ae67e37a9daf..058f93af28585d9aef965d3491fa94a61c534131 100644 (file)
@@ -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;