From 2c5fdb670fe37d757e6d81b17c0e68e3b848c3fe Mon Sep 17 00:00:00 2001 From: Molly Miller Date: Sat, 12 Jun 2021 14:12:21 +0100 Subject: Add 'if-host-match' option to m_sslinfo oper autologin configuration. This adds an option to perform the source host check (which is usually performed on manual oper login) in addition to the certificate fingerprint check when automatically logging in opers upon connection to the ircd. --- src/modules/m_sslinfo.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/modules/m_sslinfo.cpp') diff --git a/src/modules/m_sslinfo.cpp b/src/modules/m_sslinfo.cpp index ae3d2b7b6..28ba3f177 100644 --- a/src/modules/m_sslinfo.cpp +++ b/src/modules/m_sslinfo.cpp @@ -373,7 +373,23 @@ class ModuleSSLInfo { OperInfo* ifo = i->second; std::string fp = ifo->oper_block->getString("fingerprint"); - if (MatchFP(cert, fp) && ifo->oper_block->getBool("autologin")) + if (!MatchFP(cert, fp)) + continue; + + 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 (do_login) user->Oper(ifo); } } -- cgit v1.3.1-10-gc9f91