The branch, master has been updated
       via  1fcad53 dns_server: Fix a small memleak
       via  9386368 dns_server: Don't call tevent_req_finish twice
       via  7258061 s4:torture:vfs_fruit: add a test for stream names
       via  fe4909f s4:torture:vfs_fruit: pass xattr name as arg to 
torture_setup_local_xattr()
       via  1db1199 vfs_catia: run translation on stream names
       via  fb9a64e vfs_streams_xattr: stream names may contain colons
      from  eba1212 ctdb-tests: Add a policy routing test with misconfiguration

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 1fcad53d7ca1be619bbc9572100b38886114dee7
Author: Volker Lendecke <[email protected]>
Date:   Fri Aug 7 08:29:17 2015 +0200

    dns_server: Fix a small memleak
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>
    
    Autobuild-User(master): Ralph Böhme <[email protected]>
    Autobuild-Date(master): Fri Aug  7 12:57:02 CEST 2015 on sn-devel-104

commit 938636886c0bb2c0cc66976c4c6dc763d589335c
Author: Volker Lendecke <[email protected]>
Date:   Fri Aug 7 07:58:20 2015 +0200

    dns_server: Don't call tevent_req_finish twice
    
    Both tevent_req_werror and tevent_req_done call tevent_req_finish on a 
request.
    This should not be done. We should only call either of both.
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 7258061e5e9cd4b68f1c010c3667c3fd2b0663cc
Author: Ralph Boehme <[email protected]>
Date:   Sun May 10 11:58:32 2015 +0200

    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 <[email protected]>
    Reviewed-by: Stefan Metzmacher <[email protected]>

commit fe4909f1cab72f80715a996a63290462102aabc6
Author: Ralph Boehme <[email protected]>
Date:   Thu Aug 6 13:48:54 2015 +0200

    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 <[email protected]>
    Reviewed-by: Stefan Metzmacher <[email protected]>

commit 1db11998bf1b0eef5f543377700b03ab8739338d
Author: Ralph Boehme <[email protected]>
Date:   Sat May 9 15:12:41 2015 +0200

    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 <[email protected]>
    Reviewed-by: Stefan Metzmacher <[email protected]>

commit fb9a64ea37dd4b0cd754fe6d421417a4c8ccbc57
Author: Ralph Boehme <[email protected]>
Date:   Sat May 9 15:02:03 2015 +0200

    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 <[email protected]>
    Reviewed-by: Stefan Metzmacher <[email protected]>

-----------------------------------------------------------------------

Summary of changes:
 selftest/target/Samba3.pm           |   3 +-
 selftest/target/Samba4.pm           |   3 +-
 source3/modules/vfs_catia.c         |  58 ++++++++++++++-
 source3/modules/vfs_streams_xattr.c |  16 +++-
 source4/dns_server/dns_query.c      |  11 ++-
 source4/torture/vfs/fruit.c         | 143 +++++++++++++++++++++++++++++++++++-
 6 files changed, 223 insertions(+), 11 deletions(-)


Changeset truncated at 500 lines:

diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index 7ceb4fa..4638b16 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -1466,7 +1466,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 8e7ac94..16d4b28 100755
--- a/selftest/target/Samba4.pm
+++ b/selftest/target/Samba4.pm
@@ -1070,7 +1070,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/source3/modules/vfs_catia.c b/source3/modules/vfs_catia.c
index f2769a9..f455afd 100644
--- a/source3/modules/vfs_catia.c
+++ b/source3/modules/vfs_catia.c
@@ -706,11 +706,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);
@@ -720,10 +726,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
diff --git a/source3/modules/vfs_streams_xattr.c 
b/source3/modules/vfs_streams_xattr.c
index d149fc8..92bd1c9 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) {
diff --git a/source4/dns_server/dns_query.c b/source4/dns_server/dns_query.c
index 94f5d49..89cfd64 100644
--- a/source4/dns_server/dns_query.c
+++ b/source4/dns_server/dns_query.c
@@ -354,6 +354,7 @@ static WERROR handle_question(struct dns_server *dns,
                        /* First put in the CNAME record */
                        werror = create_response_rr(question->name, &recs[ri], 
&ans, &ai);
                        if (!W_ERROR_IS_OK(werror)) {
+                               TALLOC_FREE(new_q);
                                return werror;
                        }
 
@@ -673,11 +674,15 @@ struct tevent_req *dns_server_process_query_send(
                err = handle_question(dns, state, &in->questions[0],
                                      &state->answers, &state->ancount,
                                      &state->nsrecs, &state->nscount);
+
+               if (W_ERROR_EQUAL(err, DNS_ERR(NAME_ERROR))) {
+                       err = WERR_OK;
+               }
+
                if (tevent_req_werror(req, err)) {
-                       if (!W_ERROR_EQUAL(err, DNS_ERR(NAME_ERROR))) {
-                               return tevent_req_post(req, ev);
-                       }
+                       return tevent_req_post(req, ev);
                }
+
                tevent_req_done(req);
                return tevent_req_post(req, ev);
        }
diff --git a/source4/torture/vfs/fruit.c b/source4/torture/vfs/fruit.c
index 4de21b2..a74dd7d 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?
@@ -1060,6 +1071,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 +1088,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 +1207,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;
@@ -2163,6 +2176,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
@@ -2183,6 +2323,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;
 }


-- 
Samba Shared Repository

Reply via email to