diff --git a/modules/sasl.cpp b/modules/sasl.cpp index e3baeaae..1e36e199 100644 --- a/modules/sasl.cpp +++ b/modules/sasl.cpp @@ -196,6 +196,7 @@ class CSASLMod : public CModule { } void Authenticate(const CString& sLine) { + if (m_Mechanisms.empty()) return; /* Send blank authenticate for other mechanisms (like EXTERNAL). */ CString sAuthLine; if (m_Mechanisms.GetCurrent().Equals("PLAIN") && sLine.Equals("+")) { @@ -249,6 +250,7 @@ class CSASLMod : public CModule { } EModRet OnNumericMessage(CNumericMessage& msg) override { + if (m_Mechanisms.empty()) return CONTINUE; if (msg.GetCode() == 903) { /* SASL success! */ if (m_bVerbose) { diff --git a/test/integration/tests/modules.cpp b/test/integration/tests/modules.cpp index 10697961..35538c62 100644 --- a/test/integration/tests/modules.cpp +++ b/test/integration/tests/modules.cpp @@ -268,5 +268,17 @@ INSTANTIATE_TEST_CASE_P(SaslInst, SaslModuleTest, 99, {SaslModuleTest::Prefix() + "YmJi", "Yg=="}})); +TEST_F(ZNCTest, SaslMechsNotInit) { + auto znc = Run(); + auto ircd = ConnectIRCd(); + auto client = LoginClient(); + client.Write("znc loadmod sasl"); + client.Write("PRIVMSG *sasl :set * *"); + client.ReadUntil("Password has been set"); + ircd.Write("AUTHENTICATE +"); + ircd.Write("PING foo"); + ircd.ReadUntil("PONG foo"); +} + } // namespace } // namespace znc_inttest