[SCM] Samba Shared Repository - branch v4-6-test updated

Karolin Seeger kseeger at samba.org
Mon Jun 19 13:16:03 UTC 2017


The branch, v4-6-test has been updated
       via  29c2411 s3:libsmb: add cli_state_update_after_sesssetup() helper function
       via  ada73fa libcli/smb: Fix alignment problems of smb_bytes_pull_str()
       via  5a4f2e0 libcli:smb2: Gracefully handle not supported for FSCTL_VALIDATE_NEGOTIATE_INFO
       via  b4e1d73 ctdb-tests: Add more NFS eventscript tests for call-out failures
       via  6d5c1f6 ctdb-scripts: NFS call-out failures should cause event failure
      from  c08e056 messaging: fix net command failure due to unhandled return code

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-6-test


- Log -----------------------------------------------------------------
commit 29c24113f6ba921cd635a0c92713b8df570ecdd6
Author: Stefan Metzmacher <metze at samba.org>
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 <metze at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit e0069bd2a4820eca17c59d91bd1853f2f053a7a3)
    
    Autobuild-User(v4-6-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-6-test): Mon Jun 19 15:15:47 CEST 2017 on sn-devel-144

commit ada73fae662980521fd3c9e7f580dbc6f2c199e6
Author: Stefan Metzmacher <metze at samba.org>
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 <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit e60e77a8afd095bfdb3d678aa48570ca159d9b24)

commit 5a4f2e0fd26669002eb2885ad78fd9104b5d085c
Author: Andreas Schneider <asn at samba.org>
Date:   Tue May 30 16:30:33 2017 +0200

    libcli:smb2: Gracefully handle not supported for FSCTL_VALIDATE_NEGOTIATE_INFO
    
    If FSCTL_VALIDATE_NEGOTIATE_INFO is not implemented, e.g. in a SMB2 only
    server then gracefully handle NT_STATUS_NOT_SUPPORTED too.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12808
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Signed-off-by: Guenther Deschner <gd at samba.org>
    Pair-Programmed-With: Guenther Deschner <gd at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Volker Lendecke <vl at samba.org>
    Autobuild-Date(master): Thu Jun 15 17:32:45 CEST 2017 on sn-devel-144
    
    (cherry picked from commit a4d9438ecf92614a0915b9cf61f905ea8170043a)

commit b4e1d734a66d3ed5159960309275a33caa6ddd23
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Jun 9 10:57:28 2017 +1000

    ctdb-tests: Add more NFS eventscript tests for call-out failures
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12837
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 323291a46e26e0493d43052550e57e2989b83b97)

commit 6d5c1f683bc1c8a198bf7e5e72de7f9dc1b04a07
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Jun 8 14:45:43 2017 +1000

    ctdb-scripts: NFS call-out failures should cause event failure
    
    Failures in startup/shutdown/releaseip/takeip are currently
    incorrectly ignored.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12837
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 22f2068d456759612d340fdcc56276f39a710426)

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

