diff options
author | Jeremy Allison <jra@samba.org> | 2016-03-01 17:25:25 -0800 |
---|---|---|
committer | Ralph Boehme <slow@samba.org> | 2016-03-03 09:04:14 +0100 |
commit | 8e88b9783dec751fe5bd4750923b62b978080885 (patch) | |
tree | 82bc4c83f0361d933d5480aa7ebc1cdd440faa22 | |
parent | ac8fba6ef7093836eb6988e749325b69e7a7fde1 (diff) | |
download | samba-8e88b9783dec751fe5bd4750923b62b978080885.tar.gz |
VFS: Modify chmod_acl to take a const struct smb_filename * instead of const char *
Preparing to reduce use of lp_posix_pathnames().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
-rw-r--r-- | examples/VFS/skel_opaque.c | 5 | ||||
-rw-r--r-- | examples/VFS/skel_transparent.c | 7 | ||||
-rw-r--r-- | source3/include/vfs.h | 11 | ||||
-rw-r--r-- | source3/include/vfs_macros.h | 8 | ||||
-rw-r--r-- | source3/modules/vfs_acl_common.c | 5 | ||||
-rw-r--r-- | source3/modules/vfs_audit.c | 8 | ||||
-rw-r--r-- | source3/modules/vfs_cap.c | 26 | ||||
-rw-r--r-- | source3/modules/vfs_catia.c | 22 | ||||
-rw-r--r-- | source3/modules/vfs_ceph.c | 6 | ||||
-rw-r--r-- | source3/modules/vfs_default.c | 12 | ||||
-rw-r--r-- | source3/modules/vfs_extd_audit.c | 10 | ||||
-rw-r--r-- | source3/modules/vfs_full_audit.c | 7 | ||||
-rw-r--r-- | source3/modules/vfs_linux_xfs_sgid.c | 3 | ||||
-rw-r--r-- | source3/modules/vfs_media_harmony.c | 25 | ||||
-rw-r--r-- | source3/modules/vfs_shadow_copy2.c | 27 | ||||
-rw-r--r-- | source3/modules/vfs_snapper.c | 25 | ||||
-rw-r--r-- | source3/modules/vfs_time_audit.c | 9 | ||||
-rw-r--r-- | source3/modules/vfs_unityed_media.c | 22 | ||||
-rw-r--r-- | source3/smbd/vfs.c | 7 | ||||
-rw-r--r-- | source3/torture/cmd_vfs.c | 12 |
20 files changed, 179 insertions, 78 deletions
diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c index f772a9f9316..e7bb645f165 100644 --- a/examples/VFS/skel_opaque.c +++ b/examples/VFS/skel_opaque.c @@ -692,8 +692,9 @@ static NTSTATUS skel_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, return NT_STATUS_NOT_IMPLEMENTED; } -static int skel_chmod_acl(vfs_handle_struct *handle, const char *name, - mode_t mode) +static int skel_chmod_acl(vfs_handle_struct *handle, + const struct smb_filename *smb_fname, + mode_t mode) { errno = ENOSYS; return -1; diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c index bea2cd4272f..fe2356a6e69 100644 --- a/examples/VFS/skel_transparent.c +++ b/examples/VFS/skel_transparent.c @@ -823,10 +823,11 @@ static NTSTATUS skel_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, return SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd); } -static int skel_chmod_acl(vfs_handle_struct *handle, const char *name, - mode_t mode) +static int skel_chmod_acl(vfs_handle_struct *handle, + const struct smb_filename *smb_fname, + mode_t mode) { - return SMB_VFS_NEXT_CHMOD_ACL(handle, name, mode); + return SMB_VFS_NEXT_CHMOD_ACL(handle, smb_fname, mode); } static int skel_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, diff --git a/source3/include/vfs.h b/source3/include/vfs.h index 6a6c8656f36..9aa45fa11d1 100644 --- a/source3/include/vfs.h +++ b/source3/include/vfs.h @@ -182,6 +182,8 @@ /* Version 35 - Wrap aio async funtions args in a struct vfs_aio_state */ /* Version 35 - Change chmod from const char *, to const struct smb_filename * */ +/* Version 35 - Change chmod_acl from const char *, to + const struct smb_filename * */ #define SMB_VFS_INTERFACE_VERSION 35 @@ -787,7 +789,9 @@ struct vfs_fn_pointers { /* POSIX ACL operations. */ - int (*chmod_acl_fn)(struct vfs_handle_struct *handle, const char *name, mode_t mode); + int (*chmod_acl_fn)(struct vfs_handle_struct *handle, + const struct smb_filename *smb_fname, + mode_t mode); int (*fchmod_acl_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, mode_t mode); SMB_ACL_T (*sys_acl_get_file_fn)(struct vfs_handle_struct *handle, @@ -1230,8 +1234,9 @@ NTSTATUS smb_vfs_call_audit_file(struct vfs_handle_struct *handle, struct security_acl *sacl, uint32_t access_requested, uint32_t access_denied); -int smb_vfs_call_chmod_acl(struct vfs_handle_struct *handle, const char *name, - mode_t mode); +int smb_vfs_call_chmod_acl(struct vfs_handle_struct *handle, + const struct smb_filename *file, + mode_t mode); int smb_vfs_call_fchmod_acl(struct vfs_handle_struct *handle, struct files_struct *fsp, mode_t mode); SMB_ACL_T smb_vfs_call_sys_acl_get_file(struct vfs_handle_struct *handle, diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h index 6dc257b331a..e5e3c99866d 100644 --- a/source3/include/vfs_macros.h +++ b/source3/include/vfs_macros.h @@ -452,10 +452,10 @@ #define SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd) \ smb_vfs_call_fset_nt_acl((handle)->next, (fsp), (security_info_sent), (psd)) -#define SMB_VFS_CHMOD_ACL(conn, name, mode) \ - smb_vfs_call_chmod_acl((conn)->vfs_handles, (name), (mode)) -#define SMB_VFS_NEXT_CHMOD_ACL(handle, name, mode) \ - smb_vfs_call_chmod_acl((handle)->next, (name), (mode)) +#define SMB_VFS_CHMOD_ACL(conn, smb_fname, mode) \ + smb_vfs_call_chmod_acl((conn)->vfs_handles, (smb_fname), (mode)) +#define SMB_VFS_NEXT_CHMOD_ACL(handle, smb_fname, mode) \ + smb_vfs_call_chmod_acl((handle)->next, (smb_fname), (mode)) #define SMB_VFS_FCHMOD_ACL(fsp, mode) \ smb_vfs_call_fchmod_acl((fsp)->conn->vfs_handles, (fsp), (mode)) diff --git a/source3/modules/vfs_acl_common.c b/source3/modules/vfs_acl_common.c index 26841062fb5..ba93e7b0b5c 100644 --- a/source3/modules/vfs_acl_common.c +++ b/source3/modules/vfs_acl_common.c @@ -1105,11 +1105,12 @@ static int fchmod_acl_module_common(struct vfs_handle_struct *handle, } static int chmod_acl_acl_module_common(struct vfs_handle_struct *handle, - const char *name, mode_t mode) + const struct smb_filename *smb_fname, + mode_t mode) { if (lp_posix_pathnames()) { /* Only allow this on POSIX pathnames. */ - return SMB_VFS_NEXT_CHMOD_ACL(handle, name, mode); + return SMB_VFS_NEXT_CHMOD_ACL(handle, smb_fname, mode); } return 0; } diff --git a/source3/modules/vfs_audit.c b/source3/modules/vfs_audit.c index 92b69b17dd0..cef3bb5ab4f 100644 --- a/source3/modules/vfs_audit.c +++ b/source3/modules/vfs_audit.c @@ -233,14 +233,16 @@ static int audit_chmod(vfs_handle_struct *handle, return result; } -static int audit_chmod_acl(vfs_handle_struct *handle, const char *path, mode_t mode) +static int audit_chmod_acl(vfs_handle_struct *handle, + const struct smb_filename *smb_fname, + mode_t mode) { int result; - result = SMB_VFS_NEXT_CHMOD_ACL(handle, path, mode); + result = SMB_VFS_NEXT_CHMOD_ACL(handle, smb_fname, mode); syslog(audit_syslog_priority(handle), "chmod_acl %s mode 0x%x %s%s\n", - path, mode, + smb_fname->base_name, mode, (result < 0) ? "failed: " : "", (result < 0) ? strerror(errno) : ""); diff --git a/source3/modules/vfs_cap.c b/source3/modules/vfs_cap.c index 479c2c213ae..0bb943da9a2 100644 --- a/source3/modules/vfs_cap.c +++ b/source3/modules/vfs_cap.c @@ -461,16 +461,36 @@ static char *cap_realpath(vfs_handle_struct *handle, const char *path) return SMB_VFS_NEXT_REALPATH(handle, cappath); } -static int cap_chmod_acl(vfs_handle_struct *handle, const char *path, mode_t mode) +static int cap_chmod_acl(vfs_handle_struct *handle, + const struct smb_filename *smb_fname, + mode_t mode) { - 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; /* If the underlying VFS doesn't have ACL support... */ if (!cappath) { errno = ENOMEM; return -1; } - return SMB_VFS_NEXT_CHMOD_ACL(handle, cappath, mode); + cap_smb_fname = synthetic_smb_fname(talloc_tos(), + cappath, + NULL, + NULL); + if (cap_smb_fname == NULL) { + TALLOC_FREE(cappath); + errno = ENOMEM; + return -1; + } + + ret = SMB_VFS_NEXT_CHMOD_ACL(handle, cap_smb_fname, mode); + saved_errno = errno; + TALLOC_FREE(cappath); + TALLOC_FREE(cap_smb_fname); + errno = saved_errno; + return ret; } static SMB_ACL_T cap_sys_acl_get_file(vfs_handle_struct *handle, diff --git a/source3/modules/vfs_catia.c b/source3/modules/vfs_catia.c index 7f06fb737e8..e142ccef8ef 100644 --- a/source3/modules/vfs_catia.c +++ b/source3/modules/vfs_catia.c @@ -871,22 +871,38 @@ catia_get_nt_acl(struct vfs_handle_struct *handle, static int catia_chmod_acl(vfs_handle_struct *handle, - const char *path, + const struct smb_filename *smb_fname, mode_t mode) { char *mapped_name = NULL; + struct smb_filename *mapped_smb_fname = NULL; NTSTATUS status; int ret; + int saved_errno; 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_CHMOD_ACL(handle, mapped_name, mode); + mapped_smb_fname = synthetic_smb_fname(talloc_tos(), + mapped_name, + NULL, + NULL); + if (mapped_smb_fname == NULL) { + TALLOC_FREE(mapped_name); + errno = ENOMEM; + return -1; + } + ret = SMB_VFS_NEXT_CHMOD_ACL(handle, mapped_smb_fname, mode); + saved_errno = errno; TALLOC_FREE(mapped_name); + TALLOC_FREE(mapped_smb_fname); + errno = saved_errno; return ret; } diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c index e61c39dd801..82e15c8dfcc 100644 --- a/source3/modules/vfs_ceph.c +++ b/source3/modules/vfs_ceph.c @@ -362,8 +362,10 @@ static int cephwrap_mkdir(struct vfs_handle_struct *handle, * mess up any inherited ACL bits that were set. JRA. */ int saved_errno = errno; /* We may get ENOSYS */ - if ((SMB_VFS_CHMOD_ACL(handle->conn, path, mode) == -1) && (errno == ENOSYS)) + if ((SMB_VFS_CHMOD_ACL(handle->conn, smb_fname, mode) == -1) && + (errno == ENOSYS)) { errno = saved_errno; + } } return result; @@ -650,7 +652,7 @@ static int cephwrap_chmod(struct vfs_handle_struct *handle, { int saved_errno = errno; /* We might get ENOSYS */ result = SMB_VFS_CHMOD_ACL(handle->conn, - smb_fname->base_name, + smb_fname, mode); if (result == 0) { return result; diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index fbb0bcb806f..bb55facbb08 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -498,8 +498,10 @@ static int vfswrap_mkdir(vfs_handle_struct *handle, * mess up any inherited ACL bits that were set. JRA. */ int saved_errno = errno; /* We may get ENOSYS */ - if ((SMB_VFS_CHMOD_ACL(handle->conn, path, mode) == -1) && (errno == ENOSYS)) + if ((SMB_VFS_CHMOD_ACL(handle->conn, smb_fname, mode) == -1) && + (errno == ENOSYS)) { errno = saved_errno; + } } END_PROFILE(syscall_mkdir); @@ -1694,7 +1696,7 @@ static int vfswrap_chmod(vfs_handle_struct *handle, { int saved_errno = errno; /* We might get ENOSYS */ result = SMB_VFS_CHMOD_ACL(handle->conn, - smb_fname->base_name, + smb_fname, mode); if (result == 0) { END_PROFILE(syscall_chmod); @@ -2362,7 +2364,9 @@ static NTSTATUS vfswrap_audit_file(struct vfs_handle_struct *handle, return NT_STATUS_OK; /* Nothing to do here ... */ } -static int vfswrap_chmod_acl(vfs_handle_struct *handle, const char *name, mode_t mode) +static int vfswrap_chmod_acl(vfs_handle_struct *handle, + const struct smb_filename *smb_fname, + mode_t mode) { #ifdef HAVE_NO_ACL errno = ENOSYS; @@ -2371,7 +2375,7 @@ static int vfswrap_chmod_acl(vfs_handle_struct *handle, const char *name, mode_t int result; START_PROFILE(chmod_acl); - result = chmod_acl(handle->conn, name, mode); + result = chmod_acl(handle->conn, smb_fname->base_name, mode); END_PROFILE(chmod_acl); return result; #endif diff --git a/source3/modules/vfs_extd_audit.c b/source3/modules/vfs_extd_audit.c index 5aa6a30ed8f..0d8ca59732d 100644 --- a/source3/modules/vfs_extd_audit.c +++ b/source3/modules/vfs_extd_audit.c @@ -292,20 +292,22 @@ static int audit_chmod(vfs_handle_struct *handle, return result; } -static int audit_chmod_acl(vfs_handle_struct *handle, const char *path, mode_t mode) +static int audit_chmod_acl(vfs_handle_struct *handle, + const struct smb_filename *smb_fname, + mode_t mode) { int result; - result = SMB_VFS_NEXT_CHMOD_ACL(handle, path, mode); + result = SMB_VFS_NEXT_CHMOD_ACL(handle, smb_fname, mode); if (lp_syslog() > 0) { syslog(audit_syslog_priority(handle), "chmod_acl %s mode 0x%x %s%s\n", - path, mode, + smb_fname->base_name, mode, (result < 0) ? "failed: " : "", (result < 0) ? strerror(errno) : ""); } DEBUG(1, ("vfs_extd_audit: chmod_acl %s mode 0x%x %s %s\n", - path, (unsigned int)mode, + smb_fname->base_name, (unsigned int)mode, (result < 0) ? "failed: " : "", (result < 0) ? strerror(errno) : "")); diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index 43a88082e38..4a7b3588941 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -1951,14 +1951,15 @@ static NTSTATUS smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_stru } static int smb_full_audit_chmod_acl(vfs_handle_struct *handle, - const char *path, mode_t mode) + const struct smb_filename *smb_fname, + mode_t mode) { int result; - result = SMB_VFS_NEXT_CHMOD_ACL(handle, path, mode); + result = SMB_VFS_NEXT_CHMOD_ACL(handle, smb_fname, mode); do_log(SMB_VFS_OP_CHMOD_ACL, (result >= 0), handle, - "%s|%o", path, mode); + "%s|%o", smb_fname->base_name, mode); return result; } diff --git a/source3/modules/vfs_linux_xfs_sgid.c b/source3/modules/vfs_linux_xfs_sgid.c index fca0d130f52..0c0507b0c5a 100644 --- a/source3/modules/vfs_linux_xfs_sgid.c +++ b/source3/modules/vfs_linux_xfs_sgid.c @@ -96,7 +96,8 @@ static int linux_xfs_sgid_mkdir(vfs_handle_struct *handle, } static int linux_xfs_sgid_chmod_acl(vfs_handle_struct *handle, - const char *name, mode_t mode) + const struct smb_filename *smb_fname, + mode_t mode) { errno = ENOSYS; return -1; diff --git a/source3/modules/vfs_media_harmony.c b/source3/modules/vfs_media_harmony.c index 6a54862bf2a..e1f05ccdbee 100644 --- a/source3/modules/vfs_media_harmony.c +++ b/source3/modules/vfs_media_harmony.c @@ -2073,33 +2073,30 @@ out: * Failure: set errno, return -1 */ static int mh_chmod_acl(vfs_handle_struct *handle, - const char *path, + const struct smb_filename *smb_fname, mode_t mode) { int status; - char *clientPath; - TALLOC_CTX *ctx; + struct smb_filename *clientFname = NULL; DEBUG(MH_INFO_DEBUG, ("Entering mh_chmod_acl\n")); - if (!is_in_media_files(path)) + if (!is_in_media_files(smb_fname->base_name)) { - status = SMB_VFS_NEXT_CHMOD_ACL(handle, path, mode); + status = SMB_VFS_NEXT_CHMOD_ACL(handle, smb_fname, mode); 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_CHMOD_ACL(handle, clientPath, mode); + status = SMB_VFS_NEXT_CHMOD_ACL(handle, clientFname, mode); err: - TALLOC_FREE(clientPath); + TALLOC_FREE(clientFname); out: return status; } diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c index 1aaf44eb34c..c83ce1e529f 100644 --- a/source3/modules/vfs_shadow_copy2.c +++ b/source3/modules/vfs_shadow_copy2.c @@ -1809,29 +1809,44 @@ static int shadow_copy2_setxattr(struct vfs_handle_struct *handle, } static int shadow_copy2_chmod_acl(vfs_handle_struct *handle, - const char *fname, mode_t mode) + const struct smb_filename *smb_fname, + mode_t mode) { time_t timestamp; char *stripped; ssize_t ret; int saved_errno; - char *conv; + char *conv = NULL; + struct smb_filename *conv_smb_fname = NULL; - if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname, - ×tamp, &stripped)) { + if (!shadow_copy2_strip_snapshot(talloc_tos(), + handle, + smb_fname->base_name, + ×tamp, + &stripped)) { return -1; } if (timestamp == 0) { - return SMB_VFS_NEXT_CHMOD_ACL(handle, fname, mode); + return SMB_VFS_NEXT_CHMOD_ACL(handle, smb_fname, mode); } conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp); TALLOC_FREE(stripped); if (conv == NULL) { return -1; } - ret = SMB_VFS_NEXT_CHMOD_ACL(handle, conv, mode); + conv_smb_fname = synthetic_smb_fname(talloc_tos(), + conv, + NULL, + NULL); + if (conv_smb_fname == NULL) { + TALLOC_FREE(conv); + errno = ENOMEM; + return -1; + } + ret = SMB_VFS_NEXT_CHMOD_ACL(handle, conv_smb_fname, mode); saved_errno = errno; TALLOC_FREE(conv); + TALLOC_FREE(conv_smb_fname); errno = saved_errno; return ret; } diff --git a/source3/modules/vfs_snapper.c b/source3/modules/vfs_snapper.c index 0a0f5eb1cca..fb9936931c0 100644 --- a/source3/modules/vfs_snapper.c +++ b/source3/modules/vfs_snapper.c @@ -2741,29 +2741,44 @@ static int snapper_gmt_setxattr(struct vfs_handle_struct *handle, } static int snapper_gmt_chmod_acl(vfs_handle_struct *handle, - const char *fname, mode_t mode) + const struct smb_filename *smb_fname, + mode_t mode) { time_t timestamp; char *stripped; ssize_t ret; int saved_errno; char *conv; + struct smb_filename *conv_smb_fname = NULL; - if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, fname, - ×tamp, &stripped)) { + if (!snapper_gmt_strip_snapshot(talloc_tos(), + handle, + smb_fname->base_name, + ×tamp, + &stripped)) { return -1; } if (timestamp == 0) { - return SMB_VFS_NEXT_CHMOD_ACL(handle, fname, mode); + return SMB_VFS_NEXT_CHMOD_ACL(handle, smb_fname, mode); } conv = snapper_gmt_convert(talloc_tos(), handle, stripped, timestamp); TALLOC_FREE(stripped); if (conv == NULL) { return -1; } - ret = SMB_VFS_NEXT_CHMOD_ACL(handle, conv, mode); + conv_smb_fname = synthetic_smb_fname(talloc_tos(), + conv, + NULL, + NULL); + if (conv_smb_fname == NULL) { + TALLOC_FREE(conv); + errno = ENOMEM; + return -1; + } + ret = SMB_VFS_NEXT_CHMOD_ACL(handle, conv_smb_fname, mode); saved_errno = errno; TALLOC_FREE(conv); + TALLOC_FREE(conv_smb_fname); errno = saved_errno; return ret; } diff --git a/source3/modules/vfs_time_audit.c b/source3/modules/vfs_time_audit.c index 948f154acd7..944251d934d 100644 --- a/source3/modules/vfs_time_audit.c +++ b/source3/modules/vfs_time_audit.c @@ -1941,19 +1941,22 @@ static NTSTATUS smb_time_audit_fset_nt_acl(vfs_handle_struct *handle, } static int smb_time_audit_chmod_acl(vfs_handle_struct *handle, - const char *path, mode_t mode) + const struct smb_filename *smb_fname, + mode_t mode) { int result; struct timespec ts1,ts2; double timediff; clock_gettime_mono(&ts1); - result = SMB_VFS_NEXT_CHMOD_ACL(handle, path, mode); + result = SMB_VFS_NEXT_CHMOD_ACL(handle, smb_fname, mode); clock_gettime_mono(&ts2); timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log_fname("chmod_acl", timediff, path); + smb_time_audit_log_fname("chmod_acl", + timediff, + smb_fname->base_name); } return result; diff --git a/source3/modules/vfs_unityed_media.c b/source3/modules/vfs_unityed_media.c index 65e4d4cbbcd..dd6dc335dd8 100644 --- a/source3/modules/vfs_unityed_media.c +++ b/source3/modules/vfs_unityed_media.c @@ -1571,28 +1571,32 @@ err: } static int um_chmod_acl(vfs_handle_struct *handle, - const char *path, + const struct smb_filename *smb_fname, mode_t mode) { int status; - char *client_path = NULL; + int saved_errno; + struct smb_filename *client_fname = NULL; DEBUG(10, ("Entering um_chmod_acl\n")); - if (!is_in_media_files(path)) { - return SMB_VFS_NEXT_CHMOD_ACL(handle, path, mode); + if (!is_in_media_files(smb_fname->base_name)) { + return SMB_VFS_NEXT_CHMOD_ACL(handle, smb_fname, mode); } - 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_CHMOD_ACL(handle, client_path, mode); + status = SMB_VFS_NEXT_CHMOD_ACL(handle, client_fname, mode); err: - TALLOC_FREE(client_path); + saved_errno = errno; + TALLOC_FREE(client_fname); + errno = saved_errno; return status; } diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index 9221107f9fc..02a94e86f53 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -2301,11 +2301,12 @@ NTSTATUS smb_vfs_call_audit_file(struct vfs_handle_struct *handle, access_denied); } -int smb_vfs_call_chmod_acl(struct vfs_handle_struct *handle, const char *name, - mode_t mode) +int smb_vfs_call_chmod_acl(struct vfs_handle_struct *handle, + const struct smb_filename *smb_fname, + mode_t mode) { VFS_FIND(chmod_acl); - return handle->fns->chmod_acl_fn(handle, name, mode); + return handle->fns->chmod_acl_fn(handle, smb_fname, mode); } int smb_vfs_call_fchmod_acl(struct vfs_handle_struct *handle, diff --git a/source3/torture/cmd_vfs.c b/source3/torture/cmd_vfs.c index 3e6371407f5..a7e70b3c3a1 100644 --- a/source3/torture/cmd_vfs.c +++ b/source3/torture/cmd_vfs.c @@ -896,6 +896,7 @@ static NTSTATUS cmd_fchmod(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, static NTSTATUS cmd_chmod_acl(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, const char **argv) { + struct smb_filename *smb_fname = NULL; mode_t mode; if (argc != 3) { printf("Usage: chmod_acl <path> <mode>\n"); @@ -903,7 +904,16 @@ static NTSTATUS cmd_chmod_acl(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int ar } mode = atoi(argv[2]); - if (SMB_VFS_CHMOD_ACL(vfs->conn, argv[1], mode) == -1) { + + smb_fname = synthetic_smb_fname(talloc_tos(), + argv[1], + NULL, + NULL); + if (smb_fname == NULL) { + return NT_STATUS_NO_MEMORY; + } + + if (SMB_VFS_CHMOD_ACL(vfs->conn, smb_fname, mode) == -1) { printf("chmod_acl: error=%d (%s)\n", errno, strerror(errno)); return NT_STATUS_UNSUCCESSFUL; } |