]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
CVE-2020-25717 auth4: Make auth_anonymous pseudo-async
authorVolker Lendecke <vl@samba.org>
Wed, 14 Apr 2021 19:48:32 +0000 (21:48 +0200)
committerJule Anger <janger@samba.org>
Mon, 8 Nov 2021 09:52:09 +0000 (10:52 +0100)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556

(cherry picked from commit 759573136876ef2b1b1c7484f99570d7de957e0d)

source4/auth/ntlm/auth_anonymous.c
source4/auth/ntlm/wscript_build

index 83aeb431f5f48464277dcaa785ae3a41a4b57228..a25aacaa13782514226d4bbdc3db1dd8d6767e95 100644 (file)
 */
 
 #include "includes.h"
+#include <tevent.h>
 #include "auth/auth.h"
 #include "auth/ntlm/auth_proto.h"
 #include "param/param.h"
+#include "lib/util/tevent_ntstatus.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_AUTH
@@ -84,19 +86,65 @@ static NTSTATUS anonymous_want_check(struct auth_method_context *ctx,
  * anonymou logons to be dealt with in one place.  Non-anonymou logons 'fail'
  * and pass onto the next module.
  **/
-static NTSTATUS anonymous_check_password(struct auth_method_context *ctx,
-                                        TALLOC_CTX *mem_ctx,
-                                        const struct auth_usersupplied_info *user_info, 
-                                        struct auth_user_info_dc **_user_info_dc,
-                                        bool *authoritative)
+
+struct anonymous_check_password_state {
+       struct auth_user_info_dc *user_info_dc;
+};
+
+static struct tevent_req *anonymous_check_password_send(
+       TALLOC_CTX *mem_ctx,
+       struct tevent_context *ev,
+       struct auth_method_context *ctx,
+       const struct auth_usersupplied_info *user_info)
+{
+       struct tevent_req *req = NULL;
+       struct anonymous_check_password_state *state = NULL;
+       NTSTATUS status;
+
+       req = tevent_req_create(
+               mem_ctx,
+               &state,
+               struct anonymous_check_password_state);
+       if (req == NULL) {
+               return NULL;
+       }
+
+       status = auth_anonymous_user_info_dc(
+               state,
+               lpcfg_netbios_name(ctx->auth_ctx->lp_ctx),
+               &state->user_info_dc);
+       if (tevent_req_nterror(req, status)) {
+               return tevent_req_post(req, ev);
+       }
+       tevent_req_done(req);
+       return tevent_req_post(req, ev);
+}
+
+static NTSTATUS anonymous_check_password_recv(
+       struct tevent_req *req,
+       TALLOC_CTX *mem_ctx,
+       struct auth_user_info_dc **interim_info,
+       bool *authoritative)
 {
-       return auth_anonymous_user_info_dc(mem_ctx, lpcfg_netbios_name(ctx->auth_ctx->lp_ctx), _user_info_dc);
+       struct anonymous_check_password_state *state = tevent_req_data(
+               req, struct anonymous_check_password_state);
+       NTSTATUS status;
+
+       if (tevent_req_is_nterror(req, &status)) {
+               tevent_req_received(req);
+               return status;
+       }
+       *interim_info = talloc_move(mem_ctx, &state->user_info_dc);
+       tevent_req_received(req);
+       return NT_STATUS_OK;
 }
 
+
 static const struct auth_operations anonymous_auth_ops = {
-       .name           = "anonymous",
-       .want_check     = anonymous_want_check,
-       .check_password = anonymous_check_password
+       .name                   = "anonymous",
+       .want_check             = anonymous_want_check,
+       .check_password_send    = anonymous_check_password_send,
+       .check_password_recv    = anonymous_check_password_recv,
 };
 
 _PUBLIC_ NTSTATUS auth4_anonymous_init(TALLOC_CTX *ctx)
index 04a760c3e495b730c43297f794d18a68db68d63b..6ea0c4d7e3a80ee97653c79ec85c91691e8bceff 100644 (file)
@@ -12,7 +12,7 @@ bld.SAMBA_MODULE('auth4_anonymous',
        source='auth_anonymous.c',
        subsystem='auth4',
        init_function='auth4_anonymous_init',
-       deps='talloc'
+       deps='tevent'
        )