The branch, master has been updated
       via  f180b1c s4:rpc_server: Do some checks of LogonSamLogon flags
       via  9b28f3a s3:winbindd: Send flags=0 in 
netr_LogonSamLogon{WithFlags,Ex}()
       via  76fe65b netlogon.idl: Add netr_LogonSamLogon_flags bitmap
       via  e0069bd s3:libsmb: add cli_state_update_after_sesssetup() helper 
function
       via  a37a0cd libcli:smb: Add unit test for smb_bytes_pull_str()
       via  e60e77a libcli/smb: Fix alignment problems of smb_bytes_pull_str()
       via  c786c61 Revert "libcli:smb: Fix pulling strings from the wire"
       via  d18379f Revert "s3:libsmb: Fix printing the session setup 
information"
      from  7bce7e1 samba tool - tests: Fix shell metacharacters in generated 
password

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


- Log -----------------------------------------------------------------
commit f180b1c21ccc3ba0097e61eac7b6b7560736bdc3
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Jun 8 18:01:59 2017 +0200

    s4:rpc_server: Do some checks of LogonSamLogon flags
    
    This matches a Windows Server, at least if it is itself a
    DC of the forest root and the requested domain is the local domain of the 
DC.
    Both constraints are true on a Samba AD DC, as we don't really support
    trusts yet.
    
    Pair-Programmed-With: Andreas Schneider <[email protected]>
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Signed-off-by: Andreas Schneider <[email protected]>
    
    Autobuild-User(master): Andreas Schneider <[email protected]>
    Autobuild-Date(master): Fri Jun  9 17:06:04 CEST 2017 on sn-devel-144

commit 9b28f3af879290708851ba26ad59c2055b751dac
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Jun 8 17:10:12 2017 +0200

    s3:winbindd: Send flags=0 in netr_LogonSamLogon{WithFlags,Ex}()
    
    These extra flags are an [in,out] argument, so we have to initialize
    them to 0. If we pass NETLOGON_SAMLOGON_FLAG_PASS_TO_FOREST_ROOT
    or NETLOGON_SAMLOGON_FLAG_PASS_CROSS_FOREST_HOP, a Windows Server
    will just return NT_STATUS_NO_SUCH_USER with authoritative=1
    (at least if it is itself a DC of the forest root and the requested
     domain is the local domain of the DC).
    
    Pair-Programmed-With: Andreas Schneider <[email protected]>
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Signed-off-by: Andreas Schneider <[email protected]>

commit 76fe65b67e6d1baca49b488d07af771319c148e7
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Jun 8 17:20:50 2017 +0200

    netlogon.idl: Add netr_LogonSamLogon_flags bitmap
    
    See [MS-NRPC] 3.5.4.5.1 NetrLogonSamLogonEx (Opnum 39).
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Andreas Schneider <[email protected]>

commit e0069bd2a4820eca17c59d91bd1853f2f053a7a3
Author: Stefan Metzmacher <[email protected]>
Date:   Wed Mar 15 17:04:44 2017 +0000

    s3:libsmb: add cli_state_update_after_sesssetup() helper function
    
    This function updates cli->server_{os,type,domain} to valid values
    after a session setup.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12779
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Andreas Schneider <[email protected]>

commit a37a0cd81feaa79a6b2b79921903326e476bcbb1
Author: Andreas Schneider <[email protected]>
Date:   Thu Jun 8 16:08:15 2017 +0200

    libcli:smb: Add unit test for smb_bytes_pull_str()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12824
    
    Pair-Programmed-With: Stefan Metzmacher <[email protected]>
    Signed-off-by: Andreas Schneider <[email protected]>
    Signed-off-by: Stefan Metzmacher <[email protected]>

commit e60e77a8afd095bfdb3d678aa48570ca159d9b24
Author: Stefan Metzmacher <[email protected]>
Date:   Wed Mar 15 17:04:30 2017 +0000

    libcli/smb: Fix alignment problems of smb_bytes_pull_str()
    
    This function needs to get the whole smb buffer in order to get
    the alignment for unicode correct.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12824
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>
    Reviewed-by: Andreas Schneider <[email protected]>

