diff options
-rw-r--r-- | .travis.yml | 12 | ||||
-rw-r--r-- | docs/conf/inspircd.conf.example | 3 | ||||
-rw-r--r-- | include/configreader.h | 4 | ||||
-rw-r--r-- | include/inspircd.h | 3 | ||||
-rw-r--r-- | make/template/inspircd | 4 | ||||
-rw-r--r-- | make/template/main.mk | 21 | ||||
-rw-r--r-- | src/configreader.cpp | 3 | ||||
-rw-r--r-- | src/coremods/core_list.cpp | 3 | ||||
-rw-r--r-- | src/coremods/core_oper/cmd_kill.cpp | 4 | ||||
-rw-r--r-- | src/coremods/core_stats.cpp | 2 | ||||
-rw-r--r-- | src/inspircd.cpp | 10 | ||||
-rw-r--r-- | src/mode.cpp | 19 | ||||
-rw-r--r-- | src/modules/extra/m_ssl_gnutls.cpp | 3 | ||||
-rw-r--r-- | src/modules/extra/m_ssl_openssl.cpp | 8 | ||||
-rw-r--r-- | src/modules/m_censor.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_dccallow.cpp | 38 | ||||
-rw-r--r-- | src/modules/m_sasl.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_securelist.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/postcommand.cpp | 2 | ||||
-rw-r--r-- | src/usermanager.cpp | 1 | ||||
-rwxr-xr-x | tools/travis-ci.sh | 19 |
21 files changed, 120 insertions, 45 deletions
diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..631802526 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,12 @@ +compiler: + - "clang" + - "gcc" +language: "cpp" +notifications: + email: false +os: + - "linux" + - "osx" +script: + - "sh ./tools/travis-ci.sh" +sudo: required diff --git a/docs/conf/inspircd.conf.example b/docs/conf/inspircd.conf.example index 16c34cc24..d56ac55ac 100644 --- a/docs/conf/inspircd.conf.example +++ b/docs/conf/inspircd.conf.example @@ -695,6 +695,9 @@ # 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). diff --git a/include/configreader.h b/include/configreader.h index f2ba16902..fb93adafd 100644 --- a/include/configreader.h +++ b/include/configreader.h @@ -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. */ diff --git a/include/inspircd.h b/include/inspircd.h index ee09070f8..303d24745 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -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() diff --git a/make/template/inspircd b/make/template/inspircd index 138de29a9..cb2d2902d 100644 --- a/make/template/inspircd +++ b/make/template/inspircd @@ -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() diff --git a/make/template/main.mk b/make/template/main.mk index bff065736..818b4139d 100644 --- a/make/template/main.mk +++ b/make/template/main.mk @@ -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' diff --git a/src/configreader.cpp b/src/configreader.cpp index e607c6e7d..8a432e82f 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -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) diff --git a/src/coremods/core_list.cpp b/src/coremods/core_list.cpp index 67829a55e..6a62d122f 100644 --- a/src/coremods/core_list.cpp +++ b/src/coremods/core_list.cpp @@ -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] == '<') { diff --git a/src/coremods/core_oper/cmd_kill.cpp b/src/coremods/core_oper/cmd_kill.cpp index 0d111ce02..e75566e2f 100644 --- a/src/coremods/core_oper/cmd_kill.cpp +++ b/src/coremods/core_oper/cmd_kill.cpp @@ -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()); diff --git a/src/coremods/core_stats.cpp b/src/coremods/core_stats.cpp index d890d19ea..ee0c50db2 100644 --- a/src/coremods/core_stats.cpp +++ b/src/coremods/core_stats.cpp @@ -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 diff --git a/src/inspircd.cpp b/src/inspircd.cpp index eb24cdea0..5d4d8081f 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -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 } diff --git a/src/mode.cpp b/src/mode.cpp index b29eda828..3762dc52e 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -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; diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp index bda4e6a48..e5cb8ee90 100644 --- a/src/modules/extra/m_ssl_gnutls.cpp +++ b/src/modules/extra/m_ssl_gnutls.cpp @@ -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) diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp index 4df0d8962..8467cc6d4 100644 --- a/src/modules/extra/m_ssl_openssl.cpp +++ b/src/modules/extra/m_ssl_openssl.cpp @@ -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) diff --git a/src/modules/m_censor.cpp b/src/modules/m_censor.cpp index 7d8c74024..c8b6b73a8 100644 --- a/src/modules/m_censor.cpp +++ b/src/modules/m_censor.cpp @@ -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; } diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp index 21cc97aa5..d8fbef69a 100644 --- a/src/modules/m_dccallow.cpp +++ b/src/modules/m_dccallow.cpp @@ -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++) diff --git a/src/modules/m_sasl.cpp b/src/modules/m_sasl.cpp index 02a302c11..2b247a198 100644 --- a/src/modules/m_sasl.cpp +++ b/src/modules/m_sasl.cpp @@ -245,7 +245,7 @@ class SaslAuthenticator SendSASL(params); - if (parameters[0][0] == '*') + if (parameters[0].c_str()[0] == '*') { this->Abort(); return false; diff --git a/src/modules/m_securelist.cpp b/src/modules/m_securelist.cpp index b6c6ce174..b925c3f37 100644 --- a/src/modules/m_securelist.cpp +++ b/src/modules/m_securelist.cpp @@ -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"); diff --git a/src/modules/m_spanningtree/postcommand.cpp b/src/modules/m_spanningtree/postcommand.cpp index 7b0478229..64ca72977 100644 --- a/src/modules/m_spanningtree/postcommand.cpp +++ b/src/modules/m_spanningtree/postcommand.cpp @@ -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; } } diff --git a/src/usermanager.cpp b/src/usermanager.cpp index 7b4bbe281..5891b42f0 100644 --- a/src/usermanager.cpp +++ b/src/usermanager.cpp @@ -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 index 000000000..8828532b0 --- /dev/null +++ b/tools/travis-ci.sh @@ -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 |