The branch, master has been updated
       via  906e3f1 torture: complete dfs referral tests
       via  8a0095b dfs: Fix wrong size of referral, change order of dc referral
       via  52d32e0 idl: dfsblobs fix glitches in the implementation
       via  83f3f5e ndr: Handle the case of string array with all null 
terminated strings
      from  7c5d7a5 waf: workaround for the 'make install' breakage

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


- Log -----------------------------------------------------------------
commit 906e3f12973a26e387116508ea745dc554221764
Author: Matthieu Patou <[email protected]>
Date:   Sat Sep 4 12:04:18 2010 +0400

    torture: complete dfs referral tests
    
    Autobuild-User: Matthieu Patou <[email protected]>
    Autobuild-Date: Tue Oct  5 08:01:39 UTC 2010 on sn-devel-104

commit 8a0095b930f7ad2a4451f56f204fb0bd73bce66b
Author: Matthieu Patou <[email protected]>
Date:   Sat Sep 4 01:03:53 2010 +0400

    dfs: Fix wrong size of referral, change order of dc referral
    
    Order of referral is now like w2k8/w2k8r2 as it seems it has an
    influence on how clients manage to get it.

commit 52d32e08a4227909662a50a989633e9acd4bbb2f
Author: Matthieu Patou <[email protected]>
Date:   Sat Sep 4 00:39:16 2010 +0400

    idl: dfsblobs fix glitches in the implementation

commit 83f3f5e15aa9928f998c3afe03e71a53ad8e8d6a
Author: Matthieu Patou <[email protected]>
Date:   Sat Sep 4 20:08:05 2010 +0400

    ndr: Handle the case of string array with all null terminated strings

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

Summary of changes:
 librpc/idl/dfsblobs.idl         |    4 +-
 librpc/ndr/ndr_string.c         |   20 +++++++++++---
 source4/smb_server/smb/trans2.c |   17 ++++++++---
 source4/torture/dfs/domaindfs.c |   15 +++++++++++
 source4/torture/ndr/dfsblob.c   |   54 +++++++++++++++++++++++++++++++-------
 5 files changed, 89 insertions(+), 21 deletions(-)


Changeset truncated at 500 lines:

diff --git a/librpc/idl/dfsblobs.idl b/librpc/idl/dfsblobs.idl
index 88147b6..6151c3f 100644
--- a/librpc/idl/dfsblobs.idl
+++ b/librpc/idl/dfsblobs.idl
@@ -59,7 +59,7 @@ interface dfsblobs
        typedef struct {
                [relative_short] nstring *special_name;
                uint16 nb_expanded_names;
-               [relative_short,subcontext(0),flag(STR_NOTERM|NDR_REMAINING)] 
string_array *expanded_names;
+               [relative_short,subcontext(0),flag(NDR_REMAINING|STR_NULLTERM)] 
string_array *expanded_names;
        } dfs_domain_referral;
 
        typedef [nodiscriminant] union {
@@ -69,7 +69,7 @@ interface dfsblobs
        } dfs_referral;
 
        typedef [nodiscriminant] union {
-               [case(16)] uint8 *value;
+               [case(16)] uint8 value[16];
                [default];
        } dfs_padding;
 