commit c786c61d1a72f3f8782e8f5a4a087276ce161a6e
Author: Andreas Schneider <[email protected]>
Date:   Thu Jun 8 15:02:16 2017 +0200

    Revert "libcli:smb: Fix pulling strings from the wire"
    
    This reverts commit a4efe647c51700cee93b7574e5955e264aa96893.
    
    A different fix will follow.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12824
    
    Signed-off-by: Andreas Schneider <[email protected]>
    Reviewed-by: Stefan Metzmacher <[email protected]>

commit d18379fa009ddabfea53cb4095ff84574c699f37
Author: Andreas Schneider <[email protected]>
Date:   Thu Jun 8 16:08:54 2017 +0200

    Revert "s3:libsmb: Fix printing the session setup information"
    
    This reverts commit b6f87af427a1fa2bd397668d9f14cb0cf8ec5015.
    
    A different fix will follow.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12824
    
    Signed-off-by: Andreas Schneider <[email protected]>
    Reviewed-by: Stefan Metzmacher <[email protected]>

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

Summary of changes:
 libcli/smb/smb1cli_session.c                  |  28 ++--
 libcli/smb/smb_util.h                         |   3 +-
 libcli/smb/test_smb1cli_session.c             | 214 ++++++++++++++++++++++++++
 libcli/smb/util.c                             |  49 ++++--
 libcli/smb/wscript                            |   5 +
 librpc/idl/netlogon.idl                       |  15 +-
 selftest/tests.py                             |   3 +
 source3/libsmb/cliconnect.c                   |  77 ++++++---
 source3/libsmb/clidfs.c                       |  32 +---
 source3/libsmb/clientgen.c                    |  13 ++
 source3/torture/masktest.c                    |   4 +-
 source3/winbindd/winbindd_dual_srv.c          |   2 +-
 source3/winbindd/winbindd_pam.c               |   4 +-
 source4/rpc_server/netlogon/dcerpc_netlogon.c |  14 ++
 14 files changed, 374 insertions(+), 89 deletions(-)
 create mode 100644 libcli/smb/test_smb1cli_session.c


Changeset truncated at 500 lines:

diff --git a/libcli/smb/smb1cli_session.c b/libcli/smb/smb1cli_session.c
index 9d92aa6..11614df 100644
--- a/libcli/smb/smb1cli_session.c
+++ b/libcli/smb/smb1cli_session.c
@@ -210,16 +210,16 @@ static void smb1cli_session_setup_lm21_done(struct 
tevent_req *subreq)
        p = bytes;
 
        status = smb_bytes_pull_str(state, &state->out_native_os,
-                                   use_unicode, p,
-                                   bytes+num_bytes-p, &ret);
+                                   use_unicode, bytes, num_bytes,
+                                   p, &ret);
        if (tevent_req_nterror(req, status)) {
                return;
        }
        p += ret;
 
        status = smb_bytes_pull_str(state, &state->out_native_lm,
-                                   use_unicode, p,
-                                   bytes+num_bytes-p, &ret);
+                                   use_unicode, bytes, num_bytes,
+                                   p, &ret);
        if (tevent_req_nterror(req, status)) {
                return;
        }
@@ -493,24 +493,24 @@ static void smb1cli_session_setup_nt1_done(struct 
tevent_req *subreq)
        p = bytes;
 
        status = smb_bytes_pull_str(state, &state->out_native_os,
-                                   use_unicode, p,
-                                   bytes+num_bytes-p, &ret);
+                                   use_unicode, bytes, num_bytes,
+                                   p, &ret);
        if (tevent_req_nterror(req, status)) {
                return;
        }
        p += ret;
 
        status = smb_bytes_pull_str(state, &state->out_native_lm,
-                                   use_unicode, p,
-                                   bytes+num_bytes-p, &ret);
+                                   use_unicode, bytes, num_bytes,
+                                   p, &ret);
        if (tevent_req_nterror(req, status)) {
                return;
        }
        p += ret;
 
        status = smb_bytes_pull_str(state, &state->out_primary_domain,
-                                   use_unicode, p,
-                                   bytes+num_bytes-p, &ret);
+                                   use_unicode, bytes, num_bytes,
+                                   p, &ret);
        if (tevent_req_nterror(req, status)) {
                return;
        }
