From c6ae8d16e5b2b6a3f447162cadf9841c57e6fdbd Mon Sep 17 00:00:00 2001 From: Alexey Sokolov Date: Thu, 13 Feb 2025 20:56:02 +0000 Subject: [PATCH] saslplain: use CZNC::AuthUser() 1. this should work better with modules such as imapauth 2. it fixes a null pointer dereference when the username wasn't found This module won't work as is yet, and has some other obvious issues with this approach, but was a good starting point. --- modules/saslplain.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/modules/saslplain.cpp b/modules/saslplain.cpp index 3f467397..ba60bc97 100644 --- a/modules/saslplain.cpp +++ b/modules/saslplain.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2018 ZNC, see the NOTICE file for details. + * Copyright (C) 2004-2025 ZNC, see the NOTICE file for details. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,15 +41,8 @@ class CSASLMechanismPlain : public CModule { return HALTMODS; } - auto pUser = CZNC::Get().FindUser(sAuthcId); - - if (!sAuthcId.empty() && !sPassword.empty()) { - if (pUser->CheckPass(sPassword)) { - bAuthenticationSuccess = true; - sUser = sAuthcId; - } - } - + auto spAuth = std::make_shared(this, sAuthcId, sPassword); + CZNC::Get().AuthUser(spAuth); return HALTMODS; }