Summary of changes:
 ctdb/config/events.d/60.nfs                        |  8 +--
 ....nfs.monitor.107.sh => 06.nfs.releaseip.001.sh} |  0
 ctdb/tests/eventscripts/06.nfs.releaseip.002.sh    | 12 ++++
 ...{60.nfs.monitor.107.sh => 06.nfs.takeip.001.sh} |  0
 ctdb/tests/eventscripts/06.nfs.takeip.002.sh       | 12 ++++
 ctdb/tests/eventscripts/60.nfs.monitor.109.sh      | 12 ++++
 ....nfs.monitor.107.sh => 60.nfs.releaseip.001.sh} |  0
 ctdb/tests/eventscripts/60.nfs.releaseip.002.sh    | 12 ++++
 ...0.nfs.monitor.107.sh => 60.nfs.shutdown.001.sh} |  0
 ctdb/tests/eventscripts/60.nfs.shutdown.002.sh     | 12 ++++
 ...60.nfs.monitor.107.sh => 60.nfs.startup.001.sh} |  0
 ctdb/tests/eventscripts/60.nfs.startup.002.sh      | 12 ++++
 ...{60.nfs.monitor.107.sh => 60.nfs.takeip.001.sh} |  0
 ctdb/tests/eventscripts/60.nfs.takeip.002.sh       | 12 ++++
 libcli/smb/smb1cli_session.c                       | 28 ++++----
 libcli/smb/smbXcli_base.c                          | 15 +++++
 libcli/smb/smb_util.h                              |  3 +-
 libcli/smb/util.c                                  | 47 +++++++++-----
 source3/libsmb/cliconnect.c                        | 74 +++++++++++++++-------
 19 files changed, 202 insertions(+), 57 deletions(-)
 copy ctdb/tests/eventscripts/{60.nfs.monitor.107.sh => 06.nfs.releaseip.001.sh} (100%)
 create mode 100755 ctdb/tests/eventscripts/06.nfs.releaseip.002.sh
 copy ctdb/tests/eventscripts/{60.nfs.monitor.107.sh => 06.nfs.takeip.001.sh} (100%)
 create mode 100755 ctdb/tests/eventscripts/06.nfs.takeip.002.sh
 create mode 100755 ctdb/tests/eventscripts/60.nfs.monitor.109.sh
 copy ctdb/tests/eventscripts/{60.nfs.monitor.107.sh => 60.nfs.releaseip.001.sh} (100%)
 create mode 100755 ctdb/tests/eventscripts/60.nfs.releaseip.002.sh
 copy ctdb/tests/eventscripts/{60.nfs.monitor.107.sh => 60.nfs.shutdown.001.sh} (100%)
 create mode 100755 ctdb/tests/eventscripts/60.nfs.shutdown.002.sh
 copy ctdb/tests/eventscripts/{60.nfs.monitor.107.sh => 60.nfs.startup.001.sh} (100%)
 create mode 100755 ctdb/tests/eventscripts/60.nfs.startup.002.sh
 copy ctdb/tests/eventscripts/{60.nfs.monitor.107.sh => 60.nfs.takeip.001.sh} (100%)
 create mode 100755 ctdb/tests/eventscripts/60.nfs.takeip.002.sh


Changeset truncated at 500 lines:

diff --git a/ctdb/config/events.d/60.nfs b/ctdb/config/events.d/60.nfs
index 02d6e2b..98a18c3 100755
--- a/ctdb/config/events.d/60.nfs
+++ b/ctdb/config/events.d/60.nfs
@@ -256,20 +256,20 @@ is_ctdb_managed_service || exit 0
 
 case "$1" in
 startup)
-	nfs_callout "$@"
+	nfs_callout "$@" || exit $?
 	;;
 
 shutdown)
-	 nfs_callout "$@"
+	nfs_callout "$@" || exit $?
 	;;
 
 takeip)
-	nfs_callout "$@"
+	nfs_callout "$@" || exit $?
 	ctdb_service_set_reconfigure
 	;;
 
 releaseip)
-	nfs_callout "$@"
+	nfs_callout "$@" || exit $?
 	ctdb_service_set_reconfigure
 	;;
 
