summaryrefslogtreecommitdiff
path: root/source3/auth
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2010-07-16 18:23:55 -0400
committerAndrew Bartlett <abartlet@samba.org>2010-07-19 14:20:00 +1000
commite60ed80754f1f51c74bc338cc3a81d12f49d9687 (patch)
treee6a68ce556399746cb05e0bdb3c7ff338cf00162 /source3/auth
parente4bd6eb72fba92c0b0a3e5e636e5312629758bc1 (diff)
downloadsamba-e60ed80754f1f51c74bc338cc3a81d12f49d9687.tar.gz
samba-e60ed80754f1f51c74bc338cc3a81d12f49d9687.tar.bz2
samba-e60ed80754f1f51c74bc338cc3a81d12f49d9687.zip
s3-auth: Simplify how we free the auth_context
Turn the freeing function into a destructor and attach it to the auth_context. Make all callers TALLOC_FREE() the auth_context instead of calling the free function. Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source3/auth')
-rw-r--r--source3/auth/auth.c34
-rw-r--r--source3/auth/auth_compat.c2
-rw-r--r--source3/auth/auth_ntlmssp.c2
3 files changed, 20 insertions, 18 deletions
diff --git a/source3/auth/auth.c b/source3/auth/auth.c
index a52dab9f01..5dc1d970d6 100644
--- a/source3/auth/auth.c
+++ b/source3/auth/auth.c
@@ -322,38 +322,40 @@ static NTSTATUS check_ntlm_password(const struct auth_context *auth_context,
Clear out a auth_context, and destroy the attached TALLOC_CTX
***************************************************************************/
-static void free_auth_context(struct auth_context **auth_context)
+static int auth_context_destructor(void *ptr)
{
- auth_methods *auth_method;
+ struct auth_context *ctx = talloc_get_type(ptr, struct auth_context);
+ struct auth_methods *am;
- if (*auth_context) {
- /* Free private data of context's authentication methods */
- for (auth_method = (*auth_context)->auth_method_list; auth_method; auth_method = auth_method->next) {
- TALLOC_FREE(auth_method->private_data);
- }
- talloc_destroy(*auth_context);
- *auth_context = NULL;
+ /* Free private data of context's authentication methods */
+ for (am = ctx->auth_method_list; am; am = am->next) {
+ TALLOC_FREE(am->private_data);
}
+
+ return 0;
}
/***************************************************************************
Make a auth_info struct
***************************************************************************/
-static NTSTATUS make_auth_context(struct auth_context **auth_context)
+static NTSTATUS make_auth_context(struct auth_context **auth_context)
{
- *auth_context = TALLOC_ZERO_P(talloc_autofree_context(),
- struct auth_context);
- if (!*auth_context) {
+ struct auth_context *ctx;
+
+ ctx = talloc_zero(talloc_autofree_context(), struct auth_context);
+ if (!ctx) {
DEBUG(0,("make_auth_context: talloc failed!\n"));
return NT_STATUS_NO_MEMORY;
}
- (*auth_context)->check_ntlm_password = check_ntlm_password;
- (*auth_context)->get_ntlm_challenge = get_ntlm_challenge;
- (*auth_context)->free = free_auth_context;
+ ctx->check_ntlm_password = check_ntlm_password;
+ ctx->get_ntlm_challenge = get_ntlm_challenge;
+
+ talloc_set_destructor((TALLOC_CTX *)ctx, auth_context_destructor);
+ *auth_context = ctx;
return NT_STATUS_OK;
}
diff --git a/source3/auth/auth_compat.c b/source3/auth/auth_compat.c
index e90036f3ff..cdd4096654 100644
--- a/source3/auth/auth_compat.c
+++ b/source3/auth/auth_compat.c
@@ -59,7 +59,7 @@ NTSTATUS check_plaintext_password(const char *smb_name,
nt_status = plaintext_auth_context->check_ntlm_password(plaintext_auth_context,
user_info, server_info);
- (plaintext_auth_context->free)(&plaintext_auth_context);
+ TALLOC_FREE(plaintext_auth_context);
free_user_info(&user_info);
return nt_status;
}
diff --git a/source3/auth/auth_ntlmssp.c b/source3/auth/auth_ntlmssp.c
index 363f611431..44e9320191 100644
--- a/source3/auth/auth_ntlmssp.c
+++ b/source3/auth/auth_ntlmssp.c
@@ -332,7 +332,7 @@ void auth_ntlmssp_end(struct auth_ntlmssp_state **auth_ntlmssp_state)
TALLOC_FREE(ans->ntlmssp_state);
}
if (ans->auth_context) {
- ans->auth_context->free(&ans->auth_context);
+ TALLOC_FREE(ans->auth_context);
}
if (ans->server_info) {
TALLOC_FREE(ans->server_info);