Turn auth_ntlmssp_end into a destructor and attach it to auth_ntlmssp_state.
Remote auth_ntlmssp_end and use TALLOC_FREE in the callers.
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
return nt_status;
}
+static int auth_ntlmssp_state_destructor(void *ptr);
+
NTSTATUS auth_ntlmssp_start(struct auth_ntlmssp_state **auth_ntlmssp_state)
{
NTSTATUS nt_status;
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;
}
-void auth_ntlmssp_end(struct auth_ntlmssp_state **auth_ntlmssp_state)
+static int auth_ntlmssp_state_destructor(void *ptr)
{
- if (*auth_ntlmssp_state == NULL) {
- return;
- }
- TALLOC_FREE((*auth_ntlmssp_state)->server_info);
- TALLOC_FREE(*auth_ntlmssp_state);
+ struct auth_ntlmssp_state *ans;
+
+ ans = talloc_get_type(ptr, struct auth_ntlmssp_state);
+
+ TALLOC_FREE(ans->server_info);
+ TALLOC_FREE(ans->ntlmssp_state);
+ return 0;
}
NTSTATUS auth_ntlmssp_update(struct auth_ntlmssp_state *auth_ntlmssp_state,
void auth_ntlmssp_want_sign(struct auth_ntlmssp_state *auth_ntlmssp_state);
void auth_ntlmssp_want_seal(struct auth_ntlmssp_state *auth_ntlmssp_state);
NTSTATUS auth_ntlmssp_start(struct auth_ntlmssp_state **auth_ntlmssp_state);
-void auth_ntlmssp_end(struct auth_ntlmssp_state **auth_ntlmssp_state);
NTSTATUS auth_ntlmssp_update(struct auth_ntlmssp_state *auth_ntlmssp_state,
const DATA_BLOB request, DATA_BLOB *reply) ;
NTSTATUS auth_ntlmssp_sign_packet(struct auth_ntlmssp_state *auth_ntlmssp_state,
static void free_pipe_ntlmssp_auth_data(struct pipe_auth_data *auth)
{
- struct auth_ntlmssp_state *a = auth->a_u.auth_ntlmssp_state;
-
- if (a) {
- auth_ntlmssp_end(&a);
- }
- auth->a_u.auth_ntlmssp_state = NULL;
+ TALLOC_FREE(auth->a_u.auth_ntlmssp_state);
}
static DATA_BLOB generic_session_key(void)
session_yield(vuser);
if (vuser->auth_ntlmssp_state) {
- auth_ntlmssp_end(&vuser->auth_ntlmssp_state);
+ TALLOC_FREE(vuser->auth_ntlmssp_state);
}
DLIST_REMOVE(sconn->smb1.sessions.validated_users, vuser);
*/
if (ec->auth_ntlmssp_state) {
- auth_ntlmssp_end(&ec->auth_ntlmssp_state);
+ TALLOC_FREE(ec->auth_ntlmssp_state);
/* The auth_ntlmssp_end killed this already. */
ec->es->s.ntlmssp_state = NULL;
}
if (!NT_STATUS_EQUAL(nt_status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
/* NB. This is *NOT* an error case. JRA */
if (do_invalidate) {
- auth_ntlmssp_end(auth_ntlmssp_state);
+ TALLOC_FREE(*auth_ntlmssp_state);
if (!NT_STATUS_IS_OK(nt_status)) {
/* Kill the intermediate vuid */
invalidate_vuid(sconn, vuid);
#endif
if (*auth_ntlmssp_state) {
- auth_ntlmssp_end(auth_ntlmssp_state);
+ TALLOC_FREE(*auth_ntlmssp_state);
}
if (kerb_mech) {
NTSTATUS status;
/* Ensure we have no old NTLM state around. */
- auth_ntlmssp_end(&session->auth_ntlmssp_state);
+ TALLOC_FREE(session->auth_ntlmssp_state);
status = parse_spnego_mechanisms(in_security_buffer,
&secblob_in, &kerb_mech);
if (!NT_STATUS_IS_OK(status) &&
!NT_STATUS_EQUAL(status,
NT_STATUS_MORE_PROCESSING_REQUIRED)) {
- auth_ntlmssp_end(&session->auth_ntlmssp_state);
+ TALLOC_FREE(session->auth_ntlmssp_state);
TALLOC_FREE(session);
}
return status;
session->compat_vuser = talloc_zero(session, user_struct);
if (session->compat_vuser == NULL) {
- auth_ntlmssp_end(&session->auth_ntlmssp_state);
+ TALLOC_FREE(session->auth_ntlmssp_state);
TALLOC_FREE(session);
return NT_STATUS_NO_MEMORY;
}
DEBUG(1, ("smb2: Failed to claim session "
"for vuid=%d\n",
session->compat_vuser->vuid));
- auth_ntlmssp_end(&session->auth_ntlmssp_state);
+ TALLOC_FREE(session->auth_ntlmssp_state);
TALLOC_FREE(session);
return NT_STATUS_LOGON_FAILURE;
}
if (!NT_STATUS_IS_OK(status) &&
!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
- auth_ntlmssp_end(&session->auth_ntlmssp_state);
+ TALLOC_FREE(session->auth_ntlmssp_state);
data_blob_free(&auth);
TALLOC_FREE(session);
return status;
secblob_out.data,
secblob_out.length);
if (secblob_out.data && out_security_buffer->data == NULL) {
- auth_ntlmssp_end(&session->auth_ntlmssp_state);
+ TALLOC_FREE(session->auth_ntlmssp_state);
TALLOC_FREE(session);
return NT_STATUS_NO_MEMORY;
}
secblob_out.data,
secblob_out.length);
if (secblob_out.data && out_security_buffer->data == NULL) {
- auth_ntlmssp_end(&session->auth_ntlmssp_state);
+ TALLOC_FREE(session->auth_ntlmssp_state);
TALLOC_FREE(session);
return NT_STATUS_NO_MEMORY;
}
status = setup_ntlmssp_server_info(session, status);
if (!NT_STATUS_IS_OK(status)) {
- auth_ntlmssp_end(&session->auth_ntlmssp_state);
+ TALLOC_FREE(session->auth_ntlmssp_state);
TALLOC_FREE(session);
return status;
}
/* Unknown packet type. */
DEBUG(1,("Unknown packet type %u in smb2 sessionsetup\n",
(unsigned int)in_security_buffer.data[0] ));
- auth_ntlmssp_end(&session->auth_ntlmssp_state);
+ TALLOC_FREE(session->auth_ntlmssp_state);
TALLOC_FREE(session);
return NT_STATUS_LOGON_FAILURE;
}