summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2010-07-17 10:22:04 -0400
committerAndrew Bartlett <abartlet@samba.org>2010-07-19 14:20:02 +1000
commit673fcfa3775ac6bdc467dde0bcf6670966cab50c (patch)
tree38c12ffc79ac081320ba382cf23fc227324ebc67
parente60ed80754f1f51c74bc338cc3a81d12f49d9687 (diff)
downloadsamba-673fcfa3775ac6bdc467dde0bcf6670966cab50c.tar.gz
samba-673fcfa3775ac6bdc467dde0bcf6670966cab50c.tar.xz
samba-673fcfa3775ac6bdc467dde0bcf6670966cab50c.zip
s3-auth: auth_make ntlmssp_state the parent context
There is no need for a separate mem_ctx member. Also make the ntlmssp_state a children of auth_ntlmssp_state Also cleanup auth_ntlmssp_end to free only what is not automatically freed Signed-off-by: Andrew Bartlett <abartlet@samba.org>
-rw-r--r--source3/auth/auth_ntlmssp.c41
1 files changed, 12 insertions, 29 deletions
diff --git a/source3/auth/auth_ntlmssp.c b/source3/auth/auth_ntlmssp.c
index 44e93201917..d389ee7c1f8 100644
--- a/source3/auth/auth_ntlmssp.c
+++ b/source3/auth/auth_ntlmssp.c
@@ -24,7 +24,6 @@
#include "../libcli/auth/ntlmssp.h"
struct auth_ntlmssp_state {
- TALLOC_CTX *mem_ctx;
struct auth_context *auth_context;
struct auth_serversupplied_info *server_info;
struct ntlmssp_state *ntlmssp_state;
@@ -241,14 +240,14 @@ static NTSTATUS auth_ntlmssp_check_password(struct ntlmssp_state *ntlmssp_state,
if (auth_ntlmssp_state->server_info->user_session_key.length) {
DEBUG(10, ("Got NT session key of length %u\n",
(unsigned int)auth_ntlmssp_state->server_info->user_session_key.length));
- *user_session_key = data_blob_talloc(auth_ntlmssp_state->mem_ctx,
+ *user_session_key = data_blob_talloc(auth_ntlmssp_state,
auth_ntlmssp_state->server_info->user_session_key.data,
auth_ntlmssp_state->server_info->user_session_key.length);
}
if (auth_ntlmssp_state->server_info->lm_session_key.length) {
DEBUG(10, ("Got LM session key of length %u\n",
(unsigned int)auth_ntlmssp_state->server_info->lm_session_key.length));
- *lm_session_key = data_blob_talloc(auth_ntlmssp_state->mem_ctx,
+ *lm_session_key = data_blob_talloc(auth_ntlmssp_state,
auth_ntlmssp_state->server_info->lm_session_key.data,
auth_ntlmssp_state->server_info->lm_session_key.length);
}
@@ -258,13 +257,14 @@ static NTSTATUS auth_ntlmssp_check_password(struct ntlmssp_state *ntlmssp_state,
NTSTATUS auth_ntlmssp_start(struct auth_ntlmssp_state **auth_ntlmssp_state)
{
NTSTATUS nt_status;
- TALLOC_CTX *mem_ctx;
bool is_standalone;
const char *netbios_name;
const char *netbios_domain;
const char *dns_name;
char *dns_domain;
struct auth_ntlmssp_state *ans;
+ struct ntlmssp_state *ntlmssp_state;
+ struct auth_context *auth_context;
if ((enum server_types)lp_server_role() == ROLE_STANDALONE) {
is_standalone = true;
@@ -281,18 +281,14 @@ NTSTATUS auth_ntlmssp_start(struct auth_ntlmssp_state **auth_ntlmssp_state)
}
dns_name = get_mydnsfullname();
- mem_ctx = talloc_init("AUTH NTLMSSP context");
-
- ans = talloc_zero(mem_ctx, struct auth_ntlmssp_state);
+ ans = talloc_zero(NULL, struct auth_ntlmssp_state);
if (!ans) {
DEBUG(0,("auth_ntlmssp_start: talloc failed!\n"));
- talloc_destroy(mem_ctx);
+ TALLOC_FREE(ntlmssp_state);
return NT_STATUS_NO_MEMORY;
}
- ans->mem_ctx = mem_ctx;
-
- nt_status = ntlmssp_server_start(NULL,
+ nt_status = ntlmssp_server_start(ans,
is_standalone,
netbios_name,
netbios_domain,
@@ -303,10 +299,11 @@ NTSTATUS auth_ntlmssp_start(struct auth_ntlmssp_state **auth_ntlmssp_state)
return nt_status;
}
- nt_status = make_auth_context_subsystem(&ans->auth_context);
+ nt_status = make_auth_context_subsystem(&auth_context);
if (!NT_STATUS_IS_OK(nt_status)) {
return nt_status;
}
+ ans->auth_context = talloc_steal(ans, auth_context);
ans->ntlmssp_state->callback_private = ans;
ans->ntlmssp_state->get_challenge = auth_ntlmssp_get_challenge;
@@ -320,25 +317,11 @@ NTSTATUS auth_ntlmssp_start(struct auth_ntlmssp_state **auth_ntlmssp_state)
void auth_ntlmssp_end(struct auth_ntlmssp_state **auth_ntlmssp_state)
{
- struct auth_ntlmssp_state *ans = *auth_ntlmssp_state;
- TALLOC_CTX *mem_ctx;
-
- if (ans == NULL) {
+ if (*auth_ntlmssp_state == NULL) {
return;
}
-
- mem_ctx = ans->mem_ctx;
- if (ans->ntlmssp_state) {
- TALLOC_FREE(ans->ntlmssp_state);
- }
- if (ans->auth_context) {
- TALLOC_FREE(ans->auth_context);
- }
- if (ans->server_info) {
- TALLOC_FREE(ans->server_info);
- }
- talloc_destroy(mem_ctx);
- *auth_ntlmssp_state = NULL;
+ TALLOC_FREE((*auth_ntlmssp_state)->server_info);
+ TALLOC_FREE(*auth_ntlmssp_state);
}
NTSTATUS auth_ntlmssp_update(struct auth_ntlmssp_state *auth_ntlmssp_state,