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 ea66742..7095dbe 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 e72edbc..97e61a4 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 56c3f5d..6b1d11f 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 e1a9ba0..8e3fb32 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 5993455..fabe574 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 b21207b..6362ac8 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 fe70d78..62d40b5 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 72dde16..cf3e3f3 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 825df00..06eada9 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 f2ce646..eecbcb1 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 e0e1783..917996a 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 b6d4f9b..11103cc 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 905d573..3054c33 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 8784232..e51556f 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 3c33020..dd715d1 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 faf9f9b..de3e368 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 add0446..1ba94dc 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 4500801..5471ed3 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 49e2c61..1c88a1e 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 58d3a06..b6e95a2 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 0f4050e..d69c3f9 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 273c8ff..dd915e5 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 95ecb45..3dd8b99 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 e718c24..0b5977f 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 1ff80a7..d6d4808 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 3c6d47b..de10983 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 2d12f1d..021e331 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 561525d..4df4d4e 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 25cdf68..d640126 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 8bd5413..038317e 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;