]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Merge insp20
authorAttila Molnar <attilamolnar@hush.com>
Wed, 17 Aug 2016 10:49:48 +0000 (12:49 +0200)
committerAttila Molnar <attilamolnar@hush.com>
Wed, 17 Aug 2016 10:49:48 +0000 (12:49 +0200)
21 files changed:
.travis.yml [new file with mode: 0644]
docs/conf/inspircd.conf.example
include/configreader.h
include/inspircd.h
make/template/inspircd
make/template/main.mk
src/configreader.cpp
src/coremods/core_list.cpp
src/coremods/core_oper/cmd_kill.cpp
src/coremods/core_stats.cpp
src/inspircd.cpp
src/mode.cpp
src/modules/extra/m_ssl_gnutls.cpp
src/modules/extra/m_ssl_openssl.cpp
src/modules/m_censor.cpp
src/modules/m_dccallow.cpp
src/modules/m_sasl.cpp
src/modules/m_securelist.cpp
src/modules/m_spanningtree/postcommand.cpp
src/usermanager.cpp
tools/travis-ci.sh [new file with mode: 0755]

diff --git a/.travis.yml b/.travis.yml
new file mode 100644 (file)
index 0000000..6318025
--- /dev/null
@@ -0,0 +1,12 @@
+compiler:
+  - "clang"
+  - "gcc"
+language: "cpp"
+notifications:
+  email: false
+os:
+  - "linux"
+  - "osx"
+script:
+  - "sh ./tools/travis-ci.sh"
+sudo: required
index 16c34cc249824d6d95972cdae10d4d79190a4183..d56ac55ac22075359a44b4d55671f0610606a613 100644 (file)
           # hidekills: If defined, replaces who set a /kill with a custom string.
           hidekills=""
 
+          # hideulinekills: Hide kills from clients of ulined servers from server notices.
+          hideulinekills="yes"
+
           # hidesplits: If enabled, non-opers will not be able to see which
           # servers split in a netsplit, they will only be able to see that one
           # occurred (If their client has netsplit detection).
index f2ba16902293cf9a32b1057062c2ccb2da8162a9..fb93adafd65383d11b01c1dd01c5979c5552e230 100644 (file)
@@ -403,6 +403,10 @@ class CoreExport ServerConfig
         */
        std::string HideKillsServer;
 
+       /** Set to hide kills from clients of ulined servers in snotices.
+        */
+       bool HideULineKills;
+
        /** The full pathname and filename of the PID
         * file as defined in the configuration.
         */
index ee09070f858799d5ffca7c534769c9a96dadc3ca..303d24745664ef2936e7c145e4ad17b1cf24a809 100644 (file)
@@ -507,9 +507,10 @@ class CoreExport InspIRCd
 
        /** Attempt to write the process id to a given file
         * @param filename The PID file to attempt to write to
+        * @param exitonfail If true and the PID fail cannot be written log to stdout and exit, otherwise only log on failure
         * @return This function may bail if the file cannot be written
         */
