From 46eaac3381e072b7c08b96996d977177bbe41452 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 24 Jan 2014 18:11:49 -0500 Subject: Set a session id on our server ssl context in m_ssl_openssl. It is required for some clients which try to restore SSL sessions. --- src/modules/extra/m_ssl_openssl.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/modules') diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp index 7b7de023c..ad5eee791 100644 --- a/src/modules/extra/m_ssl_openssl.cpp +++ b/src/modules/extra/m_ssl_openssl.cpp @@ -132,6 +132,9 @@ class ModuleSSLOpenSSL : public Module SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE, OnVerify); SSL_CTX_set_verify(clictx, SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE, OnVerify); + + const unsigned char session_id[] = "inspircd"; + SSL_CTX_set_session_id_context(ctx, session_id, sizeof(session_id) - 1); } void init() -- cgit v1.2.3 From 5ae804239ee1e2f8731b73ab37e9f16d8153d477 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Sun, 26 Jan 2014 16:39:21 +0100 Subject: m_ssl_openssl Fix memory leaks on /rehash ssl, unload and in VerifyCertificate() --- src/modules/extra/m_ssl_openssl.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/modules') diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp index ad5eee791..9a54ff80b 100644 --- a/src/modules/extra/m_ssl_openssl.cpp +++ b/src/modules/extra/m_ssl_openssl.cpp @@ -265,6 +265,7 @@ class ModuleSSLOpenSSL : public Module ServerInstance->Logs->Log("m_ssl_openssl",DEFAULT, "m_ssl_openssl.so: Couldn't set DH parameters %s. SSL errors follow:", dhfile.c_str()); ERR_print_errors_cb(error_callback, this); } + DH_free(ret); } fclose(dhpfile); @@ -629,8 +630,11 @@ class ModuleSSLOpenSSL : public Module certinfo->trusted = false; } - certinfo->dn = X509_NAME_oneline(X509_get_subject_name(cert),0,0); - certinfo->issuer = X509_NAME_oneline(X509_get_issuer_name(cert),0,0); + char buf[512]; + X509_NAME_oneline(X509_get_subject_name(cert), buf, sizeof(buf)); + certinfo->dn = buf; + X509_NAME_oneline(X509_get_issuer_name(cert), buf, sizeof(buf)); + certinfo->issuer = buf; if (!X509_digest(cert, digest, md, &n)) { -- cgit v1.2.3 From 26fecc0bf2c72b9a0dea09c92ed89f78181f39f6 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Mon, 3 Feb 2014 10:08:05 +0100 Subject: m_banredirect Fix typo in a message (transfered -> transferred) Fixes issue #757 reported by @guikcd --- src/modules/m_banredirect.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/modules') diff --git a/src/modules/m_banredirect.cpp b/src/modules/m_banredirect.cpp index ee52a5cfb..2e2592541 100644 --- a/src/modules/m_banredirect.cpp +++ b/src/modules/m_banredirect.cpp @@ -321,7 +321,7 @@ class ModuleBanRedirect : public Module else { user->WriteNumeric(474, "%s %s :Cannot join channel (You are banned)", user->nick.c_str(), chan->name.c_str()); - user->WriteNumeric(470, "%s %s %s :You are banned from this channel, so you are automatically transfered to the redirected channel.", user->nick.c_str(), chan->name.c_str(), redir->targetchan.c_str()); + user->WriteNumeric(470, "%s %s %s :You are banned from this channel, so you are automatically transferred to the redirected channel.", user->nick.c_str(), chan->name.c_str(), redir->targetchan.c_str()); nofollow = true; Channel::JoinUser(user, redir->targetchan.c_str(), false, "", false, ServerInstance->Time()); nofollow = false; -- cgit v1.2.3 From 473f3d3b2f973a1d746aa456dd874e4094ac9388 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Sun, 2 Mar 2014 17:00:12 +0100 Subject: m_spanningtree Don't send snotices to servers about remote servers splitting The snotice is sent to opers when the SQUIT is processed by their server --- src/modules/m_spanningtree/treesocket1.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/modules') diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp index cb2c93548..7b233169d 100644 --- a/src/modules/m_spanningtree/treesocket1.cpp +++ b/src/modules/m_spanningtree/treesocket1.cpp @@ -201,7 +201,7 @@ void TreeSocket::Squit(TreeServer* Current, const std::string &reason) } else { - ServerInstance->SNO->WriteGlobalSno('L', "Server \002"+Current->GetName()+"\002 split from server \002"+Current->GetParent()->GetName()+"\002 with reason: "+reason); + ServerInstance->SNO->WriteToSnoMask('L', "Server \002"+Current->GetName()+"\002 split from server \002"+Current->GetParent()->GetName()+"\002 with reason: "+reason); } int num_lost_servers = 0; int num_lost_users = 0; -- cgit v1.2.3 From ed08638c1afa2742f0ebc3006dd0f1054020f7d4 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Sun, 2 Mar 2014 17:04:51 +0100 Subject: m_spanningtree Do pointer comparison before deleting one of the pointers in TreeSocket::Squit() While the previous code worked fine in practice, it was incorrect in theory --- src/modules/m_spanningtree/treesocket1.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/modules') diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp index 7b233169d..c9729cc0f 100644 --- a/src/modules/m_spanningtree/treesocket1.cpp +++ b/src/modules/m_spanningtree/treesocket1.cpp @@ -212,8 +212,9 @@ void TreeSocket::Squit(TreeServer* Current, const std::string &reason) Current->Tidy(); Current->GetParent()->DelChild(Current); Current->cull(); + const bool ismyroot = (Current == MyRoot); delete Current; - if (Current == MyRoot) + if (ismyroot) { MyRoot = NULL; Close(); -- cgit v1.2.3 From 3f601a622d886918866ae4775c1199892f43507c Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Sun, 23 Mar 2014 22:10:04 +0100 Subject: m_operprefix Don't set +y on the oper if hideoper is being unset due to deopering Fixes issue #801 reported by @UselessOper --- src/modules/m_operprefix.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/modules') diff --git a/src/modules/m_operprefix.cpp b/src/modules/m_operprefix.cpp index 25937cd6e..62ddb6c67 100644 --- a/src/modules/m_operprefix.cpp +++ b/src/modules/m_operprefix.cpp @@ -162,7 +162,8 @@ class ModuleOperPrefixMode : public Module void HideOperWatcher::AfterMode(User* source, User* dest, Channel* channel, const std::string& parameter, bool adding, ModeType type) { - if (IS_LOCAL(dest)) + // If hideoper is being unset because the user is deopering, don't set +y + if (IS_LOCAL(dest) && IS_OPER(dest)) parentmod->SetOperPrefix(dest, !adding); } -- cgit v1.2.3 From ff33ebe7d9d9fb835d6c66ff15ddef78462966d0 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Tue, 25 Mar 2014 14:40:37 +0100 Subject: m_httpd Fix typo noticed by @SaberUK --- src/modules/m_httpd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/modules') diff --git a/src/modules/m_httpd.cpp b/src/modules/m_httpd.cpp index a853e12c2..2a430d967 100644 --- a/src/modules/m_httpd.cpp +++ b/src/modules/m_httpd.cpp @@ -107,7 +107,7 @@ class HttpServerSocket : public BufferedSocket case 300: return "MULTIPLE CHOICES"; case 301: - return "MOVED PERMENANTLY"; + return "MOVED PERMANENTLY"; case 302: return "FOUND"; case 303: -- cgit v1.2.3 From 730128891aa71e2fec2f6210f2ebf339e233cd01 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Wed, 26 Mar 2014 17:24:51 +0100 Subject: m_globalload Don't pass a callback to ModuleManager::Reload() if reloading m_globalload --- src/modules/m_globalload.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/modules') diff --git a/src/modules/m_globalload.cpp b/src/modules/m_globalload.cpp index 22286b950..9e0ec7705 100644 --- a/src/modules/m_globalload.cpp +++ b/src/modules/m_globalload.cpp @@ -149,7 +149,12 @@ class CommandGreloadmodule : public Command { Module* m = ServerInstance->Modules->Find(parameters[0]); if (m) - ServerInstance->Modules->Reload(m, new GReloadModuleWorker(user->nick, user->uuid, parameters[0])); + { + GReloadModuleWorker* worker = NULL; + if (m != creator) + worker = new GReloadModuleWorker(user->nick, user->uuid, parameters[0]); + ServerInstance->Modules->Reload(m, worker); + } else { user->WriteNumeric(975, "%s %s :Could not find module by that name", user->nick.c_str(), parameters[0].c_str()); -- cgit v1.2.3 From 96d561950c8086d132297eb691bf90bb2bc61a60 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Thu, 27 Mar 2014 15:41:47 +0100 Subject: m_watch Validate targ before use, noticed while rewriting m_watch for 2.2 --- src/modules/m_watch.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_watch.cpp b/src/modules/m_watch.cpp index ec38edc31..fa7e212bb 100644 --- a/src/modules/m_watch.cpp +++ b/src/modules/m_watch.cpp @@ -316,10 +316,10 @@ class CommandWatch : public Command { for (watchlist::iterator q = wl->begin(); q != wl->end(); q++) { - if (!q->second.empty()) + User* targ = ServerInstance->FindNick(q->first.c_str()); + if (targ && !q->second.empty()) { user->WriteNumeric(604, "%s %s %s :is online", user->nick.c_str(), q->first.c_str(), q->second.c_str()); - User *targ = ServerInstance->FindNick(q->first.c_str()); if (IS_AWAY(targ)) { user->WriteNumeric(609, "%s %s %s %s %lu :is away", user->nick.c_str(), targ->nick.c_str(), targ->ident.c_str(), targ->dhost.c_str(), (unsigned long) targ->awaytime); -- cgit v1.2.3 From 23183603b7ea3b2a50ce082d573bef07ab794686 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Fri, 4 Apr 2014 18:30:02 +0200 Subject: Add REG_ALL checks to treat unregistered users as nonexistent in more cases --- src/commands/cmd_ison.cpp | 4 ++-- src/commands/cmd_kick.cpp | 4 ++-- src/modules/m_samode.cpp | 10 ++++++++++ src/modules/m_saquit.cpp | 2 +- src/modules/m_spanningtree/idle.cpp | 2 +- src/modules/m_watch.cpp | 2 +- 6 files changed, 17 insertions(+), 7 deletions(-) (limited to 'src/modules') diff --git a/src/commands/cmd_ison.cpp b/src/commands/cmd_ison.cpp index 227f1b3ed..01d12e13b 100644 --- a/src/commands/cmd_ison.cpp +++ b/src/commands/cmd_ison.cpp @@ -56,7 +56,7 @@ CmdResult CommandIson::Handle (const std::vector& parameters, User if (ison_already.find(u) != ison_already.end()) continue; - if (u) + if ((u) && (u->registered == REG_ALL)) { reply.append(u->nick).append(" "); if (reply.length() > 450) @@ -81,7 +81,7 @@ CmdResult CommandIson::Handle (const std::vector& parameters, User if (ison_already.find(u) != ison_already.end()) continue; - if (u) + if ((u) && (u->registered == REG_ALL)) { reply.append(u->nick).append(" "); if (reply.length() > 450) diff --git a/src/commands/cmd_kick.cpp b/src/commands/cmd_kick.cpp index 3c5fb0052..c497dd459 100644 --- a/src/commands/cmd_kick.cpp +++ b/src/commands/cmd_kick.cpp @@ -56,9 +56,9 @@ CmdResult CommandKick::Handle (const std::vector& parameters, User else u = ServerInstance->FindNick(parameters[1]); - if (!u || !c) + if ((!u) || (!c) || (u->registered != REG_ALL)) { - user->WriteServ( "401 %s %s :No such nick/channel", user->nick.c_str(), u ? parameters[0].c_str() : parameters[1].c_str()); + user->WriteServ( "401 %s %s :No such nick/channel", user->nick.c_str(), c ? parameters[1].c_str() : parameters[0].c_str()); return CMD_FAILURE; } diff --git a/src/modules/m_samode.cpp b/src/modules/m_samode.cpp index 9b71992a6..ea2ae24ab 100644 --- a/src/modules/m_samode.cpp +++ b/src/modules/m_samode.cpp @@ -39,6 +39,16 @@ class CommandSamode : public Command CmdResult Handle (const std::vector& parameters, User *user) { + if (parameters[0].c_str()[0] != '#') + { + User* target = ServerInstance->FindNickOnly(parameters[0]); + if ((!target) || (target->registered != REG_ALL)) + { + user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel", user->nick.c_str(), parameters[0].c_str()); + return CMD_FAILURE; + } + } + this->active = true; ServerInstance->Parser->CallHandler("MODE", parameters, user); if (ServerInstance->Modes->GetLastParse().length()) diff --git a/src/modules/m_saquit.cpp b/src/modules/m_saquit.cpp index 3b7bdc824..909a026ab 100644 --- a/src/modules/m_saquit.cpp +++ b/src/modules/m_saquit.cpp @@ -37,7 +37,7 @@ class CommandSaquit : public Command CmdResult Handle (const std::vector& parameters, User *user) { User* dest = ServerInstance->FindNick(parameters[0]); - if ((dest) && (!IS_SERVER(dest))) + if ((dest) && (!IS_SERVER(dest)) && (dest->registered == REG_ALL)) { if (ServerInstance->ULine(dest->server)) { diff --git a/src/modules/m_spanningtree/idle.cpp b/src/modules/m_spanningtree/idle.cpp index 8bc0cd2bb..0ea06a3cc 100644 --- a/src/modules/m_spanningtree/idle.cpp +++ b/src/modules/m_spanningtree/idle.cpp @@ -59,7 +59,7 @@ bool TreeSocket::Whois(const std::string &prefix, parameterlist ¶ms) { std::string who_did_the_whois = params[0]; User* who_to_send_to = ServerInstance->FindNick(who_did_the_whois); - if ((who_to_send_to) && (IS_LOCAL(who_to_send_to))) + if ((who_to_send_to) && (IS_LOCAL(who_to_send_to)) && (who_to_send_to->registered == REG_ALL)) { // an incoming reply to a whois we sent out std::string nick_whoised = prefix; diff --git a/src/modules/m_watch.cpp b/src/modules/m_watch.cpp index fa7e212bb..0e532d65b 100644 --- a/src/modules/m_watch.cpp +++ b/src/modules/m_watch.cpp @@ -238,7 +238,7 @@ class CommandWatch : public Command } User* target = ServerInstance->FindNick(nick); - if (target) + if ((target) && (target->registered == REG_ALL)) { (*wl)[nick] = std::string(target->ident).append(" ").append(target->dhost).append(" ").append(ConvToStr(target->age)); user->WriteNumeric(604, "%s %s %s :is online",user->nick.c_str(), nick, (*wl)[nick].c_str()); -- cgit v1.2.3