s3: Add the session key to the ccache_ntlm_auth response
authorVolker Lendecke <vl@samba.org>
Sun, 24 Jan 2010 15:41:30 +0000 (16:41 +0100)
committerKarolin Seeger <kseeger@samba.org>
Tue, 26 Jan 2010 13:55:33 +0000 (14:55 +0100)
(cherry picked from commit 99f6f322ae5aa13596c5b0f1a6e600b6fec48896)

nsswitch/winbind_struct_protocol.h
source3/winbindd/winbindd_ccache_access.c

index 7790155f251db928ce8c0a95e46139a03d6a53bd..2e0751f79a721372f23d0e83e0362d40ec885f14 100644 (file)
@@ -48,7 +48,8 @@ typedef char fstring[FSTRING_LEN];
  * 21: added WINBINDD_GETPWSID
  *     added WINBINDD_GETSIDALIASES
  * 22: added WINBINDD_PING_DC
- * 23: added WINBINDD_CCACHE_SAVE
+ * 23: added session_key to ccache_ntlm_auth response
+ *     added WINBINDD_CCACHE_SAVE
  */
 #define WINBIND_INTERFACE_VERSION 23
 
@@ -485,6 +486,7 @@ struct winbindd_response {
                        uint32_t group_rid;
                } user_info;
                struct {
+                       uint8_t session_key[16];
                        uint32_t auth_blob_len; /* blob in extra_data */
                } ccache_ntlm_auth;
                struct {
index 7435c2667303cdad4557c41e977e7fd9d4846948..b36b067851bb7098447911847b6a2a84c081383d 100644 (file)
@@ -46,7 +46,8 @@ static NTSTATUS do_ntlm_auth_with_hashes(const char *username,
                                        const unsigned char nt_hash[NT_HASH_LEN],
                                        const DATA_BLOB initial_msg,
                                        const DATA_BLOB challenge_msg,
-                                       DATA_BLOB *auth_msg)
+                                       DATA_BLOB *auth_msg,
+                                       uint8_t session_key[16])
 {
        NTSTATUS status;
        NTLMSSP_STATE *ntlmssp_state = NULL;
@@ -84,6 +85,8 @@ static NTSTATUS do_ntlm_auth_with_hashes(const char *username,
                goto done;
        }
 
+       ntlmssp_want_feature(ntlmssp_state, NTLMSSP_FEATURE_SESSION_KEY);
+
        /* We need to get our protocol handler into the right state. So first
           we ask it to generate the initial message. Actually the client has already
           sent its own initial message, so we're going to drop this one on the floor.
@@ -115,7 +118,16 @@ static NTSTATUS do_ntlm_auth_with_hashes(const char *username,
                data_blob_free(&reply);
                goto done;
        }
+
+       if (ntlmssp_state->session_key.length != 16) {
+               DEBUG(1, ("invalid session key length %d\n",
+                         (int)ntlmssp_state->session_key.length));
+               data_blob_free(&reply);
+               goto done;
+       }
+
        *auth_msg = data_blob(reply.data, reply.length);
+       memcpy(session_key, ntlmssp_state->session_key.data, 16);
        status = NT_STATUS_OK;
 
 done:
@@ -257,9 +269,10 @@ enum winbindd_result winbindd_dual_ccache_ntlm_auth(struct winbindd_domain *doma
        if (!initial.data || !challenge.data) {
                result = NT_STATUS_NO_MEMORY;
        } else {
-               result = do_ntlm_auth_with_hashes(name_user, name_domain,
-                                               entry->lm_hash, entry->nt_hash,
-                                               initial, challenge, &auth);
+               result = do_ntlm_auth_with_hashes(
+                       name_user, name_domain, entry->lm_hash, entry->nt_hash,
+                       initial, challenge, &auth,
+                       state->response->data.ccache_ntlm_auth.session_key);
        }
 
        data_blob_free(&initial);