From 85c8780581e0f2bb0fdb940a865857db68111fbd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 23 May 2017 15:33:31 -0700 Subject: [PATCH] s3: VFS: Change SMB_VFS_SYS_ACL_DELETE_DEF_FILE to use const struct smb_filename * instead of const char *. We need to migrate all pathname based VFS calls to use a struct to finish modernising the VFS with extra timestamp and flags parameters. Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme --- examples/VFS/skel_opaque.c | 2 +- examples/VFS/skel_transparent.c | 4 ++-- source3/include/smb_acls.h | 3 ++- source3/include/vfs.h | 7 +++++-- source3/include/vfs_macros.h | 8 ++++---- source3/lib/sysacls.c | 22 +++++++++++----------- source3/modules/posixacl_xattr.c | 6 ++++-- source3/modules/posixacl_xattr.h | 2 +- source3/modules/vfs_aixacl.c | 2 +- source3/modules/vfs_aixacl2.c | 2 +- source3/modules/vfs_cap.c | 29 ++++++++++++++++++++++++++--- source3/modules/vfs_catia.c | 28 ++++++++++++++++++++++++---- source3/modules/vfs_default.c | 5 +++-- source3/modules/vfs_fake_acls.c | 9 +++++---- source3/modules/vfs_full_audit.c | 7 +++---- source3/modules/vfs_gpfs.c | 4 ++-- source3/modules/vfs_hpuxacl.c | 7 ++++--- source3/modules/vfs_hpuxacl.h | 2 +- source3/modules/vfs_media_harmony.c | 27 +++++++++++---------------- source3/modules/vfs_nfs4acl_xattr.c | 2 +- source3/modules/vfs_posixacl.c | 4 ++-- source3/modules/vfs_posixacl.h | 2 +- source3/modules/vfs_solarisacl.c | 6 +++--- source3/modules/vfs_solarisacl.h | 2 +- source3/modules/vfs_time_audit.c | 7 ++++--- source3/modules/vfs_tru64acl.c | 4 ++-- source3/modules/vfs_tru64acl.h | 2 +- source3/modules/vfs_unityed_media.c | 26 ++++++++++++++++++-------- source3/modules/vfs_zfsacl.c | 2 +- source3/smbd/posix_acls.c | 28 +++++++++++++++++----------- source3/smbd/proto.h | 4 ++-- source3/smbd/trans2.c | 2 +- source3/smbd/vfs.c | 4 ++-- source3/torture/cmd_vfs.c | 14 +++++++++++++- 34 files changed, 180 insertions(+), 105 deletions(-) diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c index af119f32db1..801012a8965 100644 --- a/examples/VFS/skel_opaque.c +++ b/examples/VFS/skel_opaque.c @@ -787,7 +787,7 @@ static int skel_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, } static int skel_sys_acl_delete_def_file(vfs_handle_struct *handle, - const char *path) + const struct smb_filename *smb_fname) { errno = ENOSYS; return -1; diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c index e9745292730..0404a2e11c9 100644 --- a/examples/VFS/skel_transparent.c +++ b/examples/VFS/skel_transparent.c @@ -923,9 +923,9 @@ static int skel_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, } static int skel_sys_acl_delete_def_file(vfs_handle_struct *handle, - const char *path) + const struct smb_filename *smb_fname) { - return SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, path); + return SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, smb_fname); } static ssize_t skel_getxattr(vfs_handle_struct *handle, const char *path, diff --git a/source3/include/smb_acls.h b/source3/include/smb_acls.h index 3ac23dbbfd3..6a41e196e19 100644 --- a/source3/include/smb_acls.h +++ b/source3/include/smb_acls.h @@ -24,6 +24,7 @@ struct vfs_handle_struct; struct files_struct; +struct smb_filename; typedef int SMB_ACL_TYPE_T; typedef mode_t *SMB_ACL_PERMSET_T; @@ -61,7 +62,7 @@ int sys_acl_set_file(struct vfs_handle_struct *handle, int sys_acl_set_fd(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_ACL_T acl_d); int sys_acl_delete_def_file(struct vfs_handle_struct *handle, - const char *path); + const struct smb_filename *smb_fname); int no_acl_syscall_error(int err); #endif /* _SMB_ACLS_H */ diff --git a/source3/include/vfs.h b/source3/include/vfs.h index 79089806e24..8fe5536ffcc 100644 --- a/source3/include/vfs.h +++ b/source3/include/vfs.h @@ -197,6 +197,8 @@ /* Version 36 - Remove is_offline and set_offline */ /* Version 37 - Module init functions now take a TALLOC_CTX * parameter. */ /* Version 37 - Add vfs_copy_chunk_flags for DUP_EXTENTS_TO_FILE */ +/* Version 37 - Change sys_acl_delete_def_file from const char * + to const struct smb_filename * */ #define SMB_VFS_INTERFACE_VERSION 37 @@ -872,7 +874,8 @@ struct vfs_fn_pointers { DATA_BLOB *blob); int (*sys_acl_set_file_fn)(struct vfs_handle_struct *handle, const char *name, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl); int (*sys_acl_set_fd_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_ACL_T theacl); - int (*sys_acl_delete_def_file_fn)(struct vfs_handle_struct *handle, const char *path); + int (*sys_acl_delete_def_file_fn)(struct vfs_handle_struct *handle, + const struct smb_filename *smb_fname); /* EA operations. */ ssize_t (*getxattr_fn)(struct vfs_handle_struct *handle,const char *path, const char *name, void *value, size_t size); @@ -1333,7 +1336,7 @@ int smb_vfs_call_sys_acl_set_file(struct vfs_handle_struct *handle, int smb_vfs_call_sys_acl_set_fd(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_ACL_T theacl); int smb_vfs_call_sys_acl_delete_def_file(struct vfs_handle_struct *handle, - const char *path); + const struct smb_filename *smb_fname); ssize_t smb_vfs_call_getxattr(struct vfs_handle_struct *handle, const char *path, const char *name, void *value, size_t size); diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h index 0cbcf89cce5..43dfe929fff 100644 --- a/source3/include/vfs_macros.h +++ b/source3/include/vfs_macros.h @@ -510,10 +510,10 @@ #define SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl) \ smb_vfs_call_sys_acl_set_fd((handle)->next, (fsp), (theacl)) -#define SMB_VFS_SYS_ACL_DELETE_DEF_FILE(conn, path) \ - smb_vfs_call_sys_acl_delete_def_file((conn)->vfs_handles, (path)) -#define SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, path) \ - smb_vfs_call_sys_acl_delete_def_file((handle)->next, (path)) +#define SMB_VFS_SYS_ACL_DELETE_DEF_FILE(conn, smb_fname) \ + smb_vfs_call_sys_acl_delete_def_file((conn)->vfs_handles, (smb_fname)) +#define SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, smb_fname) \ + smb_vfs_call_sys_acl_delete_def_file((handle)->next, (smb_fname)) #define SMB_VFS_GETXATTR(conn,path,name,value,size) \ smb_vfs_call_getxattr((conn)->vfs_handles,(path),(name),(value),(size)) diff --git a/source3/lib/sysacls.c b/source3/lib/sysacls.c index 7cff488ba2c..b75c98149ac 100644 --- a/source3/lib/sysacls.c +++ b/source3/lib/sysacls.c @@ -385,9 +385,9 @@ int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, } int sys_acl_delete_def_file(vfs_handle_struct *handle, - const char *path) + const struct smb_filename *smb_fname) { - return posixacl_sys_acl_delete_def_file(handle, path); + return posixacl_sys_acl_delete_def_file(handle, smb_fname); } #elif defined(HAVE_AIX_ACLS) @@ -418,9 +418,9 @@ int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, } int sys_acl_delete_def_file(vfs_handle_struct *handle, - const char *path) + const struct smb_filename *smb_fname) { - return aixacl_sys_acl_delete_def_file(handle, path); + return aixacl_sys_acl_delete_def_file(handle, smb_fname); } #elif defined(HAVE_TRU64_ACLS) @@ -452,9 +452,9 @@ int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, } int sys_acl_delete_def_file(vfs_handle_struct *handle, - const char *path) + const struct smb_filename *smb_fname) { - return tru64acl_sys_acl_delete_def_file(handle, path); + return tru64acl_sys_acl_delete_def_file(handle, smb_fname); } #elif defined(HAVE_SOLARIS_UNIXWARE_ACLS) @@ -487,9 +487,9 @@ int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, } int sys_acl_delete_def_file(vfs_handle_struct *handle, - const char *path) + const struct smb_filename *smb_fname) { - return solarisacl_sys_acl_delete_def_file(handle, path); + return solarisacl_sys_acl_delete_def_file(handle, smb_fname); } #elif defined(HAVE_HPUX_ACLS) @@ -520,9 +520,9 @@ int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, } int sys_acl_delete_def_file(vfs_handle_struct *handle, - const char *path) + const struct smb_filename *smb_fname) { - return hpuxacl_sys_acl_delete_def_file(handle, path); + return hpuxacl_sys_acl_delete_def_file(handle, smb_fname); } #else /* No ACLs. */ @@ -573,7 +573,7 @@ int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, } int sys_acl_delete_def_file(vfs_handle_struct *handle, - const char *path) + const struct smb_filename *smb_fname) { #ifdef ENOTSUP errno = ENOTSUP; diff --git a/source3/modules/posixacl_xattr.c b/source3/modules/posixacl_xattr.c index 652a2eee2c2..871aa669f1a 100644 --- a/source3/modules/posixacl_xattr.c +++ b/source3/modules/posixacl_xattr.c @@ -498,7 +498,9 @@ int posixacl_xattr_acl_set_fd(vfs_handle_struct *handle, } int posixacl_xattr_acl_delete_def_file(vfs_handle_struct *handle, - const char *path_p) + const struct smb_filename *smb_fname) { - return SMB_VFS_REMOVEXATTR(handle->conn, path_p, ACL_EA_DEFAULT); + return SMB_VFS_REMOVEXATTR(handle->conn, + smb_fname->base_name, + ACL_EA_DEFAULT); } diff --git a/source3/modules/posixacl_xattr.h b/source3/modules/posixacl_xattr.h index 9e0aa5879f1..6f6316ae453 100644 --- a/source3/modules/posixacl_xattr.h +++ b/source3/modules/posixacl_xattr.h @@ -40,5 +40,5 @@ int posixacl_xattr_acl_set_fd(vfs_handle_struct *handle, SMB_ACL_T theacl); int posixacl_xattr_acl_delete_def_file(vfs_handle_struct *handle, - const char *path); + const struct smb_filename *smb_fname); #endif diff --git a/source3/modules/vfs_aixacl.c b/source3/modules/vfs_aixacl.c index 169058f2afc..c25c249a6f5 100644 --- a/source3/modules/vfs_aixacl.c +++ b/source3/modules/vfs_aixacl.c @@ -174,7 +174,7 @@ int aixacl_sys_acl_set_fd(vfs_handle_struct *handle, } int aixacl_sys_acl_delete_def_file(vfs_handle_struct *handle, - const char *path) + const struct smb_filename *smb_fname) { return 0; /* otherwise you can't set acl at upper level */ } diff --git a/source3/modules/vfs_aixacl2.c b/source3/modules/vfs_aixacl2.c index aaf6e293ec3..e46e5026215 100644 --- a/source3/modules/vfs_aixacl2.c +++ b/source3/modules/vfs_aixacl2.c @@ -538,7 +538,7 @@ int aixjfs2_sys_acl_set_fd(vfs_handle_struct *handle, } int aixjfs2_sys_acl_delete_def_file(vfs_handle_struct *handle, - const char *path) + const struct smb_filename *smb_fname) { /* Not available under AIXC ACL */ /* Don't report here any error otherwise */ diff --git a/source3/modules/vfs_cap.c b/source3/modules/vfs_cap.c index 03608301bf5..41799262675 100644 --- a/source3/modules/vfs_cap.c +++ b/source3/modules/vfs_cap.c @@ -568,15 +568,38 @@ static int cap_sys_acl_set_file(vfs_handle_struct *handle, const char *path, SMB return SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, cappath, acltype, theacl); } -static int cap_sys_acl_delete_def_file(vfs_handle_struct *handle, const char *path) +static int cap_sys_acl_delete_def_file(vfs_handle_struct *handle, + const struct smb_filename *smb_fname) { - char *cappath = capencode(talloc_tos(), path); + struct smb_filename *cap_smb_fname = NULL; + char *cappath = capencode(talloc_tos(), smb_fname->base_name); + int ret; + int saved_errno = 0; if (!cappath) { errno = ENOMEM; return -1; } - return SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, cappath); + cap_smb_fname = synthetic_smb_fname(talloc_tos(), + cappath, + NULL, + NULL, + smb_fname->flags); + if (cap_smb_fname == NULL) { + TALLOC_FREE(cappath); + errno = ENOMEM; + return -1; + } + ret = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, cap_smb_fname); + if (ret == -1) { + saved_errno = errno; + } + TALLOC_FREE(cappath); + TALLOC_FREE(cap_smb_fname); + if (saved_errno) { + errno = saved_errno; + } + return ret; } static ssize_t cap_getxattr(vfs_handle_struct *handle, const char *path, const char *name, void *value, size_t size) diff --git a/source3/modules/vfs_catia.c b/source3/modules/vfs_catia.c index 972f51a5ba6..7ed531ac0a3 100644 --- a/source3/modules/vfs_catia.c +++ b/source3/modules/vfs_catia.c @@ -1292,22 +1292,42 @@ catia_sys_acl_set_file(vfs_handle_struct *handle, static int catia_sys_acl_delete_def_file(vfs_handle_struct *handle, - const char *path) + const struct smb_filename *smb_fname) { + struct smb_filename *mapped_smb_fname = NULL; + int saved_errno = 0; char *mapped_name = NULL; NTSTATUS status; int ret; status = catia_string_replace_allocate(handle->conn, - path, &mapped_name, vfs_translate_to_unix); + smb_fname->base_name, + &mapped_name, + vfs_translate_to_unix); if (!NT_STATUS_IS_OK(status)) { errno = map_errno_from_nt_status(status); return -1; } - ret = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, mapped_name); + mapped_smb_fname = synthetic_smb_fname(talloc_tos(), + mapped_name, + NULL, + NULL, + smb_fname->flags); + if (mapped_smb_fname == NULL) { + TALLOC_FREE(mapped_name); + errno = ENOMEM; + return -1; + } + ret = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, mapped_smb_fname); + if (ret == -1) { + saved_errno = errno; + } + TALLOC_FREE(mapped_smb_fname); TALLOC_FREE(mapped_name); - + if (saved_errno != 0) { + errno = saved_errno; + } return ret; } diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index e1b2712d793..19b6925a3a4 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -2734,9 +2734,10 @@ static int vfswrap_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, return sys_acl_set_fd(handle, fsp, theacl); } -static int vfswrap_sys_acl_delete_def_file(vfs_handle_struct *handle, const char *path) +static int vfswrap_sys_acl_delete_def_file(vfs_handle_struct *handle, + const struct smb_filename *smb_fname) { - return sys_acl_delete_def_file(handle, path); + return sys_acl_delete_def_file(handle, smb_fname); } /**************************************************************** diff --git a/source3/modules/vfs_fake_acls.c b/source3/modules/vfs_fake_acls.c index 62b53b6dd61..fae8014f78e 100644 --- a/source3/modules/vfs_fake_acls.c +++ b/source3/modules/vfs_fake_acls.c @@ -357,14 +357,15 @@ static int fake_acls_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp return ret; } -static int fake_acls_sys_acl_delete_def_file(vfs_handle_struct *handle, const char *path) +static int fake_acls_sys_acl_delete_def_file(vfs_handle_struct *handle, + const struct smb_filename *smb_fname_in) { int ret; const char *name = FAKE_ACL_DEFAULT_XATTR; TALLOC_CTX *frame = talloc_stackframe(); - struct smb_filename *smb_fname; + struct smb_filename *smb_fname = cp_smb_filename_nostream(talloc_tos(), + smb_fname_in); - smb_fname = synthetic_smb_fname(frame, path, NULL, NULL, 0); if (smb_fname == NULL) { TALLOC_FREE(frame); errno = ENOMEM; @@ -383,7 +384,7 @@ static int fake_acls_sys_acl_delete_def_file(vfs_handle_struct *handle, const ch return -1; } - ret = SMB_VFS_NEXT_REMOVEXATTR(handle, path, name); + ret = SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname->base_name, name); if (ret == -1 && errno == ENOATTR) { ret = 0; errno = 0; diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index 4c2eb87ddb1..e6ee5770afe 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -2241,15 +2241,14 @@ static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct *handle, files_struct } static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct *handle, - - const char *path) + const struct smb_filename *smb_fname) { int result; - result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, path); + result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, smb_fname); do_log(SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, (result >= 0), handle, - "%s", path); + "%s", smb_fname->base_name); return result; } diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index d1d59ce6321..fa2664e8d07 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -1279,7 +1279,7 @@ static int gpfsacl_sys_acl_set_fd(vfs_handle_struct *handle, } static int gpfsacl_sys_acl_delete_def_file(vfs_handle_struct *handle, - const char *path) + const struct smb_filename *smb_fname) { struct gpfs_config_data *config; @@ -1288,7 +1288,7 @@ static int gpfsacl_sys_acl_delete_def_file(vfs_handle_struct *handle, return -1); if (!config->acl) { - return SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, path); + return SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, smb_fname); } errno = ENOTSUP; diff --git a/source3/modules/vfs_hpuxacl.c b/source3/modules/vfs_hpuxacl.c index d91657a00a6..f666a5eceb5 100644 --- a/source3/modules/vfs_hpuxacl.c +++ b/source3/modules/vfs_hpuxacl.c @@ -358,7 +358,7 @@ int hpuxacl_sys_acl_set_fd(vfs_handle_struct *handle, * check is considered unnecessary. --- Agreed? XXX */ int hpuxacl_sys_acl_delete_def_file(vfs_handle_struct *handle, - const char *path) + const struct smb_filename *smb_fname) { SMB_ACL_T smb_acl; int ret = -1; @@ -367,7 +367,7 @@ int hpuxacl_sys_acl_delete_def_file(vfs_handle_struct *handle, DEBUG(10, ("entering hpuxacl_sys_acl_delete_def_file.\n")); - smb_acl = hpuxacl_sys_acl_get_file(handle, path, + smb_acl = hpuxacl_sys_acl_get_file(handle, smb_fname->base_name, SMB_ACL_TYPE_ACCESS); if (smb_acl == NULL) { DEBUG(10, ("getting file acl failed!\n")); @@ -383,7 +383,8 @@ int hpuxacl_sys_acl_delete_def_file(vfs_handle_struct *handle, DEBUG(10, ("resulting acl is not valid!\n")); goto done; } - ret = acl(discard_const_p(char, path), ACL_SET, count, hpux_acl); + ret = acl(discard_const_p(char, smb_fname->base_name), + ACL_SET, count, hpux_acl); if (ret != 0) { DEBUG(10, ("settinge file acl failed!\n")); } diff --git a/source3/modules/vfs_hpuxacl.h b/source3/modules/vfs_hpuxacl.h index 07b32d628ca..df30e17f51b 100644 --- a/source3/modules/vfs_hpuxacl.h +++ b/source3/modules/vfs_hpuxacl.h @@ -50,7 +50,7 @@ int hpuxacl_sys_acl_set_fd(vfs_handle_struct *handle, SMB_ACL_T theacl); int hpuxacl_sys_acl_delete_def_file(vfs_handle_struct *handle, - const char *path); + const struct smb_filename *smb_fname); NTSTATUS vfs_hpuxacl_init(void); diff --git a/source3/modules/vfs_media_harmony.c b/source3/modules/vfs_media_harmony.c index 794644ed493..9a5b99db8e3 100644 --- a/source3/modules/vfs_media_harmony.c +++ b/source3/modules/vfs_media_harmony.c @@ -2179,33 +2179,28 @@ out: * Failure: set errno, return -1 */ static int mh_sys_acl_delete_def_file(vfs_handle_struct *handle, - const char *path) + const struct smb_filename *smb_fname) { int status; - char *clientPath; - TALLOC_CTX *ctx; + struct smb_filename *clientFname = NULL; DEBUG(MH_INFO_DEBUG, ("Entering mh_sys_acl_delete_def_file\n")); - if (!is_in_media_files(path)) - { + if (!is_in_media_files(smb_fname->base_name)) { status = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, - path); + smb_fname); goto out; } - clientPath = NULL; - ctx = talloc_tos(); - - if ((status = alloc_get_client_path(handle, ctx, - path, - &clientPath))) - { + status = alloc_get_client_smb_fname(handle, + talloc_tos(), + smb_fname, + &clientFname); + if (status != 0) { goto err; } - - status = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, clientPath); + status = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, clientFname); err: - TALLOC_FREE(clientPath); + TALLOC_FREE(clientFname); out: return status; } diff --git a/source3/modules/vfs_nfs4acl_xattr.c b/source3/modules/vfs_nfs4acl_xattr.c index a22ae7fc284..cae3e7bea65 100644 --- a/source3/modules/vfs_nfs4acl_xattr.c +++ b/source3/modules/vfs_nfs4acl_xattr.c @@ -615,7 +615,7 @@ static int nfs4acl_xattr_fail__sys_acl_set_fd(vfs_handle_struct *handle, } static int nfs4acl_xattr_fail__sys_acl_delete_def_file(vfs_handle_struct *handle, - const char *path) + const struct smb_filename *smb_fname) { return -1; } diff --git a/source3/modules/vfs_posixacl.c b/source3/modules/vfs_posixacl.c index 85d84a578f5..ed8f1bae8f0 100644 --- a/source3/modules/vfs_posixacl.c +++ b/source3/modules/vfs_posixacl.c @@ -129,9 +129,9 @@ int posixacl_sys_acl_set_fd(vfs_handle_struct *handle, } int posixacl_sys_acl_delete_def_file(vfs_handle_struct *handle, - const char *path) + const struct smb_filename *smb_fname) { - return acl_delete_def_file(path); + return acl_delete_def_file(smb_fname->base_name); } diff --git a/source3/modules/vfs_posixacl.h b/source3/modules/vfs_posixacl.h index 59d3dc964bd..b64bdb280ab 100644 --- a/source3/modules/vfs_posixacl.h +++ b/source3/modules/vfs_posixacl.h @@ -40,7 +40,7 @@ int posixacl_sys_acl_set_fd(vfs_handle_struct *handle, SMB_ACL_T theacl); int posixacl_sys_acl_delete_def_file(vfs_handle_struct *handle, - const char *path); + const struct smb_filename *smb_fname); NTSTATUS vfs_posixacl_init(TALLOC_CTX *); diff --git a/source3/modules/vfs_solarisacl.c b/source3/modules/vfs_solarisacl.c index e5a581c05f8..48305c50180 100644 --- a/source3/modules/vfs_solarisacl.c +++ b/source3/modules/vfs_solarisacl.c @@ -298,7 +298,7 @@ int solarisacl_sys_acl_set_fd(vfs_handle_struct *handle, * check is considered unnecessary. --- Agreed? XXX */ int solarisacl_sys_acl_delete_def_file(vfs_handle_struct *handle, - const char *path) + struct smb_filename *smb_fname) { SMB_ACL_T smb_acl; int ret = -1; @@ -307,7 +307,7 @@ int solarisacl_sys_acl_delete_def_file(vfs_handle_struct *handle, DEBUG(10, ("entering solarisacl_sys_acl_delete_def_file.\n")); - smb_acl = solarisacl_sys_acl_get_file(handle, path, + smb_acl = solarisacl_sys_acl_get_file(handle, smb_fname->base_name, SMB_ACL_TYPE_ACCESS, talloc_tos()); if (smb_acl == NULL) { DEBUG(10, ("getting file acl failed!\n")); @@ -323,7 +323,7 @@ int solarisacl_sys_acl_delete_def_file(vfs_handle_struct *handle, DEBUG(10, ("resulting acl is not valid!\n")); goto done; } - ret = acl(path, SETACL, count, solaris_acl); + ret = acl(smb_fname->base_name, SETACL, count, solaris_acl); if (ret != 0) { DEBUG(10, ("settinge file acl failed!\n")); } diff --git a/source3/modules/vfs_solarisacl.h b/source3/modules/vfs_solarisacl.h index 20f1051bb52..941f7669155 100644 --- a/source3/modules/vfs_solarisacl.h +++ b/source3/modules/vfs_solarisacl.h @@ -39,7 +39,7 @@ int solarisacl_sys_acl_set_fd(vfs_handle_struct *handle, SMB_ACL_T theacl); int solarisacl_sys_acl_delete_def_file(vfs_handle_struct *handle, - const char *path); + const struct smb_filename *smb_fname); NTSTATUS vfs_solarisacl_init(void); diff --git a/source3/modules/vfs_time_audit.c b/source3/modules/vfs_time_audit.c index 52bd00edb13..c86f0dfc181 100644 --- a/source3/modules/vfs_time_audit.c +++ b/source3/modules/vfs_time_audit.c @@ -2297,19 +2297,20 @@ static int smb_time_audit_sys_acl_set_fd(vfs_handle_struct *handle, } static int smb_time_audit_sys_acl_delete_def_file(vfs_handle_struct *handle, - const char *path) + const struct smb_filename *smb_fname) { int result; struct timespec ts1,ts2; double timediff; clock_gettime_mono(&ts1); - result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, path); + result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, smb_fname); clock_gettime_mono(&ts2); timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log_fname("sys_acl_delete_def_file", timediff, path); + smb_time_audit_log_fname("sys_acl_delete_def_file", timediff, + smb_fname->base_name); } return result; diff --git a/source3/modules/vfs_tru64acl.c b/source3/modules/vfs_tru64acl.c index 83edc15205e..83f3289deb0 100644 --- a/source3/modules/vfs_tru64acl.c +++ b/source3/modules/vfs_tru64acl.c @@ -148,9 +148,9 @@ int tru64acl_sys_acl_set_fd(vfs_handle_struct *handle, } int tru64acl_sys_acl_delete_def_file(vfs_handle_struct *handle, - const char *path) + const struct smb_filename *smb_fname) { - return acl_delete_def_file((char *)path); + return acl_delete_def_file((char *)smb_fname->base_name); } diff --git a/source3/modules/vfs_tru64acl.h b/source3/modules/vfs_tru64acl.h index af79e2f9b65..3825be08a26 100644 --- a/source3/modules/vfs_tru64acl.h +++ b/source3/modules/vfs_tru64acl.h @@ -37,7 +37,7 @@ int tru64acl_sys_acl_set_fd(vfs_handle_struct *handle, SMB_ACL_T theacl); int tru64acl_sys_acl_delete_def_file(vfs_handle_struct *handle, - const char *path); + const struct smb_filename *smb_fname); NTSTATUS vfs_tru64acl_init(void); diff --git a/source3/modules/vfs_unityed_media.c b/source3/modules/vfs_unityed_media.c index ccafb882df7..bbccb66c5cc 100644 --- a/source3/modules/vfs_unityed_media.c +++ b/source3/modules/vfs_unityed_media.c @@ -1668,27 +1668,37 @@ err: } static int um_sys_acl_delete_def_file(vfs_handle_struct *handle, - const char *path) + const struct smb_filename *smb_fname) { int status; - char *client_path = NULL; + int saved_errno = 0; + struct smb_filename *client_fname = NULL; DEBUG(10, ("Entering um_sys_acl_delete_def_file\n")); - if (!is_in_media_files(path)) { - return SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, path); + if (!is_in_media_files(smb_fname->base_name)) { + return SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, + smb_fname); } - status = alloc_get_client_path(handle, talloc_tos(), - path, &client_path); + status = alloc_get_client_smb_fname(handle, + talloc_tos(), + smb_fname, + &client_fname); if (status != 0) { goto err; } - status = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, client_path); + status = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, client_fname); err: - TALLOC_FREE(client_path); + if (status == -1) { + saved_errno = errno; + } + TALLOC_FREE(client_fname); + if (saved_errno != 0) { + errno = saved_errno; + } return status; } diff --git a/source3/modules/vfs_zfsacl.c b/source3/modules/vfs_zfsacl.c index 6eadf42e600..c59a9106260 100644 --- a/source3/modules/vfs_zfsacl.c +++ b/source3/modules/vfs_zfsacl.c @@ -314,7 +314,7 @@ static int zfsacl_fail__sys_acl_set_fd(vfs_handle_struct *handle, } static int zfsacl_fail__sys_acl_delete_def_file(vfs_handle_struct *handle, - const char *path) + const struct smb_filename *smb_fname) { return -1; } diff --git a/source3/smbd/posix_acls.c b/source3/smbd/posix_acls.c index 72bb9fe086e..c02331d1230 100644 --- a/source3/smbd/posix_acls.c +++ b/source3/smbd/posix_acls.c @@ -3927,7 +3927,7 @@ NTSTATUS set_nt_acl(files_struct *fsp, uint32_t security_info_sent, const struct become_root(); } sret = SMB_VFS_SYS_ACL_DELETE_DEF_FILE(conn, - fsp->fsp_name->base_name); + fsp->fsp_name); if (set_acl_as_root) { unbecome_root(); } @@ -3943,7 +3943,7 @@ NTSTATUS set_nt_acl(files_struct *fsp, uint32_t security_info_sent, const struct sret = SMB_VFS_SYS_ACL_DELETE_DEF_FILE( conn, - fsp->fsp_name->base_name); + fsp->fsp_name); unbecome_root(); } @@ -4410,14 +4410,18 @@ static SMB_ACL_T create_posix_acl_from_wire(connection_struct *conn, on the directory. ****************************************************************************/ -bool set_unix_posix_default_acl(connection_struct *conn, const char *fname, const SMB_STRUCT_STAT *psbuf, - uint16_t num_def_acls, const char *pdata) +bool set_unix_posix_default_acl(connection_struct *conn, + const struct smb_filename *smb_fname, + uint16_t num_def_acls, + const char *pdata) { SMB_ACL_T def_acl = NULL; - if (!S_ISDIR(psbuf->st_ex_mode)) { + if (!S_ISDIR(smb_fname->st.st_ex_mode)) { if (num_def_acls) { - DEBUG(5,("set_unix_posix_default_acl: Can't set default ACL on non-directory file %s\n", fname )); + DEBUG(5,("set_unix_posix_default_acl: Can't " + "set default ACL on non-directory file %s\n", + smb_fname->base_name )); errno = EISDIR; return False; } else { @@ -4427,9 +4431,9 @@ bool set_unix_posix_default_acl(connection_struct *conn, const char *fname, cons if (!num_def_acls) { /* Remove the default ACL. */ - if (SMB_VFS_SYS_ACL_DELETE_DEF_FILE(conn, fname) == -1) { + if (SMB_VFS_SYS_ACL_DELETE_DEF_FILE(conn, smb_fname) == -1) { DEBUG(5,("set_unix_posix_default_acl: acl_delete_def_file failed on directory %s (%s)\n", - fname, strerror(errno) )); + smb_fname->base_name, strerror(errno) )); return False; } return True; @@ -4441,14 +4445,16 @@ bool set_unix_posix_default_acl(connection_struct *conn, const char *fname, cons return False; } - if (SMB_VFS_SYS_ACL_SET_FILE(conn, fname, SMB_ACL_TYPE_DEFAULT, def_acl) == -1) { + if (SMB_VFS_SYS_ACL_SET_FILE(conn, smb_fname->base_name, + SMB_ACL_TYPE_DEFAULT, def_acl) == -1) { DEBUG(5,("set_unix_posix_default_acl: acl_set_file failed on directory %s (%s)\n", - fname, strerror(errno) )); + smb_fname->base_name, strerror(errno) )); TALLOC_FREE(def_acl); return False; } - DEBUG(10,("set_unix_posix_default_acl: set default acl for file %s\n", fname )); + DEBUG(10,("set_unix_posix_default_acl: set default acl for file %s\n", + smb_fname->base_name )); TALLOC_FREE(def_acl); return True; } diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index e2d5a6a9fbe..88ba6f9d3e4 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -783,8 +783,8 @@ int chmod_acl(connection_struct *conn, const char *name, mode_t mode); int inherit_access_posix_acl(connection_struct *conn, const char *inherit_from_dir, const char *name, mode_t mode); int fchmod_acl(files_struct *fsp, mode_t mode); -bool set_unix_posix_default_acl(connection_struct *conn, const char *fname, - const SMB_STRUCT_STAT *psbuf, +bool set_unix_posix_default_acl(connection_struct *conn, + const struct smb_filename *smb_fname, uint16_t num_def_acls, const char *pdata); bool set_unix_posix_acl(connection_struct *conn, files_struct *fsp, const char *fname, uint16_t num_acls, const char *pdata); NTSTATUS get_nt_acl_no_snum( TALLOC_CTX *ctx, const char *fname, diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 5155abb0095..f11dcd116dd 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -7157,7 +7157,7 @@ static NTSTATUS smb_set_posix_acl(connection_struct *conn, } if (valid_def_acls && !set_unix_posix_default_acl(conn, - smb_fname->base_name, &smb_fname->st, num_def_acls, + smb_fname, num_def_acls, pdata + SMB_POSIX_ACL_HEADER_SIZE + (num_file_acls*SMB_POSIX_ACL_ENTRY_SIZE))) { return map_nt_error_from_unix(errno); diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index 560c4b217a4..a4aeffe47a8 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -2493,10 +2493,10 @@ int smb_vfs_call_sys_acl_set_fd(struct vfs_handle_struct *handle, } int smb_vfs_call_sys_acl_delete_def_file(struct vfs_handle_struct *handle, - const char *path) + const struct smb_filename *smb_fname) { VFS_FIND(sys_acl_delete_def_file); - return handle->fns->sys_acl_delete_def_file_fn(handle, path); + return handle->fns->sys_acl_delete_def_file_fn(handle, smb_fname); } ssize_t smb_vfs_call_getxattr(struct vfs_handle_struct *handle, diff --git a/source3/torture/cmd_vfs.c b/source3/torture/cmd_vfs.c index b57a061ee4c..c22b5d24c3a 100644 --- a/source3/torture/cmd_vfs.c +++ b/source3/torture/cmd_vfs.c @@ -1778,17 +1778,29 @@ static NTSTATUS cmd_sys_acl_delete_def_file(struct vfs_state *vfs, TALLOC_CTX *m int argc, const char **argv) { int ret; + struct smb_filename *smb_fname = NULL; if (argc != 2) { printf("Usage: sys_acl_delete_def_file \n"); return NT_STATUS_OK; } - ret = SMB_VFS_SYS_ACL_DELETE_DEF_FILE(vfs->conn, argv[1]); + smb_fname = synthetic_smb_fname(talloc_tos(), + argv[1], + NULL, + NULL, + ssf_flags()); + + if (smb_fname == NULL) { + return NT_STATUS_NO_MEMORY; + } + ret = SMB_VFS_SYS_ACL_DELETE_DEF_FILE(vfs->conn, smb_fname); if (ret == -1) { printf("sys_acl_delete_def_file failed (%s)\n", strerror(errno)); + TALLOC_FREE(smb_fname); return NT_STATUS_UNSUCCESSFUL; } + TALLOC_FREE(smb_fname); return NT_STATUS_OK; } -- 2.34.1