-       void WritePID(const std::string &filename);
+       void WritePID(const std::string& filename, bool exitonfail = true);
 
        /** This constructor initialises all the subsystems and reads the config file.
         * @param argc The argument count passed to main()
index 138de29a9cfdb4ef6eb060bff65fe11bbfca4007..cb2d2902d520eca9752a7cf0da4b4f4004c9a2c4 100644 (file)
@@ -153,7 +153,7 @@ sub cmd_rehash()
 
 sub cmd_cron()
 {
-       if (getstatus() == 0) { goto &cmd_start(); }
+       if (getstatus() == 0) { goto &cmd_start(@_); }
        exit GENERIC_EXIT_UNSPECIFIED;
 }
 
@@ -167,7 +167,7 @@ sub cmd_restart(@)
 {
        cmd_stop();
        unlink($pidfile) if (-e $pidfile);
-       goto &cmd_start;
+       goto &cmd_start(@_);
 }
 
 sub hid_cheese_sandwich()
index bff0657362364e0bb80a0f324d0e4a2ca67b8920..818b4139d8681a7fbab038f6fa75fd12a83878de 100644 (file)
@@ -154,7 +154,7 @@ all: $(FOOTER)
 
 target: $(HEADER)
        $(MAKEENV) perl make/calcdep.pl
-       cd $(BUILDPATH); $(MAKEENV) $(MAKE) -f real.mk $(TARGET)
+       cd "$(BUILDPATH)"; $(MAKEENV) $(MAKE) -f real.mk $(TARGET)
 
 debug:
        @${MAKE} INSPIRCD_DEBUG=1 all
@@ -222,9 +222,9 @@ install: target
        @-$(INSTALL) -d -m $(INSTMODE_DIR) $(CONPATH)/examples/modules
        @-$(INSTALL) -d -m $(INSTMODE_DIR) $(MANPATH)
        @-$(INSTALL) -d -m $(INSTMODE_DIR) $(MODPATH)
-       [ $(BUILDPATH)/bin/ -ef $(BINPATH) ] || $(INSTALL) -m $(INSTMODE_BIN) $(BUILDPATH)/bin/inspircd $(BINPATH)
+       [ "$(BUILDPATH)/bin/" -ef $(BINPATH) ] || $(INSTALL) -m $(INSTMODE_BIN) "$(BUILDPATH)/bin/inspircd" $(BINPATH)
 @IFNDEF INSPIRCD_STATIC
-       [ $(BUILDPATH)/modules/ -ef $(MODPATH) ] || $(INSTALL) -m $(INSTMODE_LIB) $(BUILDPATH)/modules/*.so $(MODPATH)
+       [ "$(BUILDPATH)/modules/" -ef $(MODPATH) ] || $(INSTALL) -m $(INSTMODE_LIB) "$(BUILDPATH)/modules/"*.so $(MODPATH)
 @ENDIF
        -$(INSTALL) -m $(INSTMODE_BIN) @CONFIGURE_DIRECTORY@/inspircd $(BASE) 2>/dev/null
        -$(INSTALL) -m $(INSTMODE_LIB) .gdbargs $(BASE)/.gdbargs 2>/dev/null
@@ -261,10 +261,10 @@ GNUmakefile BSDmakefile: make/template/main.mk src/version.sh configure @CONFIGU
 
 clean:
        @echo Cleaning...
-       -rm -f $(BUILDPATH)/bin/inspircd $(BUILDPATH)/include $(BUILDPATH)/real.mk
-       -rm -rf $(BUILDPATH)/obj $(BUILDPATH)/modules
-       @-rmdir $(BUILDPATH)/bin 2>/dev/null
-       @-rmdir $(BUILDPATH) 2>/dev/null
+       -rm -f "$(BUILDPATH)/bin/inspircd" "$(BUILDPATH)/include" "$(BUILDPATH)/real.mk"
+       -rm -rf "$(BUILDPATH)/obj" "$(BUILDPATH)/modules"
+       @-rmdir "$(BUILDPATH)/bin" 2>/dev/null
+       @-rmdir "$(BUILDPATH)" 2>/dev/null
        @echo Completed.
 
 deinstall:
@@ -272,7 +272,8 @@ deinstall:
        -rm -rf $(CONPATH)/examples
        -rm -f $(MANPATH)/inspircd.1
        -rm -f $(MANPATH)/inspircd-genssl.1
-       -rm -f $(MODPATH)/*.so
+       -rm -f $(MODPATH)/m_*.so
+       -rm -f $(MODPATH)/core_*.so
        -rm -f $(BASE)/.gdbargs
        -rm -f $(BASE)/inspircd.service
        -rm -f $(BASE)/org.inspircd.plist
@@ -285,8 +286,8 @@ configureclean:
        rm -rf @CONFIGURE_DIRECTORY@
 
 distclean: clean configureclean
-       -rm -rf $(SOURCEPATH)/run
-       find $(SOURCEPATH)/src/modules -type l | xargs rm -f
+       -rm -rf "$(SOURCEPATH)/run"
+       find "$(SOURCEPATH)/src/modules" -type l | xargs rm -f
 
 help:
        @echo 'InspIRCd Makefile'
index e607c6e7d72e635564cbbae5ab7cdf9b3d968b4e..8a432e82f6a74f836038a4ebfdfb1627dd473196 100644 (file)
@@ -409,6 +409,7 @@ void ServerConfig::Fill()
        HideBans = security->getBool("hidebans");
        HideWhoisServer = security->getString("hidewhois");
        HideKillsServer = security->getString("hidekills");
+       HideULineKills = security->getBool("hideulinekills");
        RestrictBannedUsers = security->getBool("restrictbannedusers", true);
        GenericOper = security->getBool("genericoper");
        SyntaxHints = options->getBool("syntaxhints");
@@ -567,7 +568,7 @@ void ServerConfig::Apply(ServerConfig* old, const std::string &useruid)
 
        // write once here, to try it out and make sure its ok
        if (valid)
-               ServerInstance->WritePID(this->PID);
+               ServerInstance->WritePID(this->PID, !old);
 
        ConfigTagList binds = ConfTags("bind");
        if (binds.first == binds.second)
index 67829a55edf472715d7075e5c592ede7c6f2612a..6a62d122f660e1e932b4e7d28463a19cbe13f61a 100644 (file)
@@ -55,8 +55,7 @@ CmdResult CommandList::Handle (const std::vector<std::string>& parameters, User
 
        user->WriteNumeric(RPL_LISTSTART, "Channel", "Users Name");
 
-       /* Work around mIRC suckyness. YOU SUCK, KHALED! */
-       if (parameters.size() == 1)
+       if ((parameters.size() == 1) && (!parameters[0].empty()))
        {
                if (parameters[0][0] == '<')
                {
index 0d111ce02e911f5cd13a3758b547c39b4b6a3efb..e75566e2fcea19bb079eb8bf53c1d870607a0903 100644 (file)
@@ -93,7 +93,7 @@ CmdResult CommandKill::Handle (const std::vector<std::string>& parameters, User
                if (!IS_LOCAL(u))
                {
                        // remote kill
-                       if (!user->server->IsULine())
+                       if ((!ServerInstance->Config->HideULineKills) || (!user->server->IsULine()))
                                ServerInstance->SNO->WriteToSnoMask('K', "Remote kill by %s: %s (%s)", user->nick.c_str(), u->GetFullRealHost().c_str(), parameters[1].c_str());
                        this->lastuuid = u->uuid;
                }
@@ -104,7 +104,7 @@ CmdResult CommandKill::Handle (const std::vector<std::string>& parameters, User
                         * XXX - this isn't entirely correct, servers A - B - C, oper on A, client on C. Oper kills client, A and B will get remote kill
                         * snotices, C will get a local kill snotice. this isn't accurate, and needs fixing at some stage. -- w00t
                         */
-                       if (!user->server->IsULine())
+                       if ((!ServerInstance->Config->HideULineKills) || (!user->server->IsULine()))
                        {
                                if (IS_LOCAL(user))
                                        ServerInstance->SNO->WriteGlobalSno('k',"Local Kill by %s: %s (%s)", user->nick.c_str(), u->GetFullRealHost().c_str(), parameters[1].c_str());
index d890d19ea2f93e1516a611b6d97b92d048ddad81..ee0c50db2c5378068a04d2d41a27c152c0a9cb7a 100644 (file)
@@ -35,7 +35,7 @@ class CommandStats : public Command
  public:
        /** Constructor for stats.
         */
-       CommandStats ( Module* parent) : Command(parent,"STATS",1,2) { syntax = "<stats-symbol> [<servername>]"; }
+       CommandStats ( Module* parent) : Command(parent,"STATS",1,2) { allow_empty_last_param = false; syntax = "<stats-symbol> [<servername>]"; }
        /** Handle command.
         * @param parameters The parameters to the command
         * @param user The user issuing the command
index eb24cdea0a2b0d924e8a116f6e4bbd7639c17bd5..5d4d8081f02772909c4b1a5cd934fc16da05bf43 100644 (file)
@@ -194,7 +194,7 @@ bool InspIRCd::DaemonSeed()
 #endif
 }
 
-void InspIRCd::WritePID(const std::string &filename)
+void InspIRCd::WritePID(const std::string& filename, bool exitonfail)
 {
 #ifndef _WIN32
        std::string fname(filename);
@@ -208,9 +208,11 @@ void InspIRCd::WritePID(const std::string &filename)
        }
        else
        {
-               std::cout << "Failed to write PID-file '" << fname << "', exiting." << std::endl;
-               this->Logs->Log("STARTUP", LOG_DEFAULT, "Failed to write PID-file '%s', exiting.",fname.c_str());
-               Exit(EXIT_STATUS_PID);
+               if (exitonfail)
+                       std::cout << "Failed to write PID-file '" << fname << "', exiting." << std::endl;
+               this->Logs->Log("STARTUP", LOG_DEFAULT, "Failed to write PID-file '%s'%s", fname.c_str(), (exitonfail ? ", exiting." : ""));
+               if (exitonfail)
+                       Exit(EXIT_STATUS_PID);
        }
 #endif
 }
index b29eda828e197a01f5f9bb2a0a65f8c9c7c647ac..3762dc52e14d9a25b537114532d1c58c43402dfe 100644 (file)
@@ -791,24 +791,33 @@ std::string ModeParser::GiveModeList(ModeType mt)
        return type1 + "," + type2 + "," + type3 + "," + type4;
 }
 
+struct PrefixModeSorter
+{
+       bool operator()(PrefixMode* lhs, PrefixMode* rhs)
+       {
+               return lhs->GetPrefixRank() < rhs->GetPrefixRank();
+       }
+};
+
 std::string ModeParser::BuildPrefixes(bool lettersAndModes)
 {
        std::string mletters;
        std::string mprefixes;
-       insp::flat_map<int, std::pair<char, char> > prefixes;
+       std::vector<PrefixMode*> prefixes;
 
        const PrefixModeList& list = GetPrefixModes();
        for (PrefixModeList::const_iterator i = list.begin(); i != list.end(); ++i)
        {
                PrefixMode* pm = *i;
                if (pm->GetPrefix())
-                       prefixes[pm->GetPrefixRank()] = std::make_pair(pm->GetPrefix(), pm->GetModeChar());
+                       prefixes.push_back(pm);
        }
 
-       for (insp::flat_map<int, std::pair<char, char> >::reverse_iterator n = prefixes.rbegin(); n != prefixes.rend(); ++n)
+       std::sort(prefixes.begin(), prefixes.end(), PrefixModeSorter());
+       for (std::vector<PrefixMode*>::const_reverse_iterator n = prefixes.rbegin(); n != prefixes.rend(); ++n)
        {
-               mletters = mletters + n->second.first;
-               mprefixes = mprefixes + n->second.second;
+               mletters += (*n)->GetPrefix();
+               mprefixes += (*n)->GetModeChar();
        }
 
        return lettersAndModes ? "(" + mprefixes + ")" + mletters : mletters;
index bda4e6a4878410b7c0ce8ee3c0c8c43b2520c4c6..e5cb8ee9000ab3c1040db3d0a670ebce9f0c0035 100644 (file)
@@ -1076,6 +1076,9 @@ info_done_dealloc:
                        if (ret > 0)
                        {
                                reader.appendto(recvq);
+                               // Schedule a read if there is still data in the GnuTLS buffer
+                               if (gnutls_record_check_pending(sess) > 0)
+                                       SocketEngine::ChangeEventMask(user, FD_ADD_TRIAL_READ);
                                return 1;
                        }
                        else if (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED)
index 4df0d8962e96b98367d1fc3d339bb2109eae9c5a..8467cc6d416b5931efb721009aeca33611e7ea60 100644 (file)
@@ -631,8 +631,14 @@ class OpenSSLIOHook : public SSLIOHook
                        if (ret > 0)
                        {
                                recvq.append(buffer, ret);
+                               int mask = 0;
+                               // Schedule a read if there is still data in the OpenSSL buffer
+                               if (SSL_pending(sess) > 0)
+                                       mask |= FD_ADD_TRIAL_READ;
                                if (data_to_write)
-                                       SocketEngine::ChangeEventMask(user, FD_WANT_POLL_READ | FD_WANT_SINGLE_WRITE);
+                                       mask |= FD_WANT_POLL_READ | FD_WANT_SINGLE_WRITE;
+                               if (mask != 0)
+                                       SocketEngine::ChangeEventMask(user, mask);
                                return 1;
                        }
                        else if (ret == 0)
index 7d8c74024a8f0b5a5a877d6dcdabdbef0b0bb871..c8b6b73a8836cda49cd90107e3bc31c995e46457 100644 (file)
@@ -79,7 +79,7 @@ class ModuleCensor : public Module
                        {
                                if (index->second.empty())
                                {
-                                       user->WriteNumeric(ERR_WORDFILTERED, ((Channel*)dest)->name, index->first, "Your message contained a censored word, and was blocked");
+                                       user->WriteNumeric(ERR_WORDFILTERED, ((target_type == TYPE_CHANNEL) ? ((Channel*)dest)->name : ((User*)dest)->nick), index->first, "Your message contained a censored word, and was blocked");
                                        return MOD_RES_DENY;
                                }
 
index 21cc97aa5156198e1073d8c2b828405b87ffb67c..d8fbef69afa4d3d6666e0d244f7167c4d4a19b7d 100644 (file)
@@ -323,29 +323,43 @@ class ModuleDCCAllow : public Module
                                                                return MOD_RES_PASSTHRU;
                                        }
 
-                                       // tokenize
-                                       std::stringstream ss(text);
-                                       std::string buf;
-                                       std::vector<std::string> tokens;
-
-                                       while (ss >> buf)
-                                               tokens.push_back(buf);
-
-                                       if (tokens.size() < 2)
+                                       std::string buf = text.substr(5);
+                                       size_t s = buf.find(' ');
+                                       if (s == std::string::npos)
                                                return MOD_RES_PASSTHRU;
 
-                                       irc::string type = tokens[1].c_str();
+                                       irc::string type = assign(buf.substr(0, s));
 
                                        ConfigTag* conftag = ServerInstance->Config->ConfValue("dccallow");
                                        bool blockchat = conftag->getBool("blockchat");
 
                                        if (type == "SEND")
                                        {
-                                               if (tokens.size() < 3)
+                                               size_t first;
+
+                                               buf = buf.substr(s + 1);
+
+                                               if (!buf.empty() && buf[0] == '"')
+                                               {
+                                                       s = buf.find('"', 1);
+
+                                                       if (s == std::string::npos || s <= 1)
+                                                               return MOD_RES_PASSTHRU;
+
+                                                       --s;
+                                                       first = 1;
+                                               }
+                                               else
+                                               {
+                                                       s = buf.find(' ');
+                                                       first = 0;
+                                               }
+
+                                               if (s == std::string::npos)
                                                        return MOD_RES_PASSTHRU;
 
                                                std::string defaultaction = conftag->getString("action");
-                                               std::string filename = tokens[2];
+                                               std::string filename = buf.substr(first, s);
 
                                                bool found = false;
                                                for (unsigned int i = 0; i < bfl.size(); i++)
index 02a302c11cacd46d1d660a792745fcffc9efdf04..2b247a198a138ebc6e7cd9943db59002a58b0599 100644 (file)
@@ -245,7 +245,7 @@ class SaslAuthenticator
 
                SendSASL(params);
 
-               if (parameters[0][0] == '*')
+               if (parameters[0].c_str()[0] == '*')
                {
                        this->Abort();
                        return false;
index b6c6ce174f046570fd34e634b6ea3bf105f0b63d..b925c3f3733cea83d744a25677c253ffc2794855 100644 (file)
@@ -63,7 +63,7 @@ class ModuleSecureList : public Module
 
                        /* Not exempt, BOOK EM DANNO! */
                        user->WriteNotice("*** You cannot list within the first " + ConvToStr(WaitTime) + " seconds of connecting. Please try again later.");
-                       /* Some crap clients (read: mIRC, various java chat applets) muck up if they don't
+                       /* Some clients (e.g. mIRC, various java chat applets) muck up if they don't
                         * receive these numerics whenever they send LIST, so give them an empty LIST to mull over.
                         */
                        user->WriteNumeric(RPL_LISTSTART, "Channel", "Users Name");
index 7b0478229990cf2dc592bf61398eac22d5bbc1cd..64ca729779249cd2a44e8bb8fc80db9119719d71 100644 (file)
@@ -56,7 +56,7 @@ void SpanningTreeUtilities::RouteCommand(TreeServer* origin, CommandBase* thiscm
                        sdest = FindRouteTarget(routing.serverdest);
                        if (!sdest)
                        {
-                               ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Trying to route %s%s to nonexistant server %s", (encap ? "ENCAP " : ""), command.c_str(), routing.serverdest.c_str());
+                               ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Trying to route %s%s to nonexistent server %s", (encap ? "ENCAP " : ""), command.c_str(), routing.serverdest.c_str());
                                return;
                        }
                }
index 7b4bbe281cbd3a2396ffa58c668e594f64c10f35..5891b42f014f61cf3db0b70b8ab5889bb59e63d5 100644 (file)
@@ -151,6 +151,7 @@ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs
        {
                ServerInstance->Logs->Log("USERS", LOG_DEBUG, "Internal error on new connection");
                this->QuitUser(New, "Internal error handling connection");
+               return;
        }
 
        if (ServerInstance->Config->RawLog)
diff --git a/tools/travis-ci.sh b/tools/travis-ci.sh
new file mode 100755 (executable)
index 0000000..8828532
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/bash
+set -v
+if [ "$TRAVIS_OS_NAME" = "linux" ]
+then
+       sudo apt-get update --assume-yes
+       sudo apt-get install --assume-yes libgeoip-dev libgnutls-dev libldap2-dev libmysqlclient-dev libpcre3-dev libpq-dev libsqlite3-dev libssl-dev libtre-dev
+elif [ "$TRAVIS_OS_NAME" = "osx" ]
+then
+       brew update
+       brew install geoip gnutls mysql-connector-c openssl pcre postgresql sqlite3 tre
+       brew link sqlite3 --force
+else
+       >&2 echo "'$TRAVIS_OS_NAME' is an unknown Travis CI environment!"
+       exit 1
+fi
+set -e
+export TEST_BUILD_MODULES="m_geoip.cpp,m_ldap.cpp,m_mysql.cpp,m_pgsql.cpp,m_regex_pcre.cpp,m_regex_posix.cpp,m_regex_tre.cpp,m_sqlite3.cpp,m_ssl_gnutls.cpp,m_ssl_openssl.cpp"
+./tools/test-build $CXX
+./run/bin/inspircd --version