diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/commands.cpp | 6 | ||||
-rw-r--r-- | src/commands/cmd_restart.cpp | 4 | ||||
-rw-r--r-- | src/dynamic.cpp | 15 | ||||
-rw-r--r-- | src/inspircd.cpp | 5 | ||||
-rw-r--r-- | src/modules.cpp | 9 | ||||
-rw-r--r-- | src/modules/extra/README | 2 | ||||
-rw-r--r-- | src/modules/extra/m_mysql.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_blockcaps.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_cap.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_cgiirc.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_noctcp.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_sasl.cpp | 9 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.h | 2 | ||||
-rw-r--r-- | src/modules/m_timedbans.cpp | 2 | ||||
-rw-r--r-- | src/users.cpp | 3 | ||||
-rw-r--r-- | src/xline.cpp | 11 |
16 files changed, 41 insertions, 37 deletions
diff --git a/src/commands.cpp b/src/commands.cpp index d805a1f65..5bf2aeb03 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -42,8 +42,8 @@ bool InspIRCd::HostMatchesEveryone(const std::string &mask, User* user) for (user_hash::iterator u = this->Users->clientlist->begin(); u != this->Users->clientlist->end(); u++) { - if ((InspIRCd::Match(u->second->MakeHost(), mask, ascii_case_insensitive_map)) || - (InspIRCd::Match(u->second->MakeHostIP(), mask, ascii_case_insensitive_map))) + if ((InspIRCd::MatchCIDR(u->second->MakeHost(), mask, ascii_case_insensitive_map)) || + (InspIRCd::MatchCIDR(u->second->MakeHostIP(), mask, ascii_case_insensitive_map))) { matches++; } @@ -74,7 +74,7 @@ bool InspIRCd::IPMatchesEveryone(const std::string &ip, User* user) for (user_hash::iterator u = this->Users->clientlist->begin(); u != this->Users->clientlist->end(); u++) { - if (InspIRCd::Match(u->second->GetIPString(), ip, ascii_case_insensitive_map)) + if (InspIRCd::MatchCIDR(u->second->GetIPString(), ip, ascii_case_insensitive_map)) matches++; } diff --git a/src/commands/cmd_restart.cpp b/src/commands/cmd_restart.cpp index bdbcfed35..48f902d1e 100644 --- a/src/commands/cmd_restart.cpp +++ b/src/commands/cmd_restart.cpp @@ -47,7 +47,7 @@ CmdResult CommandRestart::Handle (const std::vector<std::string>& parameters, Us ServerInstance->SendError("Server restarting."); #ifndef _WIN32 - /* XXX: This hack sets FD_CLOEXEC on all possible file descriptors, so they're closed if the execv() below succeeds. + /* XXX: This hack sets FD_CLOEXEC on all possible file descriptors, so they're closed if the execvp() below succeeds. * Certainly, this is not a nice way to do things and it's slow when the fd limit is high. * * A better solution would be to set the close-on-exec flag for each fd we create (or create them with O_CLOEXEC), @@ -61,7 +61,7 @@ CmdResult CommandRestart::Handle (const std::vector<std::string>& parameters, Us } #endif - execv(ServerInstance->Config->cmdline.argv[0], ServerInstance->Config->cmdline.argv); + execvp(ServerInstance->Config->cmdline.argv[0], ServerInstance->Config->cmdline.argv); ServerInstance->SNO->WriteGlobalSno('a', "Failed RESTART - could not execute '%s' (%s)", ServerInstance->Config->cmdline.argv[0], strerror(errno)); } diff --git a/src/dynamic.cpp b/src/dynamic.cpp index 3a6a151cb..25178cfa1 100644 --- a/src/dynamic.cpp +++ b/src/dynamic.cpp @@ -43,11 +43,7 @@ DLLManager::DLLManager(const char *fname) h = dlopen(fname, RTLD_NOW|RTLD_LOCAL); if (!h) { -#ifdef _WIN32 RetrieveLastError(); -#else - err = dlerror(); -#endif } } @@ -72,11 +68,7 @@ Module* DLLManager::CallInit() initfn.vptr = dlsym(h, MODULE_INIT_STR); if (!initfn.vptr) { -#ifdef _WIN32 RetrieveLastError(); -#else - err = dlerror(); -#endif return NULL; } @@ -94,18 +86,21 @@ std::string DLLManager::GetVersion() return "Unversioned module"; } -#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) sprintf_s(errmsg, _countof(errmsg), "Error code: %u", dwErrorCode); SetLastError(ERROR_SUCCESS); err = errmsg; +#else + char* errmsg = dlerror(); + err = errmsg ? errmsg : "Unknown error"; +#endif std::string::size_type p; while ((p = err.find_last_of("\r\n")) != std::string::npos) err.erase(p, 1); } -#endif diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 0fa90fca5..66f9bfdc5 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -223,6 +223,11 @@ void InspIRCd::RehashUsersAndChans() (**i).already_sent = 0; (**i).RemoveExpiredInvites(); } + + // 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. + ServerInstance->XLines->GetAll("E"); } void InspIRCd::SetSignals() diff --git a/src/modules.cpp b/src/modules.cpp index b2d2f23c6..79a33e617 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -641,7 +641,8 @@ static ConfigTag* SlowGetTag(const std::string &tag, int index) std::string ConfigReader::ReadValue(const std::string &tag, const std::string &name, const std::string &default_value, int index, bool allow_linefeeds) { std::string result = default_value; - if (!SlowGetTag(tag, index)->readString(name, result, allow_linefeeds)) + ConfigTag* conftag = SlowGetTag(tag, index); + if (!conftag || !conftag->readString(name, result, allow_linefeeds)) { this->error = CONF_VALUE_NOT_FOUND; } @@ -656,7 +657,8 @@ std::string ConfigReader::ReadValue(const std::string &tag, const std::string &n bool ConfigReader::ReadFlag(const std::string &tag, const std::string &name, const std::string &default_value, int index) { bool def = (default_value == "yes"); - return SlowGetTag(tag, index)->getBool(name, def); + ConfigTag* conftag = SlowGetTag(tag, index); + return conftag ? conftag->getBool(name, def) : def; } bool ConfigReader::ReadFlag(const std::string &tag, const std::string &name, int index) @@ -668,7 +670,8 @@ bool ConfigReader::ReadFlag(const std::string &tag, const std::string &name, int int ConfigReader::ReadInteger(const std::string &tag, const std::string &name, const std::string &default_value, int index, bool need_positive) { int v = atoi(default_value.c_str()); - int result = SlowGetTag(tag, index)->getInt(name, v); + ConfigTag* conftag = SlowGetTag(tag, index); + int result = conftag ? conftag->getInt(name, v) : v; if ((need_positive) && (result < 0)) { diff --git a/src/modules/extra/README b/src/modules/extra/README index 2478b57cf..b59494df9 100644 --- a/src/modules/extra/README +++ b/src/modules/extra/README @@ -2,7 +2,7 @@ This directory stores modules which require external libraries to compile. For example, m_filter_pcre requires the PCRE libraries. To compile any of these modules first ensure you have the required dependencies -(read the online documentation at http://wiki.inspircd.org/) and then symlink +(read the online documentation at https://wiki.inspircd.org/) and then symlink the .cpp file from this directory into the parent directory (src/modules/). Alternatively, use the command: ./configure --enable-extras=m_extra.cpp, which will diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp index 01b1553b0..159a0b8b2 100644 --- a/src/modules/extra/m_mysql.cpp +++ b/src/modules/extra/m_mysql.cpp @@ -67,8 +67,6 @@ * if a module is ever put in a re-enterant state (stack corruption could occur, crashes, data * corruption, and worse, so DONT think about it until the day comes when InspIRCd is 100% * gauranteed threadsafe!) - * - * For a diagram of this system please see http://wiki.inspircd.org/Mysql2 */ class SQLConnection; diff --git a/src/modules/m_blockcaps.cpp b/src/modules/m_blockcaps.cpp index 200693699..7146ee068 100644 --- a/src/modules/m_blockcaps.cpp +++ b/src/modules/m_blockcaps.cpp @@ -67,7 +67,7 @@ public: { if (target_type == TYPE_CHANNEL) { - if ((!IS_LOCAL(user)) || (text.length() < minlen)) + if ((!IS_LOCAL(user)) || (text.length() < minlen) || (text == "\1ACTION\1") || (text == "\1ACTION")) return MOD_RES_PASSTHRU; Channel* c = (Channel*)dest; diff --git a/src/modules/m_cap.cpp b/src/modules/m_cap.cpp index 6b4387fdd..ae9e824f4 100644 --- a/src/modules/m_cap.cpp +++ b/src/modules/m_cap.cpp @@ -120,7 +120,7 @@ class CommandCAP : public Command } else { - user->WriteNumeric(ERR_INVALIDCAPSUBCOMMAND, "%s %s :Invalid CAP subcommand", user->nick.c_str(), subcommand.c_str()); + user->WriteNumeric(ERR_INVALIDCAPSUBCOMMAND, "%s %s :Invalid CAP subcommand", user->nick.c_str(), subcommand.empty() ? "*" : subcommand.c_str()); return CMD_FAILURE; } diff --git a/src/modules/m_cgiirc.cpp b/src/modules/m_cgiirc.cpp index 09f6a4659..9e1a546d6 100644 --- a/src/modules/m_cgiirc.cpp +++ b/src/modules/m_cgiirc.cpp @@ -99,7 +99,7 @@ class CommandWebirc : public Command realhost.set(user, user->host); realip.set(user, user->GetIPString()); - bool host_ok = (parameters[2].length() < 64); + bool host_ok = (parameters[2].length() < 64) && (parameters[2].find_first_not_of("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-") == std::string::npos); const std::string& newhost = (host_ok ? parameters[2] : parameters[3]); if (notify) diff --git a/src/modules/m_noctcp.cpp b/src/modules/m_noctcp.cpp index 1dd6fe34a..c934a05c6 100644 --- a/src/modules/m_noctcp.cpp +++ b/src/modules/m_noctcp.cpp @@ -67,7 +67,7 @@ class ModuleNoCTCP : public Module 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"); diff --git a/src/modules/m_sasl.cpp b/src/modules/m_sasl.cpp index 8ac43fba7..7108e0c07 100644 --- a/src/modules/m_sasl.cpp +++ b/src/modules/m_sasl.cpp @@ -103,6 +103,15 @@ class SaslAuthenticator 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"); + } + SendSASL(params); } diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h index 17adc9287..3e0a83111 100644 --- a/src/modules/m_spanningtree/main.h +++ b/src/modules/m_spanningtree/main.h @@ -31,7 +31,7 @@ * If you completely change the protocol, completely change the number. * * IMPORTANT: If you make changes, document your changes here, without fail: - * http://wiki.inspircd.org/List_of_protocol_changes_between_versions + * https://wiki.inspircd.org/List_of_protocol_changes_between_versions * * Failure to document your protocol changes will result in a painfully * painful death by pain. You have been warned. diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp index b47327704..61095d6eb 100644 --- a/src/modules/m_timedbans.cpp +++ b/src/modules/m_timedbans.cpp @@ -119,7 +119,7 @@ class CommandTban : public Command // 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") ? '%' : '@'; + 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 --git a/src/users.cpp b/src/users.cpp index 4dbb73a1f..9e06485e5 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -1008,8 +1008,7 @@ bool User::SetClientIP(const char* sip, bool recheck_eline) void User::SetClientIP(const irc::sockets::sockaddrs& sa, bool recheck_eline) { - cachedip.clear(); - cached_hostip.clear(); + this->InvalidateCache(); memcpy(&client_sa, &sa, sizeof(irc::sockets::sockaddrs)); } diff --git a/src/xline.cpp b/src/xline.cpp index 66d24f439..0506005ad 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -159,6 +159,7 @@ void XLineManager::CheckELines() for (LocalUserList::const_iterator u2 = ServerInstance->Users->local_users.begin(); u2 != ServerInstance->Users->local_users.end(); u2++) { User* u = (User*)(*u2); + u->exempt = false; /* This uses safe iteration to ensure that if a line expires here, it doenst trash the iterator */ LookupIter safei; @@ -169,7 +170,8 @@ void XLineManager::CheckELines() safei++; XLine *e = i->second; - u->exempt = e->Matches(u); + if ((!e->duration || ServerInstance->Time() < e->expiry) && e->Matches(u)) + u->exempt = true; i = safei; } @@ -325,13 +327,6 @@ bool XLineManager::DelLine(const char* hostmask, const std::string &type, User* void ELine::Unset() { - /* remove exempt from everyone and force recheck after deleting eline */ - for (LocalUserList::const_iterator u2 = ServerInstance->Users->local_users.begin(); u2 != ServerInstance->Users->local_users.end(); u2++) - { - User* u = (User*)(*u2); - u->exempt = false; - } - ServerInstance->XLines->CheckELines(); } |