From 53e4d90dbd1cd1ca09902e683f26e96150e08e21 Mon Sep 17 00:00:00 2001 From: Christof Schmitt Date: Thu, 9 Nov 2023 12:17:21 -0700 Subject: [PATCH] vfs_gpfs: Move fstatat_with_cap_dac_override to nfs4_acls.c MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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) --- source3/modules/nfs4_acls.c | 19 +++++++++++++++++++ source3/modules/nfs4_acls.h | 6 ++++++ source3/modules/vfs_gpfs.c | 19 ------------------- 3 files changed, 25 insertions(+), 19 deletions(-) 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) { -- 2.47.2