summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2011-11-04 12:59:54 +0100
committerStefan Metzmacher <metze@samba.org>2011-11-04 14:16:29 +0100
commite99017af7211be96a702ed86502b2f8be4b31d9d (patch)
tree7aa9edea5ea85270cae71bd8eb88420c3a86a86e
parentaea76a3aaa7ea52f563e7bc8a8ed60d9651f9e34 (diff)
downloadsamba-e99017af7211be96a702ed86502b2f8be4b31d9d.tar.gz
samba-e99017af7211be96a702ed86502b2f8be4b31d9d.tar.bz2
samba-e99017af7211be96a702ed86502b2f8be4b31d9d.zip
s3:libsmb: also remember the optional server name from the negprot response
W2K (at least sp4) and higher also send the server name. metze
-rw-r--r--source3/include/client.h1
-rw-r--r--source3/libsmb/cliconnect.c25
2 files changed, 24 insertions, 2 deletions
diff --git a/source3/include/client.h b/source3/include/client.h
index 37c1dcda44..65da738e22 100644
--- a/source3/include/client.h
+++ b/source3/include/client.h
@@ -138,6 +138,7 @@ struct cli_state {
DATA_BLOB gss_blob;
uint8_t challenge[8];
const char *workgroup;
+ const char *name;
int time_zone;
time_t system_time;
} server;
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index 30403869e7..af6c51b7b5 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -2620,6 +2620,7 @@ static void cli_negprot_done(struct tevent_req *subreq)
DATA_BLOB server_gss_blob = data_blob_null;
uint8_t server_challenge[8];
char *server_workgroup = NULL;
+ char *server_name = NULL;
int server_time_zone = 0;
time_t server_system_time = 0;
enum protocol_types protocol;
@@ -2713,8 +2714,8 @@ static void cli_negprot_done(struct tevent_req *subreq)
}
server_gss_blob = blob2;
} else {
- DATA_BLOB blob1;
- ssize_t ret;
+ DATA_BLOB blob1, blob2;
+ ssize_t ret = 0;
if (num_bytes < key_len) {
tevent_req_nterror(req, NT_STATUS_INVALID_NETWORK_RESPONSE);
@@ -2731,6 +2732,7 @@ static void cli_negprot_done(struct tevent_req *subreq)
}
blob1 = data_blob_const(bytes+key_len, num_bytes-key_len);
+ blob2 = data_blob_const(bytes+key_len, num_bytes-key_len);
if (blob1.length > 0) {
ret = pull_string_talloc(state,
(char *)inbuf,
@@ -2746,6 +2748,24 @@ static void cli_negprot_done(struct tevent_req *subreq)
return;
}
}
+
+ blob2.data += ret;
+ blob2.length -= ret;
+ if (blob2.length > 0) {
+ ret = pull_string_talloc(state,
+ (char *)inbuf,
+ SVAL(inbuf, smb_flg2),
+ &server_name,
+ blob2.data,
+ blob2.length,
+ STR_TERMINATE|
+ STR_UNICODE|
+ STR_NOALIGN);
+ if (ret == -1) {
+ tevent_req_oom(req);
+ return;
+ }
+ }
}
client_signing = "disabled";
@@ -2871,6 +2891,7 @@ static void cli_negprot_done(struct tevent_req *subreq)
cli->conn.smb1.server.guid = server_guid;
memcpy(cli->conn.smb1.server.challenge, server_challenge, 8);
cli->conn.smb1.server.workgroup = talloc_move(cli, &server_workgroup);
+ cli->conn.smb1.server.name = talloc_move(cli, &server_name);
cli->conn.smb1.server.time_zone = server_time_zone;
cli->conn.smb1.server.system_time = server_system_time;