summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2018-07-18 15:36:31 +0200
committerKarolin Seeger <kseeger@samba.org>2018-07-28 06:16:14 +0200
commitb2a3582fe05e3bf66a006318876966d9bc516351 (patch)
treeedcc2b97374a595849d73b1fdc83b65991c3f206 /source4
parent3f03c9a39bfad3ff456245b606cb35ae028ae9e7 (diff)
downloadsamba-b2a3582fe05e3bf66a006318876966d9bc516351.tar.gz
s4:libcli: split out smb_raw_negotiate_fill_transport()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13308 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org> (cherry picked from commit 17b12a9b9a9dfd859679de77aa0c7ffbc782f1bc)
Diffstat (limited to 'source4')
-rw-r--r--source4/libcli/raw/rawnegotiate.c74
1 files changed, 44 insertions, 30 deletions
diff --git a/source4/libcli/raw/rawnegotiate.c b/source4/libcli/raw/rawnegotiate.c
index f6a189ff8d7..655d5f20096 100644
--- a/source4/libcli/raw/rawnegotiate.c
+++ b/source4/libcli/raw/rawnegotiate.c
@@ -28,6 +28,47 @@
#include "../libcli/smb/smbXcli_base.h"
#include "../lib/util/tevent_ntstatus.h"
+NTSTATUS smb_raw_negotiate_fill_transport(struct smbcli_transport *transport)
+{
+ struct smbcli_negotiate *n = &transport->negotiate;
+ struct smbXcli_conn *c = transport->conn;
+ NTTIME ntt;
+
+ n->protocol = smbXcli_conn_protocol(c);
+ if (n->protocol > PROTOCOL_NT1) {
+ return NT_STATUS_REVISION_MISMATCH;
+ }
+
+ n->sec_mode = smb1cli_conn_server_security_mode(c);
+ n->max_mux = smbXcli_conn_max_requests(c);
+ n->max_xmit = smb1cli_conn_max_xmit(c);
+ n->sesskey = smb1cli_conn_server_session_key(c);
+ n->capabilities = smb1cli_conn_capabilities(c);;
+
+ /* this time arrives in real GMT */
+ ntt = smbXcli_conn_server_system_time(c);
+ n->server_time = nt_time_to_unix(ntt);
+ n->server_zone = smb1cli_conn_server_time_zone(c);
+
+ if (n->capabilities & CAP_EXTENDED_SECURITY) {
+ const DATA_BLOB *b = smbXcli_conn_server_gss_blob(c);
+ if (b) {
+ n->secblob = *b;
+ }
+ } else {
+ const uint8_t *p = smb1cli_conn_server_challenge(c);
+ if (p) {
+ n->secblob = data_blob_const(p, 8);
+ }
+ }
+
+ n->readbraw_supported = smb1cli_conn_server_readbraw(c);
+ n->readbraw_supported = smb1cli_conn_server_writebraw(c);
+ n->lockread_supported = smb1cli_conn_server_lockread(c);
+
+ return NT_STATUS_OK;
+}
+
struct smb_raw_negotiate_state {
struct smbcli_transport *transport;
};
@@ -78,10 +119,7 @@ static void smb_raw_negotiate_done(struct tevent_req *subreq)
struct smb_raw_negotiate_state *state =
tevent_req_data(req,
struct smb_raw_negotiate_state);
- struct smbcli_negotiate *n = &state->transport->negotiate;
- struct smbXcli_conn *c = state->transport->conn;
NTSTATUS status;
- NTTIME ntt;
status = smbXcli_negprot_recv(subreq);
TALLOC_FREE(subreq);
@@ -89,35 +127,11 @@ static void smb_raw_negotiate_done(struct tevent_req *subreq)
return;
}
- n->protocol = smbXcli_conn_protocol(c);
-
- n->sec_mode = smb1cli_conn_server_security_mode(c);
- n->max_mux = smbXcli_conn_max_requests(c);
- n->max_xmit = smb1cli_conn_max_xmit(c);
- n->sesskey = smb1cli_conn_server_session_key(c);
- n->capabilities = smb1cli_conn_capabilities(c);;
-
- /* this time arrives in real GMT */
- ntt = smbXcli_conn_server_system_time(c);
- n->server_time = nt_time_to_unix(ntt);
- n->server_zone = smb1cli_conn_server_time_zone(c);
-
- if (n->capabilities & CAP_EXTENDED_SECURITY) {
- const DATA_BLOB *b = smbXcli_conn_server_gss_blob(c);
- if (b) {
- n->secblob = *b;
- }
- } else {
- const uint8_t *p = smb1cli_conn_server_challenge(c);
- if (p) {
- n->secblob = data_blob_const(p, 8);
- }
+ status = smb_raw_negotiate_fill_transport(state->transport);
+ if (tevent_req_nterror(req, status)) {
+ return;
}
- n->readbraw_supported = smb1cli_conn_server_readbraw(c);
- n->readbraw_supported = smb1cli_conn_server_writebraw(c);
- n->lockread_supported = smb1cli_conn_server_lockread(c);
-
tevent_req_done(req);
}