s3: VFS: Change SMB_VFS_SYS_ACL_SET_FILE to use const struct smb_filename * instead...
authorJeremy Allison <jra@samba.org>
Wed, 24 May 2017 17:47:46 +0000 (10:47 -0700)
committerJeremy Allison <jra@samba.org>
Wed, 31 May 2017 20:50:22 +0000 (22:50 +0200)
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 <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
35 files changed:
examples/VFS/skel_opaque.c
examples/VFS/skel_transparent.c
source3/include/smb_acls.h
source3/include/vfs.h
source3/include/vfs_macros.h
source3/lib/sysacls.c
source3/modules/posixacl_xattr.c
source3/modules/posixacl_xattr.h
source3/modules/vfs_acl_tdb.c
source3/modules/vfs_acl_xattr.c
source3/modules/vfs_aixacl.c
source3/modules/vfs_aixacl2.c
source3/modules/vfs_cap.c
source3/modules/vfs_catia.c
source3/modules/vfs_default.c
source3/modules/vfs_fake_acls.c
source3/modules/vfs_full_audit.c
source3/modules/vfs_gpfs.c
source3/modules/vfs_hpuxacl.c
source3/modules/vfs_hpuxacl.h
source3/modules/vfs_media_harmony.c
source3/modules/vfs_nfs4acl_xattr.c
source3/modules/vfs_posixacl.c
source3/modules/vfs_posixacl.h
source3/modules/vfs_solarisacl.c
source3/modules/vfs_solarisacl.h
source3/modules/vfs_time_audit.c
source3/modules/vfs_tru64acl.c
source3/modules/vfs_tru64acl.h
source3/modules/vfs_unityed_media.c
source3/modules/vfs_vxfs.c
source3/modules/vfs_zfsacl.c
source3/smbd/posix_acls.c
source3/smbd/pysmbd.c
source3/smbd/vfs.c

index 8ecd0be..e715820 100644 (file)
@@ -774,8 +774,10 @@ static int skel_sys_acl_blob_get_fd(vfs_handle_struct *handle,
        return -1;
 }
 
-static int skel_sys_acl_set_file(vfs_handle_struct *handle, const char *name,
-                                SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl)
+static int skel_sys_acl_set_file(vfs_handle_struct *handle,
+                               const struct smb_filename *smb_fname,
+                               SMB_ACL_TYPE_T acltype,
+                               SMB_ACL_T theacl)
 {
        errno = ENOSYS;
        return -1;
index 82d3c37..05d6723 100644 (file)
@@ -912,10 +912,13 @@ static int skel_sys_acl_blob_get_fd(vfs_handle_struct *handle,
                                                blob_description, blob);
 }
 
-static int skel_sys_acl_set_file(vfs_handle_struct *handle, const char *name,
-                                SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl)
+static int skel_sys_acl_set_file(vfs_handle_struct *handle,
+                               const struct smb_filename *smb_fname,
+                               SMB_ACL_TYPE_T acltype,
+                               SMB_ACL_T theacl)
 {
-       return SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, name, acltype, theacl);
+       return SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, smb_fname,
+                       acltype, theacl);
 }
 
 static int skel_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
index f5603f3..73b67af 100644 (file)
@@ -59,7 +59,9 @@ SMB_ACL_T sys_acl_get_file(struct vfs_handle_struct *handle,
 SMB_ACL_T sys_acl_get_fd(struct vfs_handle_struct *handle, struct files_struct *fsp,
                         TALLOC_CTX *mem_ctx);
 int sys_acl_set_file(struct vfs_handle_struct *handle,
-                    const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d);
+                       const struct smb_filename *smb_fname,
+                       SMB_ACL_TYPE_T type,
+                       SMB_ACL_T acl_d);
 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,
index e32952a..f3a0b32 100644 (file)
                to const struct smb_filename * */
 /* Version 37 - Change sys_acl_blob_get_file from const char *
                to const struct smb_filename * */
+/* Version 37 - Change sys_acl_set_file from const char *
+               to const struct smb_filename * */
 
 #define SMB_VFS_INTERFACE_VERSION 37
 
@@ -876,7 +878,10 @@ struct vfs_fn_pointers {
        int (*sys_acl_blob_get_fd_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp,
                                      TALLOC_CTX *mem_ctx, char **blob_description,
                                      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_file_fn)(struct vfs_handle_struct *handle,
+                                       const struct smb_filename *smb_fname,
+                                       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 struct smb_filename *smb_fname);
@@ -1335,8 +1340,9 @@ int smb_vfs_call_sys_acl_blob_get_fd(struct vfs_handle_struct *handle,
                                     char **blob_description,
                                     DATA_BLOB *blob);
 int smb_vfs_call_sys_acl_set_file(struct vfs_handle_struct *handle,
-                                 const char *name, SMB_ACL_TYPE_T acltype,
-                                 SMB_ACL_T theacl);
+                               const struct smb_filename *smb_fname,
+                               SMB_ACL_TYPE_T acltype,
+                               SMB_ACL_T theacl);
 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,
index 0ca601a..ac04093 100644 (file)
 #define SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FD(handle, fsp, mem_ctx, blob_description, blob) \
        smb_vfs_call_sys_acl_blob_get_fd((handle)->next, (fsp), mem_ctx, (blob_description), (blob))
 
