diff options
author | Andrew Tridgell <tridge@samba.org> | 2004-09-26 03:50:24 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:59:16 -0500 |
commit | 9a62dce0ac2dd751c9cc3b9906eec8c4fe7c51b7 (patch) | |
tree | a6fd92fd12aae07a2bab782feecd66b4369b61f7 /source4/auth | |
parent | 764eddb69647681f784f343a122251ca1ecf62df (diff) | |
download | samba-9a62dce0ac2dd751c9cc3b9906eec8c4fe7c51b7.tar.gz samba-9a62dce0ac2dd751c9cc3b9906eec8c4fe7c51b7.tar.bz2 samba-9a62dce0ac2dd751c9cc3b9906eec8c4fe7c51b7.zip |
r2648: - use a destructor on struct server_connection to simplify the
connection termination cleanup, and to ensure that the event
contexts are properly removed for every process model
- gave auth_context the new talloc treatment, which removes another
source of memory leaks.
(This used to be commit 230e1cd777b0fba82dffcbd656cfa23c155d0560)
Diffstat (limited to 'source4/auth')
-rw-r--r-- | source4/auth/auth.c | 31 | ||||
-rw-r--r-- | source4/auth/auth.h | 1 | ||||
-rw-r--r-- | source4/auth/auth_util.c | 2 |
3 files changed, 15 insertions, 19 deletions
diff --git a/source4/auth/auth.c b/source4/auth/auth.c index 0697cee1ac..62e2b93ecb 100644 --- a/source4/auth/auth.c +++ b/source4/auth/auth.c @@ -78,7 +78,7 @@ static const uint8_t *get_ntlm_challenge(struct auth_context *auth_context) uint8_t chal[8]; generate_random_buffer(chal, sizeof(chal)); - auth_context->challenge = data_blob_talloc(auth_context->mem_ctx, + auth_context->challenge = data_blob_talloc(auth_context, chal, sizeof(chal)); challenge_set_by = "random"; @@ -269,7 +269,7 @@ void free_auth_context(struct auth_context **auth_context) } } - talloc_destroy((*auth_context)->mem_ctx); + talloc_free(*auth_context); *auth_context = NULL; } } @@ -278,21 +278,15 @@ void free_auth_context(struct auth_context **auth_context) Make a auth_info struct ***************************************************************************/ -static NTSTATUS make_auth_context(struct auth_context **auth_context) +static NTSTATUS make_auth_context(TALLOC_CTX *mem_ctx, struct auth_context **auth_context) { - TALLOC_CTX *mem_ctx; - - mem_ctx = talloc_init("authentication context"); - - *auth_context = talloc(mem_ctx, sizeof(**auth_context)); + *auth_context = talloc_p(mem_ctx, struct auth_context); if (!*auth_context) { DEBUG(0,("make_auth_context: talloc failed!\n")); - talloc_destroy(mem_ctx); return NT_STATUS_NO_MEMORY; } ZERO_STRUCTP(*auth_context); - (*auth_context)->mem_ctx = mem_ctx; (*auth_context)->check_ntlm_password = check_ntlm_password; (*auth_context)->get_ntlm_challenge = get_ntlm_challenge; @@ -303,7 +297,8 @@ static NTSTATUS make_auth_context(struct auth_context **auth_context) Make a auth_info struct for the auth subsystem ***************************************************************************/ -static NTSTATUS make_auth_context_text_list(struct auth_context **auth_context, char **text_list) +static NTSTATUS make_auth_context_text_list(TALLOC_CTX *mem_ctx, + struct auth_context **auth_context, char **text_list) { struct auth_methods *list = NULL; struct auth_methods *t = NULL; @@ -314,7 +309,7 @@ static NTSTATUS make_auth_context_text_list(struct auth_context **auth_context, return NT_STATUS_UNSUCCESSFUL; } - if (!NT_STATUS_IS_OK(nt_status = make_auth_context(auth_context))) + if (!NT_STATUS_IS_OK(nt_status = make_auth_context(mem_ctx, auth_context))) return nt_status; for (;*text_list; text_list++) { @@ -362,7 +357,7 @@ static NTSTATUS make_auth_context_text_list(struct auth_context **auth_context, Make a auth_context struct for the auth subsystem ***************************************************************************/ -NTSTATUS make_auth_context_subsystem(struct auth_context **auth_context) +NTSTATUS make_auth_context_subsystem(TALLOC_CTX *mem_ctx, struct auth_context **auth_context) { char **auth_method_list = NULL; NTSTATUS nt_status; @@ -371,7 +366,8 @@ NTSTATUS make_auth_context_subsystem(struct auth_context **auth_context) return NT_STATUS_NO_MEMORY; } - if (!NT_STATUS_IS_OK(nt_status = make_auth_context_text_list(auth_context, auth_method_list))) { + nt_status = make_auth_context_text_list(mem_ctx, auth_context, auth_method_list); + if (!NT_STATUS_IS_OK(nt_status)) { str_list_free(&auth_method_list); return nt_status; } @@ -384,14 +380,15 @@ NTSTATUS make_auth_context_subsystem(struct auth_context **auth_context) Make a auth_info struct with a fixed challenge ***************************************************************************/ -NTSTATUS make_auth_context_fixed(struct auth_context **auth_context, uint8_t chal[8]) +NTSTATUS make_auth_context_fixed(TALLOC_CTX *mem_ctx, + struct auth_context **auth_context, uint8_t chal[8]) { NTSTATUS nt_status; - if (!NT_STATUS_IS_OK(nt_status = make_auth_context_subsystem(auth_context))) { + if (!NT_STATUS_IS_OK(nt_status = make_auth_context_subsystem(mem_ctx, auth_context))) { return nt_status; } - (*auth_context)->challenge = data_blob_talloc((*auth_context)->mem_ctx, chal, 8); + (*auth_context)->challenge = data_blob_talloc(*auth_context, chal, 8); (*auth_context)->challenge_set_by = "fixed"; return nt_status; } diff --git a/source4/auth/auth.h b/source4/auth/auth.h index 6f2c7134e7..2f35b36a15 100644 --- a/source4/auth/auth.h +++ b/source4/auth/auth.h @@ -119,7 +119,6 @@ struct auth_context { /* methods, in the order they should be called */ struct auth_methods *auth_method_list; - TALLOC_CTX *mem_ctx; const uint8_t *(*get_ntlm_challenge)(struct auth_context *auth_context); NTSTATUS (*check_ntlm_password)(struct auth_context *auth_context, const struct auth_usersupplied_info *user_info, diff --git a/source4/auth/auth_util.c b/source4/auth/auth_util.c index ab725249c7..f508cff35e 100644 --- a/source4/auth/auth_util.c +++ b/source4/auth/auth_util.c @@ -512,7 +512,7 @@ BOOL make_auth_methods(struct auth_context *auth_context, struct auth_methods ** smb_panic("make_auth_methods: pointer to auth_method pointer is NULL!\n"); } - *auth_method = talloc(auth_context->mem_ctx, sizeof(**auth_method)); + *auth_method = talloc_p(auth_context, struct auth_methods); if (!*auth_method) { DEBUG(0,("make_auth_method: malloc failed!\n")); return False; |