@@ -754,16 +754,16 @@ static void smb1cli_session_setup_ext_done(struct 
tevent_req *subreq)
        p += out_security_blob_length;
 
        status = smb_bytes_pull_str(state, &state->out_native_os,
-                                   use_unicode, p,
-                                   bytes+num_bytes-p, &ret);
+                                   use_unicode, bytes, num_bytes,
+                                   p, &ret);
        if (tevent_req_nterror(req, status)) {
                return;
        }
        p += ret;
 
        status = smb_bytes_pull_str(state, &state->out_native_lm,
-                                   use_unicode, p,
-                                   bytes+num_bytes-p, &ret);
+                                   use_unicode, bytes, num_bytes,
+                                   p, &ret);
        if (tevent_req_nterror(req, status)) {
                return;
        }
diff --git a/libcli/smb/smb_util.h b/libcli/smb/smb_util.h
index 7e6f0a4..2884786 100644
--- a/libcli/smb/smb_util.h
+++ b/libcli/smb/smb_util.h
@@ -38,4 +38,5 @@ uint8_t *trans2_bytes_push_bytes(uint8_t *buf,
                                 const uint8_t *bytes, size_t num_bytes);
 NTSTATUS smb_bytes_pull_str(TALLOC_CTX *mem_ctx, char **_str, bool ucs2,
                            const uint8_t *buf, size_t buf_len,
-                           size_t *pbuf_consumed);
+                           const uint8_t *position,
+                           size_t *_consumed);
diff --git a/libcli/smb/test_smb1cli_session.c 
b/libcli/smb/test_smb1cli_session.c
new file mode 100644
index 0000000..e924b32
--- /dev/null
+++ b/libcli/smb/test_smb1cli_session.c
@@ -0,0 +1,214 @@
+#include <stdarg.h>
+#include <stddef.h>
+#include <setjmp.h>
+#include <cmocka.h>
+
+#include "replace.h"
+#include <talloc.h>
+#include "libcli/util/ntstatus.h"
+#include "smb_util.h"
+
+static const uint8_t smb1_session_setup_bytes[] = {
+       0xA1, 0x82, 0x01, 0x02, 0x30, 0x81, 0xFF, 0xA0,
+       0x03, 0x0A, 0x01, 0x01, 0xA1, 0x0C, 0x06, 0x0A,
+       0x2B, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x02,
+       0x02, 0x0A, 0xA2, 0x81, 0xE9, 0x04, 0x81, 0xE6,
+       0x4E, 0x54, 0x4C, 0x4D, 0x53, 0x53, 0x50, 0x00,
+       0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x16, 0x00,
+       0x38, 0x00, 0x00, 0x00, 0x15, 0x82, 0x89, 0x62,
+       0xF6, 0x65, 0xAB, 0x23, 0x47, 0xBC, 0x4D, 0x21,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x98, 0x00, 0x98, 0x00, 0x4E, 0x00, 0x00, 0x00,
+       0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F,
+       0x53, 0x00, 0x41, 0x00, 0x4D, 0x00, 0x42, 0x00,
+       0x41, 0x00, 0x44, 0x00, 0x4F, 0x00, 0x4D, 0x00,
+       0x41, 0x00, 0x49, 0x00, 0x4E, 0x00, 0x02, 0x00,
+       0x16, 0x00, 0x53, 0x00, 0x41, 0x00, 0x4D, 0x00,
+       0x42, 0x00, 0x41, 0x00, 0x44, 0x00, 0x4F, 0x00,
+       0x4D, 0x00, 0x41, 0x00, 0x49, 0x00, 0x4E, 0x00,
+       0x01, 0x00, 0x0E, 0x00, 0x4C, 0x00, 0x4F, 0x00,
+       0x43, 0x00, 0x41, 0x00, 0x4C, 0x00, 0x44, 0x00,
+       0x43, 0x00, 0x04, 0x00, 0x22, 0x00, 0x73, 0x00,
+       0x61, 0x00, 0x6D, 0x00, 0x62, 0x00, 0x61, 0x00,
+       0x2E, 0x00, 0x65, 0x00, 0x78, 0x00, 0x61, 0x00,
+       0x6D, 0x00, 0x70, 0x00, 0x6C, 0x00, 0x65, 0x00,
+       0x2E, 0x00, 0x63, 0x00, 0x6F, 0x00, 0x6D, 0x00,
+       0x03, 0x00, 0x32, 0x00, 0x6C, 0x00, 0x6F, 0x00,
+       0x63, 0x00, 0x61, 0x00, 0x6C, 0x00, 0x64, 0x00,
+       0x63, 0x00, 0x2E, 0x00, 0x73, 0x00, 0x61, 0x00,
+       0x6D, 0x00, 0x62, 0x00, 0x61, 0x00, 0x2E, 0x00,
+       0x65, 0x00, 0x78, 0x00, 0x61, 0x00, 0x6D, 0x00,
+       0x70, 0x00, 0x6C, 0x00, 0x65, 0x00, 0x2E, 0x00,
+       0x63, 0x00, 0x6F, 0x00, 0x6D, 0x00, 0x07, 0x00,
+       0x08, 0x00, 0x0C, 0x40, 0xA3, 0xC3, 0x5B, 0xE0,
+       0xD2, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55,
+       0x00, 0x6E, 0x00, 0x69, 0x00, 0x78, 0x00, 0x00,
+       0x00, 0x53, 0x00, 0x61, 0x00, 0x6D, 0x00, 0x62,
+       0x00, 0x61, 0x00, 0x20, 0x00, 0x34, 0x00, 0x2E,
+       0x00, 0x37, 0x00, 0x2E, 0x00, 0x30, 0x00, 0x70,
+       0x00, 0x72, 0x00, 0x65, 0x00, 0x31, 0x00, 0x2D,
+       0x00, 0x44, 0x00, 0x45, 0x00, 0x56, 0x00, 0x45,
+       0x00, 0x4C, 0x00, 0x4F, 0x00, 0x50, 0x00, 0x45,
+       0x00, 0x52, 0x00, 0x42, 0x00, 0x55, 0x00, 0x49,
+       0x00, 0x4C, 0x00, 0x44, 0x00, 0x00, 0x00, 0x53,
+       0x00, 0x41, 0x00, 0x4D, 0x00, 0x42, 0x00, 0x41,
+       0x00, 0x44, 0x00, 0x4F, 0x00, 0x4D, 0x00, 0x41,
+       0x00, 0x49, 0x00, 0x4E, 0x00, 0x00, 0x00
+};
+
+static void test_smb_bytes_pull_str(void **state)
+{
+       NTSTATUS status;
+       const uint8_t *bytes = smb1_session_setup_bytes;
+       const size_t num_bytes = sizeof(smb1_session_setup_bytes);
+       const uint8_t *p = NULL;
+       size_t ret = 0;
+       size_t out_security_blob_length = 262;
+       bool use_unicode = true;
+       char *str = NULL;
+
+       p = bytes;
+       p += out_security_blob_length;
+
+       status = smb_bytes_pull_str(NULL, &str, use_unicode,
+                                   bytes, num_bytes,
+                                   p, &ret);
+       assert_true(NT_STATUS_IS_OK(status));
+       assert_string_equal(str, "Unix");
+       assert_int_equal(ret, 0x0b);
+       TALLOC_FREE(str);
+
+       p += ret;
+       status = smb_bytes_pull_str(NULL, &str, use_unicode,
+                                   bytes, num_bytes,
+                                   p, &ret);
+       assert_true(NT_STATUS_IS_OK(status));
+       assert_string_equal(str, "Samba 4.7.0pre1-DEVELOPERBUILD");
+       assert_int_equal(ret, 0x3e);
+       TALLOC_FREE(str);
+
+       p += ret;
+       status = smb_bytes_pull_str(NULL, &str, use_unicode,
+                                   bytes, num_bytes,
+                                   p, &ret);
+       assert_true(NT_STATUS_IS_OK(status));
+       assert_string_equal(str, "SAMBADOMAIN");
+       assert_int_equal(ret, 0x18);
+       TALLOC_FREE(str);
+
+       p += ret;
+       status = smb_bytes_pull_str(NULL, &str, use_unicode,
+                                   bytes, num_bytes,
+                                   p, &ret);
+       assert_true(NT_STATUS_IS_OK(status));
+       assert_string_equal(str, "");
+       assert_int_equal(ret, 0x00);
+       TALLOC_FREE(str);
+}
+
+static void test_smb_bytes_pull_str_no_unicode(void **state)
+{
+       NTSTATUS status;
+       const uint8_t *bytes = smb1_session_setup_bytes;
+       const size_t num_bytes = sizeof(smb1_session_setup_bytes);
+       const uint8_t *p = NULL;
+       size_t ret = 0;
+       size_t out_security_blob_length = 262;
+       bool use_unicode = false;
+       char *str = NULL;
+
+       p = bytes;
+       p += out_security_blob_length;
+
+       status = smb_bytes_pull_str(NULL, &str, use_unicode,
+                                   bytes, num_bytes,
+                                   p, &ret);
+       assert_true(NT_STATUS_IS_OK(status));
+       assert_string_equal(str, "");
+       assert_int_equal(ret, 0x01);
+       TALLOC_FREE(str);
+}
+
+static void test_smb_bytes_pull_str_wrong_offset(void **state)
+{
+       NTSTATUS status;
+       const uint8_t *bytes = smb1_session_setup_bytes;
+       const size_t num_bytes = sizeof(smb1_session_setup_bytes);
+       const uint8_t *p = NULL;
+       size_t ret = 0;
+       size_t out_security_blob_length = 261;
+       bool use_unicode = true;
+       char *str = NULL;
+
+       bytes += 1;
+       p = bytes;
+       p += out_security_blob_length;
+
+       status = smb_bytes_pull_str(NULL, &str, use_unicode,
+                                   bytes, num_bytes,
+                                   p, &ret);
+       assert_true(NT_STATUS_IS_OK(status));
+
+       assert_string_equal(str, 
"\xE5\x94\x80\xE6\xB8\x80\xE6\xA4\x80\xE7\xA0\x80");
+       assert_int_equal(ret, 0x0a);
+       TALLOC_FREE(str);
+}
+
+static void test_smb_bytes_pull_str_invalid_offset(void **state)
+{
+       NTSTATUS status;
+       const uint8_t *bytes = smb1_session_setup_bytes;
+       const size_t num_bytes = sizeof(smb1_session_setup_bytes);
+       const uint8_t *p = NULL;
+       size_t ret = 0;
+       bool use_unicode = true;
+       char *str = NULL;
+       intptr_t bytes_address = (intptr_t)bytes;
+
+       /* Warning: array subscript is below array bounds */
+       p = (const uint8_t *)(bytes_address - 1);
+       status = smb_bytes_pull_str(NULL, &str, use_unicode,
+                                   bytes, num_bytes,
+                                   p, &ret);
+       assert_int_equal(NT_STATUS_V(status),
+                        NT_STATUS_V(NT_STATUS_INTERNAL_ERROR));
+
+       p = bytes + num_bytes;
+       status = smb_bytes_pull_str(NULL, &str, use_unicode,
+                                   bytes, num_bytes,
+                                   p, &ret);
+       assert_true(NT_STATUS_IS_OK(status));
+       assert_string_equal(str, "");
+       assert_int_equal(ret, 0x00);
+       TALLOC_FREE(str);
+
+       p = bytes + num_bytes - 1;
+       status = smb_bytes_pull_str(NULL, &str, use_unicode,
+                                   bytes, num_bytes,
+                                   p, &ret);
+       assert_true(NT_STATUS_IS_OK(status));
+       assert_string_equal(str, "");
+       assert_int_equal(ret, 0x01);
+       TALLOC_FREE(str);
+
+       /* Warning: array subscript is above array bounds */
+       p = (const uint8_t *)(bytes_address + num_bytes + 1);
+       status = smb_bytes_pull_str(NULL, &str, use_unicode,
+                                   bytes, num_bytes,
+                                   p, &ret);
+       assert_int_equal(NT_STATUS_V(status),
+                        NT_STATUS_V(NT_STATUS_BUFFER_TOO_SMALL));
+}
+
+int main(void)
+{
+       const struct CMUnitTest tests[] = {
+               cmocka_unit_test(test_smb_bytes_pull_str),
+               cmocka_unit_test(test_smb_bytes_pull_str_no_unicode),
+               cmocka_unit_test(test_smb_bytes_pull_str_wrong_offset),
+               cmocka_unit_test(test_smb_bytes_pull_str_invalid_offset),
+       };
+
+       cmocka_set_message_output(CM_OUTPUT_SUBUNIT);
+       return cmocka_run_group_tests(tests, NULL, NULL);
+}
diff --git a/libcli/smb/util.c b/libcli/smb/util.c
index 80d3428..7ef909c 100644
--- a/libcli/smb/util.c
+++ b/libcli/smb/util.c
@@ -319,29 +319,43 @@ uint8_t *trans2_bytes_push_bytes(uint8_t *buf,
 static NTSTATUS internal_bytes_pull_str(TALLOC_CTX *mem_ctx, char **_str,
                                        bool ucs2, bool align_odd,
                                        const uint8_t *buf, size_t buf_len,
-                                       size_t *pbuf_consumed)
+                                       const uint8_t *position,
+                                       size_t *p_consumed)
 {
        size_t pad = 0;
+       size_t offset;
        char *str = NULL;
        size_t str_len = 0;
        bool ok;
 
        *_str = NULL;
-       if (pbuf_consumed != NULL) {
-               *pbuf_consumed = 0;
+       if (p_consumed != NULL) {
+               *p_consumed = 0;
+       }
+
+       if (position < buf) {
+               return NT_STATUS_INTERNAL_ERROR;
+       }
+
+       offset = PTR_DIFF(position, buf);
+       if (offset > buf_len) {
+               return NT_STATUS_BUFFER_TOO_SMALL;
        }
 
        if (ucs2 &&
-           ((align_odd && (buf_len % 2 == 0)) ||
-            (!align_odd && (buf_len % 2 == 1)))) {
-               if (buf_len < 1) {
-                       return NT_STATUS_BUFFER_TOO_SMALL;
-               }
-               pad = 1;
-               buf_len -= pad;
-               buf += pad;
+           ((align_odd && (offset % 2 == 0)) ||
+            (!align_odd && (offset % 2 == 1)))) {
+               pad += 1;
+               offset += 1;
+       }
+
+       if (offset > buf_len) {
+               return NT_STATUS_BUFFER_TOO_SMALL;
        }
 
+       buf_len -= offset;
+       buf += offset;
+
        if (ucs2) {
                buf_len = utf16_len_n(buf, buf_len);
        } else {
@@ -361,17 +375,18 @@ static NTSTATUS internal_bytes_pull_str(TALLOC_CTX 
*mem_ctx, char **_str,
                return map_nt_error_from_unix_common(errno);
        }
 
-       if (pbuf_consumed != NULL) {
-               *pbuf_consumed = buf_len + pad;
+       if (p_consumed != NULL) {
+               *p_consumed = buf_len + pad;
        }
        *_str = str;
-       return NT_STATUS_OK;;
+       return NT_STATUS_OK;
 }
 
 NTSTATUS smb_bytes_pull_str(TALLOC_CTX *mem_ctx, char **_str, bool ucs2,
                            const uint8_t *buf, size_t buf_len,
-                           size_t *_buf_consumed)
+                           const uint8_t *position,
+                           size_t *_consumed)
 {
-       return internal_bytes_pull_str(mem_ctx, _str, ucs2, false,
-                                      buf, buf_len, _buf_consumed);
+       return internal_bytes_pull_str(mem_ctx, _str, ucs2, true,
+                                      buf, buf_len, position, _consumed);
 }
diff --git a/libcli/smb/wscript b/libcli/smb/wscript
index dacf631..e662826 100644
--- a/libcli/smb/wscript
+++ b/libcli/smb/wscript
@@ -64,3 +64,8 @@ def build(bld):
                     tstream_smbXcli_np.h
     ''',
     )
+
+    bld.SAMBA_BINARY('test_smb1cli_session',
+                     source='test_smb1cli_session.c',
+                     deps='cmocka cli_smb_common',
+                     install=False)
diff --git a/librpc/idl/netlogon.idl b/librpc/idl/netlogon.idl
index 4d1a0ef..4f9da3d 100644
--- a/librpc/idl/netlogon.idl
+++ b/librpc/idl/netlogon.idl
@@ -1597,6 +1597,17 @@ interface netlogon
 
        /****************/
        /* Function 0x27 */
+       typedef [public,bitmap32bit] bitmap {
+               /* Request MUST be passed to the domain controller at the root 
of the forest. */
+               NETLOGON_SAMLOGON_FLAG_PASS_TO_FOREST_ROOT = 0x00000001,
+               /* Request MUST be passed to the DC at the end of the first hop 
over a cross-forest trust. */
+               NETLOGON_SAMLOGON_FLAG_PASS_CROSS_FOREST_HOP = 0x00000002,
+               /* Request was passed by an RODC to a DC in a different domain. 
*/
+               NETLOGON_SAMLOGON_FLAG_RODC_TO_OTHER_DOMAIN = 0x00000004,
+               /* Request is an NTLM authentication package request passed by 
an RODC. */
+               NETLOGON_SAMLOGON_FLAG_RODC_NTLM_REQUEST = 0x00000008
+       } netr_LogonSamLogon_flags;
+
        NTSTATUS netr_LogonSamLogonEx(
                [in,unique] [string,charset(UTF16)] uint16 *server_name,
                [in,unique] [string,charset(UTF16)] uint16 *computer_name,
@@ -1605,7 +1616,7 @@ interface netlogon
                [in]  uint16 validation_level,
                [out,ref] [switch_is(validation_level)] netr_Validation 
*validation,
                [out,ref] uint8 *authoritative,
-               [in,out,ref] uint32 *flags
+               [in,out,ref] netr_LogonSamLogon_flags *flags
                );
 
        /****************/
@@ -1678,7 +1689,7 @@ interface netlogon
                [in]  uint16 validation_level,
                [out,ref] [switch_is(validation_level)] netr_Validation 
*validation,
                [out,ref] uint8 *authoritative,
-               [in,out,ref] uint32 *flags
+               [in,out,ref] netr_LogonSamLogon_flags *flags
                );
 
        /****************/
diff --git a/selftest/tests.py b/selftest/tests.py
index b9c470c..5367fe3 100644
--- a/selftest/tests.py
+++ b/selftest/tests.py
@@ -149,3 +149,6 @@ if with_cmocka:
                   [os.path.join(bindir(), 
"default/testsuite/unittests/test_sambafs_srv_pipe")])
     plantestsuite("samba.unittests.lib_util_modules", "none",
                   [os.path.join(bindir(), 
"default/testsuite/unittests/test_lib_util_modules")])
+
+    plantestsuite("samba.unittests.smb1cli_session", "none",
+                  [os.path.join(bindir(), 
"default/libcli/smb/test_smb1cli_session")])
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index 0862722..200657a 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -372,6 +372,38 @@ NTSTATUS cli_session_creds_prepare_krb5(struct cli_state 
*cli,
        return NT_STATUS_OK;
 }
 
+static NTSTATUS cli_state_update_after_sesssetup(struct cli_state *cli,
+                                                const char *native_os,
+                                                const char *native_lm,
+                                                const char *primary_domain)
+{
+#define _VALID_STR(p) ((p) != NULL && (p)[0] != '\0')
+
+       if (!_VALID_STR(cli->server_os) && _VALID_STR(native_os)) {
+               cli->server_os = talloc_strdup(cli, native_os);
+               if (cli->server_os == NULL) {
+                       return NT_STATUS_NO_MEMORY;
+               }
+       }
+
+       if (!_VALID_STR(cli->server_type) && _VALID_STR(native_lm)) {
+               cli->server_type = talloc_strdup(cli, native_lm);
+               if (cli->server_type == NULL) {
+                       return NT_STATUS_NO_MEMORY;
+               }
+       }
+
+       if (!_VALID_STR(cli->server_domain) && _VALID_STR(primary_domain)) {
+               cli->server_domain = talloc_strdup(cli, primary_domain);
+               if (cli->server_domain == NULL) {
+                       return NT_STATUS_NO_MEMORY;
+               }
+       }
+
+#undef _VALID_STRING
+       return NT_STATUS_OK;
+}
+
 /********************************************************
  Utility function to ensure we always return at least
  a valid char * pointer to an empty string for the
@@ -762,7 +794,6 @@ static void cli_sesssetup_blob_done(struct tevent_req 
*subreq)


-- 
Samba Shared Repository

Reply via email to