diff options
| author | 2021-12-14 16:56:48 +0000 | |
|---|---|---|
| committer | 2021-12-14 16:56:48 +0000 | |
| commit | e9d54724e6cf9ff3772795cf5eed4b259700214f (patch) | |
| tree | c7e06a9ca507df1db4eb5dc2e40a10da8198c086 | |
| parent | Revert "Remove support for defaults in find_{compiler,linker}_flags()". (diff) | |
| parent | If a user has a unique username then include it in bans. (diff) | |
Merge branch 'insp3' into master.
| -rw-r--r-- | include/users.h | 6 | ||||
| -rw-r--r-- | src/coremods/core_xline/cmd_eline.cpp | 4 | ||||
| -rw-r--r-- | src/coremods/core_xline/cmd_gline.cpp | 4 | ||||
| -rw-r--r-- | src/coremods/core_xline/cmd_kline.cpp | 4 | ||||
| -rw-r--r-- | src/modules/extra/m_ldap.cpp | 7 | ||||
| -rw-r--r-- | src/modules/m_anticaps.cpp | 5 | ||||
| -rw-r--r-- | src/modules/m_clearchan.cpp | 2 | ||||
| -rw-r--r-- | src/modules/m_dnsbl.cpp | 12 | ||||
| -rw-r--r-- | src/modules/m_messageflood.cpp | 2 | ||||
| -rw-r--r-- | src/modules/m_repeat.cpp | 2 | ||||
| -rw-r--r-- | src/modules/m_shun.cpp | 2 | ||||
| -rw-r--r-- | src/modules/m_spanningtree/main.cpp | 8 | ||||
| -rw-r--r-- | src/modules/m_spanningtree/main.h | 1 | ||||
| -rw-r--r-- | src/modules/m_spanningtree/netburst.cpp | 3 | ||||
| -rw-r--r-- | src/serializable.cpp | 6 | ||||
| -rw-r--r-- | src/users.cpp | 8 |
16 files changed, 56 insertions, 20 deletions
diff --git a/include/users.h b/include/users.h index 0c091e161..01e7e3de7 100644 --- a/include/users.h +++ b/include/users.h @@ -366,6 +366,9 @@ class CoreExport User : public Extensible */ unsigned int quitting:1; + /** Whether the ident field uniquely identifies this user on their origin host. */ + bool uniqueusername:1; + /** What type of user is this? */ const uint8_t usertype:2; @@ -379,6 +382,9 @@ class CoreExport User : public Extensible */ const std::string& GetHost(bool uncloak) const; + /** Retrieves the username which should be included in bans for this user. */ + const std::string& GetBanIdent() const; + /** Retrieves this user's displayed hostname. */ const std::string& GetDisplayedHost() const; diff --git a/src/coremods/core_xline/cmd_eline.cpp b/src/coremods/core_xline/cmd_eline.cpp index 71a268b27..5ee33bd9c 100644 --- a/src/coremods/core_xline/cmd_eline.cpp +++ b/src/coremods/core_xline/cmd_eline.cpp @@ -46,9 +46,9 @@ CmdResult CommandEline::Handle(User* user, const Params& parameters) User* find = ServerInstance->Users.Find(target); if ((find) && (find->registered == REG_ALL)) { - ih.first = "*"; + ih.first = find->GetBanIdent(); ih.second = find->GetIPString(); - target = std::string("*@") + find->GetIPString(); + target = ih.first + "@" + ih.second; } else ih = ServerInstance->XLines->IdentSplit(target); diff --git a/src/coremods/core_xline/cmd_gline.cpp b/src/coremods/core_xline/cmd_gline.cpp index 5d7356ca9..ad16b3720 100644 --- a/src/coremods/core_xline/cmd_gline.cpp +++ b/src/coremods/core_xline/cmd_gline.cpp @@ -47,9 +47,9 @@ CmdResult CommandGline::Handle(User* user, const Params& parameters) User* find = ServerInstance->Users.Find(target); if ((find) && (find->registered == REG_ALL)) { - ih.first = "*"; + ih.first = find->GetBanIdent(); ih.second = find->GetIPString(); - target = std::string("*@") + find->GetIPString(); + target = ih.first + "@" + ih.second; } else ih = ServerInstance->XLines->IdentSplit(target); diff --git a/src/coremods/core_xline/cmd_kline.cpp b/src/coremods/core_xline/cmd_kline.cpp index 05ab12dde..a150668d7 100644 --- a/src/coremods/core_xline/cmd_kline.cpp +++ b/src/coremods/core_xline/cmd_kline.cpp @@ -47,9 +47,9 @@ CmdResult CommandKline::Handle(User* user, const Params& parameters) User* find = ServerInstance->Users.Find(target); if ((find) && (find->registered == REG_ALL)) { - ih.first = "*"; + ih.first = find->GetBanIdent(); ih.second = find->GetIPString(); - target = std::string("*@") + find->GetIPString(); + target = ih.first + "@" + ih.second; } else ih = ServerInstance->XLines->IdentSplit(target); diff --git a/src/modules/extra/m_ldap.cpp b/src/modules/extra/m_ldap.cpp index 9eeed4e47..80775d40b 100644 --- a/src/modules/extra/m_ldap.cpp +++ b/src/modules/extra/m_ldap.cpp @@ -20,7 +20,8 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -/// $LinkerFlags: -llber -lldap_r +/// $LinkerFlags: find_compiler_flags("lber" "") find_compiler_flags("ldap" "") +/// $LinkerFlags: find_linker_flags("lber" "-llber") find_linker_flags("ldap" "-lldap_r") /// $PackageInfo: require_system("arch") libldap /// $PackageInfo: require_system("centos") openldap-devel @@ -30,6 +31,10 @@ #include "inspircd.h" #include "modules/ldap.h" +#if defined LDAP_API_FEATURE_X_OPENLDAP_REENTRANT && !LDAP_API_FEATURE_X_OPENLDAP_REENTRANT +# error InspIRCd requires OpenLDAP to be built as reentrant. +#endif + // Ignore OpenLDAP deprecation warnings on OS X Yosemite and newer. #if defined __APPLE__ # pragma GCC diagnostic push diff --git a/src/modules/m_anticaps.cpp b/src/modules/m_anticaps.cpp index 9972aca32..1f6ff0747 100644 --- a/src/modules/m_anticaps.cpp +++ b/src/modules/m_anticaps.cpp @@ -163,8 +163,9 @@ class ModuleAntiCaps final void CreateBan(Channel* channel, User* user, bool mute) { - std::string banmask(mute ? "m:" : ""); - banmask.append("*!*@"); + std::string banmask(mute ? "m:*!" : "*!"); + banmask.append(user->GetBanIdent()); + banmask.append("@"); banmask.append(user->GetDisplayedHost()); Modes::ChangeList changelist; diff --git a/src/modules/m_clearchan.cpp b/src/modules/m_clearchan.cpp index ee9f5aeaa..ee681dfc7 100644 --- a/src/modules/m_clearchan.cpp +++ b/src/modules/m_clearchan.cpp @@ -119,7 +119,7 @@ class CommandClearChan final XLine* xline; try { - mask = ((method[0] == 'Z') ? curr->GetIPString() : "*@" + curr->GetRealHost()); + mask = (method[0] == 'Z') ? curr->GetIPString() : (curr->GetBanIdent() + "@" + curr->GetRealHost()); xline = xlf->Generate(ServerInstance->Time(), 60*60, user->nick, reason, mask); } catch (ModuleException&) diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp index a94d53058..203b75518 100644 --- a/src/modules/m_dnsbl.cpp +++ b/src/modules/m_dnsbl.cpp @@ -279,11 +279,11 @@ class DNSBLResolver final case DNSBLEntry::Action::KLINE: { KLine* kl = new KLine(ServerInstance->Time(), ConfEntry->xlineduration, ServerInstance->Config->ServerName.c_str(), reason.c_str(), - "*", them->GetIPString()); + them->GetBanIdent(), them->GetIPString()); if (ServerInstance->XLines->AddLine(kl,NULL)) { - ServerInstance->SNO.WriteToSnoMask('x', "K-line added due to DNSBL match on *@%s to expire in %s (on %s): %s", - them->GetIPString().c_str(), InspIRCd::DurationString(kl->duration).c_str(), + ServerInstance->SNO.WriteToSnoMask('x', "K-line added due to DNSBL match on %s to expire in %s (on %s): %s", + kl->Displayable().c_str(), InspIRCd::DurationString(kl->duration).c_str(), InspIRCd::TimeString(kl->expiry).c_str(), reason.c_str()); ServerInstance->XLines->ApplyLines(); } @@ -297,11 +297,11 @@ class DNSBLResolver final case DNSBLEntry::Action::GLINE: { GLine* gl = new GLine(ServerInstance->Time(), ConfEntry->xlineduration, ServerInstance->Config->ServerName.c_str(), reason.c_str(), - "*", them->GetIPString()); + them->GetBanIdent(), them->GetIPString()); if (ServerInstance->XLines->AddLine(gl,NULL)) { - ServerInstance->SNO.WriteToSnoMask('x', "G-line added due to DNSBL match on *@%s to expire in %s (on %s): %s", - them->GetIPString().c_str(), InspIRCd::DurationString(gl->duration).c_str(), + ServerInstance->SNO.WriteToSnoMask('x', "G-line added due to DNSBL match on %s to expire in %s (on %s): %s", + gl->Displayable().c_str(), InspIRCd::DurationString(gl->duration).c_str(), InspIRCd::TimeString(gl->expiry).c_str(), reason.c_str()); ServerInstance->XLines->ApplyLines(); } diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp index 4149e9dc8..5cef63387 100644 --- a/src/modules/m_messageflood.cpp +++ b/src/modules/m_messageflood.cpp @@ -163,7 +163,7 @@ private: if (f->ban) { Modes::ChangeList changelist; - changelist.push_add(*banmode, "*!*@" + user->GetDisplayedHost()); + changelist.push_add(*banmode, "*!" + user->GetBanIdent() + "@" + user->GetDisplayedHost()); ServerInstance->Modes.Process(ServerInstance->FakeClient, dest, nullptr, changelist); } diff --git a/src/modules/m_repeat.cpp b/src/modules/m_repeat.cpp index 8b47d5c4b..b30729ac0 100644 --- a/src/modules/m_repeat.cpp +++ b/src/modules/m_repeat.cpp @@ -407,7 +407,7 @@ class RepeatModule final if (settings->Action == ChannelSettings::ACT_BAN) { Modes::ChangeList changelist; - changelist.push_add(*banmode, "*!*@" + user->GetDisplayedHost()); + changelist.push_add(*banmode, "*!" + user->GetBanIdent() + "@" + user->GetDisplayedHost()); ServerInstance->Modes.Process(ServerInstance->FakeClient, chan, nullptr, changelist); } diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp index 8f3a7b4fc..d231aae3e 100644 --- a/src/modules/m_shun.cpp +++ b/src/modules/m_shun.cpp @@ -72,7 +72,7 @@ class CommandShun final User *find = ServerInstance->Users.Find(target); if ((find) && (find->registered == REG_ALL)) - target = std::string("*!*@") + find->GetIPString(); + target = "*!" + find->GetBanIdent() + "@" + find->GetIPString(); if (parameters.size() == 1) { diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index ef6ce73ed..93afcd237 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -848,6 +848,14 @@ void ModuleSpanningTree::OnShutdown(const std::string& reason) children.front()->SQuit(reason, true); } +void ModuleSpanningTree::OnDecodeMetaData(Extensible* target, const std::string& extname, const std::string& extdata) +{ + // HACK: this should use automatically synced user metadata in v4. + User* dest = static_cast<User*>(target); + if (dest && (extname == "uniqueusername")) + dest->uniqueusername = true; +} + Cullable::Result ModuleSpanningTree::Cull() { if (Utils) diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h index 417beed7f..3395427aa 100644 --- a/src/modules/m_spanningtree/main.h +++ b/src/modules/m_spanningtree/main.h @@ -206,6 +206,7 @@ class ModuleSpanningTree final ModResult OnAcceptConnection(int newsock, ListenSocket* from, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server) override; void OnMode(User* source, User* u, Channel* c, const Modes::ChangeList& modes, ModeParser::ModeProcessFlag processflags) override; void OnShutdown(const std::string& reason) override; + void OnDecodeMetaData(Extensible* target, const std::string& extname, const std::string& extdata) override; Cullable::Result Cull() override; ~ModuleSpanningTree() override; void Prioritize() override; diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp index 3ca58221e..557e05126 100644 --- a/src/modules/m_spanningtree/netburst.cpp +++ b/src/modules/m_spanningtree/netburst.cpp @@ -284,6 +284,9 @@ void TreeSocket::SendUsers(BurstState& bs) if (user->IsAway()) this->WriteLine(CommandAway::Builder(user)); + if (user->uniqueusername) // TODO: convert this to BooleanExtItem in v4. + this->WriteLine(CommandMetadata::Builder(user, "uniqueusername", "1")); + for (const auto& [item, obj] : user->GetExtList()) { const std::string value = item->ToNetwork(user, obj); diff --git a/src/serializable.cpp b/src/serializable.cpp index f6ff634f9..9bc08f325 100644 --- a/src/serializable.cpp +++ b/src/serializable.cpp @@ -129,6 +129,7 @@ bool User::Deserialize(Serializable::Data& data) return false; int client_port; + bool user_uniqueusername; std::string client_addr; std::string user_modes; std::string user_oper; @@ -148,11 +149,13 @@ bool User::Deserialize(Serializable::Data& data) .Load("realhost", realhost) .Load("realname", realname) .Load("signon", signon) - .Load("snomasks", user_snomasks); + .Load("snomasks", user_snomasks) + .Load("uniqueusername", user_uniqueusername); // Apply the rest of the members. modes = std::bitset<ModeParser::MODEID_MAX>(user_modes); snomasks = std::bitset<64>(user_snomasks); + uniqueusername = user_uniqueusername; ServerConfig::OperIndex::const_iterator iter = ServerInstance->Config->OperTypes.find(user_oper); if (iter != ServerInstance->Config->OperTypes.end()) @@ -210,6 +213,7 @@ bool User::Serialize(Serializable::Data& data) .Store("realname", realname) .Store("signon", signon) .Store("snomasks", snomasks.to_string()) + .Store("uniqueusername", uniqueusername) .Store("uuid", uuid); return true; diff --git a/src/users.cpp b/src/users.cpp index 06bd58421..b5ce7cd91 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -83,6 +83,7 @@ User::User(const std::string& uid, Server* srv, Type type) , server(srv) , registered(REG_NONE) , quitting(false) + , uniqueusername(false) , usertype(type) { client_sa.sa.sa_family = AF_UNSPEC; @@ -521,6 +522,7 @@ void LocalUser::CheckClass(bool clone_count) } this->nextping = ServerInstance->Time() + a->GetPingTime(); + this->uniqueusername = a->uniqueusername; } bool LocalUser::CheckLines(bool doZline) @@ -686,6 +688,12 @@ const std::string& User::GetIPString() return cachedip; } +const std::string& User::GetBanIdent() const +{ + static const std::string wildcard = "*"; + return uniqueusername ? ident : wildcard; +} + const std::string& User::GetHost(bool uncloak) const { return uncloak ? GetRealHost() : GetDisplayedHost(); |
