diff options
Diffstat (limited to 'src')
31 files changed, 134 insertions, 73 deletions
diff --git a/src/cidr.cpp b/src/cidr.cpp index 875b95304..8d199353d 100644 --- a/src/cidr.cpp +++ b/src/cidr.cpp @@ -66,7 +66,7 @@ bool irc::sockets::MatchCIDR(const std::string &address, const std::string &cidr const std::string::size_type per_pos = cidr_copy.rfind('/'); if ((per_pos == std::string::npos) || (per_pos == cidr_copy.length()-1) || (cidr_copy.find_first_not_of("0123456789", per_pos+1) != std::string::npos) - || (cidr_copy.find_first_not_of("0123456789abcdef.:") < per_pos)) + || (cidr_copy.find_first_not_of("0123456789abcdefABCDEF.:") < per_pos)) { // The CIDR mask is invalid return false; diff --git a/src/coremods/core_stats.cpp b/src/coremods/core_stats.cpp index 1192b1be9..997dd3afe 100644 --- a/src/coremods/core_stats.cpp +++ b/src/coremods/core_stats.cpp @@ -335,7 +335,7 @@ void CommandStats::DoStats(char statschar, User* user, string_list &results) tag->init(); std::string umodes; std::string cmodes; - for(char c='A'; c < 'z'; c++) + for(char c='A'; c <= 'z'; c++) { ModeHandler* mh = ServerInstance->Modes->FindMode(c, MODETYPE_USER); if (mh && mh->NeedsOper() && tag->AllowedUserModes[c - 'A']) diff --git a/src/coremods/core_stub.cpp b/src/coremods/core_stub.cpp index 30c7ce752..bb6590261 100644 --- a/src/coremods/core_stub.cpp +++ b/src/coremods/core_stub.cpp @@ -33,7 +33,7 @@ class CommandConnect : public Command : Command(parent, "CONNECT", 1) { flags_needed = 'o'; - syntax = "<servername> [<remote-server>]"; + syntax = "<servername>"; } /** Handle command. @@ -119,7 +119,7 @@ class CommandSquit : public Command : Command(parent, "SQUIT", 1, 2) { flags_needed = 'o'; - syntax = "<servername> [<reason>]"; + syntax = "<servername>"; } /** Handle command. diff --git a/src/coremods/core_userhost.cpp b/src/coremods/core_userhost.cpp index 1b34addb5..a67824194 100644 --- a/src/coremods/core_userhost.cpp +++ b/src/coremods/core_userhost.cpp @@ -28,7 +28,7 @@ class CommandUserhost : public Command /** Constructor for userhost. */ CommandUserhost ( Module* parent) : Command(parent,"USERHOST", 1, 5) { - syntax = "<nick> {<nick>}"; + syntax = "<nick> [<nick> ...]"; } /** Handle command. * @param parameters The parameters to the command diff --git a/src/dynamic.cpp b/src/dynamic.cpp index 2fb5211fb..9984f4dbe 100644 --- a/src/dynamic.cpp +++ b/src/dynamic.cpp @@ -97,9 +97,15 @@ std::string DLLManager::GetVersion() #ifdef _WIN32 void DLLManager::RetrieveLastError() { - CHAR errmsg[100]; - FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), errmsg, 100, 0); + 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; + + 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/modules.cpp b/src/modules.cpp index 9a61a7226..42a9e8010 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -515,7 +515,7 @@ void ModuleManager::Reload(Module* mod, HandlerBase1<void, bool>* callback) { if (CanUnload(mod)) ServerInstance->AtomicActions.AddAction(new ReloadAction(mod, callback)); - else + else if (callback) callback->Call(false); } diff --git a/src/modules/extra/m_ldap.cpp b/src/modules/extra/m_ldap.cpp index 4666a86a2..9f8d68427 100644 --- a/src/modules/extra/m_ldap.cpp +++ b/src/modules/extra/m_ldap.cpp @@ -23,8 +23,8 @@ #include <ldap.h> #ifdef _WIN32 -# pragma comment(lib, "ldap.lib") -# pragma comment(lib, "lber.lib") +# pragma comment(lib, "libldap.lib") +# pragma comment(lib, "liblber.lib") #endif /* $LinkerFlags: -lldap */ diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp index fd1a83112..1002a98ba 100644 --- a/src/modules/extra/m_mysql.cpp +++ b/src/modules/extra/m_mysql.cpp @@ -28,9 +28,7 @@ #include "modules/sql.h" #ifdef _WIN32 -# pragma comment(lib, "mysqlclient.lib") -# pragma comment(lib, "advapi32.lib") -# pragma comment(linker, "/NODEFAULTLIB:LIBCMT") +# pragma comment(lib, "libmysql.lib") #endif /* VERSION 3 API: With nonblocking (threaded) requests */ diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp index 718bdd1ea..e6efb9771 100644 --- a/src/modules/extra/m_ssl_gnutls.cpp +++ b/src/modules/extra/m_ssl_gnutls.cpp @@ -47,14 +47,7 @@ #endif #ifdef _WIN32 -# pragma comment(lib, "libgnutls.lib") -# pragma comment(lib, "libgcrypt.lib") -# pragma comment(lib, "libgpg-error.lib") -# pragma comment(lib, "user32.lib") -# pragma comment(lib, "advapi32.lib") -# pragma comment(lib, "libgcc.lib") -# pragma comment(lib, "libmingwex.lib") -# pragma comment(lib, "gdi32.lib") +# pragma comment(lib, "libgnutls-28.lib") #endif /* $CompileFlags: pkgconfincludes("gnutls","/gnutls/gnutls.h","") eval("print `libgcrypt-config --cflags | tr -d \r` if `pkg-config --modversion gnutls 2>/dev/null | tr -d \r` lt '2.12'") */ @@ -693,11 +686,23 @@ class GnuTLSIOHook : public SSLIOHook goto info_done_dealloc; } - gnutls_x509_crt_get_dn(cert, str, &name_size); - certinfo->dn = str; + if (gnutls_x509_crt_get_dn(cert, str, &name_size) == 0) + { + std::string& dn = certinfo->dn; + dn = str; + // Make sure there are no chars in the string that we consider invalid + if (dn.find_first_of("\r\n") != std::string::npos) + dn.clear(); + } - gnutls_x509_crt_get_issuer_dn(cert, str, &name_size); - certinfo->issuer = str; + name_size = sizeof(str); + if (gnutls_x509_crt_get_issuer_dn(cert, str, &name_size) == 0) + { + std::string& issuer = certinfo->issuer; + issuer = str; + if (issuer.find_first_of("\r\n") != std::string::npos) + issuer.clear(); + } if ((ret = gnutls_x509_crt_get_fingerprint(cert, profile->GetHash(), digest, &digest_size)) < 0) { diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp index 9101ecd55..afead64d8 100644 --- a/src/modules/extra/m_ssl_openssl.cpp +++ b/src/modules/extra/m_ssl_openssl.cpp @@ -35,13 +35,8 @@ #include <openssl/err.h> #ifdef _WIN32 -# pragma comment(lib, "libcrypto.lib") -# pragma comment(lib, "libssl.lib") -# pragma comment(lib, "user32.lib") -# pragma comment(lib, "advapi32.lib") -# pragma comment(lib, "libgcc.lib") -# pragma comment(lib, "libmingwex.lib") -# pragma comment(lib, "gdi32.lib") +# pragma comment(lib, "ssleay32.lib") +# pragma comment(lib, "libeay32.lib") #endif /* $CompileFlags: pkgconfversion("openssl","0.9.7") pkgconfincludes("openssl","/openssl/ssl.h","") */ @@ -74,12 +69,21 @@ namespace OpenSSL public: DHParams(const std::string& filename) { +#ifdef _WIN32 + BIO* dhpfile = BIO_new_file(filename.c_str(), "r"); +#else FILE* dhpfile = fopen(filename.c_str(), "r"); +#endif if (dhpfile == NULL) throw Exception("Couldn't open DH file " + filename + ": " + strerror(errno)); +#ifdef _WIN32 + dh = PEM_read_bio_DHparams(dhpfile, NULL, NULL, NULL); + BIO_free(dhpfile); +#else dh = PEM_read_DHparams(dhpfile, NULL, NULL, NULL); fclose(dhpfile); +#endif if (!dh) throw Exception("Couldn't read DH params from file " + filename); } @@ -357,8 +361,14 @@ class OpenSSLIOHook : public SSLIOHook char buf[512]; X509_NAME_oneline(X509_get_subject_name(cert), buf, sizeof(buf)); certinfo->dn = buf; + // Make sure there are no chars in the string that we consider invalid + if (certinfo->dn.find_first_of("\r\n") != std::string::npos) + certinfo->dn.clear(); + X509_NAME_oneline(X509_get_issuer_name(cert), buf, sizeof(buf)); certinfo->issuer = buf; + if (certinfo->issuer.find_first_of("\r\n") != std::string::npos) + certinfo->issuer.clear(); if (!X509_digest(cert, profile->GetDigest(), md, &n)) { diff --git a/src/modules/m_callerid.cpp b/src/modules/m_callerid.cpp index 6f2c67300..f15760dca 100644 --- a/src/modules/m_callerid.cpp +++ b/src/modules/m_callerid.cpp @@ -183,7 +183,7 @@ public: extInfo(Creator) { allow_empty_last_param = false; - syntax = "{[+|-]<nicks>}|*}"; + syntax = "*|(+|-)<nick>[,(+|-)<nick> ...]"; TRANSLATE1(TR_CUSTOM); } diff --git a/src/modules/m_cgiirc.cpp b/src/modules/m_cgiirc.cpp index 23dc90ef8..791045780 100644 --- a/src/modules/m_cgiirc.cpp +++ b/src/modules/m_cgiirc.cpp @@ -104,6 +104,7 @@ class CommandWebirc : public Command ChangeIP(user, parameters[3]); // And follow this up by changing their host user->host = user->dhost = newhost; + user->InvalidateCache(); return CMD_SUCCESS; } diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index cbdb1d528..92f003a84 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -149,7 +149,7 @@ class CommandCheck : public Command { std::string umodes; std::string cmodes; - for(char c='A'; c < 'z'; c++) + for(char c='A'; c <= 'z'; c++) { ModeHandler* mh = ServerInstance->Modes->FindMode(c, MODETYPE_USER); if (mh && mh->NeedsOper() && loctarg->HasModePermission(c, MODETYPE_USER)) diff --git a/src/modules/m_chghost.cpp b/src/modules/m_chghost.cpp index 3a637f9d0..43b2a323b 100644 --- a/src/modules/m_chghost.cpp +++ b/src/modules/m_chghost.cpp @@ -56,7 +56,8 @@ class CommandChghost : public Command User* dest = ServerInstance->FindNick(parameters[0]); - if ((!dest) || (dest->registered != REG_ALL)) + // Allow services to change the host of unregistered users + if ((!dest) || ((dest->registered != REG_ALL) && (!user->server->IsULine()))) { user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str()); return CMD_FAILURE; diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp index 7332402ba..cc7fbd323 100644 --- a/src/modules/m_dccallow.cpp +++ b/src/modules/m_dccallow.cpp @@ -62,7 +62,7 @@ class CommandDccallow : public Command : Command(parent, "DCCALLOW", 0) , ext(Ext) { - syntax = "{[+|-]<nick> <time>|HELP|LIST}"; + syntax = "[(+|-)<nick> [<time>]]|[LIST|HELP]"; /* XXX we need to fix this so it can work with translation stuff (i.e. move +- into a seperate param */ } @@ -205,7 +205,7 @@ class CommandDccallow : public Command void DisplayHelp(User* user) { - user->WriteNumeric(998, ":DCCALLOW [<+|->nick [time]] [list] [help]"); + user->WriteNumeric(998, ":DCCALLOW [(+|-)<nick> [<time>]]|[LIST|HELP]"); user->WriteNumeric(998, ":You may allow DCCs from specific users by specifying a"); user->WriteNumeric(998, ":DCC allow for the user you want to receive DCCs from."); user->WriteNumeric(998, ":For example, to allow the user Brain to send you inspircd.exe"); diff --git a/src/modules/m_denychans.cpp b/src/modules/m_denychans.cpp index 184134025..6378ba273 100644 --- a/src/modules/m_denychans.cpp +++ b/src/modules/m_denychans.cpp @@ -56,7 +56,7 @@ class ModuleDenyChannels : public Module if (InspIRCd::Match(redirect, j->second->getString("name"))) { bool goodchan = false; - ConfigTagList goodchans = ServerInstance->Config->ConfTags("badchan"); + ConfigTagList goodchans = ServerInstance->Config->ConfTags("goodchan"); for (ConfigIter k = goodchans.first; k != goodchans.second; ++k) { if (InspIRCd::Match(redirect, k->second->getString("name"))) diff --git a/src/modules/m_hideoper.cpp b/src/modules/m_hideoper.cpp index d3c2bf444..5b226f3b8 100644 --- a/src/modules/m_hideoper.cpp +++ b/src/modules/m_hideoper.cpp @@ -76,6 +76,29 @@ class ModuleHideOper : public Module line.clear(); } } + + ModResult OnStats(char symbol, User* user, string_list& results) CXX11_OVERRIDE + { + if (symbol != 'P') + return MOD_RES_PASSTHRU; + + unsigned int count = 0; + const UserManager::OperList& opers = ServerInstance->Users->all_opers; + for (UserManager::OperList::const_iterator i = opers.begin(); i != opers.end(); ++i) + { + User* oper = *i; + if (!oper->server->IsULine() && (user->IsOper() || !oper->IsModeSet(hm))) + { + LocalUser* lu = IS_LOCAL(oper); + results.push_back("249 " + user->nick + " :" + oper->nick + " (" + oper->ident + "@" + oper->dhost + ") Idle: " + + (lu ? ConvToStr(ServerInstance->Time() - lu->idle_lastmsg) + " secs" : "unavailable")); + count++; + } + } + results.push_back("249 "+user->nick+" :"+ConvToStr(count)+" OPER(s)"); + + return MOD_RES_DENY; + } }; MODULE_INIT(ModuleHideOper) diff --git a/src/modules/m_ojoin.cpp b/src/modules/m_ojoin.cpp index e4314873b..120715429 100644 --- a/src/modules/m_ojoin.cpp +++ b/src/modules/m_ojoin.cpp @@ -57,7 +57,6 @@ class CommandOjoin : public SplitCommand if (notice) { - channel = ServerInstance->FindChan(parameters[0]); channel->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :%s joined on official network business.", parameters[0].c_str(), user->nick.c_str()); ServerInstance->PI->SendChannelNotice(channel, 0, user->nick + " joined on official network business."); diff --git a/src/modules/m_permchannels.cpp b/src/modules/m_permchannels.cpp index d23af04bc..60c4578c5 100644 --- a/src/modules/m_permchannels.cpp +++ b/src/modules/m_permchannels.cpp @@ -144,12 +144,7 @@ static bool WriteDatabase(PermChannel& permchanmode, Module* mod, bool save_list stream.close(); #ifdef _WIN32 - if (remove(permchannelsconf.c_str())) - { - ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Cannot remove old database! %s (%d)", strerror(errno), errno); - ServerInstance->SNO->WriteToSnoMask('a', "database: cannot remove old database: %s (%d)", strerror(errno), errno); - return false; - } + remove(permchannelsconf.c_str()); #endif // Use rename to move temporary to new db - this is guarenteed not to fuck up, even in case of a crash. if (rename(permchannelsnewconf.c_str(), permchannelsconf.c_str()) < 0) diff --git a/src/modules/m_spanningtree/capab.cpp b/src/modules/m_spanningtree/capab.cpp index e242bcd4a..f27fe8889 100644 --- a/src/modules/m_spanningtree/capab.cpp +++ b/src/modules/m_spanningtree/capab.cpp @@ -153,7 +153,13 @@ void TreeSocket::SendCapabilities(int phase) extra+ " PREFIX="+ServerInstance->Modes->BuildPrefixes()+ " CHANMODES="+ServerInstance->Modes->GiveModeList(MODETYPE_CHANNEL)+ - " USERMODES="+ServerInstance->Modes->GiveModeList(MODETYPE_USER) + " USERMODES="+ServerInstance->Modes->GiveModeList(MODETYPE_USER)+ + // XXX: Advertise the presence or absence of m_globops in CAPAB CAPABILITIES. + // Services want to know about it, and since m_globops was not marked as VF_(OPT)COMMON + // in 2.0, we advertise it here to not break linking to previous versions. + // Protocol version 1201 (1.2) does not have this issue because we advertise m_globops + // to 1201 protocol servers irrespectively of its module flags. + (ServerInstance->Modules->Find("m_globops.so") != NULL ? " GLOBOPS=1" : " GLOBOPS=0") ); this->WriteLine("CAPAB END"); diff --git a/src/modules/m_spanningtree/commands.h b/src/modules/m_spanningtree/commands.h index 67e2d43d6..3047e7e60 100644 --- a/src/modules/m_spanningtree/commands.h +++ b/src/modules/m_spanningtree/commands.h @@ -130,7 +130,7 @@ class CommandFJoin : public ServerCommand * @param newname The new name of the channel; must be the same or a case change of the current name */ static void LowerTS(Channel* chan, time_t TS, const std::string& newname); - void ProcessModeUUIDPair(const std::string& item, TreeSocket* src_socket, Channel* chan, irc::modestacker* modestack); + void ProcessModeUUIDPair(const std::string& item, TreeServer* sourceserver, Channel* chan, irc::modestacker* modestack); public: CommandFJoin(Module* Creator) : ServerCommand(Creator, "FJOIN", 3) { } CmdResult Handle(User* user, std::vector<std::string>& params); diff --git a/src/modules/m_spanningtree/fjoin.cpp b/src/modules/m_spanningtree/fjoin.cpp index d8027628f..d5b80fcb1 100644 --- a/src/modules/m_spanningtree/fjoin.cpp +++ b/src/modules/m_spanningtree/fjoin.cpp @@ -148,7 +148,7 @@ CmdResult CommandFJoin::Handle(User* srcuser, std::vector<std::string>& params) } irc::modestacker modestack(true); - TreeSocket* src_socket = TreeServer::Get(srcuser)->GetSocket(); + TreeServer* const sourceserver = TreeServer::Get(srcuser); /* Now, process every 'modes,uuid' pair */ irc::tokenstream users(params.back()); @@ -156,7 +156,7 @@ CmdResult CommandFJoin::Handle(User* srcuser, std::vector<std::string>& params) irc::modestacker* modestackptr = (apply_other_sides_modes ? &modestack : NULL); while (users.GetToken(item)) { - ProcessModeUUIDPair(item, src_socket, chan, modestackptr); + ProcessModeUUIDPair(item, sourceserver, chan, modestackptr); } /* Flush mode stacker if we lost the FJOIN or had equal TS */ @@ -166,7 +166,7 @@ CmdResult CommandFJoin::Handle(User* srcuser, std::vector<std::string>& params) return CMD_SUCCESS; } -void CommandFJoin::ProcessModeUUIDPair(const std::string& item, TreeSocket* src_socket, Channel* chan, irc::modestacker* modestack) +void CommandFJoin::ProcessModeUUIDPair(const std::string& item, TreeServer* sourceserver, Channel* chan, irc::modestacker* modestack) { std::string::size_type comma = item.find(','); @@ -180,6 +180,7 @@ void CommandFJoin::ProcessModeUUIDPair(const std::string& item, TreeSocket* src_ return; } + TreeSocket* src_socket = sourceserver->GetSocket(); /* Check that the user's 'direction' is correct */ TreeServer* route_back_again = TreeServer::Get(who); if (route_back_again->GetSocket() != src_socket) @@ -202,7 +203,7 @@ void CommandFJoin::ProcessModeUUIDPair(const std::string& item, TreeSocket* src_ } } - Membership* memb = chan->ForceJoin(who, NULL, route_back_again->bursting); + Membership* memb = chan->ForceJoin(who, NULL, sourceserver->bursting); if (!memb) return; diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index a17fb203c..ee4c4bdd8 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -694,6 +694,7 @@ void ModuleSpanningTree::OnUnloadModule(Module* mod) return; ServerInstance->PI->SendMetaData("modules", "-" + mod->ModuleSourceFile); +restart: // Close all connections which use an IO hook provided by this module const TreeServer::ChildServers& list = Utils->TreeRoot->GetChildren(); for (TreeServer::ChildServers::const_iterator i = list.begin(); i != list.end(); ++i) @@ -703,6 +704,8 @@ void ModuleSpanningTree::OnUnloadModule(Module* mod) { sock->SendError("SSL module unloaded"); sock->Close(); + // XXX: The list we're iterating is modified by TreeSocket::Squit() which is called by Close() + goto restart; } } diff --git a/src/modules/m_spanningtree/nick.cpp b/src/modules/m_spanningtree/nick.cpp index ecec849ee..686a2cc4c 100644 --- a/src/modules/m_spanningtree/nick.cpp +++ b/src/modules/m_spanningtree/nick.cpp @@ -42,21 +42,22 @@ CmdResult CommandNick::HandleRemote(RemoteUser* user, std::vector<std::string>& * On nick messages, check that the nick doesn't already exist here. * If it does, perform collision logic. */ + bool callfnc = true; User* x = ServerInstance->FindNickOnly(params[0]); - if ((x) && (x != user)) + if ((x) && (x != user) && (x->registered == REG_ALL)) { /* x is local, who is remote */ int collideret = Utils->DoCollision(x, TreeServer::Get(user), newts, user->ident, user->GetIPString(), user->uuid); if (collideret != 1) { - /* - * Remote client lost, or both lost, parsing or passing on this - * nickchange would be pointless, as the incoming client's server will - * soon receive SAVE to change its nick to its UID. :) -- w00t - */ - return CMD_FAILURE; + // Remote client lost, or both lost, rewrite this nick change as a change to uuid before + // forwarding and don't call ChangeNick() because DoCollision() has done it already + params[0] = user->uuid; + callfnc = false; } } - user->ChangeNick(params[0], newts); + if (callfnc) + user->ChangeNick(params[0], newts); + return CMD_SUCCESS; } diff --git a/src/modules/m_spanningtree/server.cpp b/src/modules/m_spanningtree/server.cpp index 69cae001c..f232d57d6 100644 --- a/src/modules/m_spanningtree/server.cpp +++ b/src/modules/m_spanningtree/server.cpp @@ -148,7 +148,7 @@ bool TreeSocket::Outbound_Reply_Server(parameterlist ¶ms) return true; } - this->SendError("Invalid credentials (check the other server's linking snomask for more information)"); + this->SendError("Mismatched server name or password (check the other server's snomask output for details - e.g. umode +s +Ll)"); ServerInstance->SNO->WriteToSnoMask('l',"Server connection from \2"+sname+"\2 denied, invalid link credentials"); return false; } @@ -240,7 +240,7 @@ bool TreeSocket::Inbound_Server(parameterlist ¶ms) return true; } - this->SendError("Invalid credentials"); + this->SendError("Mismatched server name or password (check the other server's snomask output for details - e.g. umode +s +Ll)"); ServerInstance->SNO->WriteToSnoMask('l',"Server connection from \2"+sname+"\2 denied, invalid link credentials"); return false; } diff --git a/src/modules/m_spanningtree/uid.cpp b/src/modules/m_spanningtree/uid.cpp index 1b17ca6e7..ac9041ecc 100644 --- a/src/modules/m_spanningtree/uid.cpp +++ b/src/modules/m_spanningtree/uid.cpp @@ -45,7 +45,18 @@ CmdResult CommandUID::HandleServer(TreeServer* remoteserver, std::vector<std::st /* check for collision */ User* collideswith = ServerInstance->FindNickOnly(params[2]); - if (collideswith) + if ((collideswith) && (collideswith->registered != REG_ALL)) + { + // User that the incoming user is colliding with is not fully registered, we force nick change the + // unregistered user to their uuid and tell them what happened + collideswith->WriteFrom(collideswith, "NICK %s", collideswith->uuid.c_str()); + collideswith->WriteNumeric(433, "%s %s :Nickname overruled.", collideswith->nick.c_str(), collideswith->nick.c_str()); + + // Clear the bit before calling User::ChangeNick() to make it NOT run the OnUserPostNick() hook + collideswith->registered &= ~REG_NICK; + collideswith->ChangeNick(collideswith->uuid, true); + } + else if (collideswith) { /* * Nick collision. diff --git a/src/modules/m_userip.cpp b/src/modules/m_userip.cpp index 96505a047..043967393 100644 --- a/src/modules/m_userip.cpp +++ b/src/modules/m_userip.cpp @@ -28,7 +28,7 @@ class CommandUserip : public Command public: CommandUserip(Module* Creator) : Command(Creator,"USERIP", 1) { - syntax = "<nick>{,<nick>}"; + syntax = "<nick> [<nick> ...]"; } CmdResult Handle (const std::vector<std::string> ¶meters, User *user) diff --git a/src/modules/m_watch.cpp b/src/modules/m_watch.cpp index 94292e4be..68fe09d64 100644 --- a/src/modules/m_watch.cpp +++ b/src/modules/m_watch.cpp @@ -207,7 +207,7 @@ class CommandWatch : public Command ext.set(user, wl); } - if (wl->size() == MAX_WATCH) + if (wl->size() >= MAX_WATCH) { user->WriteNumeric(512, "%s :Too many WATCH entries", nick); return CMD_FAILURE; diff --git a/src/modules/m_xline_db.cpp b/src/modules/m_xline_db.cpp index 1a7fd8cc5..c35f0d07a 100644 --- a/src/modules/m_xline_db.cpp +++ b/src/modules/m_xline_db.cpp @@ -135,12 +135,7 @@ class ModuleXLineDB : public Module stream.close(); #ifdef _WIN32 - if (remove(xlinedbpath.c_str())) - { - ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Cannot remove old database! %s (%d)", strerror(errno), errno); - ServerInstance->SNO->WriteToSnoMask('a', "database: cannot remove old database: %s (%d)", strerror(errno), errno); - return false; - } + remove(xlinedbpath.c_str()); #endif // Use rename to move temporary to new db - this is guarenteed not to fuck up, even in case of a crash. if (rename(xlinenewdbpath.c_str(), xlinedbpath.c_str()) < 0) diff --git a/src/socketengine.cpp b/src/socketengine.cpp index c6c520efc..1c91ccdea 100644 --- a/src/socketengine.cpp +++ b/src/socketengine.cpp @@ -291,7 +291,13 @@ std::string SocketEngine::LastError() DWORD dwErrorCode = WSAGetLastError(); if (FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dwErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)szErrorString, _countof(szErrorString), NULL) == 0) sprintf_s(szErrorString, _countof(szErrorString), "Error code: %u", dwErrorCode); - return szErrorString; + + std::string::size_type p; + std::string ret = szErrorString; + while ((p = ret.find_last_of("\r\n")) != std::string::npos) + ret.erase(p, 1); + + return ret; #endif } diff --git a/src/users.cpp b/src/users.cpp index 3f82b850c..8d22d166c 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -416,7 +416,7 @@ void OperInfo::init() { this->AllowedUserModes.set(); } - else if (*c >= 'A' && *c < 'z') + else if (*c >= 'A' && *c <= 'z') { this->AllowedUserModes[*c - 'A'] = true; } @@ -429,7 +429,7 @@ void OperInfo::init() { this->AllowedChanModes.set(); } - else if (*c >= 'A' && *c < 'z') + else if (*c >= 'A' && *c <= 'z') { this->AllowedChanModes[*c - 'A'] = true; } |