s3:libsmb: also remember the optional server name from the negprot response
authorStefan Metzmacher <metze@samba.org>
Fri, 4 Nov 2011 11:59:54 +0000 (12:59 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 4 Nov 2011 13:16:29 +0000 (14:16 +0100)
W2K (at least sp4) and higher also send the server name.

metze

source3/include/client.h
source3/libsmb/cliconnect.c

index 37c1dcda447e9fd03abbeab3dad3eb9ed8d419a1..65da738e2282a55ce1d8f44a88ee4ef4cdd9c166 100644 (file)
@@ -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;
index 30403869e73cebaa86be30c4c617f7a9a8a6a705..af6c51b7b5345d72a2fb48191e2009da1931d1c9 100644 (file)
@@ -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;