]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Merge the latest changes from insp20 into master.
authorPeter Powell <petpow@saberuk.com>
Thu, 12 Oct 2017 14:55:21 +0000 (15:55 +0100)
committerPeter Powell <petpow@saberuk.com>
Thu, 12 Oct 2017 14:55:21 +0000 (15:55 +0100)
13 files changed:
1  2 
docs/conf/inspircd.conf.example
docs/conf/modules.conf.example
include/dynamic.h
src/coremods/core_xline/cmd_zline.cpp
src/coremods/core_xline/core_xline.cpp
src/dynamic.cpp
src/inspircd.cpp
src/modules/m_blockcaps.cpp
src/modules/m_cgiirc.cpp
src/modules/m_noctcp.cpp
src/modules/m_sasl.cpp
src/modules/m_timedbans.cpp
src/xline.cpp

Simple merge
index 383c6a173ac6107e1fffbd21c9418b39b9ba5006,b0c24194a7f4c77cf0b5926d72424391d67df74f..a555d8be2f7382d7aad899e899ad8266398c1d34
  # SQLite3 module: Allows other SQL modules to access SQLite3          #
  # databases through a unified API.                                    #
  # This module is in extras. Re-run configure with:                    #
- # ./configure --enable-extras=m_sqlite.cpp
+ # ./configure --enable-extras=m_sqlite3.cpp
  # and run make install, then uncomment this module to enable it.      #
  #
 -#<module name="m_sqlite3.so">
 +#<module name="sqlite3">
  #
  #-#-#-#-#-#-#-#-#-#-#-#- SQL CONFIGURATION   -#-#-#-#-#-#-#-#-#-#-#-#-#
  #                                                                     #
