s3-ntlmssp Remove auth_ntlmssp_state_destructor, use the talloc tree instead
authorAndrew Bartlett <abartlet@samba.org>
Tue, 2 Aug 2011 01:28:51 +0000 (11:28 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 3 Aug 2011 08:48:05 +0000 (18:48 +1000)
source3/auth/auth_ntlmssp.c

index 584596963154c947d535ac5b7a7d4b61af8ba32e..c6f394f9147b8bf7cc039d18877181cfb7c9b58e 100644 (file)
@@ -160,9 +160,14 @@ static NTSTATUS auth_ntlmssp_check_password(struct ntlmssp_state *ntlmssp_state,
                                                        &auth_ntlmssp_state->server_info,
                                                        auth_ntlmssp_state->ntlmssp_state->user,
                                                        auth_ntlmssp_state->ntlmssp_state->domain);
+       }
+
+       if (!NT_STATUS_IS_OK(nt_status)) {
                return nt_status;
        }
 
+       talloc_steal(auth_ntlmssp_state, auth_ntlmssp_state->server_info);
+
        auth_ntlmssp_state->server_info->nss_token |= username_was_mapped;
 
        /* Clear out the session keys, and pass them to the caller.
@@ -187,8 +192,6 @@ static NTSTATUS auth_ntlmssp_check_password(struct ntlmssp_state *ntlmssp_state,
        return nt_status;
 }
 
-static int auth_ntlmssp_state_destructor(void *ptr);
-
 NTSTATUS auth_ntlmssp_prepare(const struct tsocket_address *remote_address,
                              struct auth_ntlmssp_state **auth_ntlmssp_state)
 {
@@ -264,24 +267,10 @@ NTSTATUS auth_ntlmssp_prepare(const struct tsocket_address *remote_address,
        ans->ntlmssp_state->set_challenge = auth_ntlmssp_set_challenge;
        ans->ntlmssp_state->check_password = auth_ntlmssp_check_password;
 
-       talloc_set_destructor((TALLOC_CTX *)ans, auth_ntlmssp_state_destructor);
-
        *auth_ntlmssp_state = ans;
        return NT_STATUS_OK;
 }
 
-static int auth_ntlmssp_state_destructor(void *ptr)
-{
-       struct auth_ntlmssp_state *ans;
-
-       ans = talloc_get_type(ptr, struct auth_ntlmssp_state);
-
-       TALLOC_FREE(ans->remote_address);
-       TALLOC_FREE(ans->server_info);
-       TALLOC_FREE(ans->ntlmssp_state);
-       return 0;
-}
-
 NTSTATUS auth_generic_start(struct auth_ntlmssp_state *auth_ntlmssp_state, const char *oid)
 {
        if (auth_ntlmssp_state->auth_context->gensec_start_mech_by_oid) {