The Samba-Bugzilla – Attachment 11326 Details for
Bug 11278
Stream names with colon don't work with fruit:encoding = native
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for 4.2 cherry-picked from master
v42-stream-names.patch (text/plain), 13.12 KB, created by
Ralph Böhme
on 2015-08-10 16:36:47 UTC
(
hide
)
Description:
Patch for 4.2 cherry-picked from master
Filename:
MIME Type:
Creator:
Ralph Böhme
Created:
2015-08-10 16:36:47 UTC
Size:
13.12 KB
patch
obsolete
>From eba4f2feab49b1f3e86829fbba1ca235109494b4 Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Sat, 9 May 2015 15:02:03 +0200 >Subject: [PATCH 1/4] vfs_streams_xattr: stream names may contain colons > >With vfs_fruit option "fruit:encoding = native" we're already converting >stream names that contain illegal NTFS characters from their on-the-wire >Unicode Private Range encoding to their native ASCII representation. > >As as result the name of xattrs storing the streams (via >vfs_streams_xattr) may contain a colon, so we have to use strrchr_m() >instead of strchr_m() for matching the stream type suffix. > >Bug: https://bugzilla.samba.org/show_bug.cgi?id=11278 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Stefan Metzmacher <metze@samba.org> >(cherry picked from commit fb9a64ea37dd4b0cd754fe6d421417a4c8ccbc57) >--- > source3/modules/vfs_streams_xattr.c | 16 +++++++++++++++- > 1 file changed, 15 insertions(+), 1 deletion(-) > >diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c >index b3c1df1..5277741 100644 >--- a/source3/modules/vfs_streams_xattr.c >+++ b/source3/modules/vfs_streams_xattr.c >@@ -112,7 +112,21 @@ static NTSTATUS streams_xattr_get_name(vfs_handle_struct *handle, > SMB_VFS_HANDLE_GET_DATA(handle, config, struct streams_xattr_config, > return NT_STATUS_UNSUCCESSFUL); > >- stype = strchr_m(stream_name + 1, ':'); >+ /* >+ * With vfs_fruit option "fruit:encoding = native" we're >+ * already converting stream names that contain illegal NTFS >+ * characters from their on-the-wire Unicode Private Range >+ * encoding to their native ASCII representation. >+ * >+ * As as result the name of xattrs storing the streams (via >+ * vfs_streams_xattr) may contain a colon, so we have to use >+ * strrchr_m() instead of strchr_m() for matching the stream >+ * type suffix. >+ * >+ * In check_path_syntax() we've already ensured the streamname >+ * we got from the client is valid. >+ */ >+ stype = strrchr_m(stream_name + 1, ':'); > > if (stype) { > if (strcasecmp_m(stype, ":$DATA") != 0) { >-- >2.1.0 > > >From 2bbb6e833afa653ceaa6c76cb22ca31a5832b199 Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Sat, 9 May 2015 15:12:41 +0200 >Subject: [PATCH 2/4] vfs_catia: run translation on stream names > >With vfs_fruit option "fruit:encoding = native" we're already converting >stream names that contain illegal NTFS characters from their on-the-wire >Unicode Private Range encoding to their native ASCII representation. > >Unfortunately the reverse mapping for stream names was not perfomed. > >Bug: https://bugzilla.samba.org/show_bug.cgi?id=11278 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Stefan Metzmacher <metze@samba.org> >(cherry picked from commit 1db11998bf1b0eef5f543377700b03ab8739338d) >--- > source3/modules/vfs_catia.c | 58 +++++++++++++++++++++++++++++++++++++++++---- > 1 file changed, 54 insertions(+), 4 deletions(-) > >diff --git a/source3/modules/vfs_catia.c b/source3/modules/vfs_catia.c >index 6743dfe..ff11a9a 100644 >--- a/source3/modules/vfs_catia.c >+++ b/source3/modules/vfs_catia.c >@@ -705,11 +705,17 @@ catia_streaminfo(struct vfs_handle_struct *handle, > struct files_struct *fsp, > const char *path, > TALLOC_CTX *mem_ctx, >- unsigned int *num_streams, >- struct stream_struct **streams) >+ unsigned int *_num_streams, >+ struct stream_struct **_streams) > { > char *mapped_name = NULL; > NTSTATUS status; >+ int i; >+ unsigned int num_streams = 0; >+ struct stream_struct *streams = NULL; >+ >+ *_num_streams = 0; >+ *_streams = NULL; > > status = catia_string_replace_allocate(handle->conn, path, > &mapped_name, vfs_translate_to_unix); >@@ -719,10 +725,54 @@ catia_streaminfo(struct vfs_handle_struct *handle, > } > > status = SMB_VFS_NEXT_STREAMINFO(handle, fsp, mapped_name, >- mem_ctx, num_streams,streams); >+ mem_ctx, &num_streams, &streams); > TALLOC_FREE(mapped_name); >+ if (!NT_STATUS_IS_OK(status)) { >+ return status; >+ } > >- return status; >+ /* >+ * Translate stream names just like the base names >+ */ >+ for (i = 0; i < num_streams; i++) { >+ /* >+ * Strip ":" prefix and ":$DATA" suffix to get a >+ * "pure" stream name and only translate that. >+ */ >+ void *old_ptr = streams[i].name; >+ char *stream_name = streams[i].name + 1; >+ char *stream_type = strrchr_m(stream_name, ':'); >+ >+ if (stream_type != NULL) { >+ *stream_type = '\0'; >+ stream_type += 1; >+ } >+ >+ status = catia_string_replace_allocate(handle->conn, stream_name, >+ &mapped_name, vfs_translate_to_windows); >+ if (!NT_STATUS_IS_OK(status)) { >+ TALLOC_FREE(streams); >+ return status; >+ } >+ >+ if (stream_type != NULL) { >+ streams[i].name = talloc_asprintf(streams, ":%s:%s", >+ mapped_name, stream_type); >+ } else { >+ streams[i].name = talloc_asprintf(streams, ":%s", >+ mapped_name); >+ } >+ TALLOC_FREE(mapped_name); >+ TALLOC_FREE(old_ptr); >+ if (streams[i].name == NULL) { >+ TALLOC_FREE(streams); >+ return NT_STATUS_NO_MEMORY; >+ } >+ } >+ >+ *_num_streams = num_streams; >+ *_streams = streams; >+ return NT_STATUS_OK; > } > > static NTSTATUS >-- >2.1.0 > > >From e2eb4dd5285b1868b3fe6a6c7d75116eb55ed0c4 Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Thu, 6 Aug 2015 13:48:54 +0200 >Subject: [PATCH 3/4] s4:torture:vfs_fruit: pass xattr name as arg to > torture_setup_local_xattr() > >Bug: https://bugzilla.samba.org/show_bug.cgi?id=11278 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Stefan Metzmacher <metze@samba.org> >(cherry picked from commit fe4909f1cab72f80715a996a63290462102aabc6) >--- > source4/torture/vfs/fruit.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > >diff --git a/source4/torture/vfs/fruit.c b/source4/torture/vfs/fruit.c >index 700eeb5..a589544 100644 >--- a/source4/torture/vfs/fruit.c >+++ b/source4/torture/vfs/fruit.c >@@ -1060,6 +1060,7 @@ static bool write_stream(struct smb2_tree *tree, > static bool torture_setup_local_xattr(struct torture_context *tctx, > const char *path_option, > const char *name, >+ const char *xattr, > const char *metadata, > size_t size) > { >@@ -1076,7 +1077,7 @@ static bool torture_setup_local_xattr(struct torture_context *tctx, > > path = talloc_asprintf(tctx, "%s/%s", spath, name); > >- result = setxattr(path, AFPINFO_EA_NETATALK, metadata, size, 0); >+ result = setxattr(path, xattr, metadata, size, 0); > if (result != 0) { > ret = false; > } >@@ -1195,6 +1196,7 @@ static bool test_read_atalk_metadata(struct torture_context *tctx, > > ret = torture_setup_local_xattr(tctx, "localdir", > BASEDIR "/torture_read_metadata", >+ AFPINFO_EA_NETATALK, > metadata_xattr, sizeof(metadata_xattr)); > if (ret == false) { > goto done; >-- >2.1.0 > > >From 14d59386b23f4eb4b31d8615f16c765e2ebfd204 Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Sun, 10 May 2015 11:58:32 +0200 >Subject: [PATCH 4/4] s4:torture:vfs_fruit: add a test for stream names > >Bug: https://bugzilla.samba.org/show_bug.cgi?id=11278 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Stefan Metzmacher <metze@samba.org> >(cherry picked from commit 7258061e5e9cd4b68f1c010c3667c3fd2b0663cc) >--- > selftest/target/Samba3.pm | 3 +- > selftest/target/Samba4.pm | 3 +- > source4/torture/vfs/fruit.c | 139 ++++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 143 insertions(+), 2 deletions(-) > >diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm >index 98b4d00..c95631f 100755 >--- a/selftest/target/Samba3.pm >+++ b/selftest/target/Samba3.pm >@@ -1234,7 +1234,8 @@ sub provision($$$$$$) > > [vfs_fruit] > path = $shrdir >- vfs objects = catia fruit streams_xattr >+ vfs objects = catia fruit streams_xattr acl_xattr >+ ea support = yes > fruit:ressource = file > fruit:metadata = netatalk > fruit:locking = netatalk >diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm >index eddd64d..83b4e74 100755 >--- a/selftest/target/Samba4.pm >+++ b/selftest/target/Samba4.pm >@@ -887,7 +887,8 @@ sub provision($$$$$$$$$) > > [vfs_fruit] > path = $ctx->{share} >- vfs objects = catia fruit streams_xattr >+ vfs objects = catia fruit streams_xattr acl_xattr >+ ea support = yes > fruit:ressource = file > fruit:metadata = netatalk > fruit:locking = netatalk >diff --git a/source4/torture/vfs/fruit.c b/source4/torture/vfs/fruit.c >index a589544..34b5342 100644 >--- a/source4/torture/vfs/fruit.c >+++ b/source4/torture/vfs/fruit.c >@@ -29,6 +29,7 @@ > #include "param/param.h" > #include "libcli/resolve/resolve.h" > #include "MacExtensions.h" >+#include "lib/util/tsort.h" > > #include "torture/torture.h" > #include "torture/util.h" >@@ -58,6 +59,16 @@ > goto done; \ > }} while (0) > >+static int qsort_string(char * const *s1, char * const *s2) >+{ >+ return strcmp(*s1, *s2); >+} >+ >+static int qsort_stream(const struct stream_struct * s1, const struct stream_struct *s2) >+{ >+ return strcmp(s1->stream_name.s, s2->stream_name.s); >+} >+ > /* > * REVIEW: > * This is hokey, but what else can we do? >@@ -2171,6 +2182,133 @@ done: > return true; > } > >+static bool check_stream_list(struct smb2_tree *tree, >+ struct torture_context *tctx, >+ const char *fname, >+ int num_exp, >+ const char **exp, >+ struct smb2_handle h) >+{ >+ union smb_fileinfo finfo; >+ NTSTATUS status; >+ int i; >+ TALLOC_CTX *tmp_ctx = talloc_new(tctx); >+ char **exp_sort; >+ struct stream_struct *stream_sort; >+ >+ finfo.generic.level = RAW_FILEINFO_STREAM_INFORMATION; >+ finfo.generic.in.file.handle = h; >+ >+ status = smb2_getinfo_file(tree, tctx, &finfo); >+ torture_assert_ntstatus_ok(tctx, status, "get stream info"); >+ >+ torture_assert_int_equal(tctx, finfo.stream_info.out.num_streams, num_exp, >+ "stream count"); >+ >+ if (num_exp == 0) { >+ TALLOC_FREE(tmp_ctx); >+ return true; >+ } >+ >+ exp_sort = talloc_memdup(tmp_ctx, exp, num_exp * sizeof(*exp)); >+ torture_assert(tctx, exp_sort != NULL, __location__); >+ >+ TYPESAFE_QSORT(exp_sort, num_exp, qsort_string); >+ >+ stream_sort = talloc_memdup(tmp_ctx, finfo.stream_info.out.streams, >+ finfo.stream_info.out.num_streams * >+ sizeof(*stream_sort)); >+ torture_assert(tctx, stream_sort != NULL, __location__); >+ >+ TYPESAFE_QSORT(stream_sort, finfo.stream_info.out.num_streams, qsort_stream); >+ >+ for (i=0; i<num_exp; i++) { >+ torture_comment(tctx, "i[%d] exp[%s] got[%s]\n", >+ i, exp_sort[i], stream_sort[i].stream_name.s); >+ torture_assert_str_equal(tctx, stream_sort[i].stream_name.s, exp_sort[i], >+ "stream name"); >+ } >+ >+ TALLOC_FREE(tmp_ctx); >+ return true; >+} >+ >+/* >+ test stream names >+*/ >+static bool test_stream_names(struct torture_context *tctx, >+ struct smb2_tree *tree, >+ struct smb2_tree *tree2) >+{ >+ TALLOC_CTX *mem_ctx = talloc_new(tctx); >+ NTSTATUS status; >+ struct smb2_create create; >+ struct smb2_handle h; >+ const char *fname = BASEDIR "\\stream_names.txt"; >+ const char *sname1; >+ bool ret; >+ /* UTF8 private use are starts at 0xef 0x80 0x80 (0xf000) */ >+ const char *streams[] = { >+ ":foo" "\xef\x80\xa2" "bar:$DATA", /* "foo:bar:$DATA" */ >+ ":bar" "\xef\x80\xa2" "baz:$DATA", /* "bar:baz:$DATA" */ >+ "::$DATA" >+ }; >+ >+ sname1 = talloc_asprintf(mem_ctx, "%s%s", fname, streams[0]); >+ >+ /* clean slate ...*/ >+ smb2_util_unlink(tree, fname); >+ smb2_deltree(tree, fname); >+ smb2_deltree(tree, BASEDIR); >+ >+ status = torture_smb2_testdir(tree, BASEDIR, &h); >+ CHECK_STATUS(status, NT_STATUS_OK); >+ smb2_util_close(tree, h); >+ >+ torture_comment(tctx, "(%s) testing stream names\n", __location__); >+ ZERO_STRUCT(create); >+ create.in.desired_access = SEC_FILE_WRITE_DATA; >+ create.in.file_attributes = FILE_ATTRIBUTE_NORMAL; >+ create.in.share_access = >+ NTCREATEX_SHARE_ACCESS_DELETE| >+ NTCREATEX_SHARE_ACCESS_READ| >+ NTCREATEX_SHARE_ACCESS_WRITE; >+ create.in.create_disposition = NTCREATEX_DISP_CREATE; >+ create.in.impersonation_level = SMB2_IMPERSONATION_ANONYMOUS; >+ create.in.fname = sname1; >+ >+ status = smb2_create(tree, mem_ctx, &create); >+ CHECK_STATUS(status, NT_STATUS_OK); >+ smb2_util_close(tree, create.out.file.handle); >+ >+ ret = torture_setup_local_xattr(tctx, "localdir", BASEDIR "/stream_names.txt", >+ "user.DosStream.bar:baz:$DATA", >+ "data", strlen("data")); >+ CHECK_VALUE(ret, true); >+ >+ ZERO_STRUCT(create); >+ create.in.fname = fname; >+ create.in.create_disposition = NTCREATEX_DISP_OPEN; >+ create.in.desired_access = SEC_RIGHTS_FILE_ALL; >+ create.in.file_attributes = FILE_ATTRIBUTE_NORMAL; >+ create.in.impersonation_level = SMB2_IMPERSONATION_ANONYMOUS; >+ status = smb2_create(tree, mem_ctx, &create); >+ CHECK_STATUS(status, NT_STATUS_OK); >+ >+ ret = check_stream_list(tree, tctx, fname, 3, streams, >+ create.out.file.handle); >+ CHECK_VALUE(ret, true); >+ >+ smb2_util_close(tree, create.out.file.handle); >+ >+done: >+ status = smb2_util_unlink(tree, fname); >+ smb2_deltree(tree, BASEDIR); >+ talloc_free(mem_ctx); >+ >+ return ret; >+} >+ > /* > * Note: This test depends on "vfs objects = catia fruit > * streams_xattr". Note: To run this test, use >@@ -2191,6 +2329,7 @@ struct torture_suite *torture_vfs_fruit(void) > torture_suite_add_2ns_smb2_test(suite, "resource fork IO", test_write_atalk_rfork_io); > torture_suite_add_2ns_smb2_test(suite, "OS X AppleDouble file conversion", test_adouble_conversion); > torture_suite_add_2ns_smb2_test(suite, "SMB2/CREATE context AAPL", test_aapl); >+ torture_suite_add_2ns_smb2_test(suite, "stream names", test_stream_names); > > return suite; > } >-- >2.1.0 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
metze
:
review+
Actions:
View
Attachments on
bug 11278
:
11305
|
11316
|
11325
| 11326