diff --git a/librpc/ndr/ndr_string.c b/librpc/ndr/ndr_string.c
index 2e04633..e1f3a52 100644
--- a/librpc/ndr/ndr_string.c
+++ b/librpc/ndr/ndr_string.c
@@ -456,7 +456,8 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string_array(struct 
ndr_pull *ndr, int ndr_f
        case LIBNDR_FLAG_STR_NULLTERM:
                /* 
                 * here the strings are null terminated
-                * but also the array is null terminated
+                * but also the array is null terminated if 
LIBNDR_FLAG_REMAINING
+                * is specified
                 */
                for (count = 0;; count++) {
                        TALLOC_CTX *tmp_ctx;
@@ -469,6 +470,11 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string_array(struct 
ndr_pull *ndr, int ndr_f
                        tmp_ctx = ndr->current_mem_ctx;
                        ndr->current_mem_ctx = a;
                        NDR_CHECK(ndr_pull_string(ndr, ndr_flags, &s));
+                       if ((ndr->data_size - ndr->offset) == 0 && ndr->flags & 
LIBNDR_FLAG_REMAINING)
+                       {
+                               a[count] = s;
+                               break;
+                       }
                        ndr->current_mem_ctx = tmp_ctx;
                        if (strcmp("", s)==0) {
                                a[count] = NULL;
@@ -491,11 +497,14 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string_array(struct 
ndr_pull *ndr, int ndr_f
                 * but serarated by a null terminator
                 *
                 * which means the same as:
-                * very string is null terminated exept the last
+                * Every string is null terminated exept the last
                 * string is terminated by the end of the buffer
                 *
                 * as LIBNDR_FLAG_STR_NULLTERM also end at the end
                 * of the buffer, we can pull each string with this flag
+                *
+                * The big difference with the case LIBNDR_FLAG_STR_NOTERM +
+                * LIBNDR_FLAG_REMAINING is that the last string will not be 
null terminated
                 */
                ndr->flags &= ~(LIBNDR_FLAG_STR_NOTERM|LIBNDR_FLAG_REMAINING);
                ndr->flags |= LIBNDR_FLAG_STR_NULLTERM;
@@ -545,8 +554,11 @@ _PUBLIC_ enum ndr_err_code ndr_push_string_array(struct 
ndr_push *ndr, int ndr_f
                for (count = 0; a && a[count]; count++) {
                        NDR_CHECK(ndr_push_string(ndr, ndr_flags, a[count]));
                }
-
-               NDR_CHECK(ndr_push_string(ndr, ndr_flags, ""));
+               /* If LIBNDR_FLAG_REMAINING then we do not add a null 
terminator to the array */
+               if (!(flags & LIBNDR_FLAG_REMAINING))
+               {
+                       NDR_CHECK(ndr_push_string(ndr, ndr_flags, ""));
+               }
                break;
 
        case LIBNDR_FLAG_STR_NOTERM:
diff --git a/source4/smb_server/smb/trans2.c b/source4/smb_server/smb/trans2.c
index 38381fd..aae85d6 100644
--- a/source4/smb_server/smb/trans2.c
+++ b/source4/smb_server/smb/trans2.c
@@ -873,7 +873,8 @@ static NTSTATUS fill_normal_dfs_referraltype(struct 
dfs_referral_type *ref,
                ZERO_STRUCTP(ref);
                ref->version = version;
                ref->referral.v3.data.server_type = DFS_SERVER_NON_ROOT;
-               ref->referral.v3.size = 18;
+               /* "normal" referral seems to always include the GUID */
+               ref->referral.v3.size = 34;
 
                ref->referral.v3.data.entry_flags = 0;
                ref->referral.v3.data.ttl = 600; /* As w2k3 */
@@ -885,7 +886,8 @@ static NTSTATUS fill_normal_dfs_referraltype(struct 
dfs_referral_type *ref,
                ZERO_STRUCTP(ref);
                ref->version = version;
                ref->referral.v4.server_type = DFS_SERVER_NON_ROOT;
-               ref->referral.v4.size = 18;
+               /* "normal" referral seems to always include the GUID */
+               ref->referral.v4.size = 34;
 
                if (isfirstoffset) {
                        ref->referral.v4.entry_flags =  
DFS_HEADER_FLAG_TARGET_BCK;
@@ -914,7 +916,12 @@ static NTSTATUS fill_domain_dfs_referraltype(struct 
dfs_referral_type *ref,
                ZERO_STRUCTP(ref);
                ref->version = version;
                ref->referral.v3.data.server_type = DFS_SERVER_NON_ROOT;
-               ref->referral.v3.size = 34;
+               /* It's hard coded ... don't think it's a good way but the 
sizeof return not the
+                * correct values
+                *
+                * We have 18 if the GUID is not included 34 otherwise
+               */
+               ref->referral.v3.size = 18;
                ref->referral.v3.data.entry_flags = 
DFS_FLAG_REFERRAL_DOMAIN_RESP;
                ref->referral.v3.data.ttl = 600; /* As w2k3 */
                ref->referral.v3.data.referrals.r2.special_name = domain;
@@ -1249,7 +1256,7 @@ static NTSTATUS dodomain_referral(TALLOC_CTX *ctx,
 
        referral = talloc(tab, struct dfs_referral_type);
        NT_STATUS_HAVE_NO_MEMORY_AND_FREE(referral, context);
-       referral_str = talloc_asprintf(referral, "\\%s", dns_domain);
+       referral_str = talloc_asprintf(referral, "\\%s", netbios_domain);
        NT_STATUS_HAVE_NO_MEMORY_AND_FREE(referral_str, context);
        status = fill_domain_dfs_referraltype(referral,  3,
                                              referral_str,
@@ -1265,7 +1272,7 @@ static NTSTATUS dodomain_referral(TALLOC_CTX *ctx,
 
        referral = talloc(tab, struct dfs_referral_type);
        NT_STATUS_HAVE_NO_MEMORY_AND_FREE(referral, context);
-       referral_str = talloc_asprintf(referral, "\\%s", netbios_domain);
+       referral_str = talloc_asprintf(referral, "\\%s", dns_domain);
        NT_STATUS_HAVE_NO_MEMORY_AND_FREE(referral_str, context);
        status = fill_domain_dfs_referraltype(referral,  3,
                                              referral_str,
diff --git a/source4/torture/dfs/domaindfs.c b/source4/torture/dfs/domaindfs.c
index 18c8439..022aaff 100644
--- a/source4/torture/dfs/domaindfs.c
+++ b/source4/torture/dfs/domaindfs.c
@@ -47,6 +47,10 @@ static bool test_getdomainreferral(struct torture_context 
*tctx,
                                 "0 domains referrals returned");
        torture_assert_int_equal(tctx, resp.header_flags, 0,
                                 "Header flag different it's not a referral 
server");
+       torture_assert_int_equal(tctx, resp.referral_entries[1].version, 3,
+                                talloc_asprintf(tctx,
+                                       "Not expected version for referral 
entry 1 got %d expected 3",
+                                       resp.referral_entries[1].version));
        torture_assert_int_equal(tctx, resp.referral_entries[0].version, 3,
                                 talloc_asprintf(tctx,
                                        "Not expected version for referral 
entry 0 got %d expected 3",
@@ -74,6 +78,7 @@ static bool test_getdcreferral(struct torture_context *tctx,
        struct dfs_GetDFSReferral r, r2, r3;
        struct dfs_referral_resp resp, resp2, resp3;
        const char* str;
+       const char* str2;
 
        r.in.req.max_referral_level = 3;
        r.in.req.servername = "";
@@ -125,6 +130,16 @@ static bool test_getdcreferral(struct torture_context 
*tctx,
                                 
resp2.referral_entries[0].referral.v3.data.referrals.r2.expanded_names[0]) > 0,
                                 1,
                                 "Length of first dc is less than 0");
+       str = 
strchr(resp2.referral_entries[0].referral.v3.data.referrals.r2.expanded_names[0],
 '.');
+       str2 = 
resp2.referral_entries[0].referral.v3.data.referrals.r2.special_name;
+       if (str2[0] == '\\') {
+               str2++;
+       }
+       torture_assert_int_equal(tctx, strlen(str) >0, 1 ,"Length of domain too 
short");
+       str++;
+       torture_assert_int_equal(tctx, strcmp(str,str2), 0,
+                                       talloc_asprintf(tctx, "Pb domain of the 
dc is not"\
+                                                               "the same as 
the requested: domain = %s got =%s",str2 ,str));
 
        r3.in.req.max_referral_level = 3;
        /*
diff --git a/source4/torture/ndr/dfsblob.c b/source4/torture/ndr/dfsblob.c
index 96d3407..23a32e1 100644
--- a/source4/torture/ndr/dfsblob.c
+++ b/source4/torture/ndr/dfsblob.c
@@ -3,7 +3,7 @@
 
    Test DFS blobs.
 
-   Copyright (C) Matthieu Patou <[email protected]> 2009
+   Copyright (C) Matthieu Patou <[email protected]> 2009-2010
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -22,29 +22,63 @@
 #include "includes.h"
 #include "torture/ndr/ndr.h"
 #include "librpc/gen_ndr/ndr_dfsblobs.h"
+#include "librpc/gen_ndr/dfsblobs.h"
 
+DATA_BLOB blob;
 static const uint8_t dfs_get_ref_in[] = {
        0x03, 0x00, 0x5c, 0x00, 0x57, 0x00, 0x32, 0x00,
        0x4b, 0x00, 0x33, 0x00, 0x00, 0x00 };
 
 static const uint8_t dfs_get_ref_out[] = {
-       0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x03, 0x00, 0x22, 0x00, 0x00, 0x00,
-       0x02, 0x00, 0x58, 0x02, 0x00, 0x00, 0x22, 0x00,
-       0x01, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x03, 0x00, 0x22, 0x00, 0x00, 0x00, 0x02, 0x00,
+       0x58, 0x02, 0x00, 0x00, 0x22, 0x00, 0x01, 0x00,
+       0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x5c, 0x00, 0x6d, 0x00, 0x73, 0x00,
+       0x77, 0x00, 0x32, 0x00, 0x6b, 0x00, 0x33, 0x00,
+       0x2e, 0x00, 0x74, 0x00, 0x73, 0x00, 0x74, 0x00,
+       0x00, 0x00, 0x5c, 0x00, 0x77, 0x00, 0x32, 0x00,
+       0x6b, 0x00, 0x33, 0x00, 0x61, 0x00, 0x64, 0x00,
+       0x76, 0x00, 0x7a, 0x00, 0x30, 0x00, 0x31, 0x00,
+       0x2e, 0x00, 0x6d, 0x00, 0x73, 0x00, 0x77, 0x00,
+       0x32, 0x00, 0x6b, 0x00, 0x33, 0x00, 0x2e, 0x00,
+       0x74, 0x00, 0x73, 0x00, 0x74, 0x00, 0x00, 0x00};
+
+static const uint8_t dfs_get_ref_out2[] = {
+       0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x03, 0x00, 0x12, 0x00, 0x00, 0x00, 0x02, 0x00,
+       0x58, 0x02, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x03, 0x00, 0x12, 0x00, 0x00, 0x00,
+       0x02, 0x00, 0x58, 0x02, 0x00, 0x00, 0x22, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x57, 0x00,
-       0x32, 0x00, 0x4b, 0x00, 0x33, 0x00, 0x00, 0x00,
-       0x5c, 0x00, 0x57, 0x00, 0x32, 0x00, 0x4b, 0x00,
-       0x33, 0x00, 0x2d, 0x00, 0x31, 0x00, 0x30, 0x00,
-       0x31, 0x00, 0x00, 0x00 };
+       0x32, 0x00, 0x4b, 0x00, 0x38, 0x00, 0x52, 0x00,
+       0x32, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x77, 0x00,
+       0x32, 0x00, 0x6b, 0x00, 0x38, 0x00, 0x72, 0x00,
+       0x32, 0x00, 0x2e, 0x00, 0x6d, 0x00, 0x61, 0x00,
+       0x74, 0x00, 0x77, 0x00, 0x73, 0x00, 0x2e, 0x00,
+       0x6e, 0x00, 0x65, 0x00, 0x74, 0x00, 0x00, 0x00
+};
+static bool dfs_referral_out_check(struct torture_context *tctx, struct 
dfs_referral_resp *r)
+{
+       torture_assert_str_equal(tctx,
+               
r->referral_entries[0].referral.v3.data.referrals.r2.special_name,
+               "\\msw2k3.tst", "Special name");
+       ndr_push_struct_blob(&blob, tctx, r, 
(ndr_push_flags_fn_t)ndr_push_dfs_referral_resp);
+       torture_assert_int_equal(tctx, blob.data[blob.length-2], 0, "expanded 
names not null terminated");
+       torture_assert_int_equal(tctx, blob.data[blob.length-1], 0, "expanded 
names not null terminated");
+       return true;
+}
 
 struct torture_suite *ndr_dfsblob_suite(TALLOC_CTX *ctx)
 {
        struct torture_suite *suite = torture_suite_create(ctx, "dfsblob");
 
        torture_suite_add_ndr_pull_fn_test(suite, dfs_GetDFSReferral_in, 
dfs_get_ref_in, NDR_IN, NULL);
-       torture_suite_add_ndr_pull_fn_test(suite, dfs_referral_resp, 
dfs_get_ref_out, NDR_BUFFERS|NDR_SCALARS, NULL);
+
+       torture_suite_add_ndr_pull_fn_test(suite, dfs_referral_resp, 
dfs_get_ref_out2, NDR_BUFFERS|NDR_SCALARS, NULL);
+
+       torture_suite_add_ndr_pull_fn_test(suite, dfs_referral_resp, 
dfs_get_ref_out, NDR_BUFFERS|NDR_SCALARS,dfs_referral_out_check);
 
        return suite;
 }


-- 
Samba Shared Repository

Reply via email to