X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_sslinfo.cpp;h=1b1ce9eaa090c059a89d95a8bcd862e473453771;hb=b4599531f97a9e6207b6bb8d728d7523b6995523;hp=d3514eac6acc4ccf1e254b517fbce2ad839e1578;hpb=fa6cfec3f8befcc650214b37664569e52f21e6b8;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_sslinfo.cpp b/src/modules/m_sslinfo.cpp index d3514eac6..1b1ce9eaa 100644 --- a/src/modules/m_sslinfo.cpp +++ b/src/modules/m_sslinfo.cpp @@ -21,6 +21,7 @@ #include "modules/ssl.h" #include "modules/webirc.h" #include "modules/whois.h" +#include "modules/who.h" enum { @@ -184,14 +185,21 @@ class ModuleSSLInfo : public Module , public WebIRC::EventListener , public Whois::EventListener + , public Who::EventListener { private: CommandSSLInfo cmd; + bool MatchFP(ssl_cert* const cert, const std::string& fp) const + { + return irc::spacesepstream(fp).Contains(cert->GetFingerprint()); + } + public: ModuleSSLInfo() : WebIRC::EventListener(this) , Whois::EventListener(this) + , Who::EventListener(this) , cmd(this) { } @@ -213,6 +221,19 @@ class ModuleSSLInfo } } + ModResult OnWhoLine(const Who::Request& request, LocalUser* source, User* user, Membership* memb, Numeric::Numeric& numeric) CXX11_OVERRIDE + { + size_t flag_index; + if (!request.GetFieldIndex('f', flag_index)) + return MOD_RES_PASSTHRU; + + ssl_cert* cert = cmd.sslapi.GetCertificate(user); + if (cert) + numeric.GetParams()[flag_index].push_back('s'); + + return MOD_RES_PASSTHRU; + } + ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) CXX11_OVERRIDE { if ((command == "OPER") && (validated)) @@ -231,7 +252,7 @@ class ModuleSSLInfo } std::string fingerprint; - if (ifo->oper_block->readString("fingerprint", fingerprint) && (!cert || cert->GetFingerprint() != fingerprint)) + if (ifo->oper_block->readString("fingerprint", fingerprint) && (!cert || !MatchFP(cert, fingerprint))) { user->WriteNumeric(ERR_NOOPERHOST, "This oper login requires a matching SSL certificate fingerprint."); user->CommandFloodPenalty += 10000; @@ -275,7 +296,7 @@ class ModuleSSLInfo { OperInfo* ifo = i->second; std::string fp = ifo->oper_block->getString("fingerprint"); - if (fp == cert->fingerprint && ifo->oper_block->getBool("autologin")) + if (MatchFP(cert, fp) && ifo->oper_block->getBool("autologin")) user->Oper(ifo); } }