diff --git a/ctdb/tests/eventscripts/60.nfs.monitor.107.sh b/ctdb/tests/eventscripts/06.nfs.releaseip.001.sh
similarity index 100%
copy from ctdb/tests/eventscripts/60.nfs.monitor.107.sh
copy to ctdb/tests/eventscripts/06.nfs.releaseip.001.sh
diff --git a/ctdb/tests/eventscripts/06.nfs.releaseip.002.sh b/ctdb/tests/eventscripts/06.nfs.releaseip.002.sh
new file mode 100755
index 0000000..c0b8939
--- /dev/null
+++ b/ctdb/tests/eventscripts/06.nfs.releaseip.002.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "callout is 'false', causes releaseip-pre to fail"
+
+setup_nfs
+
+export CTDB_NFS_CALLOUT="echo releaseip-pre ; false"
+
+required_result 1 "releaseip-pre"
+simple_test
diff --git a/ctdb/tests/eventscripts/60.nfs.monitor.107.sh b/ctdb/tests/eventscripts/06.nfs.takeip.001.sh
similarity index 100%
copy from ctdb/tests/eventscripts/60.nfs.monitor.107.sh
copy to ctdb/tests/eventscripts/06.nfs.takeip.001.sh
diff --git a/ctdb/tests/eventscripts/06.nfs.takeip.002.sh b/ctdb/tests/eventscripts/06.nfs.takeip.002.sh
new file mode 100755
index 0000000..1baf351
--- /dev/null
+++ b/ctdb/tests/eventscripts/06.nfs.takeip.002.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "callout is 'false', causes takeip-pre to fail"
+
+setup_nfs
+
+export CTDB_NFS_CALLOUT="echo takeip-pre ; false"
+
+required_result 1 "takeip-pre"
+simple_test
diff --git a/ctdb/tests/eventscripts/60.nfs.monitor.109.sh b/ctdb/tests/eventscripts/60.nfs.monitor.109.sh
new file mode 100755
index 0000000..a86f6d9
--- /dev/null
+++ b/ctdb/tests/eventscripts/60.nfs.monitor.109.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "callout is 'false', causes monitor-post to fail"
+
+setup_nfs
+
+export CTDB_NFS_CALLOUT="echo monitor-post ; false"
+
+required_result 1 "monitor-post"
+simple_test
diff --git a/ctdb/tests/eventscripts/60.nfs.monitor.107.sh b/ctdb/tests/eventscripts/60.nfs.releaseip.001.sh
similarity index 100%
copy from ctdb/tests/eventscripts/60.nfs.monitor.107.sh
copy to ctdb/tests/eventscripts/60.nfs.releaseip.001.sh
diff --git a/ctdb/tests/eventscripts/60.nfs.releaseip.002.sh b/ctdb/tests/eventscripts/60.nfs.releaseip.002.sh
new file mode 100755
index 0000000..68f636f
--- /dev/null
+++ b/ctdb/tests/eventscripts/60.nfs.releaseip.002.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "callout is 'false', causes releaseip to fail"
+
+setup_nfs
+
+export CTDB_NFS_CALLOUT="echo releaseip ; false"
+
+required_result 1 "releaseip"
+simple_test
diff --git a/ctdb/tests/eventscripts/60.nfs.monitor.107.sh b/ctdb/tests/eventscripts/60.nfs.shutdown.001.sh
similarity index 100%
copy from ctdb/tests/eventscripts/60.nfs.monitor.107.sh
copy to ctdb/tests/eventscripts/60.nfs.shutdown.001.sh
diff --git a/ctdb/tests/eventscripts/60.nfs.shutdown.002.sh b/ctdb/tests/eventscripts/60.nfs.shutdown.002.sh
new file mode 100755
index 0000000..b8bb560
--- /dev/null
+++ b/ctdb/tests/eventscripts/60.nfs.shutdown.002.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "callout is 'false', causes shutdown to fail"
+
+setup_nfs
+
+export CTDB_NFS_CALLOUT="echo shutdown ; false"
+
+required_result 1 "shutdown"
+simple_test
diff --git a/ctdb/tests/eventscripts/60.nfs.monitor.107.sh b/ctdb/tests/eventscripts/60.nfs.startup.001.sh
similarity index 100%
copy from ctdb/tests/eventscripts/60.nfs.monitor.107.sh
copy to ctdb/tests/eventscripts/60.nfs.startup.001.sh
diff --git a/ctdb/tests/eventscripts/60.nfs.startup.002.sh b/ctdb/tests/eventscripts/60.nfs.startup.002.sh
new file mode 100755
index 0000000..e020c9d
--- /dev/null
+++ b/ctdb/tests/eventscripts/60.nfs.startup.002.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "callout is 'false', causes startup to fail"
+
+setup_nfs
+
+export CTDB_NFS_CALLOUT="echo startup ; false"
+
+required_result 1 "startup"
+simple_test
diff --git a/ctdb/tests/eventscripts/60.nfs.monitor.107.sh b/ctdb/tests/eventscripts/60.nfs.takeip.001.sh
similarity index 100%
copy from ctdb/tests/eventscripts/60.nfs.monitor.107.sh
copy to ctdb/tests/eventscripts/60.nfs.takeip.001.sh
diff --git a/ctdb/tests/eventscripts/60.nfs.takeip.002.sh b/ctdb/tests/eventscripts/60.nfs.takeip.002.sh
new file mode 100755
index 0000000..4fc3f72
--- /dev/null
+++ b/ctdb/tests/eventscripts/60.nfs.takeip.002.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "callout is 'false', causes takeip to fail"
+
+setup_nfs
+
+export CTDB_NFS_CALLOUT="echo takeip ; false"
+
+required_result 1 "takeip"
+simple_test
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/smbXcli_base.c b/libcli/smb/smbXcli_base.c
index a7b24f0..593edf9 100644
--- a/libcli/smb/smbXcli_base.c
+++ b/libcli/smb/smbXcli_base.c
@@ -5321,6 +5321,21 @@ static void smb2cli_validate_negotiate_info_done(struct tevent_req *subreq)
 		tevent_req_done(req);
 		return;
 	}
