From 5513d45763073c93c326ef54d7b45d21d1397035 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Tue, 17 May 2022 14:47:03 +0200 Subject: [PATCH 01/12] vfs_gpfs: indentation and README.Coding fixes Best viewed with git show -w. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15069 Signed-off-by: Ralph Boehme Reviewed-by: Christof Schmitt (cherry picked from commit a0f7ced610013cad145ff14cedcfbb5388d1ea4f) --- source3/modules/vfs_gpfs.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index 7642c647afb5..f9a46025bfe6 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -1355,23 +1355,25 @@ static int gpfsacl_emu_chmod(vfs_handle_struct *handle, static int vfs_gpfs_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t mode) { - SMB_STRUCT_STAT st; - int rc; - - if (SMB_VFS_NEXT_FSTAT(handle, fsp, &st) != 0) { - return -1; - } - - /* avoid chmod() if possible, to preserve acls */ - if ((st.st_ex_mode & ~S_IFMT) == mode) { - return 0; - } - - rc = gpfsacl_emu_chmod(handle, fsp->fsp_name, - mode); - if (rc == 1) - return SMB_VFS_NEXT_FCHMOD(handle, fsp, mode); - return rc; + SMB_STRUCT_STAT st; + int rc; + + rc = SMB_VFS_NEXT_FSTAT(handle, fsp, &st); + if (rc != 0) { + return -1; + } + + /* avoid chmod() if possible, to preserve acls */ + if ((st.st_ex_mode & ~S_IFMT) == mode) { + return 0; + } + + rc = gpfsacl_emu_chmod(handle, fsp->fsp_name, + mode); + if (rc == 1) { + return SMB_VFS_NEXT_FCHMOD(handle, fsp, mode); + } + return rc; } static uint32_t vfs_gpfs_winattrs_to_dosmode(unsigned int winattrs) -- 2.35.3 From b0bb653a9d80e36a8c91adddd6e403391cbf6477 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Tue, 17 May 2022 15:17:34 +0200 Subject: [PATCH 02/12] vfs_gpfs: pass fsp to gpfsacl_emu_chmod() BUG: https://bugzilla.samba.org/show_bug.cgi?id=15069 Signed-off-by: Ralph Boehme Reviewed-by: Christof Schmitt (cherry picked from commit ad06d806831c80a1169468d18b3e59b239a5ba77) --- source3/modules/vfs_gpfs.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index f9a46025bfe6..05b819448e26 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -1253,9 +1253,11 @@ static uint32_t gpfsacl_mask_filter(uint32_t aceType, uint32_t aceMask, uint32_t } static int gpfsacl_emu_chmod(vfs_handle_struct *handle, - const struct smb_filename *fname, mode_t mode) + struct files_struct *fsp, + mode_t mode) { - char *path = fname->base_name; + struct smb_filename *fname = fsp->fsp_name; + char *path = fsp->fsp_name->base_name; struct SMB4ACL_T *pacl = NULL; int result; bool haveAllowEntry[SMB_ACE4_WHO_EVERYONE + 1] = {False, False, False, False}; @@ -1368,8 +1370,7 @@ static int vfs_gpfs_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t return 0; } - rc = gpfsacl_emu_chmod(handle, fsp->fsp_name, - mode); + rc = gpfsacl_emu_chmod(handle, fsp, mode); if (rc == 1) { return SMB_VFS_NEXT_FCHMOD(handle, fsp, mode); } -- 2.35.3 From b6d50490ade588fa73c58b2364f7a4cfc17e0e98 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Tue, 17 May 2022 15:25:35 +0200 Subject: [PATCH 03/12] vfs_gpfs: pass fsp to gpfs_get_nfs4_acl() BUG: https://bugzilla.samba.org/show_bug.cgi?id=15069 Signed-off-by: Ralph Boehme Reviewed-by: Christof Schmitt (cherry picked from commit 5f4625a2859bf622ea2034e5bbf63f9959e58b78) --- source3/modules/vfs_gpfs.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index 05b819448e26..900c7571070d 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -519,9 +519,11 @@ static void *vfs_gpfs_getacl(TALLOC_CTX *mem_ctx, * On failure returns -1 if there is system (GPFS) error, check errno. * Returns 0 on success */ -static int gpfs_get_nfs4_acl(TALLOC_CTX *mem_ctx, const char *fname, +static int gpfs_get_nfs4_acl(TALLOC_CTX *mem_ctx, + struct files_struct *fsp, struct SMB4ACL_T **ppacl) { + const char *fname = fsp->fsp_name->base_name; gpfs_aclCount_t i; struct gpfs_acl *gacl = NULL; DEBUG(10, ("gpfs_get_nfs4_acl invoked for %s\n", fname)); @@ -640,7 +642,7 @@ static NTSTATUS gpfsacl_fget_nt_acl(vfs_handle_struct *handle, return status; } - result = gpfs_get_nfs4_acl(frame, fsp->fsp_name->base_name, &pacl); + result = gpfs_get_nfs4_acl(frame, fsp, &pacl); if (result == 0) { status = smb_fget_nt_acl_nfs4(fsp, &config->nfs4_params, @@ -1268,7 +1270,7 @@ static int gpfsacl_emu_chmod(vfs_handle_struct *handle, DEBUG(10, ("gpfsacl_emu_chmod invoked for %s mode %o\n", path, mode)); - result = gpfs_get_nfs4_acl(frame, path, &pacl); + result = gpfs_get_nfs4_acl(frame, fsp, &pacl); if (result) { TALLOC_FREE(frame); return result; -- 2.35.3 From b35bc1af7f2c41e4ab5e304d2e89f7a3f2352505 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Tue, 17 May 2022 15:32:24 +0200 Subject: [PATCH 04/12] vfs_gpfs: pass fsp to gpfsacl_get_posix_acl() BUG: https://bugzilla.samba.org/show_bug.cgi?id=15069 Signed-off-by: Ralph Boehme Reviewed-by: Christof Schmitt (cherry picked from commit c26efe0c23b426c4a1e7073b040da85df6f1ea61) --- source3/modules/vfs_gpfs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index 900c7571070d..b3fb776e41d2 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -940,9 +940,11 @@ static SMB_ACL_T gpfs2smb_acl(const struct gpfs_acl *pacl, TALLOC_CTX *mem_ctx) return result; } -static SMB_ACL_T gpfsacl_get_posix_acl(const char *path, gpfs_aclType_t type, +static SMB_ACL_T gpfsacl_get_posix_acl(struct files_struct *fsp, + gpfs_aclType_t type, TALLOC_CTX *mem_ctx) { + const char *path = fsp->fsp_name->base_name; struct gpfs_acl *pacl; SMB_ACL_T result = NULL; @@ -1011,8 +1013,7 @@ static SMB_ACL_T gpfsacl_sys_acl_get_fd(vfs_handle_struct *handle, DEBUG(0, ("Got invalid type: %d\n", type)); smb_panic("exiting"); } - return gpfsacl_get_posix_acl(fsp->fsp_name->base_name, - gpfs_type, mem_ctx); + return gpfsacl_get_posix_acl(fsp, gpfs_type, mem_ctx); } static int gpfsacl_sys_acl_blob_get_fd(vfs_handle_struct *handle, -- 2.35.3 From 31d6fcad25c3273eb7bab99f6d7914f58175d386 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Tue, 17 May 2022 15:34:35 +0200 Subject: [PATCH 05/12] vfs_gpfs: use fsp in gpfsacl_get_posix_acl() BUG: https://bugzilla.samba.org/show_bug.cgi?id=15069 Signed-off-by: Ralph Boehme Reviewed-by: Christof Schmitt (cherry picked from commit 3764be70319d8e953a6205649fecaed06c93dbc8) --- source3/modules/vfs_gpfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index b3fb776e41d2..1511ffeab85f 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -951,8 +951,8 @@ static SMB_ACL_T gpfsacl_get_posix_acl(struct files_struct *fsp, pacl = vfs_gpfs_getacl(talloc_tos(), path, false, type); if (pacl == NULL) { - DEBUG(10, ("vfs_gpfs_getacl failed for %s with %s\n", - path, strerror(errno))); + DBG_DEBUG("vfs_gpfs_getacl failed for %s with %s\n", + fsp_str_dbg(fsp), strerror(errno)); if (errno == 0) { errno = EINVAL; } -- 2.35.3 From ecd9a933754896d0af93e3dc9fc2f5f7c79d402a Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Tue, 17 May 2022 15:35:26 +0200 Subject: [PATCH 06/12] vfs_gpfs: pass fsp to vfs_gpfs_getacl() BUG: https://bugzilla.samba.org/show_bug.cgi?id=15069 Signed-off-by: Ralph Boehme Reviewed-by: Christof Schmitt (cherry picked from commit ac458648aa3f557b7f137f7efa88806f7cb0da71) --- source3/modules/vfs_gpfs.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index 1511ffeab85f..c54016acabfc 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -438,11 +438,11 @@ static int gpfs_getacl_with_capability(const char *fname, int flags, void *buf) * */ static void *vfs_gpfs_getacl(TALLOC_CTX *mem_ctx, - const char *fname, + struct files_struct *fsp, const bool raw, const gpfs_aclType_t type) { - + const char *fname = fsp->fsp_name->base_name; void *aclbuf; size_t size = 512; int ret, flags; @@ -529,7 +529,7 @@ static int gpfs_get_nfs4_acl(TALLOC_CTX *mem_ctx, DEBUG(10, ("gpfs_get_nfs4_acl invoked for %s\n", fname)); /* Get the ACL */ - gacl = (struct gpfs_acl*) vfs_gpfs_getacl(talloc_tos(), fname, + gacl = (struct gpfs_acl*) vfs_gpfs_getacl(talloc_tos(), fsp, false, 0); if (gacl == NULL) { DEBUG(9, ("gpfs_getacl failed for %s with %s\n", @@ -821,7 +821,7 @@ static NTSTATUS gpfsacl_set_nt_acl_internal(vfs_handle_struct *handle, files_str NTSTATUS result = NT_STATUS_ACCESS_DENIED; acl = (struct gpfs_acl*) vfs_gpfs_getacl(talloc_tos(), - fsp->fsp_name->base_name, + fsp, false, 0); if (acl == NULL) { return map_nt_error_from_unix(errno); @@ -944,11 +944,10 @@ static SMB_ACL_T gpfsacl_get_posix_acl(struct files_struct *fsp, gpfs_aclType_t type, TALLOC_CTX *mem_ctx) { - const char *path = fsp->fsp_name->base_name; struct gpfs_acl *pacl; SMB_ACL_T result = NULL; - pacl = vfs_gpfs_getacl(talloc_tos(), path, false, type); + pacl = vfs_gpfs_getacl(talloc_tos(), fsp, false, type); if (pacl == NULL) { DBG_DEBUG("vfs_gpfs_getacl failed for %s with %s\n", @@ -1038,7 +1037,7 @@ static int gpfsacl_sys_acl_blob_get_fd(vfs_handle_struct *handle, errno = 0; acl = (struct gpfs_opaque_acl *) vfs_gpfs_getacl(mem_ctx, - fsp->fsp_name->base_name, + fsp, true, GPFS_ACL_TYPE_NFS4); -- 2.35.3 From 2b7d35ae50a80197cacaf236c8fd2995f71a4a66 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Tue, 17 May 2022 16:01:48 +0200 Subject: [PATCH 07/12] vfs_gpfs: pass fsp to gpfs_getacl_with_capability() BUG: https://bugzilla.samba.org/show_bug.cgi?id=15069 Signed-off-by: Ralph Boehme Reviewed-by: Christof Schmitt (cherry picked from commit 1b2c70f4d16e48998c9c8bc9e22ee8eb3c0ad53e) --- source3/modules/vfs_gpfs.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index c54016acabfc..f6decc9e2ed0 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -413,7 +413,9 @@ static void gpfs_dumpacl(int level, struct gpfs_acl *gacl) } } -static int gpfs_getacl_with_capability(const char *fname, int flags, void *buf) +static int gpfs_getacl_with_capability(struct files_struct *fsp, + int flags, + void *buf) { int ret, saved_errno; @@ -478,13 +480,13 @@ static void *vfs_gpfs_getacl(TALLOC_CTX *mem_ctx, *len = size; if (use_capability) { - ret = gpfs_getacl_with_capability(fname, flags, aclbuf); + ret = gpfs_getacl_with_capability(fsp, flags, aclbuf); } else { ret = gpfswrap_getacl(fname, flags, aclbuf); if ((ret != 0) && (errno == EACCES)) { DBG_DEBUG("Retry with DAC capability for %s\n", fname); use_capability = true; - ret = gpfs_getacl_with_capability(fname, flags, aclbuf); + ret = gpfs_getacl_with_capability(fsp, flags, aclbuf); } } -- 2.35.3 From 07efe4cac42fabd37d6144246af9ebc2abf77770 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Tue, 17 May 2022 15:43:39 +0200 Subject: [PATCH 08/12] lib/util/gpfswrap: add gpfswrap_fgetacl() Adds handle based version of gpfswrap_getacl(). BUG: https://bugzilla.samba.org/show_bug.cgi?id=15069 Signed-off-by: Ralph Boehme Reviewed-by: Christof Schmitt (cherry picked from commit d373ff3c01c2c50cd539b78494c0673974a0f046) --- lib/util/gpfswrap.c | 12 ++++++++++++ lib/util/gpfswrap.h | 1 + 2 files changed, 13 insertions(+) diff --git a/lib/util/gpfswrap.c b/lib/util/gpfswrap.c index 5cf6d2148e74..ff0b9bd70316 100644 --- a/lib/util/gpfswrap.c +++ b/lib/util/gpfswrap.c @@ -24,6 +24,7 @@ static int (*gpfs_set_share_fn)(int fd, unsigned int allow, unsigned int deny); static int (*gpfs_set_lease_fn)(int fd, unsigned int type); static int (*gpfs_getacl_fn)(const char *pathname, int flags, void *acl); +static int (*gpfs_fgetacl_fn)(int fd, int flags, void *acl); static int (*gpfs_putacl_fn)(const char *pathname, int flags, void *acl); static int (*gpfs_get_realfilename_path_fn)(const char *pathname, char *filenamep, @@ -71,6 +72,7 @@ int gpfswrap_init(void) gpfs_set_share_fn = dlsym(l, "gpfs_set_share"); gpfs_set_lease_fn = dlsym(l, "gpfs_set_lease"); gpfs_getacl_fn = dlsym(l, "gpfs_getacl"); + gpfs_fgetacl_fn = dlsym(l, "gpfs_getacl_fd"); gpfs_putacl_fn = dlsym(l, "gpfs_putacl"); gpfs_get_realfilename_path_fn = dlsym(l, "gpfs_get_realfilename_path"); gpfs_set_winattrs_path_fn = dlsym(l, "gpfs_set_winattrs_path"); @@ -122,6 +124,16 @@ int gpfswrap_getacl(const char *pathname, int flags, void *acl) return gpfs_getacl_fn(pathname, flags, acl); } +int gpfswrap_fgetacl(int fd, int flags, void *acl) +{ + if (gpfs_fgetacl_fn == NULL) { + errno = ENOSYS; + return -1; + } + + return gpfs_fgetacl_fn(fd, flags, acl); +} + int gpfswrap_putacl(const char *pathname, int flags, void *acl) { if (gpfs_putacl_fn == NULL) { diff --git a/lib/util/gpfswrap.h b/lib/util/gpfswrap.h index 764cf686d2e5..db541b31f102 100644 --- a/lib/util/gpfswrap.h +++ b/lib/util/gpfswrap.h @@ -30,6 +30,7 @@ int gpfswrap_init(void); int gpfswrap_set_share(int fd, unsigned int allow, unsigned int deny); int gpfswrap_set_lease(int fd, unsigned int type); int gpfswrap_getacl(const char *pathname, int flags, void *acl); +int gpfswrap_fgetacl(int fd, int flags, void *acl); int gpfswrap_putacl(const char *pathname, int flags, void *acl); int gpfswrap_get_realfilename_path(const char *pathname, char *filenamep, -- 2.35.3 From 684c2c1edf40984e3d760e86d96e2fdcbb834481 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Tue, 17 May 2022 16:02:10 +0200 Subject: [PATCH 09/12] vfs_gpfs: finally: use gpfswrap_fgetacl() instead of gpfswrap_getacl() Replaces path based gpfswrap_getacl() with handle based version gpfswrap_fgetacl(). When dealing with files in snapshots fsp->fsp_name points to the active dataset, which will cause ENOENT failures if files are deleted there any only present in the snapshot: [2022/05/06 11:32:55.233435, 4, pid=12962, effective(1460548, 273710), real(1460548, 0)] calling open_file with flags=0x0 flags2=0x800 mode=0644, access_mask = 0x80, open_access_mask = 0x80 [2022/05/06 11:32:55.233460, 10, pid=12962, effective(1460548, 273710), real(1460548, 0), class=vfs] gpfs_get_nfs4_acl invoked for dir/subdir/file.txt [2022/05/06 11:32:55.233495, 5, pid=12962, effective(1460548, 273710), real(1460548, 0), class=vfs] smbd_gpfs_getacl failed with No such file or directory [2022/05/06 11:32:55.233521, 9, pid=12962, effective(1460548, 273710), real(1460548, 0), class=vfs] gpfs_getacl failed for dir/subdir/file.txt with No such file or directory [2022/05/06 11:32:55.233546, 10, pid=12962, effective(1460548, 273710), real(1460548, 0)] smbd_check_access_rights_fsp: Could not get acl on dir/subdir/file.txt {@GMT-2022.05.04-11.58.53}: NT_STATUS_OBJECT_NAME_NOT_FOUND BUG: https://bugzilla.samba.org/show_bug.cgi?id=15069 Signed-off-by: Ralph Boehme Reviewed-by: Christof Schmitt (cherry picked from commit a0dc4c9026519c949070dc001e7addad7c7d35ce) --- source3/modules/vfs_gpfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index f6decc9e2ed0..5085912210d5 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -421,7 +421,7 @@ static int gpfs_getacl_with_capability(struct files_struct *fsp, set_effective_capability(DAC_OVERRIDE_CAPABILITY); - ret = gpfswrap_getacl(fname, flags, buf); + ret = gpfswrap_fgetacl(fsp_get_pathref_fd(fsp), flags, buf); saved_errno = errno; drop_effective_capability(DAC_OVERRIDE_CAPABILITY); @@ -482,7 +482,7 @@ static void *vfs_gpfs_getacl(TALLOC_CTX *mem_ctx, if (use_capability) { ret = gpfs_getacl_with_capability(fsp, flags, aclbuf); } else { - ret = gpfswrap_getacl(fname, flags, aclbuf); + ret = gpfswrap_fgetacl(fsp_get_pathref_fd(fsp), flags, aclbuf); if ((ret != 0) && (errno == EACCES)) { DBG_DEBUG("Retry with DAC capability for %s\n", fname); use_capability = true; -- 2.35.3 From 69e68a26ee14b1f8f8e1f3837367abd2cfc2cab1 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Tue, 17 May 2022 16:27:58 +0200 Subject: [PATCH 10/12] lib/util/gpfswrap: remove unused gpfswrap_getacl() BUG: https://bugzilla.samba.org/show_bug.cgi?id=15069 Signed-off-by: Ralph Boehme Reviewed-by: Christof Schmitt (cherry picked from commit 9172c5ff6a419e4daef451564650d4a3ce96bfae) --- lib/util/gpfswrap.c | 12 ------------ lib/util/gpfswrap.h | 1 - 2 files changed, 13 deletions(-) diff --git a/lib/util/gpfswrap.c b/lib/util/gpfswrap.c index ff0b9bd70316..b71a1606e7f9 100644 --- a/lib/util/gpfswrap.c +++ b/lib/util/gpfswrap.c @@ -23,7 +23,6 @@ static int (*gpfs_set_share_fn)(int fd, unsigned int allow, unsigned int deny); static int (*gpfs_set_lease_fn)(int fd, unsigned int type); -static int (*gpfs_getacl_fn)(const char *pathname, int flags, void *acl); static int (*gpfs_fgetacl_fn)(int fd, int flags, void *acl); static int (*gpfs_putacl_fn)(const char *pathname, int flags, void *acl); static int (*gpfs_get_realfilename_path_fn)(const char *pathname, @@ -71,7 +70,6 @@ int gpfswrap_init(void) gpfs_set_share_fn = dlsym(l, "gpfs_set_share"); gpfs_set_lease_fn = dlsym(l, "gpfs_set_lease"); - gpfs_getacl_fn = dlsym(l, "gpfs_getacl"); gpfs_fgetacl_fn = dlsym(l, "gpfs_getacl_fd"); gpfs_putacl_fn = dlsym(l, "gpfs_putacl"); gpfs_get_realfilename_path_fn = dlsym(l, "gpfs_get_realfilename_path"); @@ -114,16 +112,6 @@ int gpfswrap_set_lease(int fd, unsigned int type) return gpfs_set_lease_fn(fd, type); } -int gpfswrap_getacl(const char *pathname, int flags, void *acl) -{ - if (gpfs_getacl_fn == NULL) { - errno = ENOSYS; - return -1; - } - - return gpfs_getacl_fn(pathname, flags, acl); -} - int gpfswrap_fgetacl(int fd, int flags, void *acl) { if (gpfs_fgetacl_fn == NULL) { diff --git a/lib/util/gpfswrap.h b/lib/util/gpfswrap.h index db541b31f102..f9b96a3cf497 100644 --- a/lib/util/gpfswrap.h +++ b/lib/util/gpfswrap.h @@ -29,7 +29,6 @@ int gpfswrap_init(void); int gpfswrap_set_share(int fd, unsigned int allow, unsigned int deny); int gpfswrap_set_lease(int fd, unsigned int type); -int gpfswrap_getacl(const char *pathname, int flags, void *acl); int gpfswrap_fgetacl(int fd, int flags, void *acl); int gpfswrap_putacl(const char *pathname, int flags, void *acl); int gpfswrap_get_realfilename_path(const char *pathname, -- 2.35.3 From ac41d6be100f2d9f280d63573329095ba43aa579 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Tue, 17 May 2022 16:32:23 +0200 Subject: [PATCH 11/12] vfs_gpfs: use handle based gpfswrap_get_winattrs() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes detecting offline flag for files in snapshot – no idea if this is actually expected. Replaces path based gpfswrap_get_winattrs_path() with handle based version gpfswrap_get_winattrs(). When dealing with files in snapshots fsp->fsp_name points to the active dataset, which will cause ENOENT failures if files are deleted there any only present in the snapshot. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15069 Signed-off-by: Ralph Boehme Reviewed-by: Christof Schmitt (cherry picked from commit 8ae672f955bf07bb97f38b7d2f965f14e8315e9e) --- source3/modules/vfs_gpfs.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index 5085912210d5..58424cdb9a5a 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -1911,7 +1911,7 @@ static int vfs_gpfs_ftruncate(vfs_handle_struct *handle, files_struct *fsp, } static bool vfs_gpfs_is_offline(struct vfs_handle_struct *handle, - const struct smb_filename *fname, + struct files_struct *fsp, SMB_STRUCT_STAT *sbuf) { struct gpfs_winattr attrs; @@ -1926,17 +1926,17 @@ static bool vfs_gpfs_is_offline(struct vfs_handle_struct *handle, return false; } - ret = gpfswrap_get_winattrs_path(fname->base_name, &attrs); + ret = gpfswrap_get_winattrs(fsp_get_pathref_fd(fsp), &attrs); if (ret == -1) { return false; } if ((attrs.winAttrs & GPFS_WINATTR_OFFLINE) != 0) { - DBG_DEBUG("%s is offline\n", fname->base_name); + DBG_DEBUG("%s is offline\n", fsp_str_dbg(fsp)); return true; } - DBG_DEBUG("%s is online\n", fname->base_name); + DBG_DEBUG("%s is online\n", fsp_str_dbg(fsp)); return false; } @@ -1950,7 +1950,7 @@ static bool vfs_gpfs_fsp_is_offline(struct vfs_handle_struct *handle, /* * Something bad happened, always ask. */ - return vfs_gpfs_is_offline(handle, fsp->fsp_name, + return vfs_gpfs_is_offline(handle, fsp, &fsp->fsp_name->st); } @@ -1958,7 +1958,7 @@ static bool vfs_gpfs_fsp_is_offline(struct vfs_handle_struct *handle, /* * As long as it's offline, ask. */ - ext->offline = vfs_gpfs_is_offline(handle, fsp->fsp_name, + ext->offline = vfs_gpfs_is_offline(handle, fsp, &fsp->fsp_name->st); } -- 2.35.3 From b41acb6342ebbfe3b64ee022c14ba54ab8238469 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Tue, 17 May 2022 16:52:21 +0200 Subject: [PATCH 12/12] lib/util/gpfswrap: remove unused gpfswrap_get_winattrs_path() BUG: https://bugzilla.samba.org/show_bug.cgi?id=15069 Signed-off-by: Ralph Boehme Reviewed-by: Christof Schmitt Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Fri Jun 3 21:53:31 UTC 2022 on sn-devel-184 (cherry picked from commit 3bd753983c8dac33b483affa859984b7e3350d65) --- lib/util/gpfswrap.c | 14 -------------- lib/util/gpfswrap.h | 2 -- 2 files changed, 16 deletions(-) diff --git a/lib/util/gpfswrap.c b/lib/util/gpfswrap.c index b71a1606e7f9..d05358e141e3 100644 --- a/lib/util/gpfswrap.c +++ b/lib/util/gpfswrap.c @@ -33,8 +33,6 @@ static int (*gpfs_set_winattrs_path_fn)(const char *pathname, struct gpfs_winattr *attrs); static int (*gpfs_set_winattrs_fn)(int fd, int flags, struct gpfs_winattr *attrs); -static int (*gpfs_get_winattrs_path_fn)(const char *pathname, - struct gpfs_winattr *attrs); static int (*gpfs_get_winattrs_fn)(int fd, struct gpfs_winattr *attrs); static int (*gpfs_ftruncate_fn)(int fd, gpfs_off64_t length); static int (*gpfs_lib_init_fn)(int flags); @@ -75,7 +73,6 @@ int gpfswrap_init(void) gpfs_get_realfilename_path_fn = dlsym(l, "gpfs_get_realfilename_path"); gpfs_set_winattrs_path_fn = dlsym(l, "gpfs_set_winattrs_path"); gpfs_set_winattrs_fn = dlsym(l, "gpfs_set_winattrs"); - gpfs_get_winattrs_path_fn = dlsym(l, "gpfs_get_winattrs_path"); gpfs_get_winattrs_fn = dlsym(l, "gpfs_get_winattrs"); gpfs_ftruncate_fn = dlsym(l, "gpfs_ftruncate"); gpfs_lib_init_fn = dlsym(l, "gpfs_lib_init"); @@ -166,17 +163,6 @@ int gpfswrap_set_winattrs(int fd, int flags, struct gpfs_winattr *attrs) return gpfs_set_winattrs_fn(fd, flags, attrs); } -int gpfswrap_get_winattrs_path(const char *pathname, - struct gpfs_winattr *attrs) -{ - if (gpfs_get_winattrs_path_fn == NULL) { - errno = ENOSYS; - return -1; - } - - return gpfs_get_winattrs_path_fn(pathname, attrs); -} - int gpfswrap_get_winattrs(int fd, struct gpfs_winattr *attrs) { if (gpfs_get_winattrs_fn == NULL) { diff --git a/lib/util/gpfswrap.h b/lib/util/gpfswrap.h index f9b96a3cf497..1e74496c0602 100644 --- a/lib/util/gpfswrap.h +++ b/lib/util/gpfswrap.h @@ -38,8 +38,6 @@ int gpfswrap_set_winattrs_path(const char *pathname, int flags, struct gpfs_winattr *attrs); int gpfswrap_set_winattrs(int fd, int flags, struct gpfs_winattr *attrs); -int gpfswrap_get_winattrs_path(const char *pathname, - struct gpfs_winattr *attrs); int gpfswrap_get_winattrs(int fd, struct gpfs_winattr *attrs); int gpfswrap_ftruncate(int fd, gpfs_off64_t length); int gpfswrap_lib_init(int flags); -- 2.35.3