diff options
author | attilamolnar <attilamolnar@hush.com> | 2013-06-06 01:07:22 +0200 |
---|---|---|
committer | attilamolnar <attilamolnar@hush.com> | 2013-06-06 01:07:22 +0200 |
commit | d9d99cd02dadf34bfcc220734ba0c422f0acb3e6 (patch) | |
tree | 72a11fab75875b7e4f739ddd203da60e5dcbc851 /src/modules | |
parent | 8a06d54076551387f83a29360478ee6605e241b6 (diff) | |
parent | e0ff94b310e9b73ac0131e9df14fb7ca2bf3a878 (diff) |
Merge insp20
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/extra/m_geoip.cpp | 5 | ||||
-rw-r--r-- | src/modules/extra/m_mysql.cpp | 30 | ||||
-rw-r--r-- | src/modules/extra/m_pgsql.cpp | 16 | ||||
-rw-r--r-- | src/modules/extra/m_ssl_gnutls.cpp | 112 | ||||
-rw-r--r-- | src/modules/m_alias.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_cban.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_channames.cpp | 12 | ||||
-rw-r--r-- | src/modules/m_connectban.cpp | 9 | ||||
-rw-r--r-- | src/modules/m_dccallow.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_filter.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_httpd_acl.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_kicknorejoin.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_nicklock.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_operprefix.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_passforward.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_rline.cpp | 5 | ||||
-rw-r--r-- | src/modules/m_sasl.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_shun.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.cpp | 3 | ||||
-rw-r--r-- | src/modules/m_spanningtree/netburst.cpp | 1 | ||||
-rw-r--r-- | src/modules/m_spanningtree/utils.h | 3 | ||||
-rw-r--r-- | src/modules/m_svshold.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_userip.cpp | 21 |
23 files changed, 152 insertions, 97 deletions
diff --git a/src/modules/extra/m_geoip.cpp b/src/modules/extra/m_geoip.cpp index 7696146e8..ddc4e9a38 100644 --- a/src/modules/extra/m_geoip.cpp +++ b/src/modules/extra/m_geoip.cpp @@ -35,7 +35,7 @@ class ModuleGeoIP : public Module LocalStringExt ext; GeoIP* gi; - void SetExt(LocalUser* user) + std::string* SetExt(LocalUser* user) { const char* c = GeoIP_country_code_by_addr(gi, user->GetIPString().c_str()); if (!c) @@ -43,6 +43,7 @@ class ModuleGeoIP : public Module std::string* cc = new std::string(c); ext.set(user, cc); + return cc; } public: @@ -85,7 +86,7 @@ class ModuleGeoIP : public Module { std::string* cc = ext.get(user); if (!cc) - SetExt(user); + cc = SetExt(user); std::string geoip = myclass->config->getString("geoip"); if (geoip.empty()) diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp index e5d8d379c..bb8f1b573 100644 --- a/src/modules/extra/m_mysql.cpp +++ b/src/modules/extra/m_mysql.cpp @@ -180,7 +180,6 @@ class MySQLresult : public SQLResult rows++; } mysql_free_result(res); - res = NULL; } } @@ -329,10 +328,15 @@ class SQLConnection : public SQLProvider if (param < p.size()) { std::string parm = p[param++]; - char buffer[MAXBUF]; - mysql_escape_string(buffer, parm.c_str(), parm.length()); + // In the worst case, each character may need to be encoded as using two bytes, + // and one byte is the terminating null + std::vector<char> buffer(parm.length() * 2 + 1); + + // The return value of mysql_escape_string() is the length of the encoded string, + // not including the terminating null + unsigned long escapedsize = mysql_escape_string(&buffer[0], parm.c_str(), parm.length()); // mysql_real_escape_string(connection, queryend, paramscopy[paramnum].c_str(), paramscopy[paramnum].length()); - res.append(buffer); + res.append(&buffer[0], escapedsize); } } } @@ -358,9 +362,10 @@ class SQLConnection : public SQLProvider if (it != p.end()) { std::string parm = it->second; - char buffer[MAXBUF]; - mysql_escape_string(buffer, parm.c_str(), parm.length()); - res.append(buffer); + // NOTE: See above + std::vector<char> buffer(parm.length() * 2 + 1); + unsigned long escapedsize = mysql_escape_string(&buffer[0], parm.c_str(), parm.length()); + res.append(&buffer[0], escapedsize); } } } @@ -431,13 +436,14 @@ void ModuleSQL::OnRehash(User* user) i->second->lock.Lock(); i->second->lock.Unlock(); // now remove all active queries to this DB - for(unsigned int j = qq.size() - 1; j >= 0; j--) + for (size_t j = qq.size(); j > 0; j--) { - if (qq[j].c == i->second) + size_t k = j - 1; + if (qq[k].c == i->second) { - qq[j].q->OnError(err); - delete qq[j].q; - qq.erase(qq.begin() + j); + qq[k].q->OnError(err); + delete qq[k].q; + qq.erase(qq.begin() + k); } } // finally, nuke the connection diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp index 3df6b91bd..61e8d5bbb 100644 --- a/src/modules/extra/m_pgsql.cpp +++ b/src/modules/extra/m_pgsql.cpp @@ -412,16 +412,16 @@ restart: if (param < p.size()) { std::string parm = p[param++]; - char buffer[MAXBUF]; + std::vector<char> buffer(parm.length() * 2 + 1); #ifdef PGSQL_HAS_ESCAPECONN int error; - PQescapeStringConn(sql, buffer, parm.c_str(), parm.length(), &error); + size_t escapedsize = PQescapeStringConn(sql, &buffer[0], parm.data(), parm.length(), &error); if (error) ServerInstance->Logs->Log("m_pgsql", LOG_DEBUG, "BUG: Apparently PQescapeStringConn() failed"); #else - PQescapeString (buffer, parm.c_str(), parm.length()); + size_t escapedsize = PQescapeString(&buffer[0], parm.data(), parm.length()); #endif - res.append(buffer); + res.append(&buffer[0], escapedsize); } } } @@ -447,16 +447,16 @@ restart: if (it != p.end()) { std::string parm = it->second; - char buffer[MAXBUF]; + std::vector<char> buffer(parm.length() * 2 + 1); #ifdef PGSQL_HAS_ESCAPECONN int error; - PQescapeStringConn(sql, buffer, parm.c_str(), parm.length(), &error); + size_t escapedsize = PQescapeStringConn(sql, &buffer[0], parm.data(), parm.length(), &error); if (error) ServerInstance->Logs->Log("m_pgsql", LOG_DEBUG, "BUG: Apparently PQescapeStringConn() failed"); #else - PQescapeString (buffer, parm.c_str(), parm.length()); + size_t escapedsize = PQescapeString(&buffer[0], parm.data(), parm.length()); #endif - res.append(buffer); + res.append(&buffer[0], escapedsize); } } } diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp index 0659f631c..8faee2da7 100644 --- a/src/modules/extra/m_ssl_gnutls.cpp +++ b/src/modules/extra/m_ssl_gnutls.cpp @@ -77,46 +77,6 @@ static int cert_callback (gnutls_session_t session, const gnutls_datum_t * req_c return 0; } -static ssize_t gnutls_pull_wrapper(gnutls_transport_ptr_t user_wrap, void* buffer, size_t size) -{ - StreamSocket* user = reinterpret_cast<StreamSocket*>(user_wrap); - if (user->GetEventMask() & FD_READ_WILL_BLOCK) - { - errno = EAGAIN; - return -1; - } - int rv = ServerInstance->SE->Recv(user, reinterpret_cast<char *>(buffer), size, 0); - if (rv < 0) - { - /* On Windows we need to set errno for gnutls */ - if (SocketEngine::IgnoreError()) - errno = EAGAIN; - } - if (rv < (int)size) - ServerInstance->SE->ChangeEventMask(user, FD_READ_WILL_BLOCK); - return rv; -} - -static ssize_t gnutls_push_wrapper(gnutls_transport_ptr_t user_wrap, const void* buffer, size_t size) -{ - StreamSocket* user = reinterpret_cast<StreamSocket*>(user_wrap); - if (user->GetEventMask() & FD_WRITE_WILL_BLOCK) - { - errno = EAGAIN; - return -1; - } - int rv = ServerInstance->SE->Send(user, reinterpret_cast<const char *>(buffer), size, 0); - if (rv < 0) - { - /* On Windows we need to set errno for gnutls */ - if (SocketEngine::IgnoreError()) - errno = EAGAIN; - } - if (rv < (int)size) - ServerInstance->SE->ChangeEventMask(user, FD_WRITE_WILL_BLOCK); - return rv; -} - class RandGen : public HandlerBase2<void, char*, size_t> { public: @@ -132,10 +92,12 @@ class RandGen : public HandlerBase2<void, char*, size_t> class issl_session { public: + StreamSocket* socket; gnutls_session_t sess; issl_status status; reference<ssl_cert> cert; - issl_session() : sess(NULL) {} + + issl_session() : socket(NULL), sess(NULL) {} }; class CommandStartTLS : public SplitCommand @@ -213,6 +175,70 @@ class ModuleSSLGnuTLS : public Module return str ? str : "UNKNOWN"; } + static ssize_t gnutls_pull_wrapper(gnutls_transport_ptr_t session_wrap, void* buffer, size_t size) + { + issl_session* session = reinterpret_cast<issl_session*>(session_wrap); + if (session->socket->GetEventMask() & FD_READ_WILL_BLOCK) + { +#ifdef _WIN32 + gnutls_transport_set_errno(session->sess, EAGAIN); +#else + errno = EAGAIN; +#endif + return -1; + } + + int rv = ServerInstance->SE->Recv(session->socket, reinterpret_cast<char *>(buffer), size, 0); + +#ifdef _WIN32 + if (rv < 0) + { + /* Windows doesn't use errno, but gnutls does, so check SocketEngine::IgnoreError() + * and then set errno appropriately. + * The gnutls library may also have a different errno variable than us, see + * gnutls_transport_set_errno(3). + */ + gnutls_transport_set_errno(session->sess, SocketEngine::IgnoreError() ? EAGAIN : errno); + } +#endif + + if (rv < (int)size) + ServerInstance->SE->ChangeEventMask(session->socket, FD_READ_WILL_BLOCK); + return rv; + } + + static ssize_t gnutls_push_wrapper(gnutls_transport_ptr_t session_wrap, const void* buffer, size_t size) + { + issl_session* session = reinterpret_cast<issl_session*>(session_wrap); + if (session->socket->GetEventMask() & FD_WRITE_WILL_BLOCK) + { +#ifdef _WIN32 + gnutls_transport_set_errno(session->sess, EAGAIN); +#else + errno = EAGAIN; +#endif + return -1; + } + + int rv = ServerInstance->SE->Send(session->socket, reinterpret_cast<const char *>(buffer), size, 0); + +#ifdef _WIN32 + if (rv < 0) + { + /* Windows doesn't use errno, but gnutls does, so check SocketEngine::IgnoreError() + * and then set errno appropriately. + * The gnutls library may also have a different errno variable than us, see + * gnutls_transport_set_errno(3). + */ + gnutls_transport_set_errno(session->sess, SocketEngine::IgnoreError() ? EAGAIN : errno); + } +#endif + + if (rv < (int)size) + ServerInstance->SE->ChangeEventMask(session->socket, FD_WRITE_WILL_BLOCK); + return rv; + } + public: ModuleSSLGnuTLS() : starttls(this), capHandler(this, "tls"), iohook(this, "ssl/gnutls", SERVICE_IOHOOK) @@ -538,13 +564,14 @@ class ModuleSSLGnuTLS : public Module issl_session* session = &sessions[user->GetFd()]; gnutls_init(&session->sess, me_server ? GNUTLS_SERVER : GNUTLS_CLIENT); + session->socket = user; #ifdef GNUTLS_NEW_PRIO_API gnutls_priority_set(session->sess, priority); #endif gnutls_credentials_set(session->sess, GNUTLS_CRD_CERTIFICATE, x509_cred); gnutls_dh_set_prime_bits(session->sess, dh_bits); - gnutls_transport_set_ptr(session->sess, reinterpret_cast<gnutls_transport_ptr_t>(user)); + gnutls_transport_set_ptr(session->sess, reinterpret_cast<gnutls_transport_ptr_t>(session)); gnutls_transport_set_push_function(session->sess, gnutls_push_wrapper); gnutls_transport_set_pull_function(session->sess, gnutls_pull_wrapper); @@ -760,6 +787,7 @@ class ModuleSSLGnuTLS : public Module gnutls_bye(session->sess, GNUTLS_SHUT_WR); gnutls_deinit(session->sess); } + session->socket = NULL; session->sess = NULL; session->cert = NULL; session->status = ISSL_NONE; diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp index 34f4c4f64..118cedeea 100644 --- a/src/modules/m_alias.cpp +++ b/src/modules/m_alias.cpp @@ -244,7 +244,7 @@ class ModuleAlias : public Module } - int DoAlias(User *user, Channel *c, Alias *a, const std::string compare, const std::string safe) + int DoAlias(User *user, Channel *c, Alias *a, const std::string& compare, const std::string& safe) { User *u = NULL; diff --git a/src/modules/m_cban.cpp b/src/modules/m_cban.cpp index 5e629ed42..7dedb7441 100644 --- a/src/modules/m_cban.cpp +++ b/src/modules/m_cban.cpp @@ -34,7 +34,7 @@ private: irc::string matchtext; public: - CBan(time_t s_time, long d, std::string src, std::string re, std::string ch) + CBan(time_t s_time, long d, const std::string& src, const std::string& re, const std::string& ch) : XLine(s_time, d, src, re, "CBAN") { this->displaytext = ch; diff --git a/src/modules/m_channames.cpp b/src/modules/m_channames.cpp index 9b43649a8..52f781ae1 100644 --- a/src/modules/m_channames.cpp +++ b/src/modules/m_channames.cpp @@ -87,9 +87,17 @@ class ModuleChannelNames : public Module ServerInstance->SendGlobalMode(modes, ServerInstance->FakeClient); } const UserMembList* users = c->GetUsers(); - for(UserMembCIter j = users->begin(); j != users->end(); ++j) + for(UserMembCIter j = users->begin(); j != users->end(); ) + { if (IS_LOCAL(j->first)) - c->KickUser(ServerInstance->FakeClient, j->first, "Channel name no longer valid"); + { + // KickUser invalidates the iterator + UserMembCIter it = j++; + c->KickUser(ServerInstance->FakeClient, it->first, "Channel name no longer valid"); + } + else + ++j; + } } badchan = false; } diff --git a/src/modules/m_connectban.cpp b/src/modules/m_connectban.cpp index d741dfb36..eca9352e8 100644 --- a/src/modules/m_connectban.cpp +++ b/src/modules/m_connectban.cpp @@ -93,11 +93,12 @@ class ModuleConnectBan : public Module { // Create zline for set duration. ZLine* zl = new ZLine(ServerInstance->Time(), banduration, ServerInstance->Config->ServerName, "Your IP range has been attempting to connect too many times in too short a duration. Wait a while, and you will be able to connect.", mask.str()); - if (ServerInstance->XLines->AddLine(zl,NULL)) - ServerInstance->XLines->ApplyLines(); - else + if (!ServerInstance->XLines->AddLine(zl, NULL)) + { delete zl; - + return; + } + ServerInstance->XLines->ApplyLines(); std::string maskstr = mask.str(); std::string timestr = ServerInstance->TimeString(zl->expiry); ServerInstance->SNO->WriteGlobalSno('x',"Module m_connectban added Z:line on *@%s to expire on %s: Connect flooding", diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp index 5061cf250..1024c4ab2 100644 --- a/src/modules/m_dccallow.cpp +++ b/src/modules/m_dccallow.cpp @@ -166,7 +166,7 @@ class CommandDccallow : public Command length = InspIRCd::Duration(parameters[1]); } - if (!ServerInstance->IsValidMask(mask.c_str())) + if (!ServerInstance->IsValidMask(mask)) { return CMD_FAILURE; } diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp index d138c44cd..bdf849f32 100644 --- a/src/modules/m_filter.cpp +++ b/src/modules/m_filter.cpp @@ -60,7 +60,7 @@ class FilterResult bool flag_notice; bool flag_strip_color; - FilterResult(const std::string free, const std::string &rea, FilterAction act, long gt, const std::string &fla) : + FilterResult(const std::string& free, const std::string& rea, FilterAction act, long gt, const std::string& fla) : freeform(free), reason(rea), action(act), gline_time(gt) { this->FillFlags(fla); diff --git a/src/modules/m_httpd_acl.cpp b/src/modules/m_httpd_acl.cpp index 982e514ad..061d56f25 100644 --- a/src/modules/m_httpd_acl.cpp +++ b/src/modules/m_httpd_acl.cpp @@ -45,7 +45,7 @@ class ModuleHTTPAccessList : public Module std::vector<HTTPACL> acl_list; public: - void ReadConfig() + void OnRehash(User* user) { acl_list.clear(); ConfigTagList acls = ServerInstance->Config->ConfTags("httpdacl"); @@ -91,8 +91,8 @@ class ModuleHTTPAccessList : public Module void init() CXX11_OVERRIDE { - ReadConfig(); - Implementation eventlist[] = { I_OnEvent }; + OnRehash(NULL); + Implementation eventlist[] = { I_OnEvent, I_OnRehash }; ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); } diff --git a/src/modules/m_kicknorejoin.cpp b/src/modules/m_kicknorejoin.cpp index 8d2d88e99..3406f4f99 100644 --- a/src/modules/m_kicknorejoin.cpp +++ b/src/modules/m_kicknorejoin.cpp @@ -115,7 +115,7 @@ public: } } - if (!dl->size()) + if (dl->empty()) kr.ext.unset(chan); } } diff --git a/src/modules/m_nicklock.cpp b/src/modules/m_nicklock.cpp index 9da40ce78..7bd2c43b2 100644 --- a/src/modules/m_nicklock.cpp +++ b/src/modules/m_nicklock.cpp @@ -179,7 +179,7 @@ class ModuleNickLock : public Module void Prioritize() { Module *nflood = ServerInstance->Modules->Find("m_nickflood.so"); - ServerInstance->Modules->SetPriority(this, I_OnUserPreJoin, PRIORITY_BEFORE, &nflood); + ServerInstance->Modules->SetPriority(this, I_OnUserPreNick, PRIORITY_BEFORE, &nflood); } }; diff --git a/src/modules/m_operprefix.cpp b/src/modules/m_operprefix.cpp index fbb7e8b50..d061a5eab 100644 --- a/src/modules/m_operprefix.cpp +++ b/src/modules/m_operprefix.cpp @@ -51,7 +51,7 @@ class OperPrefixMode : public ModeHandler return MODEACTION_ALLOW; else { - if (source && channel) + if (channel) source->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :Only servers are permitted to change channel mode '%c'", source->nick.c_str(), channel->name.c_str(), 'y'); return MODEACTION_DENY; } diff --git a/src/modules/m_passforward.cpp b/src/modules/m_passforward.cpp index 6e29f272b..64c7df519 100644 --- a/src/modules/m_passforward.cpp +++ b/src/modules/m_passforward.cpp @@ -90,7 +90,7 @@ class ModulePassForward : public Module if (!nickrequired.empty()) { /* Check if nick exists and its server is ulined */ - User* u = ServerInstance->FindNick(nickrequired.c_str()); + User* u = ServerInstance->FindNick(nickrequired); if (!u || !ServerInstance->ULine(u->server)) return; } diff --git a/src/modules/m_rline.cpp b/src/modules/m_rline.cpp index aa96d4951..ca123cc11 100644 --- a/src/modules/m_rline.cpp +++ b/src/modules/m_rline.cpp @@ -41,11 +41,10 @@ class RLine : public XLine * @param regex Pattern to match with * @ */ - RLine(time_t s_time, long d, std::string src, std::string re, std::string regexs, dynamic_reference<RegexFactory>& rxfactory) + RLine(time_t s_time, long d, const std::string& src, const std::string& re, const std::string& regexs, dynamic_reference<RegexFactory>& rxfactory) : XLine(s_time, d, src, re, "R") + , matchtext(regexs) { - matchtext = regexs; - /* This can throw on failure, but if it does we DONT catch it here, we catch it and display it * where the object is created, we might not ALWAYS want it to output stuff to snomask x all the time */ diff --git a/src/modules/m_sasl.cpp b/src/modules/m_sasl.cpp index 8cae025e2..322a726ce 100644 --- a/src/modules/m_sasl.cpp +++ b/src/modules/m_sasl.cpp @@ -52,7 +52,7 @@ class SaslAuthenticator bool state_announced; public: - SaslAuthenticator(User *user_, std::string method, Module *ctor) + SaslAuthenticator(User* user_, const std::string& method) : user(user_), state(SASL_INIT), state_announced(false) { parameterlist params; @@ -195,7 +195,7 @@ class CommandAuthenticate : public Command SaslAuthenticator *sasl = authExt.get(user); if (!sasl) - authExt.set(user, new SaslAuthenticator(user, parameters[0], creator)); + authExt.set(user, new SaslAuthenticator(user, parameters[0])); else if (sasl->SendClientMessage(parameters) == false) // IAL abort extension --nenolod { sasl->AnnounceState(); diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp index 6da24208a..a06149b62 100644 --- a/src/modules/m_shun.cpp +++ b/src/modules/m_shun.cpp @@ -30,10 +30,10 @@ class Shun : public XLine public: std::string matchtext; - Shun(time_t s_time, long d, std::string src, std::string re, std::string shunmask) + Shun(time_t s_time, long d, const std::string& src, const std::string& re, const std::string& shunmask) : XLine(s_time, d, src, re, "SHUN") + , matchtext(shunmask) { - this->matchtext = shunmask; } bool Matches(User *u) diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 764c8b8ec..aafda7eea 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -582,8 +582,7 @@ void ModuleSpanningTree::OnChangeName(User* user, const std::string &gecos) void ModuleSpanningTree::OnChangeIdent(User* user, const std::string &ident) { - // only occurs for local clients - if (user->registered != REG_ALL) + if ((user->registered != REG_ALL) || (!IS_LOCAL(user))) return; parameterlist params; diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp index 639a397c6..8daaefd8a 100644 --- a/src/modules/m_spanningtree/netburst.cpp +++ b/src/modules/m_spanningtree/netburst.cpp @@ -183,7 +183,6 @@ void TreeSocket::SyncChannel(Channel* chan) void TreeSocket::SendUsers() { char data[MAXBUF]; - std::string dataline; for (user_hash::iterator u = ServerInstance->Users->clientlist->begin(); u != ServerInstance->Users->clientlist->end(); u++) { if (u->second->registered == REG_ALL) diff --git a/src/modules/m_spanningtree/utils.h b/src/modules/m_spanningtree/utils.h index a2566c0c8..e97df3839 100644 --- a/src/modules/m_spanningtree/utils.h +++ b/src/modules/m_spanningtree/utils.h @@ -90,9 +90,6 @@ class SpanningTreeUtilities : public classbase /** Hash of currently known server ids */ server_hash sidlist; - /** Hash of servers currently bursting but not initialized as connected - */ - std::map<irc::string,TreeSocket*> burstingserverlist; /** List of all outgoing sockets and their timeouts */ std::map<TreeSocket*, std::pair<std::string, int> > timeoutlist; diff --git a/src/modules/m_svshold.cpp b/src/modules/m_svshold.cpp index d35d5f3ba..a53298126 100644 --- a/src/modules/m_svshold.cpp +++ b/src/modules/m_svshold.cpp @@ -32,7 +32,7 @@ class SVSHold : public XLine public: std::string nickname; - SVSHold(time_t s_time, long d, std::string src, std::string re, std::string nick) + SVSHold(time_t s_time, long d, const std::string& src, const std::string& re, const std::string& nick) : XLine(s_time, d, src, re, "SVSHOLD") { this->nickname = nick; diff --git a/src/modules/m_userip.cpp b/src/modules/m_userip.cpp index 7cc2fa04d..670e9a9d7 100644 --- a/src/modules/m_userip.cpp +++ b/src/modules/m_userip.cpp @@ -30,19 +30,37 @@ class CommandUserip : public Command public: CommandUserip(Module* Creator) : Command(Creator,"USERIP", 1) { - flags_needed = 'o'; syntax = "<nick>{,<nick>}"; + syntax = "<nick>{,<nick>}"; } CmdResult Handle (const std::vector<std::string> ¶meters, User *user) { std::string retbuf = "340 " + user->nick + " :"; int nicks = 0; + bool checked_privs = false; + bool has_privs; for (int i = 0; i < (int)parameters.size(); i++) { User *u = ServerInstance->FindNick(parameters[i]); if ((u) && (u->registered == REG_ALL)) { + // Anyone may query their own IP + if (u != user) + { + if (!checked_privs) + { + // Do not trigger the insufficient priviliges message more than once + checked_privs = true; + has_privs = user->HasPrivPermission("users/auspex"); + if (!has_privs) + user->WriteNumeric(ERR_NOPRIVILEGES, "%s :Permission Denied - You do not have the required operator privileges",user->nick.c_str()); + } + + if (!has_privs) + continue; + } + retbuf = retbuf + u->nick + (u->IsOper() ? "*" : "") + "="; if (u->IsAway()) retbuf += "-"; @@ -56,7 +74,6 @@ class CommandUserip : public Command if (nicks != 0) user->WriteServ(retbuf); - /* Dont send to the network */ return CMD_SUCCESS; } }; |