From 826d930aa4de588c84b7c7f993b148c3e7cc757f Mon Sep 17 00:00:00 2001 From: Gary Lockyer Date: Mon, 28 Jan 2019 15:30:23 +1300 Subject: [PATCH] s3 auth: Create messaging and lp contexts. If 'auth event notifications' are enabled create an imessaging_context and a loadparm_context that can be passed to log_authentication_event. This will allow the generated authentication messages to be tested. Signed-off-by: Gary Lockyer Reviewed-by: Andrew Bartlett --- source3/auth/auth.c | 18 +++++++++++++++--- source3/auth/wscript_build | 2 +- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/source3/auth/auth.c b/source3/auth/auth.c index 0a96d591808..7215218413f 100644 --- a/source3/auth/auth.c +++ b/source3/auth/auth.c @@ -21,6 +21,9 @@ #include "auth.h" #include "../lib/tsocket/tsocket.h" +#include "param/param.h" +#include "../lib/messaging/messaging.h" + #undef DBGC_CLASS #define DBGC_CLASS DBGC_AUTH @@ -176,6 +179,8 @@ NTSTATUS auth_check_ntlm_password(TALLOC_CTX *mem_ctx, auth_methods *auth_method; struct auth_serversupplied_info *server_info = NULL; struct dom_sid sid = {0}; + struct imessaging_context *msg_ctx = NULL; + struct loadparm_context *lp_ctx = NULL; if (user_info == NULL || auth_context == NULL || pserver_info == NULL) { return NT_STATUS_LOGON_FAILURE; @@ -183,6 +188,12 @@ NTSTATUS auth_check_ntlm_password(TALLOC_CTX *mem_ctx, frame = talloc_stackframe(); + if (lp_auth_event_notification()) { + lp_ctx = loadparm_init_s3(frame, loadparm_s3_helpers()); + msg_ctx = imessaging_client_init( + frame, lp_ctx, global_event_context()); + } + *pauthoritative = 1; DEBUG(3, ("check_ntlm_password: Checking password for unmapped user [%s]\\[%s]@[%s] with the new password interface\n", @@ -299,7 +310,8 @@ NTSTATUS auth_check_ntlm_password(TALLOC_CTX *mem_ctx, sid = (struct dom_sid) {0}; } - log_authentication_event(NULL, NULL, + log_authentication_event(msg_ctx, + lp_ctx, &auth_context->start_time, user_info, nt_status, @@ -333,8 +345,8 @@ fail: user_info->client.account_name, user_info->mapped.account_name, nt_errstr(nt_status), *pauthoritative)); - log_authentication_event(NULL, - NULL, + log_authentication_event(msg_ctx, + lp_ctx, &auth_context->start_time, user_info, nt_status, diff --git a/source3/auth/wscript_build b/source3/auth/wscript_build index d27c231caa7..c1062199aa8 100644 --- a/source3/auth/wscript_build +++ b/source3/auth/wscript_build @@ -21,7 +21,7 @@ bld.SAMBA3_LIBRARY('auth', user_krb5.c auth_ntlmssp.c auth_generic.c''', - deps='''PLAINTEXT_AUTH SLCACHE DCUTIL TOKEN_UTIL AUTH_COMMON libcli_netlogon3 samba-hostconfig''', + deps='''PLAINTEXT_AUTH SLCACHE DCUTIL TOKEN_UTIL AUTH_COMMON libcli_netlogon3 samba-hostconfig MESSAGING''', private_library=True) bld.SAMBA3_MODULE('auth_sam', -- 2.34.1