+	if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) {
+		/*
+		 * The response was signed, but not supported
+		 *
+		 * This might be returned by older Windows versions or by
+		 * NetApp SMB server implementations.
+		 *
+		 * See
+		 *
+		 * https://blogs.msdn.microsoft.com/openspecification/2012/06/28/smb3-secure-dialect-negotiation/
+		 *
+		 */
+		tevent_req_done(req);
+		return;
+	}
 	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/util.c b/libcli/smb/util.c
index ef8c9fa..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, true,
-				       buf, buf_len, _buf_consumed);
+				       buf, buf_len, position, _consumed);
 }
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index a2362ce..ef03da1 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)
 		subreq, struct tevent_req);
 	struct cli_sesssetup_blob_state *state = tevent_req_data(
 		req, struct cli_sesssetup_blob_state);
-	struct cli_state *cli = state->cli;
 	NTSTATUS status;
 
 	if (smbXcli_conn_protocol(state->cli->conn) >= PROTOCOL_SMB2_02) {
@@ -784,15 +815,16 @@ static void cli_sesssetup_blob_done(struct tevent_req *subreq)
 		return;
 	}
 
-	if (cli->server_os == NULL) {
-		cli->server_os = talloc_move(cli, &state->out_native_os);
-	}
-	if (cli->server_type == NULL) {
-		cli->server_type = talloc_move(cli, &state->out_native_lm);
-	}
-
 	state->status = status;
 
+	status = cli_state_update_after_sesssetup(state->cli,
+						  state->out_native_os,
+						  state->out_native_lm,
+						  NULL);
+	if (tevent_req_nterror(req, status)) {
+		return;
+	}
+
 	if (state->blob.length != 0) {
 		/*
 		 * More to send
@@ -1667,14 +1699,12 @@ static void cli_session_setup_creds_done_nt1(struct tevent_req *subreq)
 		return;
 	}
 
-	if (cli->server_os == NULL) {
-		cli->server_os = talloc_move(cli, &state->out_native_os);
-	}
-	if (cli->server_type == NULL) {
-		cli->server_type = talloc_move(cli, &state->out_native_lm);
-	}
-	if (cli->server_domain == NULL) {
-		cli->server_domain = talloc_move(cli, &state->out_primary_domain);
+	status = cli_state_update_after_sesssetup(state->cli,
+						  state->out_native_os,
+						  state->out_native_lm,
+						  state->out_primary_domain);
+	if (tevent_req_nterror(req, status)) {
+		return;
 	}
 
 	ok = smb1cli_conn_activate_signing(cli->conn,
@@ -1707,7 +1737,6 @@ static void cli_session_setup_creds_done_lm21(struct tevent_req *subreq)
 		subreq, struct tevent_req);
 	struct cli_session_setup_creds_state *state = tevent_req_data(
 		req, struct cli_session_setup_creds_state);
-	struct cli_state *cli = state->cli;
 	NTSTATUS status;
 
 	status = smb1cli_session_setup_lm21_recv(subreq, state,
@@ -1720,11 +1749,12 @@ static void cli_session_setup_creds_done_lm21(struct tevent_req *subreq)
 		return;
 	}
 
-	if (cli->server_os == NULL) {
-		cli->server_os = talloc_move(cli, &state->out_native_os);
-	}
-	if (cli->server_type == NULL) {
-		cli->server_type = talloc_move(cli, &state->out_native_lm);
+	status = cli_state_update_after_sesssetup(state->cli,
+						  state->out_native_os,
+						  state->out_native_lm,
+						  NULL);
+	if (tevent_req_nterror(req, status)) {
+		return;
 	}
 
 	tevent_req_done(req);


-- 
Samba Shared Repository



More information about the samba-cvs mailing list