-#define SMB_VFS_SYS_ACL_SET_FILE(conn, name, acltype, theacl) \
-       smb_vfs_call_sys_acl_set_file((conn)->vfs_handles, (name), (acltype), (theacl))
-#define SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, name, acltype, theacl) \
-       smb_vfs_call_sys_acl_set_file((handle)->next, (name), (acltype), (theacl))
+#define SMB_VFS_SYS_ACL_SET_FILE(conn, smb_fname, acltype, theacl) \
+       smb_vfs_call_sys_acl_set_file((conn)->vfs_handles, (smb_fname), (acltype), (theacl))
+#define SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, smb_fname, acltype, theacl) \
+       smb_vfs_call_sys_acl_set_file((handle)->next, (smb_fname), (acltype), (theacl))
 
 #define SMB_VFS_SYS_ACL_SET_FD(fsp, theacl) \
        smb_vfs_call_sys_acl_set_fd((fsp)->conn->vfs_handles, (fsp), (theacl))
index 8016773..0bf3c37 100644 (file)
@@ -375,9 +375,11 @@ SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp, TALLOC_CT
 }
 
 int sys_acl_set_file(vfs_handle_struct *handle,
-                    const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d)
+                       const struct smb_filename *smb_fname,
+                       SMB_ACL_TYPE_T type,
+                       SMB_ACL_T acl_d)
 {
-       return posixacl_sys_acl_set_file(handle, name, type, acl_d);
+       return posixacl_sys_acl_set_file(handle, smb_fname, type, acl_d);
 }
 
 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
@@ -409,9 +411,11 @@ SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp,
 }
 
 int sys_acl_set_file(vfs_handle_struct *handle,
-                    const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d)
+                       const struct smb_filename *smb_fname,
+                       SMB_ACL_TYPE_T type,
+                       SMB_ACL_T acl_d)
 {
-       return aixacl_sys_acl_set_file(handle, name, type, acl_d);
+       return aixacl_sys_acl_set_file(handle, smb_fname, type, acl_d);
 }
 
 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
@@ -444,9 +448,11 @@ SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp,
 }
 
 int sys_acl_set_file(vfs_handle_struct *handle,
-                    const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d)
+                       const struct smb_filename *smb_fname,
+                       SMB_ACL_TYPE_T type,
+                       SMB_ACL_T acl_d)
 {
-       return tru64acl_sys_acl_set_file(handle, name, type, acl_d);
+       return tru64acl_sys_acl_set_file(handle, smb_fname, type, acl_d);
 }
 
 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
@@ -480,9 +486,11 @@ SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp,
 }
 
 int sys_acl_set_file(vfs_handle_struct *handle,
-                    const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d)
+                       const struct smb_filename *smb_fname,
+                       SMB_ACL_TYPE_T type,
+                       SMB_ACL_T acl_d)
 {
-       return solarisacl_sys_acl_set_file(handle, name, type, acl_d);
+       return solarisacl_sys_acl_set_file(handle, smb_fname, type, acl_d);
 }
 
 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
@@ -514,9 +522,11 @@ SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp,
 }
 
 int sys_acl_set_file(vfs_handle_struct *handle,
-                    const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d)
+                       const struct smb_filename *smb_fname,
+                       SMB_ACL_TYPE_T type,
+                       SMB_ACL_T acl_d)
 {
-       return hpuxacl_sys_acl_set_file(handle, name, type, acl_d);
+       return hpuxacl_sys_acl_set_file(handle, smb_fname, type, acl_d);
 }
 
 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
