From 2cfd1708d552195022e6567a156bec3a00ba7630 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Thu, 26 Aug 2021 18:17:22 +0100 Subject: Always respect the host field when automatically logging in opers. --- src/modules/m_sslinfo.cpp | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) (limited to 'src/modules/m_sslinfo.cpp') diff --git a/src/modules/m_sslinfo.cpp b/src/modules/m_sslinfo.cpp index 36fe7fdc8..9d46ee62c 100644 --- a/src/modules/m_sslinfo.cpp +++ b/src/modules/m_sslinfo.cpp @@ -373,27 +373,19 @@ class ModuleSSLInfo return; // Find an auto-oper block for this user - for (const auto& [_, ifo] : ServerInstance->Config->oper_blocks) + for (const auto& [_, info] : ServerInstance->Config->oper_blocks) { - std::string fp = ifo->oper_block->getString("fingerprint"); - if (!MatchFP(cert, fp)) - continue; + auto oper = info->oper_block; + if (!oper->getBool("autologin")) + continue; // No autologin for this block. - bool do_login = false; - const std::string autologin = ifo->oper_block->getString("autologin"); - if (stdalgo::string::equalsci(autologin, "if-host-match")) - { - const std::string& userHost = localuser->MakeHost(); - const std::string& userIP = localuser->MakeHostIP(); - do_login = InspIRCd::MatchMask(ifo->oper_block->getString("host"), userHost, userIP); - } - else if (ifo->oper_block->getBool("autologin")) - { - do_login = true; - } + if (!InspIRCd::MatchMask(oper->getString("host"), localuser->MakeHost(), localuser->MakeHostIP())) + continue; // Host doesn't match. + + if (!MatchFP(cert, oper->getString("fingerprint"))) + continue; // Fingerprint doesn't match. - if (do_login) - user->Oper(ifo); + user->Oper(info); } } -- cgit v1.3.1-10-gc9f91