Simple merge
index 1bc7e8afd7595e4810dc0bba667c8f53492f8ca2,0000000000000000000000000000000000000000..af9d54a5b6e66b4a4df55daddf8312b4e34e3788
mode 100644,000000..100644
--- /dev/null
@@@ -1,107 -1,0 +1,107 @@@
-       return InspIRCd::Match(user->GetIPString(), ip, ascii_case_insensitive_map);
 +/*
 + * InspIRCd -- Internet Relay Chat Daemon
 + *
 + *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
 + *   Copyright (C) 2009 Matt Smith <dz@inspircd.org>
 + *   Copyright (C) 2007-2008 Robin Burchell <robin+git@viroteck.net>
 + *
 + * This file is part of InspIRCd.  InspIRCd is free software: you can
 + * redistribute it and/or modify it under the terms of the GNU General Public
 + * License as published by the Free Software Foundation, version 2.
 + *
 + * This program is distributed in the hope that it will be useful, but WITHOUT
 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 + * details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +
 +#include "inspircd.h"
 +#include "xline.h"
 +#include "core_xline.h"
 +
 +CommandZline::CommandZline(Module* parent)
 +      : Command(parent, "ZLINE", 1, 3)
 +{
 +      flags_needed = 'o';
 +      syntax = "<ipmask> [<duration> :<reason>]";
 +}
 +
 +CmdResult CommandZline::Handle (const std::vector<std::string>& parameters, User *user)
 +{
 +      std::string target = parameters[0];
 +
 +      if (parameters.size() >= 3)
 +      {
 +              if (target.find('!') != std::string::npos)
 +              {
 +                      user->WriteNotice("*** You cannot include a nickname in a zline, a zline must ban only an IP mask");
 +                      return CMD_FAILURE;
 +              }
 +
 +              User *u = ServerInstance->FindNick(target);
 +
 +              if ((u) && (u->registered == REG_ALL))
 +              {
 +                      target = u->GetIPString();
 +              }
 +
 +              const char* ipaddr = target.c_str();
 +
 +              if (strchr(ipaddr,'@'))
 +              {
 +                      while (*ipaddr != '@')
 +                              ipaddr++;
 +                      ipaddr++;
 +              }
 +
 +              IPMatcher matcher;
 +              if (InsaneBan::MatchesEveryone(ipaddr, matcher, user, "Z", "ipmasks"))
 +                      return CMD_FAILURE;
 +
 +              unsigned long duration = InspIRCd::Duration(parameters[1]);
 +              ZLine* zl = new ZLine(ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), ipaddr);
 +              if (ServerInstance->XLines->AddLine(zl,user))
 +              {
 +                      if (!duration)
 +                      {
 +                              ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent Z-line for %s: %s", user->nick.c_str(), ipaddr, parameters[2].c_str());
 +                      }
 +                      else
 +                      {
 +                              time_t c_requires_crap = duration + ServerInstance->Time();
 +                              std::string timestr = InspIRCd::TimeString(c_requires_crap);
 +                              ServerInstance->SNO->WriteToSnoMask('x',"%s added timed Z-line for %s, expires on %s: %s",user->nick.c_str(),ipaddr,
 +                                              timestr.c_str(), parameters[2].c_str());
 +                      }
 +                      ServerInstance->XLines->ApplyLines();
 +              }
 +              else
 +              {
 +                      delete zl;
 +                      user->WriteNotice("*** Z-Line for " + std::string(ipaddr) + " already exists");
 +              }
 +      }
 +      else
 +      {
 +              if (ServerInstance->XLines->DelLine(target.c_str(),"Z",user))
 +              {
 +                      ServerInstance->SNO->WriteToSnoMask('x',"%s removed Z-line on %s",user->nick.c_str(),target.c_str());
 +              }
 +              else
 +              {
 +                      user->WriteNotice("*** Z-Line " + target + " not found in list, try /stats Z.");
 +                      return CMD_FAILURE;
 +              }
 +      }
 +
 +      return CMD_SUCCESS;
 +}
 +
 +bool CommandZline::IPMatcher::Check(User* user, const std::string& ip) const
 +{
++      return InspIRCd::MatchCIDR(user->GetIPString(), ip, ascii_case_insensitive_map);
 +}
index 93ac1db311868040137f1a63269eb4daceb770cc,0000000000000000000000000000000000000000..d6c804748559d93678ec7f1eafca5665fc0bef8e
mode 100644,000000..100644
--- /dev/null
@@@ -1,93 -1,0 +1,93 @@@
-       return ((InspIRCd::Match(user->MakeHost(), mask, ascii_case_insensitive_map)) ||
-                       (InspIRCd::Match(user->MakeHostIP(), mask, ascii_case_insensitive_map)));
 +/*
 + * InspIRCd -- Internet Relay Chat Daemon
 + *
 + *   Copyright (C) 2014 Attila Molnar <attilamolnar@hush.com>
 + *
 + * This file is part of InspIRCd.  InspIRCd is free software: you can
 + * redistribute it and/or modify it under the terms of the GNU General Public
 + * License as published by the Free Software Foundation, version 2.
 + *
 + * This program is distributed in the hope that it will be useful, but WITHOUT
 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 + * details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +
 +#include "inspircd.h"
 +#include "xline.h"
 +#include "core_xline.h"
 +
 +bool InsaneBan::MatchesEveryone(const std::string& mask, MatcherBase& test, User* user, const char* bantype, const char* confkey)
 +{
 +      ConfigTag* insane = ServerInstance->Config->ConfValue("insane");
 +
 +      if (insane->getBool(confkey))
 +              return false;
 +
 +      float itrigger = insane->getFloat("trigger", 95.5);
 +
 +      long matches = test.Run(mask);
 +
 +      if (!matches)
 +              return false;
 +
 +      float percent = ((float)matches / (float)ServerInstance->Users->GetUsers().size()) * 100;
 +      if (percent > itrigger)
 +      {
 +              ServerInstance->SNO->WriteToSnoMask('a', "\2WARNING\2: %s tried to set a %s-line mask of %s, which covers %.2f%% of the network!", user->nick.c_str(), bantype, mask.c_str(), percent);
 +              return true;
 +      }
 +      return false;
 +}
 +
 +bool InsaneBan::IPHostMatcher::Check(User* user, const std::string& mask) const
 +{
++      return ((InspIRCd::MatchCIDR(user->MakeHost(), mask, ascii_case_insensitive_map)) ||
++                      (InspIRCd::MatchCIDR(user->MakeHostIP(), mask, ascii_case_insensitive_map)));
 +}
 +
 +class CoreModXLine : public Module
 +{
 +      CommandEline cmdeline;
 +      CommandGline cmdgline;
 +      CommandKline cmdkline;
 +      CommandQline cmdqline;
 +      CommandZline cmdzline;
 +
 + public:
 +      CoreModXLine()
 +              : cmdeline(this), cmdgline(this), cmdkline(this), cmdqline(this), cmdzline(this)
 +      {
 +      }
 +
 +      ModResult OnUserPreNick(LocalUser* user, const std::string& newnick) CXX11_OVERRIDE
 +      {
 +              // Check Q-Lines (for local nick changes only, remote servers have our Q-Lines to enforce themselves)
 +
 +              XLine* xline = ServerInstance->XLines->MatchesLine("Q", newnick);
 +              if (!xline)
 +                      return MOD_RES_PASSTHRU; // No match
 +
 +              // A Q-Line matched the new nick, tell opers if the user is registered
 +              if (user->registered == REG_ALL)
 +              {
 +                      ServerInstance->SNO->WriteGlobalSno('a', "Q-Lined nickname %s from %s: %s",
 +                              newnick.c_str(), user->GetFullRealHost().c_str(), xline->reason.c_str());
 +              }
 +
 +              // Send a numeric because if we deny then the core doesn't reply anything
 +              user->WriteNumeric(ERR_ERRONEUSNICKNAME, newnick, InspIRCd::Format("Invalid nickname: %s", xline->reason.c_str()));
 +              return MOD_RES_DENY;
 +      }
 +
 +      Version GetVersion() CXX11_OVERRIDE
 +      {
 +              return Version("Provides the ELINE, GLINE, KLINE, QLINE, and ZLINE commands", VF_VENDOR|VF_CORE);
 +      }
 +};
 +
 +MODULE_INIT(CoreModXLine)
diff --cc src/dynamic.cpp
index 340f40e19d0892f0f94a606e586f6c1f61957ccd,25178cfa111c7f287461e9fd4053e7f70e22cb0a..f138b04d1dd9f30d49a3eb48fd56058ab0b0ec28
@@@ -91,12 -83,12 +83,12 @@@ std::string DLLManager::GetVersion(
        const char* srcver = (char*)dlsym(h, "inspircd_src_version");
        if (srcver)
                return srcver;
 -      return "Unversioned module";
 +      return "";
  }
  
- #ifdef _WIN32
  void DLLManager::RetrieveLastError()
  {
+ #if defined _WIN32
        char errmsg[500];
        DWORD dwErrorCode = GetLastError();
        if (FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dwErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)errmsg, _countof(errmsg), NULL) == 0)
index bc0875502d0fca20b51bf04566a73b17211fc336,66f9bfdc56ca0de5edba55836444c8031a74c710..47660f75267234ed3bdfbc87110750e415b2fc41
@@@ -642,10 -831,13 +642,17 @@@ void InspIRCd::Run(
                        OLDTIME = TIME.tv_sec;
  
                        if ((TIME.tv_sec % 3600) == 0)
 -                              this->RehashUsersAndChans();
 -                              FOREACH_MOD(I_OnGarbageCollect, OnGarbageCollect());
+                       {
 -                      Timers->TickTimers(TIME.tv_sec);
 -                      this->DoBackgroundUserStuff();
 +                              FOREACH_MOD(OnGarbageCollect, ());
 +
++                              // HACK: ELines are not expired properly at the moment but it can't be fixed as
++                              // the 2.0 XLine system is a spaghetti nightmare. Instead we skip over expired
++                              // ELines in XLineManager::CheckELines() and expire them here instead.
++                              XLines->GetAll("E");
+                       }
 +                      Timers.TickTimers(TIME.tv_sec);
 +                      Users->DoBackgroundUserStuff();
  
                        if ((TIME.tv_sec % 5) == 0)
                        {
Simple merge
index 305801b0ac8b095c29b8db5aa22e40af9091788d,9e1a546d6ae41ffe89b6a766b1f3051282ac00a2..d8dbe6da7cafde7cb0de1a4db753f62e156f716f
@@@ -106,8 -99,7 +106,8 @@@ class CommandWebIRC : public SplitComma
                                                realhost.set(user, user->host);
                                                realip.set(user, user->GetIPString());
  
 -                                              bool host_ok = (parameters[2].length() < 64) && (parameters[2].find_first_not_of("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-") == std::string::npos);
 +                                              // Check if we're happy with the provided hostname. If it's problematic then make sure we won't set a host later, just the IP
-                                               bool host_ok = (parameters[2].length() <= ServerInstance->Config->Limits.MaxHost);
++                                              bool host_ok = (parameters[2].length() <= ServerInstance->Config->Limits.MaxHost) && (parameters[2].find_first_not_of("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-") == std::string::npos);
                                                const std::string& newhost = (host_ok ? parameters[2] : parameters[3]);
  
                                                if (notify)
index 9dd9bf852d25e1dd3da1e4ed88079ad2f1aba315,c934a05c6edbfbe254d17b28f27d8c84d7a1fb5d..7139643286741bc87bce63476ce34a4602b218db
@@@ -50,11 -67,10 +50,11 @@@ class ModuleNoCTCP : public Modul
                if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user)))
                {
                        Channel* c = (Channel*)dest;
-                       if ((text.empty()) || (text[0] != '\001') || (!strncmp(text.c_str(),"\1ACTION ",8)))
+                       if ((text.empty()) || (text[0] != '\001') || (!strncmp(text.c_str(),"\1ACTION ", 8)) || (text == "\1ACTION\1") || (text == "\1ACTION"))
                                return MOD_RES_PASSTHRU;
  
 -                      ModResult res = ServerInstance->OnCheckExemption(user,c,"noctcp");
 +                      ModResult res;
 +                      FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, c, "noctcp"));
                        if (res == MOD_RES_ALLOW)
                                return MOD_RES_PASSTHRU;
  
index fe1438ccffe7c59a8c1d747a58d72a8f8f476693,0ef93ec5ae66476923dfe7eaded192dba54711df..eedf968b404a5af062ca01030006eaabebf7a350
@@@ -169,13 -51,64 +169,14 @@@ class SaslAuthenticato
        SaslResult result;
        bool state_announced;
  
 -      /* taken from m_services_account */
 -      static bool ReadCGIIRCExt(const char* extname, User* user, std::string& out)
 -      {
 -              ExtensionItem* wiext = ServerInstance->Extensions.GetItem(extname);
 -              if (!wiext)
 -                      return false;
 -
 -              if (wiext->creator->ModuleSourceFile != "m_cgiirc.so")
 -                      return false;
 -
 -              StringExtItem* stringext = static_cast<StringExtItem*>(wiext);
 -              std::string* addr = stringext->get(user);
 -              if (!addr)
 -                      return false;
 -
 -              out = *addr;
 -              return true;
 -      }
 -
 -
        void SendHostIP()
        {
 -              std::string host, ip;
 -
 -              if (!ReadCGIIRCExt("cgiirc_webirc_hostname", user, host))
 -              {
 -                      host = user->host;
 -              }
 -              if (!ReadCGIIRCExt("cgiirc_webirc_ip", user, ip))
 -              {
 -                      ip = user->GetIPString();
 -              }
 -              else
 -              {
 -                      /* IP addresses starting with a : on irc are a Bad Thing (tm) */
 -                      if (ip.c_str()[0] == ':')
 -                              ip.insert(ip.begin(),1,'0');
 -              }
 -
                parameterlist params;
 -              params.push_back(sasl_target);
 -              params.push_back("SASL");
 -              params.push_back(user->uuid);
 -              params.push_back("*");
 -              params.push_back("H");
 -              params.push_back(host);
 -              params.push_back(ip);
 -
 -              LocalUser* lu = IS_LOCAL(user);
 -              if (lu)
 -              {
 -                      // NOTE: SaslAuthenticator instances are only created for local
 -                      // users so this parameter will always be appended.
 -                      SocketCertificateRequest req(&lu->eh, ServerInstance->Modules->Find("m_sasl.so"));
 -                      params.push_back(req.cert ? "S" : "P");
 -              }
 +              params.push_back(user->host);
 +              params.push_back(user->GetIPString());
++              params.push_back(SSLIOHook::IsSSL(&user->eh) ? "S" : "P");
  
 -              SendSASL(params);
 +              SendSASL(user, "*", 'H', params);
        }
  
   public:
