s3: VFS: Change SMB_VFS_REMOVEXATTR to use const struct smb_filename * instead of...
authorJeremy Allison <jra@samba.org>
Wed, 24 May 2017 18:35:50 +0000 (11:35 -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>
26 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_posix_eadb.c
source3/modules/vfs_shadow_copy2.c
source3/modules/vfs_snapper.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/trans2.c
source3/smbd/vfs.c
source3/torture/cmd_vfs.c

index 981bfbffe33348a931cfb34d635656cd9e7f1ece..ea66742d858ad45362144ba2970bba51e359ce6f 100644 (file)
@@ -829,8 +829,9 @@ static ssize_t skel_flistxattr(vfs_handle_struct *handle,
        return -1;
 }
 
-static int skel_removexattr(vfs_handle_struct *handle, const char *path,
-                           const char *name)
+static int skel_removexattr(vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       const char *name)
 {
        errno = ENOSYS;
        return -1;
index ec7a9f1aee03e3e9b2294815724ad8677e2cd068..e72edbc04d8cd2e88eeee039075dfee70f2d8f04 100644 (file)
@@ -961,10 +961,11 @@ static ssize_t skel_flistxattr(vfs_handle_struct *handle,
        return SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
 }
 
-static int skel_removexattr(vfs_handle_struct *handle, const char *path,
-                           const char *name)
+static int skel_removexattr(vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       const char *name)
 {
-       return SMB_VFS_NEXT_REMOVEXATTR(handle, path, name);
+       return SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, name);
 }
 
 static int skel_fremovexattr(vfs_handle_struct *handle,
index 7046513480de162522383baaa4e4fb2ee42744e9..56c3f5d56b78186a2e44cb55023ccc1bee9df09c 100644 (file)
                to const struct smb_filename * */
 /* Version 37 - Change listxattr from const char *
                to const struct smb_filename * */
+/* Version 37 - Change removexattr from const char *
+               to const struct smb_filename * */
 
 #define SMB_VFS_INTERFACE_VERSION 37
 
@@ -896,7 +898,9 @@ struct vfs_fn_pointers {
                                        char *list,
                                        size_t size);
        ssize_t (*flistxattr_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, char *list, size_t size);
-       int (*removexattr_fn)(struct vfs_handle_struct *handle, const char *path, const char *name);
+       int (*removexattr_fn)(struct vfs_handle_struct *handle,
+                                       const struct smb_filename *smb_fname,
+                                       const char *name);
        int (*fremovexattr_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name);
        int (*setxattr_fn)(struct vfs_handle_struct *handle, const char *path, const char *name, const void *value, size_t size, int flags);
        int (*fsetxattr_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name, const void *value, size_t size, int flags);
@@ -1368,7 +1372,8 @@ ssize_t smb_vfs_call_flistxattr(struct vfs_handle_struct *handle,
                                struct files_struct *fsp, char *list,
                                size_t size);
 int smb_vfs_call_removexattr(struct vfs_handle_struct *handle,
-                            const char *path, const char *name);
+                               const struct smb_filename *smb_fname,
+                               const char *name);
 int smb_vfs_call_fremovexattr(struct vfs_handle_struct *handle,
                              struct files_struct *fsp, const char *name);
 int smb_vfs_call_setxattr(struct vfs_handle_struct *handle, const char *path,
index f5c0332cf208d0d7c82dc8074f75d69ac20222e2..e1a9ba05024dd078eb260511f8152d28c427cb60 100644 (file)
 #define SMB_VFS_NEXT_FLISTXATTR(handle,fsp,list,size) \
        smb_vfs_call_flistxattr((handle)->next,(fsp),(list),(size))
 
-#define SMB_VFS_REMOVEXATTR(conn,path,name) \
-       smb_vfs_call_removexattr((conn)->vfs_handles,(path),(name))
-#define SMB_VFS_NEXT_REMOVEXATTR(handle,path,name) \
-       smb_vfs_call_removexattr((handle)->next,(path),(name))
+#define SMB_VFS_REMOVEXATTR(conn,smb_fname,name) \
+       smb_vfs_call_removexattr((conn)->vfs_handles,(smb_fname),(name))
+#define SMB_VFS_NEXT_REMOVEXATTR(handle,smb_fname,name) \
+       smb_vfs_call_removexattr((handle)->next,(smb_fname),(name))
 
 #define SMB_VFS_FREMOVEXATTR(fsp,name) \
        smb_vfs_call_fremovexattr((fsp)->conn->vfs_handles, (fsp), (name))
index 416295fc6a88647de3e5e17c60d1155c6b68b3a0..59934551e143535a6f023bee14bc0142f70941da 100644 (file)
@@ -504,6 +504,6 @@ int posixacl_xattr_acl_delete_def_file(vfs_handle_struct *handle,
                                const struct smb_filename *smb_fname)
 {
        return SMB_VFS_REMOVEXATTR(handle->conn,
-                       smb_fname->base_name,
+                       smb_fname,
                        ACL_EA_DEFAULT);
 }
index 1dc70824bf573cb49fa332b6604c99c4539b5bc4..b21207bc205f89e01c9829d47347449613961275 100644 (file)
@@ -181,7 +181,7 @@ static int sys_acl_set_file_xattr(vfs_handle_struct *handle,
        }
 
        become_root();
-       SMB_VFS_REMOVEXATTR(handle->conn, smb_fname->base_name,
+       SMB_VFS_REMOVEXATTR(handle->conn, smb_fname,
                        XATTR_NTACL_NAME);
        unbecome_root();
 
index 91f624ee96b4cf2010d8d437068efa8239ccf53b..fe70d781d0737e28efac9642e80e13aba080a20a 100644 (file)
@@ -711,16 +711,42 @@ static ssize_t cap_listxattr(vfs_handle_struct *handle,
        return ret;
 }
 
-static int cap_removexattr(vfs_handle_struct *handle, const char *path, const char *name)
+static int cap_removexattr(vfs_handle_struct *handle,
+                               const struct smb_filename *smb_fname,
+                               const char *name)
 {
-       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);
+       int ret;
+       int saved_errno = 0;
 
        if (!cappath || !capname) {
                errno = ENOMEM;
                return -1;
        }
-        return SMB_VFS_NEXT_REMOVEXATTR(handle, cappath, capname);
+       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_REMOVEXATTR(handle, cap_smb_fname, capname);
+       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 int cap_fremovexattr(vfs_handle_struct *handle, struct files_struct *fsp, const char *path)
index 844f2418c60158fc0caa3c8a037246fba80b46bc..72dde16b39ecba65303737fcf480077d027e62b6 100644 (file)
@@ -1452,16 +1452,21 @@ catia_listxattr(vfs_handle_struct *handle,
 }
 
 static int
-catia_removexattr(vfs_handle_struct *handle, const char *path,
-                 const char *name)
+catia_removexattr(vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       const char *name)
 {
+       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;
@@ -1475,9 +1480,29 @@ catia_removexattr(vfs_handle_struct *handle, const char *path,
                return -1;
        }
 
-       ret = SMB_VFS_NEXT_REMOVEXATTR(handle, mapped_name, mapped_ea_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_REMOVEXATTR(handle, mapped_smb_fname,
+                               mapped_ea_name);
+       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 874bd40d733c3caf2b0708314b26af88f350f7e8..825df00ddd810b9954ba8aac9f769bc5f2a7b629 100644 (file)
@@ -1296,11 +1296,14 @@ static ssize_t cephwrap_flistxattr(struct vfs_handle_struct *handle, struct file
        }
 }
 
-static int cephwrap_removexattr(struct vfs_handle_struct *handle, const char *path, const char *name)
+static int cephwrap_removexattr(struct vfs_handle_struct *handle,
+                               const struct smb_filename *smb_fname,
+                               const char *name)
 {
        int ret;
-       DBG_DEBUG("[CEPH] removexattr(%p, %s, %s)\n", handle, path, name);
-       ret = ceph_removexattr(handle->data, path, name);
+       DBG_DEBUG("[CEPH] removexattr(%p, %s, %s)\n", handle,
+                       smb_fname->base_name, name);
+       ret = ceph_removexattr(handle->data, smb_fname->base_name, name);
        DBG_DEBUG("[CEPH] removexattr(...) = %d\n", ret);
        WRAP_RETURN(ret);
 }
index dfdcfb4f23dac88be66c1b28db48f62c52507db1..f2ce646e049501b9face52c3dae445f374c39930 100644 (file)
@@ -2770,9 +2770,11 @@ static ssize_t vfswrap_flistxattr(struct vfs_handle_struct *handle, struct files
        return flistxattr(fsp->fh->fd, list, size);
 }
 
-static int vfswrap_removexattr(struct vfs_handle_struct *handle, const char *path, const char *name)
+static int vfswrap_removexattr(struct vfs_handle_struct *handle,
+                               const struct smb_filename *smb_fname,
+                               const char *name)
 {
-       return removexattr(path, name);
+       return removexattr(smb_fname->base_name, name);
 }
 
 static int vfswrap_fremovexattr(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name)
index fc655c874eb404cc63bbcd46d1437e1c19628655..e0e17830ba2c9dcf63b5674bd7f1e334975244a2 100644 (file)
@@ -389,7 +389,7 @@ static int fake_acls_sys_acl_delete_def_file(vfs_handle_struct *handle,
                return -1;
        }
 
-       ret = SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname->base_name, name);
+       ret = SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, name);
        if (ret == -1 && errno == ENOATTR) {
                ret = 0;
                errno = 0;
index 7bc259bf35282c271615ac130ed1a52614ec0b41..b6d4f9bf4514081c0840f78ed5002e1ce4f53e3f 100644 (file)
@@ -3150,7 +3150,7 @@ static int fruit_unlink_meta_netatalk(vfs_handle_struct *handle,
                                      const struct smb_filename *smb_fname)
 {
        return SMB_VFS_REMOVEXATTR(handle->conn,
-                                  smb_fname->base_name,
+                                  smb_fname,
                                   AFPINFO_EA_NETATALK);
 }
 
@@ -3870,7 +3870,7 @@ static ssize_t fruit_pwrite_meta_netatalk(vfs_handle_struct *handle,
 
        if (ai_empty_finderinfo(ai)) {
                ret = SMB_VFS_REMOVEXATTR(handle->conn,
-                                         fsp->fsp_name->base_name,
+                                         fsp->fsp_name,
                                          AFPINFO_EA_NETATALK);
 
                if (ret != 0 && errno != ENOENT && errno != ENOATTR) {
index f50f24d02b1a4519e6b7f2205176e6eec61077f2..905d5730c71e793f6c6f919d4220349185f693bf 100644 (file)
@@ -2313,15 +2313,15 @@ static ssize_t smb_full_audit_flistxattr(struct vfs_handle_struct *handle,
 }
 
 static int smb_full_audit_removexattr(struct vfs_handle_struct *handle,
-                            const char *path,
+                            const struct smb_filename *smb_fname,
                             const char *name)
 {
        int result;
 
-       result = SMB_VFS_NEXT_REMOVEXATTR(handle, path, name);
+       result = SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, name);
 
        do_log(SMB_VFS_OP_REMOVEXATTR, (result >= 0), handle,
-              "%s|%s", path, name);
+              "%s|%s", smb_fname->base_name, name);
 
        return result;
 }
index 30629b8db6c03d76833ed6f337014204b0dadf22..8784232ebd3a2d0951507a9806f7e6a8c76533e7 100644 (file)
@@ -1331,9 +1331,10 @@ static ssize_t vfs_gluster_flistxattr(struct vfs_handle_struct *handle,
 }
 
 static int vfs_gluster_removexattr(struct vfs_handle_struct *handle,
-                                  const char *path, const char *name)
+                               const struct smb_filename *smb_fname,
+                               const char *name)
 {
-       return glfs_removexattr(handle->data, path, name);
+       return glfs_removexattr(handle->data, smb_fname->base_name, name);
 }
 
 static int vfs_gluster_fremovexattr(struct vfs_handle_struct *handle,
index 2113e0310a11d1cf0b5efb7d7f6093fe559049a4..3c330201f06baf7f3dbd1c48ab2b1247368f9922 100644 (file)
@@ -2281,33 +2281,28 @@ out:
  * In this case, "name" is an attr name.
  */
 static int mh_removexattr(struct vfs_handle_struct *handle,
-               const char *path,
+               const struct smb_filename *smb_fname,
                const char *name)
 {
        int status;
-       char *clientPath;
-       TALLOC_CTX *ctx;
+       struct smb_filename *clientFname = NULL;
 
        DEBUG(MH_INFO_DEBUG, ("Entering mh_removexattr\n"));
-       if (!is_in_media_files(path))
-       {
-               status = SMB_VFS_NEXT_REMOVEXATTR(handle, path, name);
+       if (!is_in_media_files(smb_fname->base_name)) {
+               status = SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, name);
                goto out;
        }
 
-       clientPath = NULL;
-       ctx = talloc_tos();
-
-       if ((status = alloc_get_client_path(handle, ctx,
-                               path,
-                               &clientPath)))
-       {
+       status = alloc_get_client_smb_fname(handle,
+                               talloc_tos(),
+                               smb_fname,
+                               &clientFname);
+       if (status != 0) {
                goto err;
        }
-
-       status = SMB_VFS_NEXT_REMOVEXATTR(handle, clientPath, name);
+       status = SMB_VFS_NEXT_REMOVEXATTR(handle, clientFname, name);
 err:
-       TALLOC_FREE(clientPath);
+       TALLOC_FREE(clientFname);
 out:
        return status;
 }
index b5f92dff9c150432935b9b1a6bdfd479ba4dc46a..add044652912ea12df651e1b2ff6db9cc9eded3b 100644 (file)
@@ -221,13 +221,14 @@ static int posix_eadb_removeattr(struct tdb_wrap *db_ctx,
 }
 
 static int posix_eadb_removexattr(struct vfs_handle_struct *handle,
-                                const char *path, const char *name)
+                               const struct smb_filename *smb_fname,
+                               const char *name)
 {
        struct tdb_wrap *db;
 
        SMB_VFS_HANDLE_GET_DATA(handle, db, struct tdb_wrap, return -1);
 
-       return posix_eadb_removeattr(db, path, -1, name);
+       return posix_eadb_removeattr(db, smb_fname->base_name, -1, name);
 }
 
 static int posix_eadb_fremovexattr(struct vfs_handle_struct *handle,
index 74176793a14c1234b1e57bfd4c1234d8cd3d66e3..450080106dabb96eccdb9b5e2e534c6180cf3588 100644 (file)
@@ -2414,30 +2414,45 @@ static ssize_t shadow_copy2_listxattr(struct vfs_handle_struct *handle,
 }
 
 static int shadow_copy2_removexattr(vfs_handle_struct *handle,
-                                   const char *fname, const char *aname)
+                               const struct smb_filename *smb_fname,
+                               const char *aname)
 {
        time_t timestamp = 0;
        char *stripped = NULL;
        int saved_errno = 0;
        int ret;
        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_REMOVEXATTR(handle, fname, aname);
+               return SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, aname);
        }
        conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
        TALLOC_FREE(stripped);
        if (conv == NULL) {
                return -1;
        }
-       ret = SMB_VFS_NEXT_REMOVEXATTR(handle, conv, aname);
+       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_REMOVEXATTR(handle, conv_smb_fname, aname);
        if (ret == -1) {
                saved_errno = errno;
        }
+       TALLOC_FREE(conv_smb_fname);
        TALLOC_FREE(conv);
        if (saved_errno != 0) {
                errno = saved_errno;
index bc98f78189aa16d13c66617be1afedbd8d70d4fc..49e2c61f50ce1e297fdac17f929360f1c54f3fa2 100644 (file)
@@ -2747,29 +2747,50 @@ static ssize_t snapper_gmt_listxattr(struct vfs_handle_struct *handle,
 }
 
 static int snapper_gmt_removexattr(vfs_handle_struct *handle,
-                                  const char *fname, const char *aname)
+                               const struct smb_filename *smb_fname,
+                               const char *aname)
 {
-       time_t timestamp;
-       char *stripped;
-       int ret, saved_errno;
-       char *conv;
+       time_t timestamp = 0;
+       char *stripped = NULL;
+       ssize_t ret;
+       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_REMOVEXATTR(handle, fname, aname);
+               return SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, aname);
        }
        conv = snapper_gmt_convert(talloc_tos(), handle, stripped, timestamp);
        TALLOC_FREE(stripped);
        if (conv == NULL) {
                return -1;
        }
-       ret = SMB_VFS_NEXT_REMOVEXATTR(handle, conv, aname);
-       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_REMOVEXATTR(handle, conv_smb_fname, aname);
+       if (ret == -1) {
+               saved_errno = errno;
+       }
+       TALLOC_FREE(conv_smb_fname);
+       TALLOC_FREE(conv);
+       if (saved_errno != 0) {
+               errno = saved_errno;
+       }
        return ret;
 }
 
index f481f27657f886e48e40bc2bcc0279c903eff526..0f4050efb9e4433f27002b66e8572d26d89f6948 100644 (file)
@@ -588,7 +588,7 @@ static int streams_xattr_unlink(vfs_handle_struct *handle,
                goto fail;
        }
 
-       ret = SMB_VFS_REMOVEXATTR(handle->conn, smb_fname->base_name, xattr_name);
+       ret = SMB_VFS_REMOVEXATTR(handle->conn, smb_fname, xattr_name);
 
        if ((ret == -1) && (errno == ENOATTR)) {
                errno = ENOENT;
@@ -672,7 +672,7 @@ static int streams_xattr_rename(vfs_handle_struct *handle,
        }
 
        /* remove the old stream */
-       oret = SMB_VFS_REMOVEXATTR(handle->conn, smb_fname_src->base_name,
+       oret = SMB_VFS_REMOVEXATTR(handle->conn, smb_fname_src,
                                   src_xattr_name);
        if (oret < 0) {
                if (errno == ENOATTR) {
index e260c4727e3f6d77f9608945e452e135f5010511..273c8ff02eaf2babadcd9d4b692283d7ff0c71a8 100644 (file)
@@ -2404,19 +2404,21 @@ static ssize_t smb_time_audit_flistxattr(struct vfs_handle_struct *handle,
 }
 
 static int smb_time_audit_removexattr(struct vfs_handle_struct *handle,
-                                     const char *path, const char *name)
+                               const struct smb_filename *smb_fname,
+                               const char *name)
 {
        int result;
        struct timespec ts1,ts2;
        double timediff;
 
        clock_gettime_mono(&ts1);
-       result = SMB_VFS_NEXT_REMOVEXATTR(handle, path, name);
+       result = SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, name);
        clock_gettime_mono(&ts2);
        timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
 
        if (timediff > audit_timeout) {
-               smb_time_audit_log_fname("removexattr", timediff, path);
+               smb_time_audit_log_fname("removexattr", timediff,
+                       smb_fname->base_name);
        }
 
        return result;
index 7b60856ae7542a9c5abdb223ebe3dac54c7ee40d..95ecb458af7f04bd3d9382dcead0b7d0afe52c25 100644 (file)
@@ -1781,28 +1781,30 @@ err:
 }
 
 static int um_removexattr(struct vfs_handle_struct *handle,
-                         const char *path,
+                         const struct smb_filename *smb_fname,
                          const char *name)
 {
        int status;
-       char *client_path = NULL;
+       struct smb_filename *client_fname = NULL;
 
        DEBUG(10, ("Entering um_removexattr\n"));
 
-       if (!is_in_media_files(path)) {
-               return SMB_VFS_NEXT_REMOVEXATTR(handle, path, name);
+       if (!is_in_media_files(smb_fname->base_name)) {
+               return SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, name);
        }
 
-       status = alloc_get_client_path(handle, talloc_tos(),
-                                      path, &client_path);
+       status = alloc_get_client_smb_fname(handle,
+                               talloc_tos(),
+                               smb_fname,
+                               &client_fname);
        if (status != 0) {
                goto err;
        }
 
-       status = SMB_VFS_NEXT_REMOVEXATTR(handle, client_path, name);
+       status = SMB_VFS_NEXT_REMOVEXATTR(handle, client_fname, name);
 
 err:
-       TALLOC_FREE(client_path);
+       TALLOC_FREE(client_fname);
        return status;
 }
 
index c678636d14a9760e6d0e07c33634e54064319cb0..e718c24191390520ab82b0b40647e614b2120a13 100644 (file)
@@ -534,7 +534,6 @@ static int vxfs_set_xattr(struct vfs_handle_struct *handle,  const char *path,
        }
 
        is_dir = S_ISDIR(smb_fname->st.st_ex_mode);
-       TALLOC_FREE(smb_fname);
 
        ret = vxfs_setxattr_path(path, name, value, size, flags,
                                  is_dir);
@@ -543,7 +542,8 @@ static int vxfs_set_xattr(struct vfs_handle_struct *handle,  const char *path,
                /*
                 * Now remve old style xattr if it exists
                 */
-               SMB_VFS_NEXT_REMOVEXATTR(handle, path, name);
+               SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, name);
+               TALLOC_FREE(smb_fname);
                /*
                 * Do not bother about return value
                 */
@@ -551,6 +551,8 @@ static int vxfs_set_xattr(struct vfs_handle_struct *handle,  const char *path,
                return ret;
        }
 
+       TALLOC_FREE(smb_fname);
+
        DEBUG(10, ("Fallback to xattr\n"));
        if (strcmp(name, XATTR_NTACL_NAME) == 0) {
                return SMB_VFS_NEXT_SETXATTR(handle, path, XATTR_USER_NTACL,
@@ -651,31 +653,33 @@ static ssize_t vxfs_fget_xattr(struct vfs_handle_struct *handle,
 }
 
 static int vxfs_remove_xattr(struct vfs_handle_struct *handle,
-                            const char *path, const char *name){
-       struct smb_filename *smb_fname;
+                               const struct smb_filename *smb_fname_in,
+                               const char *name)
+{
        bool is_dir = false;
        int ret = 0, ret_new = 0, old_errno;
+       struct smb_filename *smb_fname = NULL;
 
        DEBUG(10, ("In vxfs_remove_xattr\n"));
 
+       smb_fname = cp_smb_filename_nostream(talloc_tos(), smb_fname_in);
+       if (smb_fname == NULL) {
+               errno = ENOMEM;
+               return -1;
+       }
+
        /* Remove with old way */
        if (strcmp(name, XATTR_NTACL_NAME) == 0) {
-               ret = SMB_VFS_NEXT_REMOVEXATTR(handle, path,
+               ret = SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname,
                                               XATTR_USER_NTACL);
        } else {
                if (strcasecmp(name, XATTR_USER_NTACL) != 0) {
-                       ret = SMB_VFS_NEXT_REMOVEXATTR(handle, path,
+                       ret = SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname,
                                                       name);
                }
        }
-       old_errno = errno;
-
        /* Remove with new way */
-       smb_fname = synthetic_smb_fname(talloc_tos(), path, NULL, NULL, 0);
-       if (smb_fname == NULL) {
-               errno = ENOMEM;
-               return -1;
-       }
+       old_errno = errno;
 
        if (SMB_VFS_NEXT_STAT(handle, smb_fname) != 0) {
                TALLOC_FREE(smb_fname);
@@ -687,7 +691,7 @@ static int vxfs_remove_xattr(struct vfs_handle_struct *handle,
        /*
         * If both fail, return failuer else return whichever succeeded
         */
-       ret_new = vxfs_removexattr_path(path, name, is_dir);
+       ret_new = vxfs_removexattr_path(smb_fname_in->base_name, name, is_dir);
        if (errno == ENOTSUP || errno == ENOSYS) {
                errno = old_errno;
        }
index a4f80b20eda01aac5c8c5cc0825dd721fa1c8ea1..1ff80a72b1bb3d385be0354438988df867bd10a7 100644 (file)
@@ -260,7 +260,8 @@ static ssize_t xattr_tdb_flistxattr(struct vfs_handle_struct *handle,
 }
 
 static int xattr_tdb_removexattr(struct vfs_handle_struct *handle,
-                                const char *path, const char *name)
+                               const struct smb_filename *smb_fname,
+                               const char *name)
 {
        struct file_id id;
        struct db_context *db;
@@ -273,7 +274,7 @@ static int xattr_tdb_removexattr(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 ret;
index 8c1190b5d30c3227b97c600a5564cb99d51fe384..561525d669940e17b47afd783c81ad3919ca4929 100644 (file)
@@ -800,7 +800,7 @@ NTSTATUS set_ea(connection_struct *conn, files_struct *fsp,
                                DEBUG(10,("set_ea: deleting ea name %s on file %s.\n",
                                        unix_ea_name, smb_fname->base_name));
                                ret = SMB_VFS_REMOVEXATTR(conn,
-                                               smb_fname->base_name,
+                                               smb_fname,
                                                unix_ea_name);
                        }
 #ifdef ENOATTR
index d27ab397419c5fb730f96c9a3a6aee05f8ede5ef..25cdf68dcdebbe0aeb2011b6f98318c16fb843e9 100644 (file)
@@ -2536,10 +2536,11 @@ ssize_t smb_vfs_call_flistxattr(struct vfs_handle_struct *handle,
 }
 
 int smb_vfs_call_removexattr(struct vfs_handle_struct *handle,
-                            const char *path, const char *name)
+                               const struct smb_filename *smb_fname,
+                               const char *name)
 {
        VFS_FIND(removexattr);
-       return handle->fns->removexattr_fn(handle, path, name);
+       return handle->fns->removexattr_fn(handle, smb_fname, name);
 }
 
 int smb_vfs_call_fremovexattr(struct vfs_handle_struct *handle,
index 7155ac3a170ef58a20399a1e1e9305a3362bd0a6..8bd541318f2f107e6ab4cae7f5253dc9f81a4308 100644 (file)
@@ -1423,13 +1423,24 @@ static NTSTATUS cmd_removexattr(struct vfs_state *vfs, TALLOC_CTX *mem_ctx,
                                int argc, const char **argv)
 {
        ssize_t ret;
+       struct smb_filename *smb_fname = NULL;
 
        if (argc != 3) {
                printf("Usage: removexattr <path> <xattr>\n");
                return NT_STATUS_OK;
        }
 
-       ret = SMB_VFS_REMOVEXATTR(vfs->conn, argv[1], argv[2]);
+       smb_fname = synthetic_smb_fname(talloc_tos(),
+                                       argv[1],
+                                       NULL,
+                                       NULL,
+                                       ssf_flags());
+
+       if (smb_fname == NULL) {
+               return NT_STATUS_NO_MEMORY;
+       }
+
+       ret = SMB_VFS_REMOVEXATTR(vfs->conn, smb_fname, argv[2]);
        if (ret == -1) {
                int err = errno;
                printf("removexattr returned (%s)\n", strerror(err));