From: Christof Schmitt Date: Thu, 9 Nov 2023 19:17:21 +0000 (-0700) Subject: vfs_gpfs: Move fstatat_with_cap_dac_override to nfs4_acls.c X-Git-Tag: samba-4.18.9~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=53e4d90dbd1cd1ca09902e683f26e96150e08e21;p=thirdparty%2Fsamba.git vfs_gpfs: Move fstatat_with_cap_dac_override to nfs4_acls.c All stat DAC_CAP_OVERRIDE code is being moved to nfs4_acls.c to allow reuse by other filesystem modules. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15507 Signed-off-by: Christof Schmitt Reviewed-by: Björn Jacke (cherry picked from commit 316c96ea83a7b70d35879e4743193bb1e9cb566c) --- diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c index 1107d628e9e..418c34b4a83 100644 --- a/source3/modules/nfs4_acls.c +++ b/source3/modules/nfs4_acls.c @@ -116,6 +116,25 @@ int smbacl4_get_vfs_params(struct connection_struct *conn, return 0; } +int fstatat_with_cap_dac_override(int fd, + const char *pathname, + SMB_STRUCT_STAT *sbuf, + int flags, + bool fake_dir_create_times) +{ + int ret; + + set_effective_capability(DAC_OVERRIDE_CAPABILITY); + ret = sys_fstatat(fd, + pathname, + sbuf, + flags, + fake_dir_create_times); + drop_effective_capability(DAC_OVERRIDE_CAPABILITY); + + 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 096688b0dff..edb767f1ce8 100644 --- a/source3/modules/nfs4_acls.h +++ b/source3/modules/nfs4_acls.h @@ -118,6 +118,12 @@ struct smbacl4_vfs_params { int smbacl4_get_vfs_params(struct connection_struct *conn, struct smbacl4_vfs_params *params); +int fstatat_with_cap_dac_override(int fd, + const char *pathname, + SMB_STRUCT_STAT *sbuf, + int flags, + bool fake_dir_create_times); + 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 967e5b9cb8b..7f3dd6e7eb0 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -1594,25 +1594,6 @@ static NTSTATUS vfs_gpfs_fset_dos_attributes(struct vfs_handle_struct *handle, return NT_STATUS_OK; } -static int fstatat_with_cap_dac_override(int fd, - const char *pathname, - SMB_STRUCT_STAT *sbuf, - int flags, - bool fake_dir_create_times) -{ - int ret; - - set_effective_capability(DAC_OVERRIDE_CAPABILITY); - ret = sys_fstatat(fd, - pathname, - sbuf, - flags, - fake_dir_create_times); - drop_effective_capability(DAC_OVERRIDE_CAPABILITY); - - return ret; -} - static int stat_with_capability(struct vfs_handle_struct *handle, struct smb_filename *smb_fname, int flag) {