The previous patch (NTLMSSP common code factoring) was missing a minor detail -
authorAndrew Bartlett <abartlet@samba.org>
Tue, 28 Jan 2003 05:13:07 +0000 (05:13 +0000)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 28 Jan 2003 05:13:07 +0000 (05:13 +0000)
testing :-).  This gets the 'signiture' after the extended security blob,
rather than over the top of it.

Also move that code to the top of the file, with some of the other util functions.

Andrew Bartlett

source/smbd/sesssetup.c

index 23a44d8df7cfeaabf7f119ff887bc94d4ea617eb..51bdfd6354c18e371f87ac7a235cce3b9e76dddd 100644 (file)
@@ -68,6 +68,37 @@ static void add_signature(char *outbuf)
        set_message_end(outbuf,p);
 }
 
+/****************************************************************************
+send a security blob via a session setup reply
+****************************************************************************/
+static BOOL reply_sesssetup_blob(connection_struct *conn, char *outbuf,
+                                DATA_BLOB blob, NTSTATUS nt_status)
+{
+       char *p;
+
+       set_message(outbuf,4,0,True);
+
+       /* we set NT_STATUS_MORE_PROCESSING_REQUIRED to tell the other end
+          that we aren't finished yet */
+
+       nt_status = nt_status_squash(nt_status);
+       SIVAL(outbuf, smb_rcls, NT_STATUS_V(nt_status));
+       SSVAL(outbuf, smb_vwv0, 0xFF); /* no chaining possible */
+       SSVAL(outbuf, smb_vwv3, blob.length);
+       p = smb_buf(outbuf);
+
+       /* should we cap this? */
+       memcpy(p, blob.data, blob.length);
+       p += blob.length;
+
+       p += srvstr_push(outbuf, p, "Unix", -1, STR_TERMINATE);
+       p += srvstr_push(outbuf, p, "Samba", -1, STR_TERMINATE);
+       p += srvstr_push(outbuf, p, lp_workgroup(), -1, STR_TERMINATE);
+       set_message_end(outbuf,p);
+
+       return send_smb(smbd_server_fd(),outbuf);
+}
+
 /****************************************************************************
  Do a 'guest' logon, getting back the 
 ****************************************************************************/
@@ -209,31 +240,6 @@ static int reply_spnego_kerberos(connection_struct *conn,
 #endif
 
 
-/****************************************************************************
-send a security blob via a session setup reply
-****************************************************************************/
-static BOOL reply_sesssetup_blob(connection_struct *conn, char *outbuf,
-                                DATA_BLOB blob, NTSTATUS nt_status)
-{
-       char *p;
-
-       set_message(outbuf,4,0,True);
-
-       /* we set NT_STATUS_MORE_PROCESSING_REQUIRED to tell the other end
-          that we aren't finished yet */
-
-       nt_status = nt_status_squash(nt_status);
-       SIVAL(outbuf, smb_rcls, NT_STATUS_V(nt_status));
-       SSVAL(outbuf, smb_vwv0, 0xFF); /* no chaining possible */
-       SSVAL(outbuf, smb_vwv3, blob.length);
-       p = smb_buf(outbuf);
-       memcpy(p, blob.data, blob.length);
-
-       add_signature(outbuf);
-       
-       return send_smb(smbd_server_fd(),outbuf);
-}
-
 /****************************************************************************
  send a session setup reply, wrapped in SPNEGO.
  get vuid and check first.
@@ -243,6 +249,7 @@ static BOOL reply_spnego_ntlmssp(connection_struct *conn, char *outbuf,
                                 AUTH_NTLMSSP_STATE **auth_ntlmssp_state,
                                 DATA_BLOB *ntlmssp_blob, NTSTATUS nt_status) 
 {
+       BOOL ret;
        DATA_BLOB response;
        struct auth_serversupplied_info *server_info;
        server_info = (*auth_ntlmssp_state)->server_info;
@@ -274,14 +281,14 @@ static BOOL reply_spnego_ntlmssp(connection_struct *conn, char *outbuf,
        }
 
         response = spnego_gen_auth_response(ntlmssp_blob, nt_status);
-       reply_sesssetup_blob(conn, outbuf, response, nt_status);
+       ret = reply_sesssetup_blob(conn, outbuf, response, nt_status);
        data_blob_free(&response);
 
-       if (!NT_STATUS_EQUAL(nt_status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
+       if (!ret || !NT_STATUS_EQUAL(nt_status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
                auth_ntlmssp_end(&global_ntlmssp_state);
        }
 
-       return True;
+       return ret;
 }
 
 /****************************************************************************