@@ -558,7 +568,9 @@ SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp,
 }
 
 int sys_acl_set_file(vfs_handle_struct *handle,
-                    const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d)
+                       const struct smb_filename *smb_fname,
+                       SMB_ACL_TYPE_T type,
+                       SMB_ACL_T acl_d)
 {
 #ifdef ENOTSUP
        errno = ENOTSUP;
index ded16a0..416295f 100644 (file)
@@ -444,7 +444,7 @@ SMB_ACL_T posixacl_xattr_acl_get_fd(vfs_handle_struct *handle,
 }
 
 int posixacl_xattr_acl_set_file(vfs_handle_struct *handle,
-                               const char *path_p,
+                               const struct smb_filename *smb_fname,
                                SMB_ACL_TYPE_T type,
                                SMB_ACL_T theacl)
 {
@@ -474,7 +474,8 @@ int posixacl_xattr_acl_set_file(vfs_handle_struct *handle,
                return -1;
        }
 
-       return SMB_VFS_SETXATTR(handle->conn, path_p, name, buf, size, 0);
+       return SMB_VFS_SETXATTR(handle->conn, smb_fname->base_name,
+                       name, buf, size, 0);
 }
 
 int posixacl_xattr_acl_set_fd(vfs_handle_struct *handle,
index 8751692..70962dd 100644 (file)
@@ -31,7 +31,7 @@ SMB_ACL_T posixacl_xattr_acl_get_fd(vfs_handle_struct *handle,
                                    TALLOC_CTX *mem_ctx);
 
 int posixacl_xattr_acl_set_file(vfs_handle_struct *handle,
-                               const char *name,
+                               const struct smb_filename *smb_fname,
                                SMB_ACL_TYPE_T type,
                                SMB_ACL_T theacl);
 
index 68abc33..817add7 100644 (file)
@@ -246,7 +246,7 @@ static int unlink_acl_tdb(vfs_handle_struct *handle,
        struct db_context *db = acl_db;
        int ret = -1;
 
-       smb_fname_tmp = cp_smb_filename(talloc_tos(), smb_fname);
+       smb_fname_tmp = cp_smb_filename_nostream(talloc_tos(), smb_fname);
        if (smb_fname_tmp == NULL) {
                errno = ENOMEM;
                goto out;
@@ -383,31 +383,44 @@ static int connect_acl_tdb(struct vfs_handle_struct *handle,
 *********************************************************************/
 
 static int sys_acl_set_file_tdb(vfs_handle_struct *handle,
-                              const char *path,
-                              SMB_ACL_TYPE_T type,
-                              SMB_ACL_T theacl)
+                       const struct smb_filename *smb_fname_in,
+                       SMB_ACL_TYPE_T type,
+                       SMB_ACL_T theacl)
 {
        struct db_context *db = acl_db;
        int ret = -1;
-       struct smb_filename smb_fname = {
-               .base_name = discard_const_p(char, path)
+       int saved_errno = 0;
+       struct smb_filename *smb_fname = NULL;
+
+       smb_fname = cp_smb_filename_nostream(talloc_tos(), smb_fname_in);
+       if (smb_fname == NULL) {
+               return -1;
        };
 
-       ret = SMB_VFS_STAT(handle->conn, &smb_fname);
+       ret = SMB_VFS_STAT(handle->conn, smb_fname);
        if (ret == -1) {
-               return -1;
+               saved_errno = errno;
+               goto fail;
        }
 
        ret = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle,
-                                               path,
+                                               smb_fname,
                                                type,
                                                theacl);
        if (ret == -1) {
-               return -1;
+               saved_errno = errno;
+               goto fail;
        }
 
-       acl_tdb_delete(handle, db, &smb_fname.st);
-       return 0;
+       acl_tdb_delete(handle, db, &smb_fname->st);
+
+fail:
+       TALLOC_FREE(smb_fname);
+
+       if (saved_errno != 0) {
+               errno = saved_errno;
+       }
+       return ret;
 }
 
 /*********************************************************************
index 96bd016..1dc7082 100644 (file)
@@ -168,12 +168,12 @@ static NTSTATUS store_acl_blob_fsp(vfs_handle_struct *handle,
 *********************************************************************/
 
 static int sys_acl_set_file_xattr(vfs_handle_struct *handle,
-                              const char *name,
-                              SMB_ACL_TYPE_T type,
-                              SMB_ACL_T theacl)
+                               const struct smb_filename *smb_fname,
+                               SMB_ACL_TYPE_T type,
+                               SMB_ACL_T theacl)
 {
        int ret = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle,
-                                               name,
+                                               smb_fname,
                                                type,
                                                theacl);
        if (ret == -1) {
@@ -181,7 +181,8 @@ static int sys_acl_set_file_xattr(vfs_handle_struct *handle,
        }
 
        become_root();
-       SMB_VFS_REMOVEXATTR(handle->conn, name, XATTR_NTACL_NAME);
+       SMB_VFS_REMOVEXATTR(handle->conn, smb_fname->base_name,
+                       XATTR_NTACL_NAME);
        unbecome_root();
 
        return ret;
index 024c9aa..f6c42cb 100644 (file)
@@ -134,9 +134,9 @@ SMB_ACL_T aixacl_sys_acl_get_fd(vfs_handle_struct *handle,
 }
 
 int aixacl_sys_acl_set_file(vfs_handle_struct *handle,
-                             const char *name,
-                             SMB_ACL_TYPE_T type,
-                             SMB_ACL_T theacl)
+                       const struct smb_filename *smb_fname,
+                       SMB_ACL_TYPE_T type,
+                       SMB_ACL_T theacl)
 {
        struct acl *file_acl = NULL;
        unsigned int rc;
@@ -145,7 +145,7 @@ int aixacl_sys_acl_set_file(vfs_handle_struct *handle,
        if (!file_acl)
                return -1;
 
-       rc = chacl((char *)name,file_acl,file_acl->acl_len);
+       rc = chacl((char *)smb_fname->base_name,file_acl,file_acl->acl_len);
        DEBUG(10,("errno is %d\n",errno));
        DEBUG(10,("return code is %d\n",rc));
        SAFE_FREE(file_acl);
index 8613b59..2e4b61e 100644 (file)
@@ -468,9 +468,9 @@ NTSTATUS aixjfs2_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint3
 }
 
 int aixjfs2_sys_acl_set_file(vfs_handle_struct *handle,
-                             const char *name,
-                             SMB_ACL_TYPE_T type,
-                             SMB_ACL_T theacl)
+                               const struct smb_filename *smb_fname,
+                               SMB_ACL_TYPE_T type,
+                               SMB_ACL_T theacl)
 {
        struct acl      *acl_aixc;
        acl_type_t      acl_type_info;
@@ -478,7 +478,8 @@ int aixjfs2_sys_acl_set_file(vfs_handle_struct *handle,
 
        DEBUG(10, ("aixjfs2_sys_acl_set_file invoked for %s", name));
 
-       rc = aixjfs2_query_acl_support((char *)name, ACL_AIXC, &acl_type_info);
+       rc = aixjfs2_query_acl_support((char *)smb_fname->base_name,
+                       ACL_AIXC, &acl_type_info);
        if (rc) {
                DEBUG(8, ("jfs2_set_nt_acl: AIXC support not found\n"));
                return -1;
@@ -498,7 +499,7 @@ int aixjfs2_sys_acl_set_file(vfs_handle_struct *handle,
        );
        if (rc) {
                DEBUG(2, ("aclx_put failed with %s for %s\n",
-                       strerror(errno), name));
+                       strerror(errno), smb_fname->base_name));
                return -1;
        }
 
index 8aba431..8d621cc 100644 (file)
@@ -581,15 +581,41 @@ static SMB_ACL_T cap_sys_acl_get_file(vfs_handle_struct *handle,
        return ret;
 }
 
-static int cap_sys_acl_set_file(vfs_handle_struct *handle, const char *path, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl)
+static int cap_sys_acl_set_file(vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       SMB_ACL_TYPE_T acltype,
+                       SMB_ACL_T theacl)
 {
-       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_SET_FILE(handle, cappath, acltype, theacl);
+       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_SET_FILE(handle, cap_smb_fname,
+                               acltype, theacl);
+       if (ret == -1) {
+               saved_errno = errno;
+       }
+       TALLOC_FREE(cappath);
+       TALLOC_FREE(cap_smb_fname);
+       if (saved_errno != 0) {
+               errno = saved_errno;
+       }
+       return ret;
 }
 
 static int cap_sys_acl_delete_def_file(vfs_handle_struct *handle,
index 18dbc80..24fc26d 100644 (file)
@@ -1291,24 +1291,46 @@ catia_sys_acl_get_file(vfs_handle_struct *handle,
 
 static int
 catia_sys_acl_set_file(vfs_handle_struct *handle,
-                      const char *path,
-                      SMB_ACL_TYPE_T type,
-                      SMB_ACL_T theacl)
+                       const struct smb_filename *smb_fname,
+                       SMB_ACL_TYPE_T type,
+                       SMB_ACL_T theacl)
 {
+       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_SET_FILE(handle, mapped_name, type, theacl);
-       TALLOC_FREE(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_SET_FILE(handle, mapped_smb_fname,
+                       type, theacl);
+       if (ret == -1) {
+               saved_errno = errno;
+       }
+       TALLOC_FREE(mapped_smb_fname);
+       TALLOC_FREE(mapped_name);
+       if (saved_errno != 0) {
+               errno = saved_errno;
+       }
        return ret;
 }
 
index c3de3d7..ad47f38 100644 (file)
@@ -2724,9 +2724,12 @@ static SMB_ACL_T vfswrap_sys_acl_get_fd(vfs_handle_struct *handle,
        return sys_acl_get_fd(handle, fsp, mem_ctx);
 }
 
-static int vfswrap_sys_acl_set_file(vfs_handle_struct *handle, const char *name, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl)
+static int vfswrap_sys_acl_set_file(vfs_handle_struct *handle,
+                               const struct smb_filename *smb_fname,
+                               SMB_ACL_TYPE_T acltype,
+                               SMB_ACL_T theacl)
 {
-       return sys_acl_set_file(handle, name, acltype, theacl);
+       return sys_acl_set_file(handle, smb_fname, acltype, theacl);
 }
 
 static int vfswrap_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, SMB_ACL_T theacl)
index cb8d123..fc655c8 100644 (file)
@@ -316,7 +316,10 @@ static SMB_ACL_T fake_acls_sys_acl_get_fd(struct vfs_handle_struct *handle,
 }
 
 
-static int fake_acls_sys_acl_set_file(vfs_handle_struct *handle, const char *path, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl)
+static int fake_acls_sys_acl_set_file(vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       SMB_ACL_TYPE_T acltype,
+                       SMB_ACL_T theacl)
 {
        int ret;
        const char *name = NULL;
@@ -336,7 +339,8 @@ static int fake_acls_sys_acl_set_file(vfs_handle_struct *handle, const char *pat
                name = FAKE_ACL_DEFAULT_XATTR;
                break;
        }
-       ret = SMB_VFS_NEXT_SETXATTR(handle, path, name, blob.data, blob.length, 0);
+       ret = SMB_VFS_NEXT_SETXATTR(handle, smb_fname->base_name,
+                       name, blob.data, blob.length, 0);
        TALLOC_FREE(frame);
        return ret;
 }
index 6d281d8..07f01c2 100644 (file)
@@ -2214,17 +2214,17 @@ static int smb_full_audit_sys_acl_blob_get_fd(vfs_handle_struct *handle,
 }
 
 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct *handle,
-
-                                 const char *name, SMB_ACL_TYPE_T acltype,
-                                 SMB_ACL_T theacl)
+                               const struct smb_filename *smb_fname,
+                               SMB_ACL_TYPE_T acltype,
+                               SMB_ACL_T theacl)
 {
        int result;
 
-       result = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, name, acltype,
+       result = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, smb_fname, acltype,
                                               theacl);
 
        do_log(SMB_VFS_OP_SYS_ACL_SET_FILE, (result >= 0), handle,
-              "%s", name);
+              "%s", smb_fname->base_name);
 
        return result;
 }
index 87ddf5d..4dc9f76 100644 (file)
@@ -1233,7 +1233,7 @@ static struct gpfs_acl *smb2gpfs_acl(const SMB_ACL_T pacl,
 }
 
 static int gpfsacl_sys_acl_set_file(vfs_handle_struct *handle,
-                                   const char *name,
+                                   const struct smb_filename *smb_fname,
                                    SMB_ACL_TYPE_T type,
                                    SMB_ACL_T theacl)
 {
@@ -1246,7 +1246,8 @@ static int gpfsacl_sys_acl_set_file(vfs_handle_struct *handle,
                                return -1);
 
        if (!config->acl) {
-               return SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, name, type, theacl);
+               return SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, smb_fname,
+                               type, theacl);
        }
 
        gpfs_acl = smb2gpfs_acl(theacl, type);
