From: Jeremy Allison Date: Thu, 25 May 2017 19:41:31 +0000 (-0700) Subject: s3: VFS: Change SMB_VFS_SETXATTR to use const struct smb_filename * instead of const... X-Git-Tag: ldb-1.1.31~176 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=48956fa4d3b37105ad3e8e742c21b5583d79db11;p=thirdparty%2Fsamba.git s3: VFS: Change SMB_VFS_SETXATTR to use const struct smb_filename * instead of const char *. 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 Reviewed-by: Ralph Boehme --- diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c index ea66742d858..7095dbeaefb 100644 --- a/examples/VFS/skel_opaque.c +++ b/examples/VFS/skel_opaque.c @@ -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; diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c index e72edbc04d8..97e61a4bd84 100644 --- a/examples/VFS/skel_transparent.c +++ b/examples/VFS/skel_transparent.c @@ -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, diff --git a/source3/include/vfs.h b/source3/include/vfs.h index 56c3f5d56b7..6b1d11f06a5 100644 --- a/source3/include/vfs.h +++ b/source3/include/vfs.h @@ -209,6 +209,9 @@ 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); diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h index e1a9ba05024..8e3fb32758e 100644 --- a/source3/include/vfs_macros.h +++ b/source3/include/vfs_macros.h @@ -545,10 +545,10 @@ #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)) diff --git a/source3/modules/posixacl_xattr.c b/source3/modules/posixacl_xattr.c index 59934551e14..fabe574aadb 100644 --- a/source3/modules/posixacl_xattr.c +++ b/source3/modules/posixacl_xattr.c @@ -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); } diff --git a/source3/modules/vfs_acl_xattr.c b/source3/modules/vfs_acl_xattr.c index b21207bc205..6362ac81d92 100644 --- a/source3/modules/vfs_acl_xattr.c +++ b/source3/modules/vfs_acl_xattr.c @@ -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); } diff --git a/source3/modules/vfs_cap.c b/source3/modules/vfs_cap.c index fe70d781d07..62d40b5da10 100644 --- a/source3/modules/vfs_cap.c +++ b/source3/modules/vfs_cap.c @@ -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) diff --git a/source3/modules/vfs_catia.c b/source3/modules/vfs_catia.c index 72dde16b39e..cf3e3f3fe52 100644 --- a/source3/modules/vfs_catia.c +++ b/source3/modules/vfs_catia.c @@ -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; } diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c index 825df00ddd8..06eada97f68 100644 --- a/source3/modules/vfs_ceph.c +++ b/source3/modules/vfs_ceph.c @@ -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); } diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index f2ce646e049..eecbcb18ddd 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -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) diff --git a/source3/modules/vfs_fake_acls.c b/source3/modules/vfs_fake_acls.c index e0e17830ba2..917996af0a4 100644 --- a/source3/modules/vfs_fake_acls.c +++ b/source3/modules/vfs_fake_acls.c @@ -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), diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index b6d4f9bf451..11103ccb365 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -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); diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index 905d5730c71..3054c33cd5f 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -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; } diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c index 8784232ebd3..e51556f8bf6 100644 --- a/source3/modules/vfs_glusterfs.c +++ b/source3/modules/vfs_glusterfs.c @@ -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, diff --git a/source3/modules/vfs_media_harmony.c b/source3/modules/vfs_media_harmony.c index 3c330201f06..dd715d1861b 100644 --- a/source3/modules/vfs_media_harmony.c +++ b/source3/modules/vfs_media_harmony.c @@ -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; } diff --git a/source3/modules/vfs_nfs4acl_xattr.c b/source3/modules/vfs_nfs4acl_xattr.c index faf9f9b0597..de3e368ca88 100644 --- a/source3/modules/vfs_nfs4acl_xattr.c +++ b/source3/modules/vfs_nfs4acl_xattr.c @@ -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; diff --git a/source3/modules/vfs_posix_eadb.c b/source3/modules/vfs_posix_eadb.c index add04465291..1ba94dca710 100644 --- a/source3/modules/vfs_posix_eadb.c +++ b/source3/modules/vfs_posix_eadb.c @@ -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, diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c index 450080106da..5471ed3d083 100644 --- a/source3/modules/vfs_shadow_copy2.c +++ b/source3/modules/vfs_shadow_copy2.c @@ -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, - ×tamp, &stripped)) { + if (!shadow_copy2_strip_snapshot(talloc_tos(), + handle, + smb_fname->base_name, + ×tamp, + &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; diff --git a/source3/modules/vfs_snapper.c b/source3/modules/vfs_snapper.c index 49e2c61f50c..1c88a1e4912 100644 --- a/source3/modules/vfs_snapper.c +++ b/source3/modules/vfs_snapper.c @@ -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, - ×tamp, &stripped)) { + if (!snapper_gmt_strip_snapshot(talloc_tos(), + handle, + smb_fname->base_name, + ×tamp, + &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; } diff --git a/source3/modules/vfs_streams_depot.c b/source3/modules/vfs_streams_depot.c index 58d3a06c310..b6e95a2787d 100644 --- a/source3/modules/vfs_streams_depot.c +++ b/source3/modules/vfs_streams_depot.c @@ -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; } diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c index 0f4050efb9e..d69c3f9a3f2 100644 --- a/source3/modules/vfs_streams_xattr.c +++ b/source3/modules/vfs_streams_xattr.c @@ -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); } diff --git a/source3/modules/vfs_time_audit.c b/source3/modules/vfs_time_audit.c index 273c8ff02ea..dd915e512a9 100644 --- a/source3/modules/vfs_time_audit.c +++ b/source3/modules/vfs_time_audit.c @@ -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; diff --git a/source3/modules/vfs_unityed_media.c b/source3/modules/vfs_unityed_media.c index 95ecb458af7..3dd8b996cc9 100644 --- a/source3/modules/vfs_unityed_media.c +++ b/source3/modules/vfs_unityed_media.c @@ -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; } diff --git a/source3/modules/vfs_vxfs.c b/source3/modules/vfs_vxfs.c index e718c241913..0b5977f7706 100644 --- a/source3/modules/vfs_vxfs.c +++ b/source3/modules/vfs_vxfs.c @@ -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, diff --git a/source3/modules/vfs_xattr_tdb.c b/source3/modules/vfs_xattr_tdb.c index 1ff80a72b1b..d6d48088334 100644 --- a/source3/modules/vfs_xattr_tdb.c +++ b/source3/modules/vfs_xattr_tdb.c @@ -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; diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c index 3c6d47bb6dc..de10983ae6a 100644 --- a/source3/smbd/dosmode.c +++ b/source3/smbd/dosmode.c @@ -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; diff --git a/source3/smbd/posix_acls.c b/source3/smbd/posix_acls.c index 2d12f1dfd9f..021e3311395 100644 --- a/source3/smbd/posix_acls.c +++ b/source3/smbd/posix_acls.c @@ -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); } diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 561525d6699..4df4d4e0f43 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -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, diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index 25cdf68dcde..d640126e243 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -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, diff --git a/source3/torture/cmd_vfs.c b/source3/torture/cmd_vfs.c index 8bd541318f2..038317ebffc 100644 --- a/source3/torture/cmd_vfs.c +++ b/source3/torture/cmd_vfs.c @@ -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 [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;