s3: VFS: Change SMB_VFS_GETXATTR to use const struct smb_filename * instead of const...
authorJeremy Allison <jra@samba.org>
Thu, 25 May 2017 23:42:04 +0000 (16:42 -0700)
committerJeremy Allison <jra@samba.org>
Thu, 1 Jun 2017 00:58:53 +0000 (02:58 +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>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Jun  1 02:58:53 CEST 2017 on sn-devel-144

31 files changed:
examples/VFS/skel_opaque.c
examples/VFS/skel_transparent.c
source3/include/vfs.h
source3/include/vfs_macros.h
source3/modules/posixacl_xattr.c
source3/modules/vfs_acl_xattr.c
source3/modules/vfs_cap.c
source3/modules/vfs_catia.c
source3/modules/vfs_ceph.c
source3/modules/vfs_default.c
source3/modules/vfs_fake_acls.c
source3/modules/vfs_fruit.c
source3/modules/vfs_full_audit.c
source3/modules/vfs_glusterfs.c
source3/modules/vfs_media_harmony.c
source3/modules/vfs_nfs4acl_xattr.c
source3/modules/vfs_posix_eadb.c
source3/modules/vfs_shadow_copy2.c
source3/modules/vfs_snapper.c
source3/modules/vfs_streams_depot.c
source3/modules/vfs_streams_xattr.c
source3/modules/vfs_time_audit.c
source3/modules/vfs_unityed_media.c
source3/modules/vfs_vxfs.c
source3/modules/vfs_xattr_tdb.c
source3/smbd/dosmode.c
source3/smbd/posix_acls.c
source3/smbd/proto.h
source3/smbd/trans2.c
source3/smbd/vfs.c
source3/torture/cmd_vfs.c

index 7095dbeaefb1408fead18913fdb3a5adefe3e121..c5d4359d8b2dc42d6cfca816813f91bdd4835b4d 100644 (file)
@@ -797,8 +797,11 @@ static int skel_sys_acl_delete_def_file(vfs_handle_struct *handle,
        return -1;
 }
 
-static ssize_t skel_getxattr(vfs_handle_struct *handle, const char *path,
-                            const char *name, void *value, size_t size)
+static ssize_t skel_getxattr(vfs_handle_struct *handle,
+                               const struct smb_filename *smb_fname,
+                               const char *name,
+                               void *value,
+                               size_t size)
 {
        errno = ENOSYS;
        return -1;
index 97e61a4bd8469bc619243e525438ecf3034127a2..91ea5c6a6a774c438b161a7b81c85437091831aa 100644 (file)
@@ -933,10 +933,13 @@ static int skel_sys_acl_delete_def_file(vfs_handle_struct *handle,
        return SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, smb_fname);
 }
 
-static ssize_t skel_getxattr(vfs_handle_struct *handle, const char *path,
-                            const char *name, void *value, size_t size)
+static ssize_t skel_getxattr(vfs_handle_struct *handle,
+                               const struct smb_filename *smb_fname,
+                               const char *name,
+                               void *value,
+                               size_t size)
 {
-       return SMB_VFS_NEXT_GETXATTR(handle, path, name, value, size);
+       return SMB_VFS_NEXT_GETXATTR(handle, smb_fname, name, value, size);
 }
 
 static ssize_t skel_fgetxattr(vfs_handle_struct *handle,
index 6b1d11f06a5b5ca87c45025774de0476dae7ae22..30002bd9814b73cf32dc0ee7abc1e643ec9b38d3 100644 (file)
                to const struct smb_filename * */
 /* Version 37 - Change setxattr from const char *
                to const struct smb_filename * */
-
+/* Version 37 - Change getxattr from const char *
+               to const struct smb_filename * */
 
 #define SMB_VFS_INTERFACE_VERSION 37
 
@@ -894,7 +895,11 @@ struct vfs_fn_pointers {
                                        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);
+       ssize_t (*getxattr_fn)(struct vfs_handle_struct *handle,
+                                       const struct smb_filename *smb_fname,
+                                       const char *name,
+                                       void *value,
+                                       size_t size);
        ssize_t (*fgetxattr_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name, void *value, size_t size);
        ssize_t (*listxattr_fn)(struct vfs_handle_struct *handle,
                                        const struct smb_filename *smb_fname,
@@ -1365,8 +1370,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 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);
+                               const struct smb_filename *smb_fname,
+                               const char *name,
+                               void *value,
+                               size_t size);
 ssize_t smb_vfs_call_fgetxattr(struct vfs_handle_struct *handle,
                               struct files_struct *fsp, const char *name,
                               void *value, size_t size);
index 8e3fb32758efc54642c05722062dd8f2fec39927..0ebd4698f48d08875a17de6c069c94cbb60b4f6e 100644 (file)
 #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))
-#define SMB_VFS_NEXT_GETXATTR(handle,path,name,value,size) \
-       smb_vfs_call_getxattr((handle)->next,(path),(name),(value),(size))
+#define SMB_VFS_GETXATTR(conn,smb_fname,name,value,size) \
+       smb_vfs_call_getxattr((conn)->vfs_handles,(smb_fname),(name),(value),(size))
+#define SMB_VFS_NEXT_GETXATTR(handle,smb_fname,name,value,size) \
+       smb_vfs_call_getxattr((handle)->next,(smb_fname),(name),(value),(size))
 
 #define SMB_VFS_FGETXATTR(fsp,name,value,size) \
        smb_vfs_call_fgetxattr((fsp)->conn->vfs_handles, (fsp), (name),(value),(size))
index fabe574aadbc3a98775d4685fdf263b3ddcdf8b4..759d372facbf1b8164c27dbb75738017468e651b 100644 (file)
@@ -360,10 +360,10 @@ SMB_ACL_T posixacl_xattr_acl_get_file(vfs_handle_struct *handle,
                return NULL;
        }
 
-       ret = SMB_VFS_GETXATTR(handle->conn, smb_fname->base_name,
+       ret = SMB_VFS_GETXATTR(handle->conn, smb_fname,
                                name, buf, size);
        if (ret < 0 && errno == ERANGE) {
-               size = SMB_VFS_GETXATTR(handle->conn, smb_fname->base_name,
+               size = SMB_VFS_GETXATTR(handle->conn, smb_fname,
                                        name, NULL, 0);
                if (size > 0) {
                        buf = alloca(size);
@@ -371,7 +371,7 @@ SMB_ACL_T posixacl_xattr_acl_get_file(vfs_handle_struct *handle,
                                return NULL;
                        }
                        ret = SMB_VFS_GETXATTR(handle->conn,
-                                               smb_fname->base_name, name,
+                                               smb_fname, name,
                                                buf, size);
                }
        }
index 6362ac81d9258efc7d0b02980a0bbdd2546fddf4..367be65f7a400c58d57afe3cc5b74d30d6bc7bea 100644 (file)
@@ -51,7 +51,7 @@ static ssize_t getxattr_do(vfs_handle_struct *handle,
        if (fsp && fsp->fh->fd != -1) {
                sizeret = SMB_VFS_FGETXATTR(fsp, xattr_name, val, size);
        } else {
-               sizeret = SMB_VFS_GETXATTR(handle->conn, smb_fname->base_name,
+               sizeret = SMB_VFS_GETXATTR(handle->conn, smb_fname,
                                           XATTR_NTACL_NAME, val, size);
        }
        if (sizeret == -1) {
index 62d40b5da106d0b2f43afe8129a3cb5577b295ba..c124592af934cadb662239fa0cc215c1bf2d8b65 100644 (file)
@@ -652,16 +652,45 @@ static int cap_sys_acl_delete_def_file(vfs_handle_struct *handle,
        return ret;
 }
 
-static ssize_t cap_getxattr(vfs_handle_struct *handle, const char *path, const char *name, void *value, size_t size)
+static ssize_t cap_getxattr(vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       const char *name,
+                       void *value,
+                       size_t size)
 {
-       char *cappath = capencode(talloc_tos(), path);
+       struct smb_filename *cap_smb_fname = NULL;
+       char *cappath = capencode(talloc_tos(), smb_fname->base_name);
        char *capname = capencode(talloc_tos(), name);
+       ssize_t ret;
+       int saved_errno = 0;
 
        if (!cappath || !capname) {
                errno = ENOMEM;
                return -1;
        }
-        return SMB_VFS_NEXT_GETXATTR(handle, cappath, capname, value, size);
+       cap_smb_fname = synthetic_smb_fname(talloc_tos(),
+                                       cappath,
+                                       NULL,
+                                       NULL,
+                                       smb_fname->flags);
+       if (cap_smb_fname == NULL) {
+               TALLOC_FREE(cappath);
+               TALLOC_FREE(capname);
+               errno = ENOMEM;
+               return -1;
+       }
+       ret = SMB_VFS_NEXT_GETXATTR(handle, cap_smb_fname,
+                       capname, value, size);
+       if (ret == -1) {
+               saved_errno = errno;
+       }
+       TALLOC_FREE(cappath);
+       TALLOC_FREE(capname);
+       TALLOC_FREE(cap_smb_fname);
+       if (saved_errno) {
+               errno = saved_errno;
+       }
+       return ret;
 }
 
 static ssize_t cap_fgetxattr(vfs_handle_struct *handle, struct files_struct *fsp, const char *path, void *value, size_t size)
index cf3e3f3fe525f9a0fe6efb98850005e09e38d356..2592367ed2b3d2a86c2c97a3f98157e2482675a2 100644 (file)
@@ -1376,16 +1376,23 @@ catia_sys_acl_delete_def_file(vfs_handle_struct *handle,
 }
 
 static ssize_t
-catia_getxattr(vfs_handle_struct *handle, const char *path,
-              const char *name, void *value, size_t size)
+catia_getxattr(vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       const char *name,
+                       void *value,
+                       size_t size)
 {
+       struct smb_filename *mapped_smb_fname = NULL;
        char *mapped_name = NULL;
        char *mapped_ea_name = NULL;
        NTSTATUS status;
        ssize_t ret;
+       int saved_errno = 0;
 
        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;
@@ -1399,10 +1406,29 @@ catia_getxattr(vfs_handle_struct *handle, const char *path,
                return -1;
        }
 
-       ret = SMB_VFS_NEXT_GETXATTR(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);
+               TALLOC_FREE(mapped_ea_name);
+               errno = ENOMEM;
+               return -1;
+       }
+
+       ret = SMB_VFS_NEXT_GETXATTR(handle, mapped_smb_fname,
                                mapped_ea_name, value, size);
+       if (ret == -1) {
+               saved_errno = errno;
+       }
        TALLOC_FREE(mapped_name);
        TALLOC_FREE(mapped_ea_name);
+       TALLOC_FREE(mapped_smb_fname);
+       if (saved_errno != 0) {
+               errno = saved_errno;
+       }
 
        return ret;
 }
index 06eada97f684d68bd2c850072d2b52a1261c127e..571d144c3beb33566a8d12892e7d2875e3e6eb23 100644 (file)
@@ -1217,11 +1217,17 @@ static const char *cephwrap_connectpath(struct vfs_handle_struct *handle,
  Extended attribute operations.
 *****************************************************************/
 
-static ssize_t cephwrap_getxattr(struct vfs_handle_struct *handle,const char *path, const char *name, void *value, size_t size)
+static ssize_t cephwrap_getxattr(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       const char *name,
+                       void *value,
+                       size_t size)
 {
        int ret;
-       DBG_DEBUG("[CEPH] getxattr(%p, %s, %s, %p, %llu)\n", handle, path, name, value, llu(size));
-       ret = ceph_getxattr(handle->data, path, name, value, size);
+       DBG_DEBUG("[CEPH] getxattr(%p, %s, %s, %p, %llu)\n", handle,
+                       smb_fname->base_name, name, value, llu(size));
+       ret = ceph_getxattr(handle->data,
+                       smb_fname->base_name, name, value, size);
        DBG_DEBUG("[CEPH] getxattr(...) = %d\n", ret);
        if (ret < 0) {
                WRAP_RETURN(ret);
index eecbcb18ddd32d029e24dae4c4e457fbc86f09a6..5a4be7e216c674c8a1bcecb34215ffc941aabb56 100644 (file)
@@ -2747,9 +2747,13 @@ static int vfswrap_sys_acl_delete_def_file(vfs_handle_struct *handle,
  Extended attribute operations.
 *****************************************************************/
 
-static ssize_t vfswrap_getxattr(struct vfs_handle_struct *handle,const char *path, const char *name, void *value, size_t size)
+static ssize_t vfswrap_getxattr(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       const char *name,
+                       void *value,
+                       size_t size)
 {
-       return getxattr(path, name, value, size);
+       return getxattr(smb_fname->base_name, name, value, size);
 }
 
 static ssize_t vfswrap_fgetxattr(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name, void *value, size_t size)
index 917996af0a43cb2dfc5ebe2458fbc04eb777be77..7de5cf00bd632238cd6696cdff8069fe6f131ace 100644 (file)
 #define FAKE_ACL_DEFAULT_XATTR "system.fake_default_acl"
 
 static int fake_acls_uid(vfs_handle_struct *handle,
-                        const char *path,
+                        struct smb_filename *smb_fname,
                         uid_t *uid)
 {
        ssize_t size;
        uint8_t uid_buf[4];
-       size = SMB_VFS_NEXT_GETXATTR(handle, path, FAKE_UID, uid_buf, sizeof(uid_buf));
+       size = SMB_VFS_NEXT_GETXATTR(handle, smb_fname,
+                       FAKE_UID, uid_buf, sizeof(uid_buf));
        if (size == -1 && errno == ENOATTR) {
                return 0;
        }
@@ -53,13 +54,14 @@ static int fake_acls_uid(vfs_handle_struct *handle,
 }
 
 static int fake_acls_gid(vfs_handle_struct *handle,
-                        const char *path,
+                        struct smb_filename *smb_fname,
                         uid_t *gid)
 {
        ssize_t size;
        uint8_t gid_buf[4];
 
-       size = SMB_VFS_NEXT_GETXATTR(handle, path, FAKE_GID, gid_buf, sizeof(gid_buf));
+       size = SMB_VFS_NEXT_GETXATTR(handle, smb_fname,
+                       FAKE_GID, gid_buf, sizeof(gid_buf));
        if (size == -1 && errno == ENOATTR) {
                return 0;
        }
@@ -131,12 +133,14 @@ static int fake_acls_stat(vfs_handle_struct *handle,
                        return -1;
                }
                
-               ret = fake_acls_uid(handle, path, &smb_fname->st.st_ex_uid);
+               ret = fake_acls_uid(handle, &smb_fname_base,
+                                       &smb_fname->st.st_ex_uid);
                if (ret != 0) {
                        TALLOC_FREE(frame);
                        return ret;
                }
-               ret = fake_acls_gid(handle, path, &smb_fname->st.st_ex_gid);
+               ret = fake_acls_gid(handle, &smb_fname_base,
+                                       &smb_fname->st.st_ex_gid);
                if (ret != 0) {
                        TALLOC_FREE(frame);
                        return ret;
@@ -179,8 +183,10 @@ static int fake_acls_lstat(vfs_handle_struct *handle,
                 * because linux doesn't support using them, but we
                 * could fake them in xattr_tdb if we really wanted
                 * to.  We ignore errors because the link might not point anywhere */
-               fake_acls_uid(handle, path, &smb_fname->st.st_ex_uid);
-               fake_acls_gid(handle, path, &smb_fname->st.st_ex_gid);
+               fake_acls_uid(handle, &smb_fname_base,
+                       &smb_fname->st.st_ex_uid);
+               fake_acls_gid(handle, &smb_fname_base,
+                       &smb_fname->st.st_ex_gid);
                TALLOC_FREE(frame);
        }
 
@@ -250,7 +256,6 @@ static SMB_ACL_T fake_acls_sys_acl_get_file(struct vfs_handle_struct *handle,
        ssize_t length;
        const char *name = NULL;
        struct smb_acl_t *acl = NULL;
-       const char *path = smb_fname->base_name;
        TALLOC_CTX *frame = talloc_stackframe();
        switch (type) {
        case SMB_ACL_TYPE_ACCESS:
@@ -269,7 +274,8 @@ static SMB_ACL_T fake_acls_sys_acl_get_file(struct vfs_handle_struct *handle,
                        TALLOC_FREE(frame);
                        return NULL;
                }
-               length = SMB_VFS_NEXT_GETXATTR(handle, path, name, blob.data, blob.length);
+               length = SMB_VFS_NEXT_GETXATTR(handle, smb_fname,
+                               name, blob.data, blob.length);
                blob.length = length;
        } while (length == -1 && errno == ERANGE);
        if (length == -1 && errno == ENOATTR) {
index 11103ccb3655924056ae76e5453805c984cc3c62..c4277b9ec34d74da4b6caf0bb16b0f67d48d31ed 100644 (file)
@@ -796,7 +796,7 @@ static ssize_t ad_read_meta(struct adouble *ad,
 
        DEBUG(10, ("reading meta xattr for %s\n", smb_fname->base_name));
 
-       ealen = SMB_VFS_GETXATTR(ad->ad_handle->conn, smb_fname->base_name,
+       ealen = SMB_VFS_GETXATTR(ad->ad_handle->conn, smb_fname,
                                 AFPINFO_EA_NETATALK, ad->ad_data,
                                 AD_DATASZ_XATTR);
        if (ealen == -1) {
index 3054c33cd5f50c7f451338ee9b7e00575f3c88b9..fd8c8c14173ec5e8203313626f4664ed38d30725 100644 (file)
@@ -2256,15 +2256,15 @@ static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
 }
 
 static ssize_t smb_full_audit_getxattr(struct vfs_handle_struct *handle,
-                             const char *path,
+                             const struct smb_filename *smb_fname,
                              const char *name, void *value, size_t size)
 {
        ssize_t result;
 
-       result = SMB_VFS_NEXT_GETXATTR(handle, path, name, value, size);
+       result = SMB_VFS_NEXT_GETXATTR(handle, smb_fname, name, value, size);
 
        do_log(SMB_VFS_OP_GETXATTR, (result >= 0), handle,
-              "%s|%s", path, name);
+              "%s|%s", smb_fname->base_name, name);
 
        return result;
 }
index e51556f8bf65b490ee1a3aee637059360853b9a6..c6489732b756cdcd68db27ace1fadb4618369ba2 100644 (file)
@@ -1302,10 +1302,13 @@ static const char *vfs_gluster_connectpath(struct vfs_handle_struct *handle,
 /* EA Operations */
 
 static ssize_t vfs_gluster_getxattr(struct vfs_handle_struct *handle,
-                                   const char *path, const char *name,
-                                   void *value, size_t size)
+                               const struct smb_filename *smb_fname,
+                               const char *name,
+                               void *value,
+                               size_t size)
 {
-       return glfs_getxattr(handle->data, path, name, value, size);
+       return glfs_getxattr(handle->data, smb_fname->base_name,
+                       name, value, size);
 }
 
 static ssize_t vfs_gluster_fgetxattr(struct vfs_handle_struct *handle,
index dd715d1861ba82b157687d73284d965298446b6a..422ca3dfcebe566a5c6baf37b06496cd342a14f6 100644 (file)
@@ -2205,37 +2205,33 @@ out:
  * In this case, "name" is an attr name.
  */
 static ssize_t mh_getxattr(struct vfs_handle_struct *handle,
-               const char *path,
+               const struct smb_filename *smb_fname,
                const char *name,
                void *value,
                size_t size)
 {
+       int status;
+       struct smb_filename *clientFname = NULL;
        ssize_t ret;
-       char *clientPath;
-       TALLOC_CTX *ctx;
 
        DEBUG(MH_INFO_DEBUG, ("Entering mh_getxattr\n"));
-       if (!is_in_media_files(path))
-       {
-               ret = SMB_VFS_NEXT_GETXATTR(handle, path, name, value,
-                               size);
+       if (!is_in_media_files(smb_fname->base_name)) {
+               ret = SMB_VFS_NEXT_GETXATTR(handle, smb_fname,
+                                       name, value, size);
                goto out;
        }
 
-       clientPath = NULL;
-       ctx = talloc_tos();
-
-       if (alloc_get_client_path(handle, ctx,
-                               path,
-                               &clientPath))
-       {
+       status = alloc_get_client_smb_fname(handle,
+                               talloc_tos(),
+                               smb_fname,
+                               &clientFname);
+       if (status != 0) {
                ret = -1;
                goto err;
        }
-
-       ret = SMB_VFS_NEXT_GETXATTR(handle, clientPath, name, value, size);
+       ret = SMB_VFS_NEXT_GETXATTR(handle, clientFname, name, value, size);
 err:
-       TALLOC_FREE(clientPath);
+       TALLOC_FREE(clientFname);
 out:
        return ret;
 }
index de3e368ca88d8bd40275fbad3a9967c6547662c1..951faa478493d3ade238b1bad5a6c59f759aa9f5 100644 (file)
@@ -148,8 +148,10 @@ static NTSTATUS nfs4_fget_nfs4_acl(vfs_handle_struct *handle, TALLOC_CTX *mem_ct
 }
 
 /* Fetch the NFSv4 ACL from the xattr, and convert into Samba's internal NFSv4 format */
-static NTSTATUS nfs4_get_nfs4_acl(vfs_handle_struct *handle, TALLOC_CTX *mem_ctx,
-                                 const char *path, struct SMB4ACL_T **ppacl)
+static NTSTATUS nfs4_get_nfs4_acl(vfs_handle_struct *handle,
+                               TALLOC_CTX *mem_ctx,
+                               const struct smb_filename *smb_fname,
+                               struct SMB4ACL_T **ppacl)
 {
        NTSTATUS status;
        DATA_BLOB blob = data_blob_null;
@@ -164,7 +166,8 @@ static NTSTATUS nfs4_get_nfs4_acl(vfs_handle_struct *handle, TALLOC_CTX *mem_ctx
                        errno = ENOMEM;
                        return NT_STATUS_NO_MEMORY;
                }
-               length = SMB_VFS_NEXT_GETXATTR(handle, path, NFS4ACL_XATTR_NAME, blob.data, blob.length);
+               length = SMB_VFS_NEXT_GETXATTR(handle, smb_fname,
+                               NFS4ACL_XATTR_NAME, blob.data, blob.length);
                blob.length = length;
        } while (length == -1 && errno == ERANGE);
        if (length == -1) {
@@ -402,7 +405,7 @@ static struct SMB4ACL_T *nfs4acls_defaultacl(TALLOC_CTX *mem_ctx)
  * Todo: Really use mem_ctx after fixing interface of nfs4_acls
  */
 static struct SMB4ACL_T *nfs4acls_inheritacl(vfs_handle_struct *handle,
-       const char *path,
+       const struct smb_filename *smb_fname_in,
        TALLOC_CTX *mem_ctx)
 {
        char *parent_dir = NULL;
@@ -412,12 +415,14 @@ static struct SMB4ACL_T *nfs4acls_inheritacl(vfs_handle_struct *handle,
        SMB_ACE4PROP_T ace;
        bool isdir;
        struct smb_filename *smb_fname = NULL;
+       struct smb_filename *smb_fname_parent = NULL;
        NTSTATUS status;
        int ret;
        TALLOC_CTX *frame = talloc_stackframe();
 
-       DEBUG(10, ("nfs4acls_inheritacl invoked for %s\n", path));
-       smb_fname = synthetic_smb_fname(frame, path, NULL, NULL, 0);
+       DEBUG(10, ("nfs4acls_inheritacl invoked for %s\n",
+                       smb_fname_in->base_name));
+       smb_fname = cp_smb_filename_nostream(frame, smb_fname_in);
        if (smb_fname == NULL) {
                TALLOC_FREE(frame);
                errno = ENOMEM;
@@ -436,7 +441,7 @@ static struct SMB4ACL_T *nfs4acls_inheritacl(vfs_handle_struct *handle,
        isdir = S_ISDIR(smb_fname->st.st_ex_mode);
 
        if (!parent_dirname(talloc_tos(),
-                           path,
+                           smb_fname->base_name,
                            &parent_dir,
                            NULL)) {
                TALLOC_FREE(frame);
@@ -444,11 +449,24 @@ static struct SMB4ACL_T *nfs4acls_inheritacl(vfs_handle_struct *handle,
                return NULL;
        }
 
-       status = nfs4_get_nfs4_acl(handle, frame, parent_dir, &pparentacl);
+       smb_fname_parent = synthetic_smb_fname(talloc_tos(),
+                               parent_dir,
+                               NULL,
+                               NULL,
+                               0);
+       if (smb_fname_parent == NULL) {
+               TALLOC_FREE(frame);
+               errno = ENOMEM;
+               return NULL;
+       }
+
+       status = nfs4_get_nfs4_acl(handle, frame, smb_fname_parent,
+                                       &pparentacl);
        if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)
            && strncmp(parent_dir, ".", 2) != 0) {
-               pparentacl = nfs4acls_inheritacl(handle, parent_dir,
-                                                frame);
+               pparentacl = nfs4acls_inheritacl(handle,
+                                               smb_fname_parent,
+                                               frame);
        }
        else if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
                pparentacl = nfs4acls_defaultacl(frame);
@@ -527,7 +545,7 @@ static NTSTATUS nfs4acl_xattr_fget_nt_acl(struct vfs_handle_struct *handle,
 
        status = nfs4_fget_nfs4_acl(handle, frame, fsp, &pacl);
        if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
-               pacl = nfs4acls_inheritacl(handle, fsp->fsp_name->base_name,
+               pacl = nfs4acls_inheritacl(handle, fsp->fsp_name,
                                           frame);
        }
        else if (!NT_STATUS_IS_OK(status)) {
@@ -549,12 +567,11 @@ static NTSTATUS nfs4acl_xattr_get_nt_acl(struct vfs_handle_struct *handle,
 {
        struct SMB4ACL_T *pacl;
        NTSTATUS status;
-       const char *name = smb_fname->base_name;
        TALLOC_CTX *frame = talloc_stackframe();
 
-       status = nfs4_get_nfs4_acl(handle, frame, name, &pacl);
+       status = nfs4_get_nfs4_acl(handle, frame, smb_fname, &pacl);
        if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
-               pacl = nfs4acls_inheritacl(handle, name, frame);
+               pacl = nfs4acls_inheritacl(handle, smb_fname, frame);
        }
        else if (!NT_STATUS_IS_OK(status)) {
                TALLOC_FREE(frame);
index 1ba94dca710f5ebca304b0655266e6d83ea60998..889655e52ce053235eed1111afe2215cba235554 100644 (file)
@@ -77,14 +77,17 @@ static ssize_t posix_eadb_getattr(struct tdb_wrap *db_ctx,
 }
 
 static ssize_t posix_eadb_getxattr(struct vfs_handle_struct *handle,
-                                 const char *path, const char *name,
-                                 void *value, size_t size)
+                               const struct smb_filename *smb_fname,
+                               const char *name,
+                               void *value,
+                               size_t size)
 {
        struct tdb_wrap *db;
 
        SMB_VFS_HANDLE_GET_DATA(handle, db, struct tdb_wrap, return -1);
 
-       return posix_eadb_getattr(db, path, -1, name, value, size);
+       return posix_eadb_getattr(db, smb_fname->base_name,
+                       -1, name, value, size);
 }
 
 static ssize_t posix_eadb_fgetxattr(struct vfs_handle_struct *handle,
index 5471ed3d0830368926e4482597b3a050218deeda..dba164efe0e221f0681f0cfa9c3a77d8d06bbd4e 100644 (file)
@@ -2333,21 +2333,27 @@ static int shadow_copy2_chflags(vfs_handle_struct *handle, const char *fname,
 }
 
 static ssize_t shadow_copy2_getxattr(vfs_handle_struct *handle,
-                                    const char *fname, const char *aname,
-                                    void *value, size_t size)
+                               const struct smb_filename *smb_fname,
+                               const char *aname,
+                               void *value,
+                               size_t size)
 {
        time_t timestamp = 0;
        char *stripped = NULL;
        ssize_t ret;
        int saved_errno = 0;
        char *conv;
+       struct smb_filename *conv_smb_fname = NULL;
 
-       if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
-                                        &timestamp, &stripped)) {
+       if (!shadow_copy2_strip_snapshot(talloc_tos(),
+                               handle,
+                               smb_fname->base_name,
+                               &timestamp,
+                               &stripped)) {
                return -1;
        }
        if (timestamp == 0) {
-               return SMB_VFS_NEXT_GETXATTR(handle, fname, aname, value,
+               return SMB_VFS_NEXT_GETXATTR(handle, smb_fname, aname, value,
                                             size);
        }
        conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
@@ -2355,10 +2361,22 @@ static ssize_t shadow_copy2_getxattr(vfs_handle_struct *handle,
        if (conv == NULL) {
                return -1;
        }
-       ret = SMB_VFS_NEXT_GETXATTR(handle, conv, aname, value, size);
+
+       conv_smb_fname = synthetic_smb_fname(talloc_tos(),
+                                       conv,
+                                       NULL,
+                                       NULL,
+                                       smb_fname->flags);
+       if (conv_smb_fname == NULL) {
+               TALLOC_FREE(conv);
+               return -1;
+       }
+
+       ret = SMB_VFS_NEXT_GETXATTR(handle, conv_smb_fname, aname, value, size);
        if (ret == -1) {
                saved_errno = errno;
        }
+       TALLOC_FREE(conv_smb_fname);
        TALLOC_FREE(conv);
        if (saved_errno != 0) {
                errno = saved_errno;
index 1c88a1e49124473851ff47a3fe424fbd15c816d3..2274a56a61ad3474758f1a51986376bdff65350b 100644 (file)
@@ -2669,21 +2669,27 @@ static int snapper_gmt_chflags(vfs_handle_struct *handle, const char *fname,
 }
 
 static ssize_t snapper_gmt_getxattr(vfs_handle_struct *handle,
-                                   const char *fname, const char *aname,
-                                   void *value, size_t size)
+                               const struct smb_filename *smb_fname,
+                               const char *aname,
+                               void *value,
+                               size_t size)
 {
-       time_t timestamp;
-       char *stripped;
+       time_t timestamp = 0;
+       char *stripped = NULL;
        ssize_t ret;
-       int saved_errno;
-       char *conv;
+       int saved_errno = 0;
+       char *conv = NULL;
+       struct smb_filename *conv_smb_fname = NULL;
 
-       if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, fname,
-                                       &timestamp, &stripped)) {
+       if (!snapper_gmt_strip_snapshot(talloc_tos(),
+                                       handle,
+                                       smb_fname->base_name,
+                                       &timestamp,
+                                       &stripped)) {
                return -1;
        }
        if (timestamp == 0) {
-               return SMB_VFS_NEXT_GETXATTR(handle, fname, aname, value,
+               return SMB_VFS_NEXT_GETXATTR(handle, smb_fname, aname, value,
                                             size);
        }
        conv = snapper_gmt_convert(talloc_tos(), handle, stripped, timestamp);
@@ -2691,10 +2697,25 @@ static ssize_t snapper_gmt_getxattr(vfs_handle_struct *handle,
        if (conv == NULL) {
                return -1;
        }
-       ret = SMB_VFS_NEXT_GETXATTR(handle, conv, aname, value, size);
-       saved_errno = errno;
+       conv_smb_fname = synthetic_smb_fname(talloc_tos(),
+                                       conv,
+                                       NULL,
+                                       NULL,
+                                       smb_fname->flags);
        TALLOC_FREE(conv);
-       errno = saved_errno;
+       if (conv_smb_fname == NULL) {
+               errno = ENOMEM;
+               return -1;
+       }
+       ret = SMB_VFS_NEXT_GETXATTR(handle, conv_smb_fname, aname, value, size);
+       if (ret == -1) {
+               saved_errno = errno;
+       }
+       TALLOC_FREE(conv_smb_fname);
+       TALLOC_FREE(conv);
+       if (saved_errno != 0) {
+               errno = saved_errno;
+       }
        return ret;
 }
 
index b6e95a2787d5ab49f475b126f0c087f95d849e9d..04c1cdb7d4854a85592e6c5d6083b4216bd8a27c 100644 (file)
@@ -67,13 +67,14 @@ static uint32_t hash_fn(DATA_BLOB key)
  * an option to put in a special ACL entry for a non-existing group.
  */
 
-static bool file_is_valid(vfs_handle_struct *handle, const char *path)
+static bool file_is_valid(vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname)
 {
        char buf;
 
-       DEBUG(10, ("file_is_valid (%s) called\n", path));
+       DEBUG(10, ("file_is_valid (%s) called\n", smb_fname->base_name));
 
-       if (SMB_VFS_GETXATTR(handle->conn, path, SAMBA_XATTR_MARKER,
+       if (SMB_VFS_GETXATTR(handle->conn, smb_fname, SAMBA_XATTR_MARKER,
                                  &buf, sizeof(buf)) != sizeof(buf)) {
                DEBUG(10, ("GETXATTR failed: %s\n", strerror(errno)));
                return false;
@@ -228,7 +229,7 @@ static char *stream_dir(vfs_handle_struct *handle,
                }
 
                if (!check_valid ||
-                   file_is_valid(handle, smb_fname->base_name)) {
+                   file_is_valid(handle, smb_fname)) {
                        return result;
                }
 
index d69c3f9a3f289869e3fcea920e57f99616ac619c..5114c094035e4c9bd95bec5ee8aa915ff4555c12 100644 (file)
@@ -79,14 +79,14 @@ static SMB_INO_T stream_inode(const SMB_STRUCT_STAT *sbuf, const char *sname)
 
 static ssize_t get_xattr_size(connection_struct *conn,
                                files_struct *fsp,
-                               const char *fname,
+                               const struct smb_filename *smb_fname,
                                const char *xattr_name)
 {
        NTSTATUS status;
        struct ea_struct ea;
        ssize_t result;
 
-       status = get_ea_value(talloc_tos(), conn, fsp, fname,
+       status = get_ea_value(talloc_tos(), conn, fsp, smb_fname,
                              xattr_name, &ea);
 
        if (!NT_STATUS_IS_OK(status)) {
@@ -190,8 +190,8 @@ static bool streams_xattr_recheck(struct stream_io *sio)
        TALLOC_FREE(sio->base);
        sio->xattr_name = talloc_strdup(VFS_MEMCTX_FSP_EXTENSION(sio->handle, sio->fsp),
                                        xattr_name);
-       sio->base = talloc_strdup(VFS_MEMCTX_FSP_EXTENSION(sio->handle, sio->fsp),
-                                 sio->fsp->fsp_name->base_name);
+        sio->base = talloc_strdup(VFS_MEMCTX_FSP_EXTENSION(sio->handle, sio->fsp),
+                                  sio->fsp->fsp_name->base_name);
        sio->fsp_name_ptr = sio->fsp->fsp_name;
 
        TALLOC_FREE(xattr_name);
@@ -259,15 +259,16 @@ static int streams_xattr_fstat(vfs_handle_struct *handle, files_struct *fsp,
                ret = SMB_VFS_STAT(handle->conn, smb_fname_base);
        }
        *sbuf = smb_fname_base->st;
-       TALLOC_FREE(smb_fname_base);
 
        if (ret == -1) {
+               TALLOC_FREE(smb_fname_base);
                return -1;
        }
 
        sbuf->st_ex_size = get_xattr_size(handle->conn, fsp,
-                                       io->base, io->xattr_name);
+                                       smb_fname_base, io->xattr_name);
        if (sbuf->st_ex_size == -1) {
+               TALLOC_FREE(smb_fname_base);
                return -1;
        }
 
@@ -278,6 +279,7 @@ static int streams_xattr_fstat(vfs_handle_struct *handle, files_struct *fsp,
         sbuf->st_ex_mode |= S_IFREG;
         sbuf->st_ex_blocks = sbuf->st_ex_size / STAT_ST_BLOCKSIZE + 1;
 
+       TALLOC_FREE(smb_fname_base);
        return 0;
 }
 
@@ -317,7 +319,7 @@ static int streams_xattr_stat(vfs_handle_struct *handle,
 
        /* Augment the base file's stat information before returning. */
        smb_fname->st.st_ex_size = get_xattr_size(handle->conn, NULL,
-                                                 smb_fname->base_name,
+                                                 smb_fname,
                                                  xattr_name);
        if (smb_fname->st.st_ex_size == -1) {
                errno = ENOENT;
@@ -368,7 +370,7 @@ static int streams_xattr_lstat(vfs_handle_struct *handle,
 
        /* Augment the base file's stat information before returning. */
        smb_fname->st.st_ex_size = get_xattr_size(handle->conn, NULL,
-                                                 smb_fname->base_name,
+                                                 smb_fname,
                                                  xattr_name);
        if (smb_fname->st.st_ex_size == -1) {
                errno = ENOENT;
@@ -470,7 +472,7 @@ static int streams_xattr_open(vfs_handle_struct *handle,
         }
 
        status = get_ea_value(talloc_tos(), handle->conn, NULL,
-                             smb_fname->base_name, xattr_name, &ea);
+                             smb_fname, xattr_name, &ea);
 
        DEBUG(10, ("get_ea_value returned %s\n", nt_errstr(status)));
 
@@ -654,7 +656,7 @@ static int streams_xattr_rename(vfs_handle_struct *handle,
 
        /* read the old stream */
        status = get_ea_value(talloc_tos(), handle->conn, NULL,
-                             smb_fname_src->base_name, src_xattr_name, &ea);
+                             smb_fname_src, src_xattr_name, &ea);
        if (!NT_STATUS_IS_OK(status)) {
                errno = ENOENT;
                goto fail;
@@ -744,7 +746,7 @@ static NTSTATUS walk_xattr_streams(vfs_handle_struct *handle,
                status = get_ea_value(names,
                                        handle->conn,
                                        fsp,
-                                       smb_fname->base_name,
+                                       smb_fname,
                                        names[i],
                                        &ea);
                if (!NT_STATUS_IS_OK(status)) {
@@ -950,6 +952,7 @@ static ssize_t streams_xattr_pwrite(vfs_handle_struct *handle,
                (struct stream_io *)VFS_FETCH_FSP_EXTENSION(handle, fsp);
        struct ea_struct ea;
        NTSTATUS status;
+       struct smb_filename *smb_fname_base = NULL;
        int ret;
 
        DEBUG(10, ("streams_xattr_pwrite called for %d bytes\n", (int)n));
@@ -962,8 +965,19 @@ static ssize_t streams_xattr_pwrite(vfs_handle_struct *handle,
                return -1;
        }
 
+       /* Create an smb_filename with stream_name == NULL. */
+       smb_fname_base = synthetic_smb_fname(talloc_tos(),
+                                       sio->base,
+                                       NULL,
+                                       NULL,
+                                       fsp->fsp_name->flags);
+       if (smb_fname_base == NULL) {
+               errno = ENOMEM;
+               return -1;
+       }
+
        status = get_ea_value(talloc_tos(), handle->conn, fsp,
-                             sio->base, sio->xattr_name, &ea);
+                             smb_fname_base, sio->xattr_name, &ea);
        if (!NT_STATUS_IS_OK(status)) {
                return -1;
        }
@@ -1014,6 +1028,7 @@ static ssize_t streams_xattr_pread(vfs_handle_struct *handle,
        struct ea_struct ea;
        NTSTATUS status;
        size_t length, overlap;
+       struct smb_filename *smb_fname_base = NULL;
 
        DEBUG(10, ("streams_xattr_pread: offset=%d, size=%d\n",
                   (int)offset, (int)n));
@@ -1026,8 +1041,19 @@ static ssize_t streams_xattr_pread(vfs_handle_struct *handle,
                return -1;
        }
 
+       /* Create an smb_filename with stream_name == NULL. */
+       smb_fname_base = synthetic_smb_fname(talloc_tos(),
+                                       sio->base,
+                                       NULL,
+                                       NULL,
+                                       fsp->fsp_name->flags);
+       if (smb_fname_base == NULL) {
+               errno = ENOMEM;
+               return -1;
+       }
+
        status = get_ea_value(talloc_tos(), handle->conn, fsp,
-                             sio->base, sio->xattr_name, &ea);
+                             smb_fname_base, sio->xattr_name, &ea);
        if (!NT_STATUS_IS_OK(status)) {
                return -1;
        }
@@ -1219,6 +1245,7 @@ static int streams_xattr_ftruncate(struct vfs_handle_struct *handle,
        NTSTATUS status;
         struct stream_io *sio =
                (struct stream_io *)VFS_FETCH_FSP_EXTENSION(handle, fsp);
+       struct smb_filename *smb_fname_base = NULL;
 
        DEBUG(10, ("streams_xattr_ftruncate called for file %s offset %.0f\n",
                   fsp_str_dbg(fsp), (double)offset));
@@ -1231,8 +1258,19 @@ static int streams_xattr_ftruncate(struct vfs_handle_struct *handle,
                return -1;
        }
 
+       /* Create an smb_filename with stream_name == NULL. */
+       smb_fname_base = synthetic_smb_fname(talloc_tos(),
+                                       sio->base,
+                                       NULL,
+                                       NULL,
+                                       fsp->fsp_name->flags);
+       if (smb_fname_base == NULL) {
+               errno = ENOMEM;
+               return -1;
+       }
+
        status = get_ea_value(talloc_tos(), handle->conn, fsp,
-                             sio->base, sio->xattr_name, &ea);
+                             smb_fname_base, sio->xattr_name, &ea);
        if (!NT_STATUS_IS_OK(status)) {
                return -1;
        }
index dd915e512a9be95274b1d7b8dfecc8c3c82e02c2..761711b7423109acc08721210c59744b9de61371 100644 (file)
@@ -2321,20 +2321,23 @@ static int smb_time_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
 }
 
 static ssize_t smb_time_audit_getxattr(struct vfs_handle_struct *handle,
-                                      const char *path, const char *name,
-                                      void *value, size_t size)
+                               const struct smb_filename *smb_fname,
+                               const char *name,
+                               void *value,
+                               size_t size)
 {
        ssize_t result;
        struct timespec ts1,ts2;
        double timediff;
 
        clock_gettime_mono(&ts1);
-       result = SMB_VFS_NEXT_GETXATTR(handle, path, name, value, size);
+       result = SMB_VFS_NEXT_GETXATTR(handle, smb_fname, name, value, size);
        clock_gettime_mono(&ts2);
        timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
 
        if (timediff > audit_timeout) {
-               smb_time_audit_log_fname("getxattr", timediff, path);
+               smb_time_audit_log_fname("getxattr", timediff,
+                       smb_fname->base_name);
        }
 
        return result;
index 3dd8b996cc9e453a3e5617f3f610879c0df64618..7c8bee05861818c8229d90efe9db6002f5e6f017 100644 (file)
@@ -1722,30 +1722,33 @@ err:
 }
 
 static ssize_t um_getxattr(struct vfs_handle_struct *handle,
-                          const char *path,
+                          const struct smb_filename *smb_fname,
                           const char *name,
                           void *value,
                           size_t size)
 {
        ssize_t ret;
-       char *client_path = NULL;
+       struct smb_filename *client_fname = NULL;
        int status;
 
        DEBUG(10, ("Entering um_getxattr\n"));
-       if (!is_in_media_files(path)) {
-               return SMB_VFS_NEXT_GETXATTR(handle, path, name, value, size);
+       if (!is_in_media_files(smb_fname->base_name)) {
+               return SMB_VFS_NEXT_GETXATTR(handle, smb_fname,
+                               name, value, size);
        }
 
-       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) {
                ret = -1;
                goto err;
        }
 
-       ret = SMB_VFS_NEXT_GETXATTR(handle, client_path, name, value, size);
+       ret = SMB_VFS_NEXT_GETXATTR(handle, client_fname, name, value, size);
 err:
-       TALLOC_FREE(client_path);
+       TALLOC_FREE(client_fname);
        return ret;
 }
 
index 0b5977f7706cec898966f6c79d9ddc18ae97772a..f1f61f18578401e1328639a1a6e08f455c4cf2c1 100644 (file)
@@ -621,12 +621,14 @@ static int vxfs_fset_xattr(struct vfs_handle_struct *handle,
 }
 
 static ssize_t vxfs_get_xattr(struct vfs_handle_struct *handle,
-                             const char *path, const char *name,
-                             void *value, size_t size){
+                               const struct smb_filename *smb_fname,
+                               const char *name,
+                               void *value,
+                               size_t size){
        int ret;
 
        DEBUG(10, ("In vxfs_get_xattr\n"));
-       ret = vxfs_getxattr_path(path, name, value, size);
+       ret = vxfs_getxattr_path(smb_fname->base_name, name, value, size);
        if ((ret != -1) || ((errno != ENOTSUP) &&
                            (errno != ENOSYS) && (errno != ENODATA))) {
                return ret;
@@ -634,8 +636,8 @@ static ssize_t vxfs_get_xattr(struct vfs_handle_struct *handle,
 
        DEBUG(10, ("Fallback to xattr\n"));
        if (strcmp(name, XATTR_NTACL_NAME) == 0) {
-               return SMB_VFS_NEXT_GETXATTR(handle, path, XATTR_USER_NTACL,
-                                            value, size);
+               return SMB_VFS_NEXT_GETXATTR(handle, smb_fname,
+                               XATTR_USER_NTACL, value, size);
        }
 
        /* Clients can't see XATTR_USER_NTACL directly. */
@@ -644,7 +646,7 @@ static ssize_t vxfs_get_xattr(struct vfs_handle_struct *handle,
                return -1;
        }
 
-       return SMB_VFS_NEXT_GETXATTR(handle, path, name, value, size);
+       return SMB_VFS_NEXT_GETXATTR(handle, smb_fname, name, value, size);
 }
 
 static ssize_t vxfs_fget_xattr(struct vfs_handle_struct *handle,
index d6d480883342e2a458027e7d895626a1d0b0083d..c9bb4728e342c7fb021f9ef829110426867a83c3 100644 (file)
@@ -57,8 +57,10 @@ static int xattr_tdb_get_file_id(struct vfs_handle_struct *handle,
 }
 
 static ssize_t xattr_tdb_getxattr(struct vfs_handle_struct *handle,
-                                 const char *path, const char *name,
-                                 void *value, size_t size)
+                               const struct smb_filename *smb_fname,
+                               const char *name,
+                               void *value,
+                               size_t size)
 {
        struct file_id id;
        struct db_context *db;
@@ -73,7 +75,7 @@ static ssize_t xattr_tdb_getxattr(struct vfs_handle_struct *handle,
                                        TALLOC_FREE(frame); return -1;
                                });
 
-       ret = xattr_tdb_get_file_id(handle, path, &id);
+       ret = xattr_tdb_get_file_id(handle, smb_fname->base_name, &id);
        if (ret == -1) {
                TALLOC_FREE(frame);
                return -1;
index de10983ae6a411b47233bcb499e93d8f37fe6454..0ee6894785169a8ba72dca77eb475a36066ae0ad 100644 (file)
@@ -278,7 +278,7 @@ NTSTATUS get_ea_dos_attribute(connection_struct *conn,
        /* Don't reset pattr to zero as we may already have filename-based attributes we
           need to preserve. */
 
-       sizeret = SMB_VFS_GETXATTR(conn, smb_fname->base_name,
+       sizeret = SMB_VFS_GETXATTR(conn, smb_fname,
                                   SAMBA_XATTR_DOS_ATTRIB, attrstr,
                                   sizeof(attrstr));
        if (sizeret == -1) {
index 021e3311395ed9189a512be32ffe72a3fc44de56..e4403458495493c7e9a419d6bf5053e5abc0df25 100644 (file)
@@ -629,7 +629,7 @@ static struct pai_val *fload_inherited_info(files_struct *fsp)
                                        pai_buf, pai_buf_size);
                } else {
                        ret = SMB_VFS_GETXATTR(fsp->conn,
-                                              fsp->fsp_name->base_name,
+                                              fsp->fsp_name,
                                               SAMBA_POSIX_INHERITANCE_EA_NAME,
                                               pai_buf, pai_buf_size);
                }
@@ -681,7 +681,7 @@ static struct pai_val *fload_inherited_info(files_struct *fsp)
 ************************************************************************/
 
 static struct pai_val *load_inherited_info(const struct connection_struct *conn,
-                                          const char *fname)
+                                          const struct smb_filename *smb_fname)
 {
        char *pai_buf;
        size_t pai_buf_size = 1024;
@@ -697,7 +697,7 @@ static struct pai_val *load_inherited_info(const struct connection_struct *conn,
        }
 
        do {
-               ret = SMB_VFS_GETXATTR(conn, fname,
+               ret = SMB_VFS_GETXATTR(conn, smb_fname,
                                       SAMBA_POSIX_INHERITANCE_EA_NAME,
                                       pai_buf, pai_buf_size);
 
@@ -716,7 +716,8 @@ static struct pai_val *load_inherited_info(const struct connection_struct *conn,
                }
        } while (ret == -1);
 
-       DEBUG(10,("load_inherited_info: ret = %lu for file %s\n", (unsigned long)ret, fname));
+       DEBUG(10,("load_inherited_info: ret = %lu for file %s\n",
+                       (unsigned long)ret, smb_fname->base_name));
 
        if (ret == -1) {
                /* No attribute or not supported. */
@@ -736,7 +737,7 @@ static struct pai_val *load_inherited_info(const struct connection_struct *conn,
        if (paiv) {
                DEBUG(10,("load_inherited_info: ACL type 0x%x for file %s\n",
                        (unsigned int)paiv->sd_type,
-                       fname));
+                       smb_fname->base_name));
        }
 
        TALLOC_FREE(pai_buf);
@@ -3593,7 +3594,7 @@ NTSTATUS posix_get_nt_acl(struct connection_struct *conn,
                def_acl = free_empty_sys_acl(conn, def_acl);
        }
 
-       pal = load_inherited_info(conn, smb_fname->base_name);
+       pal = load_inherited_info(conn, smb_fname);
 
        status = posix_get_nt_acl_common(conn,
                                        smb_fname->base_name,
index 06d2461839bd6b85d4a978e3fb7a36765320c0b7..89797296a779e8280eb085fe088d25da9c93f509 100644 (file)
@@ -1143,8 +1143,10 @@ uint64_t get_FileIndex(connection_struct *conn, const SMB_STRUCT_STAT *psbuf);
 void aapl_force_zero_file_id(struct smbd_server_connection *sconn);
 bool samba_private_attr_name(const char *unix_ea_name);
 NTSTATUS get_ea_value(TALLOC_CTX *mem_ctx, connection_struct *conn,
-                     files_struct *fsp, const char *fname,
-                     const char *ea_name, struct ea_struct *pea);
+                       files_struct *fsp,
+                       const struct smb_filename *smb_fname,
+                       const char *ea_name,
+                       struct ea_struct *pea);
 NTSTATUS get_ea_names_from_file(TALLOC_CTX *mem_ctx,
                        connection_struct *conn,
                        files_struct *fsp,
index 4df4d4e0f43892c89e5dac9733e92ca5563dc90b..a35297c25230f4bc3107a8d3a7a13e2d3fd75427 100644 (file)
@@ -203,9 +203,12 @@ bool samba_private_attr_name(const char *unix_ea_name)
  Get one EA value. Fill in a struct ea_struct.
 ****************************************************************************/
 
-NTSTATUS get_ea_value(TALLOC_CTX *mem_ctx, connection_struct *conn,
-                     files_struct *fsp, const char *fname,
-                     const char *ea_name, struct ea_struct *pea)
+NTSTATUS get_ea_value(TALLOC_CTX *mem_ctx,
+                       connection_struct *conn,
+                       files_struct *fsp,
+                       const struct smb_filename *smb_fname,
+                       const char *ea_name,
+                       struct ea_struct *pea)
 {
        /* Get the value of this xattr. Max size is 64k. */
        size_t attr_size = 256;
@@ -222,7 +225,8 @@ NTSTATUS get_ea_value(TALLOC_CTX *mem_ctx, connection_struct *conn,
        if (fsp && fsp->fh->fd != -1) {
                sizeret = SMB_VFS_FGETXATTR(fsp, ea_name, val, attr_size);
        } else {
-               sizeret = SMB_VFS_GETXATTR(conn, fname, ea_name, val, attr_size);
+               sizeret = SMB_VFS_GETXATTR(conn, smb_fname,
+                               ea_name, val, attr_size);
        }
 
        if (sizeret == -1 && errno == ERANGE && attr_size != 65536) {
@@ -458,7 +462,7 @@ static NTSTATUS get_ea_list_from_file_path(TALLOC_CTX *mem_ctx,
                status = get_ea_value(listp,
                                        conn,
                                        fsp,
-                                       smb_fname->base_name,
+                                       smb_fname,
                                        names[i],
                                        &listp->ea);
 
index d640126e243f1c4dda697824c538b6b45e0cae59..9873f7fa2e551ad7b5a6e800033d42a11b84dfb1 100644 (file)
@@ -2503,11 +2503,13 @@ int smb_vfs_call_sys_acl_delete_def_file(struct vfs_handle_struct *handle,
 }
 
 ssize_t smb_vfs_call_getxattr(struct vfs_handle_struct *handle,
-                             const char *path, const char *name, void *value,
-                             size_t size)
+                               const struct smb_filename *smb_fname,
+                               const char *name,
+                               void *value,
+                               size_t size)
 {
        VFS_FIND(getxattr);
-       return handle->fns->getxattr_fn(handle, path, name, value, size);
+       return handle->fns->getxattr_fn(handle, smb_fname, name, value, size);
 }
 
 ssize_t smb_vfs_call_fgetxattr(struct vfs_handle_struct *handle,
index 038317ebffc7f465edb40c7aaacff2d94e167d80..0e04a88b7e28206f5bcfe5dc748e596cc564e057 100644 (file)
@@ -1309,6 +1309,7 @@ static NTSTATUS cmd_getxattr(struct vfs_state *vfs, TALLOC_CTX *mem_ctx,
 {
        uint8_t *buf;
        ssize_t ret;
+       struct smb_filename *smb_fname = NULL;
 
        if (argc != 3) {
                printf("Usage: getxattr <path> <xattr>\n");
@@ -1317,7 +1318,13 @@ static NTSTATUS cmd_getxattr(struct vfs_state *vfs, TALLOC_CTX *mem_ctx,
 
        buf = NULL;
 
-       ret = SMB_VFS_GETXATTR(vfs->conn, argv[1], argv[2], buf,
+       smb_fname = synthetic_smb_fname_split(mem_ctx,
+                                       argv[1],
+                                       lp_posix_pathnames());
+       if (smb_fname == NULL) {
+               return NT_STATUS_NO_MEMORY;
+       }
+       ret = SMB_VFS_GETXATTR(vfs->conn, smb_fname, argv[2], buf,
                               talloc_get_size(buf));
        if (ret == -1) {
                int err = errno;
@@ -1328,7 +1335,7 @@ static NTSTATUS cmd_getxattr(struct vfs_state *vfs, TALLOC_CTX *mem_ctx,
        if (buf == NULL) {
                return NT_STATUS_NO_MEMORY;
        }
-       ret = SMB_VFS_GETXATTR(vfs->conn, argv[1], argv[2], buf,
+       ret = SMB_VFS_GETXATTR(vfs->conn, smb_fname, argv[2], buf,
                               talloc_get_size(buf));
        if (ret == -1) {
                int err = errno;