@@ -1254,7 +1255,7 @@ static int gpfsacl_sys_acl_set_file(vfs_handle_struct *handle,
                return -1;
        }
 
-       result = gpfswrap_putacl(discard_const_p(char, name),
+       result = gpfswrap_putacl(discard_const_p(char, smb_fname->base_name),
                                 GPFS_PUTACL_STRUCT|GPFS_ACL_SAMBA, gpfs_acl);
 
        SAFE_FREE(gpfs_acl);
index c344cb9..53e0ad6 100644 (file)
@@ -209,7 +209,7 @@ SMB_ACL_T hpuxacl_sys_acl_get_fd(vfs_handle_struct *handle,
 
 
 int hpuxacl_sys_acl_set_file(vfs_handle_struct *handle,
-                            const char *name,
+                            const struct smb_filename *smb_fname_in,
                             SMB_ACL_TYPE_T type,
                             SMB_ACL_T theacl)
 {
@@ -222,7 +222,7 @@ int hpuxacl_sys_acl_set_file(vfs_handle_struct *handle,
        DEBUG(10, ("hpuxacl_sys_acl_set_file called for file '%s'\n",
                   name));
 
-       smb_fname = synthetic_smb_fname(talloc_tos(), name, NULL, NULL, 0);
+       smb_fname = cp_smb_filename(talloc_tos(), smb_fname_in);
        if (smb_fname == NULL) {
                status = NT_STATUS_NO_MEMORY;
                goto done;
index b629c7d..b1b9ec3 100644 (file)
@@ -41,7 +41,7 @@ SMB_ACL_T hpuxacl_sys_acl_get_fd(vfs_handle_struct *handle,
                                 files_struct *fsp);
 
 int hpuxacl_sys_acl_set_file(vfs_handle_struct *handle,
-                            const char *name,
+                            const struct smb_filename *smb_fname,
                             SMB_ACL_TYPE_T type,
                             SMB_ACL_T theacl);
 
index cad3d9f..6915fb0 100644 (file)
@@ -2138,36 +2138,32 @@ out:
  * In this case, "name" is a path.
  */
 static int mh_sys_acl_set_file(vfs_handle_struct *handle,
-               const char *name,
+               const struct smb_filename *smb_fname,
                SMB_ACL_TYPE_T acltype,
                SMB_ACL_T theacl)
 {
        int status;
-       char *clientPath;
-       TALLOC_CTX *ctx;
+       struct smb_filename *clientFname = NULL;
 
        DEBUG(MH_INFO_DEBUG, ("Entering mh_sys_acl_set_file\n"));
-       if (!is_in_media_files(name))
-       {
-               status = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, name,
+       if (!is_in_media_files(smb_fname->base_name)) {
+               status = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, smb_fname,
                                acltype, theacl);
                goto out;
        }
 
-       clientPath = NULL;
-       ctx = talloc_tos();
-
-       if ((status = alloc_get_client_path(handle, ctx,
-                               name,
-                               &clientPath)))
-       {
+       status = alloc_get_client_smb_fname(handle,
+                               talloc_tos(),
+                               smb_fname,
+                               &clientFname);
+       if (status != 0) {
                goto err;
        }
 
-       status = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, clientPath,
+       status = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, clientFname,
                        acltype, theacl);
 err:
-       TALLOC_FREE(clientPath);
+       TALLOC_FREE(clientFname);
 out:
        return status;
 }
index a0c4af7..faf9f9b 100644 (file)
@@ -600,7 +600,7 @@ static SMB_ACL_T nfs4acl_xattr_fail__sys_acl_get_fd(vfs_handle_struct *handle,
 }
 
 static int nfs4acl_xattr_fail__sys_acl_set_file(vfs_handle_struct *handle,
-                                        const char *name,
+                                        const struct smb_filename *smb_fname,
                                         SMB_ACL_TYPE_T type,
                                         SMB_ACL_T theacl)
 {
index d99f538..0cad9b6 100644 (file)
@@ -81,7 +81,7 @@ SMB_ACL_T posixacl_sys_acl_get_fd(vfs_handle_struct *handle,
 }
 
 int posixacl_sys_acl_set_file(vfs_handle_struct *handle,
-                             const char *name,
+                             const struct smb_filename *smb_fname,
                              SMB_ACL_TYPE_T type,
                              SMB_ACL_T theacl)
 {
@@ -89,7 +89,9 @@ int posixacl_sys_acl_set_file(vfs_handle_struct *handle,
        acl_type_t acl_type;
        acl_t acl;
 
-       DEBUG(10, ("Calling acl_set_file: %s, %d\n", name, type));
+       DEBUG(10, ("Calling acl_set_file: %s, %d\n",
+                       smb_fname->base_name,
+                       type));
 
        switch(type) {
        case SMB_ACL_TYPE_ACCESS:
@@ -106,7 +108,7 @@ int posixacl_sys_acl_set_file(vfs_handle_struct *handle,
        if ((acl = smb_acl_to_posix(theacl)) == NULL) {
                return -1;
        }
-       res = acl_set_file(name, acl_type, acl);
+       res = acl_set_file(smb_fname->base_name, acl_type, acl);
        if (res != 0) {
                DEBUG(10, ("acl_set_file failed: %s\n", strerror(errno)));
        }
index 8dd138e..9cd3160 100644 (file)
@@ -31,7 +31,7 @@ SMB_ACL_T posixacl_sys_acl_get_fd(vfs_handle_struct *handle,
                                  TALLOC_CTX *mem_ctx);
 
 int posixacl_sys_acl_set_file(vfs_handle_struct *handle,
-                             const char *name,
+                             const struct smb_filename *smb_fname,
                              SMB_ACL_TYPE_T type,
                              SMB_ACL_T theacl);
 
index 4506274..74086bd 100644 (file)
@@ -136,19 +136,23 @@ SMB_ACL_T solarisacl_sys_acl_get_fd(vfs_handle_struct *handle,
 }
 
 int solarisacl_sys_acl_set_file(vfs_handle_struct *handle,
-                               const char *name,
+                               const struct smb_filename *smb_fname_in,
                                SMB_ACL_TYPE_T type,
                                SMB_ACL_T theacl)
 {
        int ret = -1;
        SOLARIS_ACL_T solaris_acl = NULL;
        int count;
-       struct smb_filename smb_fname = {
-               .base_name = discard_const_p(char, name)
-       };
+       struct smb_filename *smb_fname = NULL;
+
+       smb_fname = cp_smb_filename_nostream(talloc_tos(), smb_fname_in);
+       if (smb_fname == NULL) {
+               errno = ENOMEM;
+               goto done;
+       }
 
        DEBUG(10, ("solarisacl_sys_acl_set_file called for file '%s'\n",
-                  name));
+                  smb_fname->base_name));
 
        if ((type != SMB_ACL_TYPE_ACCESS) && (type != SMB_ACL_TYPE_DEFAULT)) {
                errno = EINVAL;
@@ -176,12 +180,12 @@ int solarisacl_sys_acl_set_file(vfs_handle_struct *handle,
         * For a Windows acl mapped call on a symlink, we want to follow
         * it.
         */
-       ret = SMB_VFS_STAT(handle->conn, &smb_fname);
+       ret = SMB_VFS_STAT(handle->conn, smb_fname);
        if (ret != 0) {
                DEBUG(10, ("Error in stat call: %s\n", strerror(errno)));
                goto done;
        }
-       if (S_ISDIR(smb_fname.st.st_ex_mode)) {
+       if (S_ISDIR(smb_fname->st.st_ex_mode)) {
                SOLARIS_ACL_T other_acl = NULL;
                int other_count;
                SMB_ACL_TYPE_T other_type;
@@ -190,7 +194,8 @@ int solarisacl_sys_acl_set_file(vfs_handle_struct *handle,
                        ? SMB_ACL_TYPE_DEFAULT
                        : SMB_ACL_TYPE_ACCESS;
                DEBUGADD(10, ("getting acl from filesystem\n"));
-               if (!solaris_acl_get_file(name, &other_acl, &other_count)) {
+               if (!solaris_acl_get_file(smb_fname->base_name,
+                                       &other_acl, &other_count)) {
                        DEBUG(10, ("error getting acl from directory\n"));
                        goto done;
                }
@@ -217,12 +222,13 @@ int solarisacl_sys_acl_set_file(vfs_handle_struct *handle,
                goto done;
        }
 
-       ret = acl(name, SETACL, count, solaris_acl);
-       
+       ret = acl(smb_fname->base_name, SETACL, count, solaris_acl);
+
  done:
        DEBUG(10, ("solarisacl_sys_acl_set_file %s.\n",
                   ((ret != 0) ? "failed" : "succeeded")));
        SAFE_FREE(solaris_acl);
+       TALLOC_FREE(smb_fname);
        return ret;
 }
 
index 0ee4fa3..02bd371 100644 (file)
@@ -30,7 +30,7 @@ SMB_ACL_T solarisacl_sys_acl_get_fd(vfs_handle_struct *handle,
                                    TALLOC_CTX *mem_ctx);
 
 int solarisacl_sys_acl_set_file(vfs_handle_struct *handle,
-                               const char *name,
+                               const struct smb_filename *smb_fname,
                                SMB_ACL_TYPE_T type,
                                SMB_ACL_T theacl);
 
index d62df37..2a2f084 100644 (file)
@@ -2258,7 +2258,7 @@ static int smb_time_audit_sys_acl_blob_get_fd(vfs_handle_struct *handle,
 }
 
 static int smb_time_audit_sys_acl_set_file(vfs_handle_struct *handle,
-                                          const char *name,
+                                          const struct smb_filename *smb_fname,
                                           SMB_ACL_TYPE_T acltype,
                                           SMB_ACL_T theacl)
 {
@@ -2267,13 +2267,14 @@ static int smb_time_audit_sys_acl_set_file(vfs_handle_struct *handle,
        double timediff;
 
        clock_gettime_mono(&ts1);
-       result = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, name, acltype,
+       result = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, smb_fname, acltype,
                                               theacl);
        clock_gettime_mono(&ts2);
        timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
 
        if (timediff > audit_timeout) {
-               smb_time_audit_log_fname("sys_acl_set_file", timediff, name);
+               smb_time_audit_log_fname("sys_acl_set_file", timediff,
+                       smb_fname->base_name);
        }
 
        return result;
index 69e5dfc..d44e56a 100644 (file)
@@ -88,7 +88,7 @@ SMB_ACL_T tru64acl_sys_acl_get_fd(vfs_handle_struct *handle,
 }
 
 int tru64acl_sys_acl_set_file(vfs_handle_struct *handle,
-                             const char *name,
+                             const struct smb_filename *smb_fname,
                              SMB_ACL_TYPE_T type,
                              SMB_ACL_T theacl)
 {
@@ -97,7 +97,7 @@ int tru64acl_sys_acl_set_file(vfs_handle_struct *handle,
         acl_t tru64_acl;
 
         DEBUG(10, ("tru64acl_sys_acl_set_file called with name %s, type %d\n", 
-                       name, type));
+                       smb_fname->base_name, type));
 
         switch(type) {
         case SMB_ACL_TYPE_ACCESS:
@@ -120,7 +120,8 @@ int tru64acl_sys_acl_set_file(vfs_handle_struct *handle,
                 goto fail;
         }
        DEBUG(10, ("got tru64 acl...\n"));
-        res = acl_set_file((char *)name, the_acl_type, tru64_acl);
+        res = acl_set_file((char *)smb_fname->base_name,
+                               the_acl_type, tru64_acl);
         acl_free(tru64_acl);
         if (res != 0) {
                 DEBUG(10, ("acl_set_file failed: %s\n", strerror(errno)));
index 0af0930..8dab1f0 100644 (file)
@@ -28,7 +28,7 @@ SMB_ACL_T tru64acl_sys_acl_get_fd(vfs_handle_struct *handle,
                                  files_struct *fsp);
 
 int tru64acl_sys_acl_set_file(vfs_handle_struct *handle,
-                             const char *name,
+                             const struct smb_filename *smb_fname,
                              SMB_ACL_TYPE_T type,
                              SMB_ACL_T theacl);
 
index 93d9ce6..21d5416 100644 (file)
@@ -1649,31 +1649,40 @@ err:
 }
 
 static int um_sys_acl_set_file(vfs_handle_struct *handle,
-                              const char *name,
+                              const struct smb_filename *smb_fname,
                               SMB_ACL_TYPE_T acltype,
                               SMB_ACL_T theacl)
 {
        int status;
-       char *client_path = NULL;
+       int saved_errno = 0;
+       struct smb_filename *client_fname = NULL;
 
        DEBUG(10, ("Entering um_sys_acl_set_file\n"));
 
-       if (!is_in_media_files(name)) {
-               return SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, name,
+       if (!is_in_media_files(smb_fname->base_name)) {
+               return SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, smb_fname,
                                                     acltype, theacl);
        }
 
-       status = alloc_get_client_path(handle, talloc_tos(),
-                                      name, &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_SET_FILE(handle, client_path,
+       status = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, client_fname,
                                               acltype, theacl);
 
 err:
-       TALLOC_FREE(client_path);
+       if (status == -1) {
+               saved_errno = errno;
+       }
+       TALLOC_FREE(client_fname);
+       if (saved_errno != 0) {
+               errno = saved_errno;
+       }
        return status;
 }
 
index 6586494..5dc9ba2 100644 (file)
@@ -499,14 +499,18 @@ static int vxfs_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
        return SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl);
 }
 
-static int vxfs_sys_acl_set_file(vfs_handle_struct *handle,  const char *name,
-                                SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl)
+static int vxfs_sys_acl_set_file(vfs_handle_struct *handle,
+                               const struct smb_filename *smb_fname,
+                               SMB_ACL_TYPE_T acltype,
+                               SMB_ACL_T theacl)
 {
-       if (vxfs_compare(handle->conn, (char *)name, theacl, acltype)) {
+       if (vxfs_compare(handle->conn, (char *)smb_fname->base_name,
+                       theacl, acltype)) {
                return 0;
        }
 
-       return SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, name, acltype, theacl);
+       return SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, smb_fname,
+                       acltype, theacl);
 }
 
 static int vxfs_set_xattr(struct vfs_handle_struct *handle,  const char *path,
index cf341da..76cf528 100644 (file)
@@ -299,7 +299,7 @@ static SMB_ACL_T zfsacl_fail__sys_acl_get_fd(vfs_handle_struct *handle,
 }
 
 static int zfsacl_fail__sys_acl_set_file(vfs_handle_struct *handle,
-                                        const char *name,
+                                        const struct smb_filename *smb_fname,
                                         SMB_ACL_TYPE_T type,
                                         SMB_ACL_T theacl)
 {
index 07e0584..2d12f1d 100644 (file)
@@ -2970,7 +2970,7 @@ static bool set_canon_ace_list(files_struct *fsp,
         */
 
        if(default_ace || fsp->is_directory || fsp->fh->fd == -1) {
-               if (SMB_VFS_SYS_ACL_SET_FILE(conn, fsp->fsp_name->base_name,
+               if (SMB_VFS_SYS_ACL_SET_FILE(conn, fsp->fsp_name,
                                             the_acl_type, the_acl) == -1) {
                        /*
                         * Some systems allow all the above calls and only fail with no ACL support
@@ -2990,7 +2990,7 @@ static bool set_canon_ace_list(files_struct *fsp,
 
                                become_root();
                                sret = SMB_VFS_SYS_ACL_SET_FILE(conn,
-                                   fsp->fsp_name->base_name, the_acl_type,
+                                   fsp->fsp_name, the_acl_type,
                                    the_acl);
                                unbecome_root();
                                if (sret == 0) {
@@ -4173,7 +4173,7 @@ static int copy_access_posix_acl(connection_struct *conn,
        if ((ret = chmod_acl_internals(conn, posix_acl, mode)) == -1)
                goto done;
 
-       ret = SMB_VFS_SYS_ACL_SET_FILE(conn, smb_fname_to->base_name,
+       ret = SMB_VFS_SYS_ACL_SET_FILE(conn, smb_fname_to,
                        SMB_ACL_TYPE_ACCESS, posix_acl);
 
  done:
@@ -4466,7 +4466,7 @@ bool set_unix_posix_default_acl(connection_struct *conn,
                return False;
        }
 
-       if (SMB_VFS_SYS_ACL_SET_FILE(conn, smb_fname->base_name,
+       if (SMB_VFS_SYS_ACL_SET_FILE(conn, smb_fname,
                                SMB_ACL_TYPE_DEFAULT, def_acl) == -1) {
                DEBUG(5,("set_unix_posix_default_acl: acl_set_file failed on directory %s (%s)\n",
                        smb_fname->base_name, strerror(errno) ));
@@ -4603,7 +4603,10 @@ static bool remove_posix_acl(connection_struct *conn,
                        goto done;
                }
        } else {
-               if (SMB_VFS_SYS_ACL_SET_FILE(conn, fname, SMB_ACL_TYPE_ACCESS, new_file_acl) == -1) {
+               if (SMB_VFS_SYS_ACL_SET_FILE(conn,
+                                       smb_fname,
+                                       SMB_ACL_TYPE_ACCESS,
+                                       new_file_acl) == -1) {
                        DEBUG(5,("remove_posix_acl: acl_set_file failed on %s (%s)\n",
                                fname, strerror(errno) ));
                        goto done;
@@ -4657,7 +4660,8 @@ bool set_unix_posix_acl(connection_struct *conn, files_struct *fsp,
                        return False;
                }
        } else {
-               if (SMB_VFS_SYS_ACL_SET_FILE(conn, fname, SMB_ACL_TYPE_ACCESS, file_acl) == -1) {
+               if (SMB_VFS_SYS_ACL_SET_FILE(conn, smb_fname,
+                                       SMB_ACL_TYPE_ACCESS, file_acl) == -1) {
                        DEBUG(5,("set_unix_posix_acl: acl_set_file failed on %s (%s)\n",
                                fname, strerror(errno) ));
                        TALLOC_FREE(file_acl);
index df6ab18..63fc5d6 100644 (file)
@@ -81,6 +81,7 @@ static int set_sys_acl_conn(const char *fname,
                                 SMB_ACL_T theacl, connection_struct *conn)
 {
        int ret;
+       struct smb_filename *smb_fname = NULL;
        mode_t saved_umask;
 
        TALLOC_CTX *frame = talloc_stackframe();
@@ -89,7 +90,16 @@ static int set_sys_acl_conn(const char *fname,
           so set our umask to 0 */
        saved_umask = umask(0);
 
-       ret = SMB_VFS_SYS_ACL_SET_FILE( conn, fname, acltype, theacl);
+       smb_fname = synthetic_smb_fname_split(frame,
+                                       fname,
+                                       lp_posix_pathnames());
+       if (smb_fname == NULL) {
+               TALLOC_FREE(frame);
+               umask(saved_umask);
+               return -1;
+       }
+
+       ret = SMB_VFS_SYS_ACL_SET_FILE( conn, smb_fname, acltype, theacl);
 
        umask(saved_umask);
 
index 8dd84a2..fc0a519 100644 (file)
@@ -2479,11 +2479,13 @@ int smb_vfs_call_sys_acl_blob_get_fd(struct vfs_handle_struct *handle,
 }
 
 int smb_vfs_call_sys_acl_set_file(struct vfs_handle_struct *handle,
-                                 const char *name, SMB_ACL_TYPE_T acltype,
-                                 SMB_ACL_T theacl)
+                               const struct smb_filename *smb_fname,
+                               SMB_ACL_TYPE_T acltype,
+                               SMB_ACL_T theacl)
 {
        VFS_FIND(sys_acl_set_file);
-       return handle->fns->sys_acl_set_file_fn(handle, name, acltype, theacl);
+       return handle->fns->sys_acl_set_file_fn(handle, smb_fname,
+                               acltype, theacl);
 }
 
 int smb_vfs_call_sys_acl_set_fd(struct vfs_handle_struct *handle,