s3 auth: Create messaging and lp contexts.
authorGary Lockyer <gary@catalyst.net.nz>
Mon, 28 Jan 2019 02:30:23 +0000 (15:30 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 20 Feb 2019 05:03:08 +0000 (06:03 +0100)
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 <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/auth/auth.c
source3/auth/wscript_build

index 0a96d591808bd14a4231c7ce2bb7c9a2e0316aeb..7215218413fd4ba9933fe9afbfc48ab381d3d6ba 100644 (file)
@@ -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,
index d27c231caa740e5cd4ceda1f1ae50742e1effd6a..c1062199aa86288c57d394a060f6c32e283b4816 100644 (file)
@@ -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',