s3: VFS: Change SMB_VFS_SETXATTR to use const struct smb_filename * instead of const...
authorJeremy Allison <jra@samba.org>
Thu, 25 May 2017 19:41:31 +0000 (12:41 -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>
30 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/trans2.c
source3/smbd/vfs.c
source3/torture/cmd_vfs.c

index ea66742d858ad45362144ba2970bba51e359ce6f..7095dbeaefb1408fead18913fdb3a5adefe3e121 100644 (file)
@@ -845,9 +845,12 @@ static int skel_fremovexattr(vfs_handle_struct *handle,
        return SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
 }
 
-static int skel_setxattr(vfs_handle_struct *handle, const char *path,
-                        const char *name, const void *value, size_t size,
-                        int flags)
+static int skel_setxattr(vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       const char *name,
+                       const void *value,
+                       size_t size,
+                       int flags)
 {
        errno = ENOSYS;
        return -1;
index e72edbc04d8cd2e88eeee039075dfee70f2d8f04..97e61a4bd8469bc619243e525438ecf3034127a2 100644 (file)
@@ -974,11 +974,15 @@ static int skel_fremovexattr(vfs_handle_struct *handle,
        return SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
 }
 
-static int skel_setxattr(vfs_handle_struct *handle, const char *path,
-                        const char *name, const void *value, size_t size,
-                        int flags)
+static int skel_setxattr(vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       const char *name,
+                       const void *value,
+                       size_t size,
+                       int flags)
 {
-       return SMB_VFS_NEXT_SETXATTR(handle, path, name, value, size, flags);
+       return SMB_VFS_NEXT_SETXATTR(handle, smb_fname,
+                       name, value, size, flags);
 }
 
 static int skel_fsetxattr(vfs_handle_struct *handle, struct files_struct *fsp,
index 56c3f5d56b78186a2e44cb55023ccc1bee9df09c..6b1d11f06a5b5ca87c45025774de0476dae7ae22 100644 (file)
                to const struct smb_filename * */
 /* Version 37 - Change removexattr from const char *
                to const struct smb_filename * */
+/* Version 37 - Change setxattr from const char *
+               to const struct smb_filename * */
+
 
 #define SMB_VFS_INTERFACE_VERSION 37
 
@@ -902,7 +905,12 @@ struct vfs_fn_pointers {
                                        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 (*setxattr_fn)(struct vfs_handle_struct *handle,
+                                       const struct smb_filename *smb_fname,
+                                       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);
 
        /* aio operations */
@@ -1376,9 +1384,12 @@ int smb_vfs_call_removexattr(struct vfs_handle_struct *handle,
                                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,
-                         const char *name, const void *value, size_t size,
-                         int flags);
+int smb_vfs_call_setxattr(struct vfs_handle_struct *handle,
+                               const struct smb_filename *smb_fname,
+                               const char *name,
+                               const void *value,
+                               size_t size,
+                               int flags);
 int smb_vfs_call_lsetxattr(struct vfs_handle_struct *handle, const char *path,
                           const char *name, const void *value, size_t size,
                           int flags);
index e1a9ba05024dd078eb260511f8152d28c427cb60..8e3fb32758efc54642c05722062dd8f2fec39927 100644 (file)
 #define SMB_VFS_NEXT_FREMOVEXATTR(handle,fsp,name) \
        smb_vfs_call_fremovexattr((handle)->next,(fsp),(name))
 
-#define SMB_VFS_SETXATTR(conn,path,name,value,size,flags) \
-       smb_vfs_call_setxattr((conn)->vfs_handles,(path),(name),(value),(size),(flags))
-#define SMB_VFS_NEXT_SETXATTR(handle,path,name,value,size,flags) \
-       smb_vfs_call_setxattr((handle)->next,(path),(name),(value),(size),(flags))
+#define SMB_VFS_SETXATTR(conn,smb_fname,name,value,size,flags) \
+       smb_vfs_call_setxattr((conn)->vfs_handles,(smb_fname),(name),(value),(size),(flags))
+#define SMB_VFS_NEXT_SETXATTR(handle,smb_fname,name,value,size,flags) \
+       smb_vfs_call_setxattr((handle)->next,(smb_fname),(name),(value),(size),(flags))
 
 #define SMB_VFS_FSETXATTR(fsp,name,value,size,flags) \
        smb_vfs_call_fsetxattr((fsp)->conn->vfs_handles, (fsp), (name),(value),(size),(flags))
index 59934551e143535a6f023bee14bc0142f70941da..fabe574aadbc3a98775d4685fdf263b3ddcdf8b4 100644 (file)
@@ -474,7 +474,7 @@ int posixacl_xattr_acl_set_file(vfs_handle_struct *handle,
                return -1;
        }
 
-       return SMB_VFS_SETXATTR(handle->conn, smb_fname->base_name,
+       return SMB_VFS_SETXATTR(handle->conn, smb_fname,
                        name, buf, size, 0);
 }
 
index b21207bc205f89e01c9829d47347449613961275..6362ac81d9258efc7d0b02980a0bbdd2546fddf4 100644 (file)
@@ -144,7 +144,7 @@ static NTSTATUS store_acl_blob_fsp(vfs_handle_struct *handle,
                ret = SMB_VFS_FSETXATTR(fsp, XATTR_NTACL_NAME,
                        pblob->data, pblob->length, 0);
        } else {
-               ret = SMB_VFS_SETXATTR(fsp->conn, fsp->fsp_name->base_name,
+               ret = SMB_VFS_SETXATTR(fsp->conn, fsp->fsp_name,
                                XATTR_NTACL_NAME,
                                pblob->data, pblob->length, 0);
        }
index fe70d781d0737e28efac9642e80e13aba080a20a..62d40b5da106d0b2f43afe8129a3cb5577b295ba 100644 (file)
@@ -760,16 +760,46 @@ static int cap_fremovexattr(vfs_handle_struct *handle, struct files_struct *fsp,
         return SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, cappath);
 }
 
-static int cap_setxattr(vfs_handle_struct *handle, const char *path, const char *name, const void *value, size_t size, int flags)
+static int cap_setxattr(vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       const char *name,
+                       const void *value,
+                       size_t size,
+                       int flags)
 {
-       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_SETXATTR(handle, cappath, capname, value, size, flags);
+       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_SETXATTR(handle, cap_smb_fname,
+                               capname, value, size, flags);
+       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_fsetxattr(vfs_handle_struct *handle, struct files_struct *fsp, const char *path, const void *value, size_t size, int flags)
index 72dde16b39ecba65303737fcf480077d027e62b6..cf3e3f3fe525f9a0fe6efb98850005e09e38d356 100644 (file)
@@ -1508,17 +1508,24 @@ catia_removexattr(vfs_handle_struct *handle,
 }
 
 static int
-catia_setxattr(vfs_handle_struct *handle, const char *path,
-              const char *name, const void *value, size_t size,
-              int flags)
+catia_setxattr(vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       const char *name,
+                       const void *value,
+                       size_t size,
+                       int flags)
 {
+       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;
@@ -1532,10 +1539,29 @@ catia_setxattr(vfs_handle_struct *handle, const char *path,
                return -1;
        }
 
-       ret = SMB_VFS_NEXT_SETXATTR(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_SETXATTR(handle, mapped_smb_fname, mapped_ea_name,
                        value, size, flags);
+       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 825df00ddd810b9954ba8aac9f769bc5f2a7b629..06eada97f684d68bd2c850072d2b52a1261c127e 100644 (file)
@@ -1321,11 +1321,18 @@ static int cephwrap_fremovexattr(struct vfs_handle_struct *handle, struct files_
        WRAP_RETURN(ret);
 }
 
-static int cephwrap_setxattr(struct vfs_handle_struct *handle, const char *path, const char *name, const void *value, size_t size, int flags)
+static int cephwrap_setxattr(struct vfs_handle_struct *handle,
+                               const struct smb_filename *smb_fname,
+                               const char *name,
+                               const void *value,
+                               size_t size,
+                               int flags)
 {
        int ret;
-       DBG_DEBUG("[CEPH] setxattr(%p, %s, %s, %p, %llu, %d)\n", handle, path, name, value, llu(size), flags);
-       ret = ceph_setxattr(handle->data, path, name, value, size, flags);
+       DBG_DEBUG("[CEPH] setxattr(%p, %s, %s, %p, %llu, %d)\n", handle,
+                       smb_fname->base_name, name, value, llu(size), flags);
+       ret = ceph_setxattr(handle->data, smb_fname->base_name,
+                       name, value, size, flags);
        DBG_DEBUG("[CEPH] setxattr(...) = %d\n", ret);
        WRAP_RETURN(ret);
 }
index f2ce646e049501b9face52c3dae445f374c39930..eecbcb18ddd32d029e24dae4c4e457fbc86f09a6 100644 (file)
@@ -2782,9 +2782,14 @@ static int vfswrap_fremovexattr(struct vfs_handle_struct *handle, struct files_s
        return fremovexattr(fsp->fh->fd, name);
 }
 
-static int vfswrap_setxattr(struct vfs_handle_struct *handle, const char *path, const char *name, const void *value, size_t size, int flags)
+static int vfswrap_setxattr(struct vfs_handle_struct *handle,
+                               const struct smb_filename *smb_fname,
+                               const char *name,
+                               const void *value,
+                               size_t size,
+                               int flags)
 {
-       return setxattr(path, name, value, size, flags);
+       return setxattr(smb_fname->base_name, name, value, size, flags);
 }
 
 static int vfswrap_fsetxattr(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name, const void *value, size_t size, int flags)
index e0e17830ba2c9dcf63b5674bd7f1e334975244a2..917996af0a43cb2dfc5ebe2458fbc04eb777be77 100644 (file)
@@ -339,7 +339,7 @@ static int fake_acls_sys_acl_set_file(vfs_handle_struct *handle,
                name = FAKE_ACL_DEFAULT_XATTR;
                break;
        }
-       ret = SMB_VFS_NEXT_SETXATTR(handle, smb_fname->base_name,
+       ret = SMB_VFS_NEXT_SETXATTR(handle, smb_fname,
                        name, blob.data, blob.length, 0);
        TALLOC_FREE(frame);
        return ret;
@@ -409,7 +409,7 @@ static int fake_acls_chown(vfs_handle_struct *handle,
        if (uid != -1) {
                SIVAL(id_buf, 0, uid);
                ret = SMB_VFS_NEXT_SETXATTR(handle,
-                               smb_fname->base_name,
+                               smb_fname,
                                FAKE_UID,
                                id_buf,
                                sizeof(id_buf),
@@ -421,7 +421,7 @@ static int fake_acls_chown(vfs_handle_struct *handle,
        if (gid != -1) {
                SIVAL(id_buf, 0, gid);
                ret = SMB_VFS_NEXT_SETXATTR(handle,
-                               smb_fname->base_name,
+                               smb_fname,
                                FAKE_GID,
                                id_buf,
                                sizeof(id_buf),
@@ -451,7 +451,7 @@ static int fake_acls_lchown(vfs_handle_struct *handle,
                 */
                SIVAL(id_buf, 0, uid);
                ret = SMB_VFS_NEXT_SETXATTR(handle,
-                               smb_fname->base_name,
+                               smb_fname,
                                FAKE_UID,
                                id_buf,
                                sizeof(id_buf),
@@ -463,7 +463,7 @@ static int fake_acls_lchown(vfs_handle_struct *handle,
        if (gid != -1) {
                SIVAL(id_buf, 0, gid);
                ret = SMB_VFS_NEXT_SETXATTR(handle,
-                               smb_fname->base_name,
+                               smb_fname,
                                FAKE_GID,
                                id_buf,
                                sizeof(id_buf),
index b6d4f9bf4514081c0840f78ed5002e1ce4f53e3f..11103ccb3655924056ae76e5453805c984cc3c62 100644 (file)
@@ -1419,7 +1419,7 @@ static int ad_set(struct adouble *ad, const struct smb_filename *smb_fname)
        }
 
        ret = SMB_VFS_SETXATTR(ad->ad_handle->conn,
-                              smb_fname->base_name,
+                              smb_fname,
                               AFPINFO_EA_NETATALK,
                               ad->ad_data,
                               AD_DATASZ_XATTR, 0);
index 905d5730c71e793f6c6f919d4220349185f693bf..3054c33cd5f50c7f451338ee9b7e00575f3c88b9 100644 (file)
@@ -2341,17 +2341,17 @@ static int smb_full_audit_fremovexattr(struct vfs_handle_struct *handle,
 }
 
 static int smb_full_audit_setxattr(struct vfs_handle_struct *handle,
-                         const char *path,
+                         const struct smb_filename *smb_fname,
                          const char *name, const void *value, size_t size,
                          int flags)
 {
        int result;
 
-       result = SMB_VFS_NEXT_SETXATTR(handle, path, name, value, size,
+       result = SMB_VFS_NEXT_SETXATTR(handle, smb_fname, name, value, size,
                                       flags);
 
        do_log(SMB_VFS_OP_SETXATTR, (result >= 0), handle,
-              "%s|%s", path, name);
+              "%s|%s", smb_fname->base_name, name);
 
        return result;
 }
index 8784232ebd3a2d0951507a9806f7e6a8c76533e7..e51556f8bf65b490ee1a3aee637059360853b9a6 100644 (file)
@@ -1344,10 +1344,11 @@ static int vfs_gluster_fremovexattr(struct vfs_handle_struct *handle,
 }
 
 static int vfs_gluster_setxattr(struct vfs_handle_struct *handle,
-                               const char *path, const char *name,
+                               const struct smb_filename *smb_fname,
+                               const char *name,
                                const void *value, size_t size, int flags)
 {
-       return glfs_setxattr(handle->data, path, name, value, size, flags);
+       return glfs_setxattr(handle->data, smb_fname->base_name, name, value, size, flags);
 }
 
 static int vfs_gluster_fsetxattr(struct vfs_handle_struct *handle,
index 3c330201f06baf7f3dbd1c48ab2b1247368f9922..dd715d1861ba82b157687d73284d965298446b6a 100644 (file)
@@ -2313,38 +2313,33 @@ out:
  * In this case, "name" is an attr name.
  */
 static int mh_setxattr(struct vfs_handle_struct *handle,
-               const char *path,
+               const struct smb_filename *smb_fname,
                const char *name,
                const void *value,
                size_t size,
                int flags)
 {
        int status;
-       char *clientPath;
-       TALLOC_CTX *ctx;
+       struct smb_filename *clientFname = NULL;
 
        DEBUG(MH_INFO_DEBUG, ("Entering mh_setxattr\n"));
-       if (!is_in_media_files(path))
-       {
-               status = SMB_VFS_NEXT_SETXATTR(handle, path, name, value,
+       if (!is_in_media_files(smb_fname->base_name)) {
+               status = SMB_VFS_NEXT_SETXATTR(handle, smb_fname, name, value,
                                size, flags);
                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_SETXATTR(handle, clientPath, name, value,
+       status = SMB_VFS_NEXT_SETXATTR(handle, clientFname, name, value,
                        size, flags);
 err:
-       TALLOC_FREE(clientPath);
+       TALLOC_FREE(clientFname);
 out:
        return status;
 }
index faf9f9b0597b6c856cb54bb158f12ab99bf6d699..de3e368ca88d8bd40275fbad3a9967c6547662c1 100644 (file)
@@ -251,7 +251,7 @@ static bool nfs4acl_smb4acl2nfs4acl(TALLOC_CTX *mem_ctx,
 }
 
 static bool nfs4acl_xattr_set_smb4acl(vfs_handle_struct *handle,
-                                     const char *path,
+                                     const struct smb_filename *smb_fname,
                                      struct SMB4ACL_T *smbacl)
 {
        TALLOC_CTX *frame = talloc_stackframe();
@@ -278,7 +278,7 @@ static bool nfs4acl_xattr_set_smb4acl(vfs_handle_struct *handle,
                errno = EINVAL;
                return false;
        }
-       ret = SMB_VFS_NEXT_SETXATTR(handle, path, NFS4ACL_XATTR_NAME,
+       ret = SMB_VFS_NEXT_SETXATTR(handle, smb_fname, NFS4ACL_XATTR_NAME,
                                    blob.data, blob.length, 0);
        if (ret != 0) {
                DEBUG(0, ("can't store acl in xattr: %s\n", strerror(errno)));
@@ -509,7 +509,7 @@ static struct SMB4ACL_T *nfs4acls_inheritacl(vfs_handle_struct *handle,
 
        /* store the returned ACL to get it directly in the
           future and avoid dynamic inheritance behavior. */
-       nfs4acl_xattr_set_smb4acl(handle, path, pchildacl);
+       nfs4acl_xattr_set_smb4acl(handle, smb_fname, pchildacl);
 
        TALLOC_FREE(frame);
        return pchildacl;
index add044652912ea12df651e1b2ff6db9cc9eded3b..1ba94dca710f5ebca304b0655266e6d83ea60998 100644 (file)
@@ -124,14 +124,18 @@ static int posix_eadb_setattr(struct tdb_wrap *db_ctx,
 }
 
 static int posix_eadb_setxattr(struct vfs_handle_struct *handle,
-                             const char *path, const char *name,
-                             const void *value, size_t size, int flags)
+                               const struct smb_filename *smb_fname,
+                               const char *name,
+                               const void *value,
+                               size_t size,
+                               int flags)
 {
        struct tdb_wrap *db;
 
        SMB_VFS_HANDLE_GET_DATA(handle, db, struct tdb_wrap, return -1);
 
-       return posix_eadb_setattr(db, path, -1, name, value, size, flags);
+       return posix_eadb_setattr(db, smb_fname->base_name,
+                       -1, name, value, size, flags);
 }
 
 static int posix_eadb_fsetxattr(struct vfs_handle_struct *handle,
index 450080106dabb96eccdb9b5e2e534c6180cf3588..5471ed3d0830368926e4482597b3a050218deeda 100644 (file)
@@ -2461,7 +2461,7 @@ static int shadow_copy2_removexattr(vfs_handle_struct *handle,
 }
 
 static int shadow_copy2_setxattr(struct vfs_handle_struct *handle,
-                                const char *fname,
+                                const struct smb_filename *smb_fname,
                                 const char *aname, const void *value,
                                 size_t size, int flags)
 {
@@ -2470,24 +2470,39 @@ static int shadow_copy2_setxattr(struct vfs_handle_struct *handle,
        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_SETXATTR(handle, fname, aname, value, size,
-                                            flags);
+               return SMB_VFS_NEXT_SETXATTR(handle, smb_fname,
+                                       aname, value, size, flags);
        }
        conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
        TALLOC_FREE(stripped);
        if (conv == NULL) {
                return -1;
        }
-       ret = SMB_VFS_NEXT_SETXATTR(handle, conv, aname, value, size, flags);
+       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_SETXATTR(handle, conv_smb_fname,
+                               aname, value, size, flags);
        if (ret == -1) {
                saved_errno = errno;
        }
+       TALLOC_FREE(conv_smb_fname);
        TALLOC_FREE(conv);
        if (saved_errno != 0) {
                errno = saved_errno;
index 49e2c61f50ce1e297fdac17f929360f1c54f3fa2..1c88a1e49124473851ff47a3fe424fbd15c816d3 100644 (file)
@@ -2795,33 +2795,53 @@ static int snapper_gmt_removexattr(vfs_handle_struct *handle,
 }
 
 static int snapper_gmt_setxattr(struct vfs_handle_struct *handle,
-                               const char *fname,
+                               const struct smb_filename *smb_fname,
                                const char *aname, const void *value,
                                size_t size, int flags)
 {
-       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_SETXATTR(handle, fname, aname, value, size,
-                                            flags);
+               return SMB_VFS_NEXT_SETXATTR(handle, smb_fname,
+                                       aname, value, size, flags);
        }
        conv = snapper_gmt_convert(talloc_tos(), handle, stripped, timestamp);
        TALLOC_FREE(stripped);
        if (conv == NULL) {
                return -1;
        }
-       ret = SMB_VFS_NEXT_SETXATTR(handle, conv, aname, value, size, flags);
-       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_SETXATTR(handle, conv_smb_fname,
+                               aname, value, size, flags);
+       if (ret == -1) {
+               saved_errno = errno;
+       }
+       TALLOC_FREE(conv_smb_fname);
+       TALLOC_FREE(conv);
+       if (saved_errno != 0) {
+               errno = saved_errno;
+       }
        return ret;
 }
 
index 58d3a06c310ecd5fb5ec694fc59d0e1bb85b7a2f..b6e95a2787d5ab49f475b126f0c087f95d849e9d 100644 (file)
@@ -87,14 +87,15 @@ static bool file_is_valid(vfs_handle_struct *handle, const char *path)
        return true;
 }
 
-static bool mark_file_valid(vfs_handle_struct *handle, const char *path)
+static bool mark_file_valid(vfs_handle_struct *handle,
+                               const struct smb_filename *smb_fname)
 {
        char buf = '1';
        int ret;
 
-       DEBUG(10, ("marking file %s as valid\n", path));
+       DEBUG(10, ("marking file %s as valid\n", smb_fname->base_name));
 
-       ret = SMB_VFS_SETXATTR(handle->conn, path, SAMBA_XATTR_MARKER,
+       ret = SMB_VFS_SETXATTR(handle->conn, smb_fname, SAMBA_XATTR_MARKER,
                                    &buf, sizeof(buf), 0);
 
        if (ret == -1) {
@@ -350,7 +351,7 @@ static char *stream_dir(vfs_handle_struct *handle,
                goto fail;
        }
 
-       if (check_valid && !mark_file_valid(handle, smb_fname->base_name)) {
+       if (check_valid && !mark_file_valid(handle, smb_fname)) {
                goto fail;
        }
 
index 0f4050efb9e4433f27002b66e8572d26d89f6948..d69c3f9a3f289869e3fcea920e57f99616ac619c 100644 (file)
@@ -661,7 +661,7 @@ static int streams_xattr_rename(vfs_handle_struct *handle,
        }
 
        /* (over)write the new stream */
-       nret = SMB_VFS_SETXATTR(handle->conn, smb_fname_src->base_name,
+       nret = SMB_VFS_SETXATTR(handle->conn, smb_fname_src,
                                dst_xattr_name, ea.value.data, ea.value.length,
                                0);
        if (nret < 0) {
@@ -992,7 +992,7 @@ static ssize_t streams_xattr_pwrite(vfs_handle_struct *handle,
                                ea.value.data, ea.value.length, 0);
        } else {
                ret = SMB_VFS_SETXATTR(fsp->conn,
-                                      fsp->fsp_name->base_name,
+                                      fsp->fsp_name,
                                sio->xattr_name,
                                ea.value.data, ea.value.length, 0);
        }
@@ -1262,7 +1262,7 @@ static int streams_xattr_ftruncate(struct vfs_handle_struct *handle,
                                ea.value.data, ea.value.length, 0);
        } else {
                ret = SMB_VFS_SETXATTR(fsp->conn,
-                               fsp->fsp_name->base_name,
+                               fsp->fsp_name,
                                sio->xattr_name,
                                ea.value.data, ea.value.length, 0);
        }
index 273c8ff02eaf2babadcd9d4b692283d7ff0c71a8..dd915e512a9be95274b1d7b8dfecc8c3c82e02c2 100644 (file)
@@ -2445,22 +2445,25 @@ static int smb_time_audit_fremovexattr(struct vfs_handle_struct *handle,
 }
 
 static int smb_time_audit_setxattr(struct vfs_handle_struct *handle,
-                                  const char *path, const char *name,
-                                  const void *value, size_t size,
-                                  int flags)
+                               const struct smb_filename *smb_fname,
+                               const char *name,
+                               const void *value,
+                               size_t size,
+                               int flags)
 {
        int result;
        struct timespec ts1,ts2;
        double timediff;
 
        clock_gettime_mono(&ts1);
-       result = SMB_VFS_NEXT_SETXATTR(handle, path, name, value, size,
+       result = SMB_VFS_NEXT_SETXATTR(handle, smb_fname, name, value, size,
                                       flags);
        clock_gettime_mono(&ts2);
        timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
 
        if (timediff > audit_timeout) {
-               smb_time_audit_log_fname("setxattr", timediff, path);
+               smb_time_audit_log_fname("setxattr", timediff,
+                               smb_fname->base_name);
        }
 
        return result;
index 95ecb458af7f04bd3d9382dcead0b7d0afe52c25..3dd8b996cc9e453a3e5617f3f610879c0df64618 100644 (file)
@@ -1809,33 +1809,35 @@ err:
 }
 
 static int um_setxattr(struct vfs_handle_struct *handle,
-                      const char *path,
+                      const struct smb_filename *smb_fname,
                       const char *name,
                       const void *value,
                       size_t size,
                       int flags)
 {
        int status;
-       char *client_path = NULL;
+       struct smb_filename *client_fname = NULL;
 
        DEBUG(10, ("Entering um_setxattr\n"));
 
-       if (!is_in_media_files(path)) {
-               return SMB_VFS_NEXT_SETXATTR(handle, path, name, value,
+       if (!is_in_media_files(smb_fname->base_name)) {
+               return SMB_VFS_NEXT_SETXATTR(handle, smb_fname, name, value,
                                             size, flags);
        }
 
-       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_SETXATTR(handle, client_path, name, value,
+       status = SMB_VFS_NEXT_SETXATTR(handle, client_fname, name, value,
                                       size, flags);
 
 err:
-       TALLOC_FREE(client_path);
+       TALLOC_FREE(client_fname);
        return status;
 }
 
index e718c24191390520ab82b0b40647e614b2120a13..0b5977f7706cec898966f6c79d9ddc18ae97772a 100644 (file)
@@ -513,16 +513,21 @@ static int vxfs_sys_acl_set_file(vfs_handle_struct *handle,
                        acltype, theacl);
 }
 
-static int vxfs_set_xattr(struct vfs_handle_struct *handle,  const char *path,
-                         const char *name, const void *value, size_t size,
-                         int flags){
-       struct smb_filename *smb_fname;
+static int vxfs_set_xattr(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname_in,
+                       const char *name,
+                       const void *value,
+                       size_t size,
+                       int flags)
+{
+       struct smb_filename *smb_fname = NULL;
        bool is_dir = false;
        int ret = 0;
+       int saved_errno = 0;
 
        DEBUG(10, ("In vxfs_set_xattr\n"));
 
-       smb_fname = synthetic_smb_fname(talloc_tos(), path, NULL, NULL, 0);
+       smb_fname = cp_smb_filename_nostream(talloc_tos(), smb_fname_in);
        if (smb_fname == NULL) {
                errno = ENOMEM;
                return -1;
@@ -535,37 +540,55 @@ static int vxfs_set_xattr(struct vfs_handle_struct *handle,  const char *path,
 
        is_dir = S_ISDIR(smb_fname->st.st_ex_mode);
 
-       ret = vxfs_setxattr_path(path, name, value, size, flags,
-                                 is_dir);
+       ret = vxfs_setxattr_path(smb_fname_in->base_name, name, value, size,
+                                flags, is_dir);
        if ((ret == 0) ||
            ((ret == -1) && (errno != ENOTSUP) && (errno != ENOSYS))) {
                /*
                 * Now remve old style xattr if it exists
                 */
                SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, name);
-               TALLOC_FREE(smb_fname);
                /*
                 * Do not bother about return value
                 */
-
-               return ret;
+               if (ret != 0) {
+                       saved_errno = errno;
+               }
+               goto fail;
        }
 
-       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,
-                                            value, size, flags);
+               ret = SMB_VFS_NEXT_SETXATTR(handle, smb_fname,
+                                           XATTR_USER_NTACL,
+                                           value, size, flags);
+               if (ret != 0) {
+                       saved_errno = errno;
+                       goto fail;
+               }
+               return 0;
        }
 
        /* Clients can't set XATTR_USER_NTACL directly. */
        if (strcasecmp(name, XATTR_USER_NTACL) == 0) {
-               errno = EACCES;
-               return -1;
+               saved_errno = EACCES;
+               ret = -1;
+               goto fail;
        }
 
-       return SMB_VFS_NEXT_SETXATTR(handle, path, name, value, size, flags);
+       ret = SMB_VFS_NEXT_SETXATTR(handle, smb_fname,
+                                   name, value, size, flags);
+       if (ret != 0) {
+               saved_errno = errno;
+               goto fail;
+       }
+
+fail:
+       TALLOC_FREE(smb_fname);
+       if (saved_errno != 0) {
+               saved_errno = errno;
+       }
+       return ret;
 }
 
 static int vxfs_fset_xattr(struct vfs_handle_struct *handle,
index 1ff80a72b1bb3d385be0354438988df867bd10a7..d6d480883342e2a458027e7d895626a1d0b0083d 100644 (file)
@@ -148,8 +148,11 @@ static ssize_t xattr_tdb_fgetxattr(struct vfs_handle_struct *handle,
 }
 
 static int xattr_tdb_setxattr(struct vfs_handle_struct *handle,
-                             const char *path, const char *name,
-                             const void *value, size_t size, int flags)
+                               const struct smb_filename *smb_fname,
+                               const char *name,
+                               const void *value,
+                               size_t size,
+                               int flags)
 {
        struct file_id id;
        struct db_context *db;
@@ -162,7 +165,7 @@ static int xattr_tdb_setxattr(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 3c6d47bb6dc820d565372bc2077384f9c9f4df39..de10983ae6a411b47233bcb499e93d8f37fe6454 100644 (file)
@@ -420,7 +420,7 @@ NTSTATUS set_ea_dos_attribute(connection_struct *conn,
                return NT_STATUS_INVALID_PARAMETER;
        }
 
-       if (SMB_VFS_SETXATTR(conn, smb_fname->base_name,
+       if (SMB_VFS_SETXATTR(conn, smb_fname,
                             SAMBA_XATTR_DOS_ATTRIB, blob.data, blob.length,
                             0) == -1) {
                NTSTATUS status = NT_STATUS_OK;
index 2d12f1dfd9f24c7ac601402c6deb438b32d020f2..021e3311395ed9189a512be32ffe72a3fc44de56 100644 (file)
@@ -275,7 +275,7 @@ static void store_inheritance_attributes(files_struct *fsp,
                ret = SMB_VFS_FSETXATTR(fsp, SAMBA_POSIX_INHERITANCE_EA_NAME,
                                pai_buf, store_size, 0);
        } else {
-               ret = SMB_VFS_SETXATTR(fsp->conn, fsp->fsp_name->base_name,
+               ret = SMB_VFS_SETXATTR(fsp->conn, fsp->fsp_name,
                                       SAMBA_POSIX_INHERITANCE_EA_NAME,
                                       pai_buf, store_size, 0);
        }
index 561525d669940e17b47afd783c81ad3919ca4929..4df4d4e0f43892c89e5dac9733e92ca5563dc90b 100644 (file)
@@ -822,7 +822,7 @@ NTSTATUS set_ea(connection_struct *conn, files_struct *fsp,
                                DEBUG(10,("set_ea: setting ea name %s on file %s.\n",
                                        unix_ea_name, smb_fname->base_name));
                                ret = SMB_VFS_SETXATTR(conn,
-                                               smb_fname->base_name,
+                                               smb_fname,
                                                unix_ea_name,
                                                ea_list->ea.value.data,
                                                ea_list->ea.value.length,
index 25cdf68dcdebbe0aeb2011b6f98318c16fb843e9..d640126e243f1c4dda697824c538b6b45e0cae59 100644 (file)
@@ -2550,12 +2550,16 @@ int smb_vfs_call_fremovexattr(struct vfs_handle_struct *handle,
        return handle->fns->fremovexattr_fn(handle, fsp, name);
 }
 
-int smb_vfs_call_setxattr(struct vfs_handle_struct *handle, const char *path,
-                         const char *name, const void *value, size_t size,
-                         int flags)
+int smb_vfs_call_setxattr(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       const char *name,
+                       const void *value,
+                       size_t size,
+                       int flags)
 {
        VFS_FIND(setxattr);
-       return handle->fns->setxattr_fn(handle, path, name, value, size, flags);
+       return handle->fns->setxattr_fn(handle, smb_fname,
+                       name, value, size, flags);
 }
 
 int smb_vfs_call_fsetxattr(struct vfs_handle_struct *handle,
index 8bd541318f2f107e6ab4cae7f5253dc9f81a4308..038317ebffc7f465edb40c7aaacff2d94e167d80 100644 (file)
@@ -1399,6 +1399,7 @@ static NTSTATUS cmd_setxattr(struct vfs_state *vfs, TALLOC_CTX *mem_ctx,
 {
        ssize_t ret;
        int flags = 0;
+       struct smb_filename *smb_fname = NULL;
 
        if ((argc < 4) || (argc > 5)) {
                printf("Usage: setxattr <path> <xattr> <value> [flags]\n");
@@ -1409,7 +1410,13 @@ static NTSTATUS cmd_setxattr(struct vfs_state *vfs, TALLOC_CTX *mem_ctx,
                flags = atoi(argv[4]);
        }
 
-       ret = SMB_VFS_SETXATTR(vfs->conn, argv[1], argv[2],
+       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_SETXATTR(vfs->conn, smb_fname, argv[2],
                               argv[3], strlen(argv[3]), flags);
        if (ret == -1) {
                int err = errno;