From e5125c2c84a80a4b23a285bda34eeb4489e6aa6d Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 11 Dec 2016 09:24:52 -0500 Subject: Allow nonconfirmed opers to confirm accounts --- modules/commands/ns_register.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/commands/ns_register.cpp b/modules/commands/ns_register.cpp index ce5dbc997..1595d51a8 100644 --- a/modules/commands/ns_register.cpp +++ b/modules/commands/ns_register.cpp @@ -27,7 +27,7 @@ class CommandNSConfirm : public Command { const Anope::string &passcode = params[0]; - if (source.nc && !source.nc->HasExt("UNCONFIRMED") && source.HasPriv("nickserv/confirm")) + if (source.nc && (!source.nc->HasExt("UNCONFIRMED") || source.IsOper()) && source.HasPriv("nickserv/confirm")) { NickAlias *na = NickAlias::Find(passcode); if (na == NULL) -- cgit From 358f46b8ae10921b1d6f69683f77606ef2909b60 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 11 Dec 2016 09:34:37 -0500 Subject: Fix setting kill quick in webcpanel --- modules/webcpanel/pages/nickserv/info.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/webcpanel/pages/nickserv/info.cpp b/modules/webcpanel/pages/nickserv/info.cpp index b1c1e2afa..c0d7296fb 100644 --- a/modules/webcpanel/pages/nickserv/info.cpp +++ b/modules/webcpanel/pages/nickserv/info.cpp @@ -72,7 +72,7 @@ bool WebCPanel::NickServ::Info::OnRequest(HTTPProvider *server, const Anope::str } else if (message.post_data["kill"] == "quick" && !na->nc->HasExt("KILL_QUICK")) { - na->nc->Shrink("KILLPROTECT"); + na->nc->Extend("KILLPROTECT"); na->nc->Extend("KILL_QUICK"); replacements["MESSAGES"] = "Kill updated"; } -- cgit From d092f5e7c858e8cbaaa89595818a8a2077355561 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 11 Dec 2016 09:43:22 -0500 Subject: Fix detecting if chghost/chgident is loaded on inspircd and don't send them unless they are --- modules/protocol/inspircd20.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp index f7ad9da21..fa0150e21 100644 --- a/modules/protocol/inspircd20.cpp +++ b/modules/protocol/inspircd20.cpp @@ -394,8 +394,6 @@ struct IRCDMessageCapab : Message::Capab chmodes.clear(); umodes.clear(); Servers::Capab.insert("SERVERS"); - Servers::Capab.insert("CHGHOST"); - Servers::Capab.insert("CHGIDENT"); Servers::Capab.insert("TOPICLOCK"); IRCD->CanSVSHold = false; } -- cgit From b3010c3c6b2a938c28ff10ab67f09528f0c91896 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 15 Dec 2016 08:24:40 -0500 Subject: logger: log source nick if there is no user or account --- src/logger.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/logger.cpp b/src/logger.cpp index c681e42fa..a5eb44346 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -145,7 +145,9 @@ Anope::string Log::FormatSource() const return this->u->GetMask(); else if (nc) return nc->display; - return ""; + else if (source) + return source->GetNick(); + return ""; } Anope::string Log::FormatCommand() const -- cgit From 438103199485f0e0e80289874f6f5cf70f8a76e3 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 19 Dec 2016 19:03:10 -0500 Subject: m_sasl: log hostname/ip, if provided --- include/modules/sasl.h | 16 +++++++++++++--- modules/m_sasl.cpp | 36 ++++++++++++++++++++++++++++++------ 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/include/modules/sasl.h b/include/modules/sasl.h index 6cb1d21c9..cd6c7c8c5 100644 --- a/include/modules/sasl.h +++ b/include/modules/sasl.h @@ -46,6 +46,7 @@ namespace SASL { time_t created; Anope::string uid; + Anope::string hostname, ip; Reference mech; Session(Mechanism *m, const Anope::string &u) : created(Anope::CurTime), uid(u), mech(m) { } @@ -76,9 +77,10 @@ namespace SASL class IdentifyRequest : public ::IdentifyRequest { Anope::string uid; + Anope::string hostname, ip; public: - IdentifyRequest(Module *m, const Anope::string &id, const Anope::string &acc, const Anope::string &pass) : ::IdentifyRequest(m, acc, pass), uid(id) { } + IdentifyRequest(Module *m, const Anope::string &id, const Anope::string &acc, const Anope::string &pass, const Anope::string &h, const Anope::string &i) : ::IdentifyRequest(m, acc, pass), uid(id), hostname(h), ip(i) { } void OnSuccess() anope_override { @@ -96,7 +98,11 @@ namespace SASL Session *s = sasl->GetSession(uid); if (s) { - Log(Config->GetClient("NickServ"), "sasl") << "A user identified to account " << this->GetAccount() << " using SASL"; + Anope::string user = "A user"; + if (!hostname.empty() && !ip.empty()) + user = hostname + " (" + ip + ")"; + + Log(Config->GetClient("NickServ"), "sasl") << user << " identified to account " << this->GetAccount() << " using SASL"; sasl->Succeed(s, na->nc); delete s; } @@ -121,7 +127,11 @@ namespace SASL else if (na->nc->HasExt("NS_SUSPENDED")) accountstatus = "suspended "; - Log(Config->GetClient("NickServ"), "sasl") << "A user failed to identify for " << accountstatus << "account " << this->GetAccount() << " using SASL"; + Anope::string user = "A user"; + if (!hostname.empty() && !ip.empty()) + user = hostname + " (" + ip + ")"; + + Log(Config->GetClient("NickServ"), "sasl") << user << " failed to identify for " << accountstatus << "account " << this->GetAccount() << " using SASL"; } }; } diff --git a/modules/m_sasl.cpp b/modules/m_sasl.cpp index e1f55bcc9..3dff6c41f 100644 --- a/modules/m_sasl.cpp +++ b/modules/m_sasl.cpp @@ -55,7 +55,7 @@ class Plain : public Mechanism return; } - SASL::IdentifyRequest *req = new SASL::IdentifyRequest(this->owner, m.source, acc, pass); + SASL::IdentifyRequest *req = new SASL::IdentifyRequest(this->owner, m.source, acc, pass, sess->hostname, sess->ip); FOREACH_MOD(OnCheckAuthentication, (NULL, req)); req->Dispatch(); } @@ -104,16 +104,20 @@ class External : public Mechanism return; } + Anope::string user = "A user"; + if (!mysess->hostname.empty() && !mysess->ip.empty()) + user = mysess->hostname + " (" + mysess->ip + ")"; + NickCore *nc = certs->FindAccountFromCert(mysess->cert); if (!nc || nc->HasExt("NS_SUSPENDED")) { - Log(Config->GetClient("NickServ"), "sasl") << "A user failed to identify using certificate " << mysess->cert << " using SASL EXTERNAL"; + Log(Config->GetClient("NickServ"), "sasl") << user << " failed to identify using certificate " << mysess->cert << " using SASL EXTERNAL"; sasl->Fail(sess); delete sess; return; } - Log(Config->GetClient("NickServ"), "sasl") << "A user identified to account " << nc->display << " using SASL EXTERNAL"; + Log(Config->GetClient("NickServ"), "sasl") << user << " identified to account " << nc->display << " using SASL EXTERNAL"; sasl->Succeed(sess, nc); delete sess; } @@ -160,8 +164,21 @@ class SASLService : public SASL::Service, public Timer return; } - if (!session) - session = mech->CreateSession(m.source); + Anope::string hostname, ip; + if (session) + { + // Copy over host/ip to mech-specific session + hostname = session->hostname; + ip = session->ip; + delete session; + } + + session = mech->CreateSession(m.source); + if (session) + { + session->hostname = hostname; + session->ip = ip; + } } else if (m.type == "D") { @@ -169,6 +186,13 @@ class SASLService : public SASL::Service, public Timer sessions.erase(m.source); return; } + else if (m.type == "H") + { + if (!session) + session = new Session(NULL, m.source); + session->hostname = m.data; + session->ip = m.ext; + } if (session && session->mech) session->mech->ProcessMessage(session, m); @@ -261,7 +285,7 @@ class SASLService : public SASL::Service, public Timer Session *s = it->second; ++it; - if (!s || !s->mech || s->created + 60 < Anope::CurTime) + if (!s || s->created + 60 < Anope::CurTime) { delete s; sessions.erase(key); -- cgit From 574c8dfbc798df444899b4907efc50a40ec6e4a4 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 21 Dec 2016 10:35:57 -0500 Subject: Fix previous commit, deleting sessions removes it from the map which invalidates the reference --- modules/m_sasl.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/m_sasl.cpp b/modules/m_sasl.cpp index 3dff6c41f..cb7030bb4 100644 --- a/modules/m_sasl.cpp +++ b/modules/m_sasl.cpp @@ -150,7 +150,7 @@ class SASLService : public SASL::Service, public Timer } } - Session* &session = sessions[m.source]; + Session* session = GetSession(m.source); if (m.type == "S") { @@ -178,18 +178,22 @@ class SASLService : public SASL::Service, public Timer { session->hostname = hostname; session->ip = ip; + + sessions[m.source] = session; } } else if (m.type == "D") { delete session; - sessions.erase(m.source); return; } else if (m.type == "H") { if (!session) + { session = new Session(NULL, m.source); + sessions[m.source] = session; + } session->hostname = m.data; session->ip = m.ext; } -- cgit From ec7ce09ef45c491ea833ca39ee2dc0ff3cdf5f90 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 22 Dec 2016 20:52:43 -0500 Subject: Make User::Mask behave more like 1.8 --- include/users.h | 7 +++---- src/users.cpp | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/include/users.h b/include/users.h index 6f50d0cbd..27fce6cf8 100644 --- a/include/users.h +++ b/include/users.h @@ -347,10 +347,9 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe /* Returns a mask that will most likely match any address the * user will have from that location. For IP addresses, wildcards the - * appropriate subnet mask (e.g. 35.1.1.1 -> 35.*; 128.2.1.1 -> 128.2.*); - * for named addresses, wildcards the leftmost part of the name unless the - * name only contains two parts. If the username begins with a ~, delete - * it. + * last octet (e.g. 35.1.1.1 -> 35.1.1.*). for named addresses, wildcards + * the leftmost part of the name unless the name only contains two parts. + * If the username begins with a ~, replace with *. */ Anope::string Mask() const; diff --git a/src/users.cpp b/src/users.cpp index 25e558c5f..059b89377 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -781,7 +781,7 @@ Anope::string User::Mask() const sockaddrs addr(mhost); if (addr.valid() && addr.sa.sa_family == AF_INET) { - size_t dot = mhost.find('.'); + size_t dot = mhost.rfind('.'); mask += mhost.substr(0, dot) + (dot == Anope::string::npos ? "" : ".*"); } else -- cgit From 2b7f0084b773a56dbcd80b1d2d86b64257814e5a Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 22 Dec 2016 20:59:04 -0500 Subject: Move log messages for status mode change for unknown user to debug --- src/channels.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/channels.cpp b/src/channels.cpp index 3d824f0d8..d4e0c8f6d 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -280,7 +280,7 @@ void Channel::SetModeInternal(MessageSource &setter, ChannelMode *ocm, const Ano if (!u) { - Log() << "MODE " << this->name << " +" << cm->mchar << " for non-existent user " << param; + Log(LOG_DEBUG) << "MODE " << this->name << " +" << cm->mchar << " for non-existent user " << param; return; } @@ -351,7 +351,7 @@ void Channel::RemoveModeInternal(MessageSource &setter, ChannelMode *ocm, const if (!u) { - Log() << "Channel::RemoveModeInternal() MODE " << this->name << "-" << cm->mchar << " for non-existent user " << param; + Log(LOG_DEBUG) << "Channel::RemoveModeInternal() MODE " << this->name << "-" << cm->mchar << " for non-existent user " << param; return; } -- cgit From 7cede5bb6068a7c197f7d27548883332f6ad4b6d Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 7 Jan 2017 18:03:53 -0500 Subject: os_list: also allow patterns in nick!user@host#realname form --- modules/commands/os_list.cpp | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/modules/commands/os_list.cpp b/modules/commands/os_list.cpp index 07eb9f30d..810ea56df 100644 --- a/modules/commands/os_list.cpp +++ b/modules/commands/os_list.cpp @@ -134,6 +134,7 @@ class CommandOSUserList : public Command const Anope::string &opt = params.size() > 1 ? params[1] : ""; Channel *c; std::set modes; + unsigned int count = 0; if (!pattern.empty()) Log(LOG_ADMIN, source, this) << "for " << pattern; @@ -144,7 +145,7 @@ class CommandOSUserList : public Command modes.insert("INVIS"); ListFormatter list(source.GetAccount()); - list.AddColumn(_("Name")).AddColumn(_("Mask")); + list.AddColumn(_("Name")).AddColumn(_("Mask")).AddColumn(_("Realname")); if (!pattern.empty() && (c = Channel::Find(pattern))) { @@ -162,7 +163,10 @@ class CommandOSUserList : public Command ListFormatter::ListEntry entry; entry["Name"] = uc->user->nick; entry["Mask"] = uc->user->GetIdent() + "@" + uc->user->GetDisplayedHost(); + entry["Realname"] = uc->user->realname; list.AddEntry(entry); + + ++count; } } else @@ -180,9 +184,27 @@ class CommandOSUserList : public Command if (!pattern.empty()) { - Anope::string mask = u2->nick + "!" + u2->GetIdent() + "@" + u2->GetDisplayedHost(), mask2 = u2->nick + "!" + u2->GetIdent() + "@" + u2->host, mask3 = u2->nick + "!" + u2->GetIdent() + "@" + u2->ip.addr(); - if (!Anope::Match(mask, pattern, false, true) && !Anope::Match(mask2, pattern, false, true) && !Anope::Match(mask3, pattern, false, true)) + /* check displayed host, host, and ip */ + Anope::string masks[] = { + u2->nick + "!" + u2->GetIdent() + "@" + u2->GetDisplayedHost(), + u2->nick + "!" + u2->GetIdent() + "@" + u2->host, + u2->nick + "!" + u2->GetIdent() + "@" + u2->ip.addr() + }; + + bool match = false; + for (unsigned int i = 0; i < sizeof(masks) / sizeof(*masks); ++i) + { + /* Check mask with realname included, too */ + if (Anope::Match(masks[i], pattern, false, true) || Anope::Match(masks[i] + "#" + u2->realname, pattern, false, true)) + { + match = true; + break; + } + } + + if (!match) continue; + if (!modes.empty()) for (std::set::iterator mit = modes.begin(), mit_end = modes.end(); mit != mit_end; ++mit) if (!u2->HasMode(*mit)) @@ -192,7 +214,10 @@ class CommandOSUserList : public Command ListFormatter::ListEntry entry; entry["Name"] = u2->nick; entry["Mask"] = u2->GetIdent() + "@" + u2->GetDisplayedHost(); + entry["Realname"] = u2->realname; list.AddEntry(entry); + + ++count; } } @@ -202,7 +227,7 @@ class CommandOSUserList : public Command for (unsigned i = 0; i < replies.size(); ++i) source.Reply(replies[i]); - source.Reply(_("End of users list.")); + source.Reply(_("End of users list. \002%u\002 users shown."), count); return; } @@ -214,8 +239,8 @@ class CommandOSUserList : public Command "nick is registered or not.\n" " \n" "If \002pattern\002 is given, lists only users that match it (it must be in\n" - "the format nick!user@host). If \002channel\002 is given, lists only users\n" - "that are on the given channel. If INVISIBLE is specified, only users\n" + "the format nick!user@host[#realname]). If \002channel\002 is given, lists\n" + "only users that are on the given channel. If INVISIBLE is specified, only users\n" "with the +i flag will be listed.")); const Anope::string ®exengine = Config->GetBlock("options")->Get("regexengine"); -- cgit From fe6271dffb92707a013a53b6e704ae2ceec36ebb Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 7 Jan 2017 18:04:07 -0500 Subject: ngircd: move metadata non-exietent user log message to debug --- modules/protocol/ngircd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp index c401f406c..56869c63a 100644 --- a/modules/protocol/ngircd.cpp +++ b/modules/protocol/ngircd.cpp @@ -317,7 +317,7 @@ struct IRCDMessageMetadata : IRCDMessage User *u = User::Find(params[0]); if (!u) { - Log() << "received METADATA for non-existent user " << params[0]; + Log(LOG_DEBUG) << "received METADATA for non-existent user " << params[0]; return; } if (params[1].equals_cs("accountname")) -- cgit From 46aeb8b70b116ffe37a6f1a72ddb9c69b7cccc98 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 7 Jan 2017 18:09:14 -0500 Subject: os_list: show number of channels listed, too --- modules/commands/os_list.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/commands/os_list.cpp b/modules/commands/os_list.cpp index 810ea56df..780cdd05e 100644 --- a/modules/commands/os_list.cpp +++ b/modules/commands/os_list.cpp @@ -26,6 +26,7 @@ class CommandOSChanList : public Command const Anope::string &opt = params.size() > 1 ? params[1] : ""; std::set modes; User *u2; + unsigned int count = 0; if (!pattern.empty()) Log(LOG_ADMIN, source, this) << "for " << pattern; @@ -60,6 +61,8 @@ class CommandOSChanList : public Command entry["Modes"] = cc->chan->GetModes(true, true); entry["Topic"] = cc->chan->topic; list.AddEntry(entry); + + ++count; } } else @@ -83,6 +86,8 @@ class CommandOSChanList : public Command entry["Modes"] = c->GetModes(true, true); entry["Topic"] = c->topic; list.AddEntry(entry); + + ++count; } } @@ -92,7 +97,7 @@ class CommandOSChanList : public Command for (unsigned i = 0; i < replies.size(); ++i) source.Reply(replies[i]); - source.Reply(_("End of channel list.")); + source.Reply(_("End of channel list. \002%u\002 channels shown."), count); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override -- cgit