index 44c6c4c4f85ce33ad8e8e83e16cd5197c44204c0,61095d6ebae2f2ed70ce316ff21c1f1f66fc2024..9890800e4c524f4222080cedc30474e85c0455af
@@@ -118,8 -118,8 +118,8 @@@ class CommandTban : public Comman
                TimedBanList.push_back(T);
  
                // If halfop is loaded, send notice to halfops and above, otherwise send to ops and above
--              ModeHandler* mh = ServerInstance->Modes->FindMode('h', MODETYPE_CHANNEL);
-               char pfxchar = (mh && mh->name == "halfop") ? '%' : '@';
++              PrefixMode* mh = ServerInstance->Modes->FindPrefixMode('h');
+               char pfxchar = (mh && mh->name == "halfop") ? mh->GetPrefix() : '@';
  
                channel->WriteAllExcept(ServerInstance->FakeClient, true, pfxchar, tmp, "NOTICE %s :%s added a timed ban on %s lasting for %ld seconds.", channel->name.c_str(), user->nick.c_str(), mask.c_str(), duration);
                return CMD_SUCCESS;
diff --cc src/xline.cpp
index b116d2e1f9eb5859e6e954b9345c4a9784264df8,0506005add1926b256762955f579b6feea55cbbf..257af9ca7a72ba4a63b6b64a8910fa722761e3ad
@@@ -155,10 -156,10 +155,11 @@@ void XLineManager::CheckELines(
        if (ELines.empty())
                return;
  
 -      for (LocalUserList::const_iterator u2 = ServerInstance->Users->local_users.begin(); u2 != ServerInstance->Users->local_users.end(); u2++)
 +      const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers();
 +      for (UserManager::LocalList::const_iterator u2 = list.begin(); u2 != list.end(); u2++)
        {
 -              User* u = (User*)(*u2);
 +              LocalUser* u = *u2;
+               u->exempt = false;
  
                /* This uses safe iteration to ensure that if a line expires here, it doenst trash the iterator */
                LookupIter safei;