diff options
Diffstat (limited to 'source4/auth')
-rw-r--r-- | source4/auth/auth.c | 27 | ||||
-rw-r--r-- | source4/auth/auth.h | 3 | ||||
-rw-r--r-- | source4/auth/auth_simple.c | 17 | ||||
-rw-r--r-- | source4/auth/gensec/gensec.c | 37 | ||||
-rw-r--r-- | source4/auth/gensec/gensec.h | 1 | ||||
-rw-r--r-- | source4/auth/ntlmssp/ntlmssp_server.c | 5 |
6 files changed, 63 insertions, 27 deletions
diff --git a/source4/auth/auth.c b/source4/auth/auth.c index d3b9e28f7b..e478ac250b 100644 --- a/source4/auth/auth.c +++ b/source4/auth/auth.c @@ -360,8 +360,9 @@ NTSTATUS auth_check_password_recv(struct auth_check_password_request *req, Make a auth_info struct for the auth subsystem ***************************************************************************/ NTSTATUS auth_context_create(TALLOC_CTX *mem_ctx, const char **methods, - struct auth_context **auth_ctx, - struct event_context *ev) + struct event_context *ev, + struct messaging_context *msg, + struct auth_context **auth_ctx) { int i; struct auth_context *ctx; @@ -371,22 +372,24 @@ NTSTATUS auth_context_create(TALLOC_CTX *mem_ctx, const char **methods, return NT_STATUS_INTERNAL_ERROR; } + if (!ev) { + DEBUG(0,("auth_context_create: called with out event context\n")); + return NT_STATUS_INTERNAL_ERROR; + } + + if (!msg) { + DEBUG(0,("auth_context_create: called with out messaging context\n")); + return NT_STATUS_INTERNAL_ERROR; + } + ctx = talloc(mem_ctx, struct auth_context); NT_STATUS_HAVE_NO_MEMORY(ctx); ctx->challenge.set_by = NULL; ctx->challenge.may_be_modified = False; ctx->challenge.data = data_blob(NULL, 0); ctx->methods = NULL; - - if (ev == NULL) { - ev = event_context_init(ctx); - if (ev == NULL) { - talloc_free(ctx); - return NT_STATUS_NO_MEMORY; - } - } - - ctx->event_ctx = ev; + ctx->event_ctx = ev; + ctx->msg_ctx = msg; for (i=0; methods[i] ; i++) { struct auth_method_context *method; diff --git a/source4/auth/auth.h b/source4/auth/auth.h index 7ebab9c8e1..badfe14762 100644 --- a/source4/auth/auth.h +++ b/source4/auth/auth.h @@ -171,6 +171,9 @@ struct auth_context { /* the event context to use for calls that can block */ struct event_context *event_ctx; + + /* the messaging context which can be used by backends */ + struct messaging_context *msg_ctx; }; /* this structure is used by backends to determine the size of some critical types */ diff --git a/source4/auth/auth_simple.c b/source4/auth/auth_simple.c index 4448e227e7..a0bb636bb6 100644 --- a/source4/auth/auth_simple.c +++ b/source4/auth/auth_simple.c @@ -26,11 +26,13 @@ #include "auth/auth.h" #include "lib/events/events.h" -_PUBLIC_ NTSTATUS authenticate_username_pw(TALLOC_CTX *mem_ctx, - const char *nt4_domain, - const char *nt4_username, - const char *password, - struct auth_session_info **session_info) +_PUBLIC_ NTSTATUS authenticate_username_pw(TALLOC_CTX *mem_ctx, + struct event_context *ev, + struct messaging_context *msg, + const char *nt4_domain, + const char *nt4_username, + const char *password, + struct auth_session_info **session_info) { struct auth_context *auth_context; struct auth_usersupplied_info *user_info; @@ -42,8 +44,9 @@ _PUBLIC_ NTSTATUS authenticate_username_pw(TALLOC_CTX *mem_ctx, return NT_STATUS_NO_MEMORY; } - nt_status = auth_context_create(tmp_ctx, lp_auth_methods(), &auth_context, - event_context_find(mem_ctx)); + nt_status = auth_context_create(tmp_ctx, lp_auth_methods(), + ev, msg, + &auth_context); if (!NT_STATUS_IS_OK(nt_status)) { talloc_free(tmp_ctx); return nt_status; diff --git a/source4/auth/gensec/gensec.c b/source4/auth/gensec/gensec.c index c0aba3924c..ecdac8564a 100644 --- a/source4/auth/gensec/gensec.c +++ b/source4/auth/gensec/gensec.c @@ -465,8 +465,9 @@ const char **gensec_security_oids(struct gensec_security *gensec_security, @note The mem_ctx is only a parent and may be NULL. */ static NTSTATUS gensec_start(TALLOC_CTX *mem_ctx, - struct gensec_security **gensec_security, - struct event_context *ev) + struct event_context *ev, + struct messaging_context *msg, + struct gensec_security **gensec_security) { (*gensec_security) = talloc(mem_ctx, struct gensec_security); NT_STATUS_HAVE_NO_MEMORY(*gensec_security); @@ -489,6 +490,7 @@ static NTSTATUS gensec_start(TALLOC_CTX *mem_ctx, } (*gensec_security)->event_ctx = ev; + (*gensec_security)->msg_ctx = msg; return NT_STATUS_OK; } @@ -514,6 +516,7 @@ _PUBLIC_ NTSTATUS gensec_subcontext_start(TALLOC_CTX *mem_ctx, (*gensec_security)->subcontext = True; (*gensec_security)->event_ctx = parent->event_ctx; + (*gensec_security)->msg_ctx = parent->msg_ctx; return NT_STATUS_OK; } @@ -529,10 +532,20 @@ _PUBLIC_ NTSTATUS gensec_client_start(TALLOC_CTX *mem_ctx, struct event_context *ev) { NTSTATUS status; - status = gensec_start(mem_ctx, gensec_security, ev); + struct event_context *new_ev = NULL; + + if (ev == NULL) { + new_ev = event_context_init(mem_ctx); + NT_STATUS_HAVE_NO_MEMORY(new_ev); + ev = new_ev; + } + + status = gensec_start(mem_ctx, ev, NULL, gensec_security); if (!NT_STATUS_IS_OK(status)) { + talloc_free(new_ev); return status; } + talloc_steal((*gensec_security), new_ev); (*gensec_security)->gensec_role = GENSEC_CLIENT; return status; @@ -545,11 +558,23 @@ _PUBLIC_ NTSTATUS gensec_client_start(TALLOC_CTX *mem_ctx, @note The mem_ctx is only a parent and may be NULL. */ NTSTATUS gensec_server_start(TALLOC_CTX *mem_ctx, - struct gensec_security **gensec_security, - struct event_context *ev) + struct event_context *ev, + struct messaging_context *msg, + struct gensec_security **gensec_security) { NTSTATUS status; - status = gensec_start(mem_ctx, gensec_security, ev); + + if (!ev) { + DEBUG(0,("gensec_server_start: no event context given!\n")); + return NT_STATUS_INTERNAL_ERROR; + } + + if (!msg) { + DEBUG(0,("gensec_server_start: no messaging context given!\n")); + return NT_STATUS_INTERNAL_ERROR; + } + + status = gensec_start(mem_ctx, ev, msg, gensec_security); if (!NT_STATUS_IS_OK(status)) { return status; } diff --git a/source4/auth/gensec/gensec.h b/source4/auth/gensec/gensec.h index be5e900188..ce015086f6 100644 --- a/source4/auth/gensec/gensec.h +++ b/source4/auth/gensec/gensec.h @@ -122,6 +122,7 @@ struct gensec_security { BOOL subcontext; uint32_t want_features; struct event_context *event_ctx; + struct messaging_context *msg_ctx; /* only valid as server */ struct socket_address *my_addr, *peer_addr; }; diff --git a/source4/auth/ntlmssp/ntlmssp_server.c b/source4/auth/ntlmssp/ntlmssp_server.c index b574622bbe..eab5838113 100644 --- a/source4/auth/ntlmssp/ntlmssp_server.c +++ b/source4/auth/ntlmssp/ntlmssp_server.c @@ -830,8 +830,9 @@ NTSTATUS gensec_ntlmssp_server_start(struct gensec_security *gensec_security) } nt_status = auth_context_create(gensec_ntlmssp_state, lp_auth_methods(), - &gensec_ntlmssp_state->auth_context, - gensec_security->event_ctx); + gensec_security->event_ctx, + gensec_security->msg_ctx, + &gensec_ntlmssp_state->auth_context); NT_STATUS_NOT_OK_RETURN(nt_status); gensec_ntlmssp_state->get_challenge = auth_ntlmssp_get_challenge; |