From 889cbf87536e3050a5d327a5c338c329e9c3320c Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 14 Dec 2021 09:58:49 +0000 Subject: Fix the ldap module on OpenLDAP 2.5. --- src/modules/extra/m_ldap.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/modules') diff --git a/src/modules/extra/m_ldap.cpp b/src/modules/extra/m_ldap.cpp index 422a98f6f..4b506e18a 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 . */ -/// $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 -- cgit v1.3.1-10-gc9f91 From 901e092c21ba4092a22786afa24f40f7fe416e5e Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 14 Dec 2021 14:55:06 +0000 Subject: Add a build time check that OpenLDAP is reentrant. --- src/modules/extra/m_ldap.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/modules') diff --git a/src/modules/extra/m_ldap.cpp b/src/modules/extra/m_ldap.cpp index 4b506e18a..8aea323a3 100644 --- a/src/modules/extra/m_ldap.cpp +++ b/src/modules/extra/m_ldap.cpp @@ -31,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 -- cgit v1.3.1-10-gc9f91 From 64340dc50901f88336d9a2933dad98b462b6f36b Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 14 Dec 2021 15:48:57 +0000 Subject: Sync uniqueusername from the connect class to the user. This is a massive hack for now but should be made to sync properly in v4 when we have extensibles that don't suck. --- include/users.h | 3 +++ src/modules/m_spanningtree/main.cpp | 8 ++++++++ src/modules/m_spanningtree/main.h | 1 + src/modules/m_spanningtree/netburst.cpp | 3 +++ src/serializable.cpp | 6 +++++- src/users.cpp | 2 ++ 6 files changed, 22 insertions(+), 1 deletion(-) (limited to 'src/modules') diff --git a/include/users.h b/include/users.h index 2079cf773..04225ba6e 100644 --- a/include/users.h +++ b/include/users.h @@ -363,6 +363,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 unsigned int usertype:2; diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index c829b31d3..5e30469e9 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -803,6 +803,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(target); + if (dest && (extname == "uniqueusername")) + dest->uniqueusername = true; +} + CullResult ModuleSpanningTree::cull() { if (Utils) diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h index 076369493..7e8ce3af6 100644 --- a/src/modules/m_spanningtree/main.h +++ b/src/modules/m_spanningtree/main.h @@ -222,6 +222,7 @@ class ModuleSpanningTree ModResult OnAcceptConnection(int newsock, ListenSocket* from, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server) CXX11_OVERRIDE; void OnMode(User* source, User* u, Channel* c, const Modes::ChangeList& modes, ModeParser::ModeProcessFlag processflags) CXX11_OVERRIDE; void OnShutdown(const std::string& reason) CXX11_OVERRIDE; + void OnDecodeMetaData(Extensible* target, const std::string& extname, const std::string& extdata) CXX11_OVERRIDE; CullResult cull() CXX11_OVERRIDE; ~ModuleSpanningTree(); Version GetVersion() CXX11_OVERRIDE; diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp index 227e9667c..931d5b0ff 100644 --- a/src/modules/m_spanningtree/netburst.cpp +++ b/src/modules/m_spanningtree/netburst.cpp @@ -296,6 +296,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")); + const Extensible::ExtensibleStore& exts = user->GetExtList(); for (Extensible::ExtensibleStore::const_iterator i = exts.begin(); i != exts.end(); ++i) { diff --git a/src/serializable.cpp b/src/serializable.cpp index b351d4099..13d94ef29 100644 --- a/src/serializable.cpp +++ b/src/serializable.cpp @@ -132,6 +132,7 @@ bool User::Deserialize(Serializable::Data& data) return false; long client_port; + bool user_uniqueusername; std::string client_addr; std::string user_modes; std::string user_oper; @@ -151,11 +152,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(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()) @@ -213,6 +216,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 6d8766082..fc66cf70c 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -84,6 +84,7 @@ User::User(const std::string& uid, Server* srv, UserType type) , server(srv) , registered(REG_NONE) , quitting(false) + , uniqueusername(false) , usertype(type) { client_sa.sa.sa_family = AF_UNSPEC; @@ -555,6 +556,7 @@ void LocalUser::CheckClass(bool clone_count) } this->nextping = ServerInstance->Time() + a->GetPingTime(); + this->uniqueusername = a->uniqueusername; } bool LocalUser::CheckLines(bool doZline) -- cgit v1.3.1-10-gc9f91 From 15a68932b6238cf52c3e86d1d029b0e65b8b755b Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 14 Dec 2021 15:54:51 +0000 Subject: If a user has a unique username then include it in bans. --- include/users.h | 3 +++ src/coremods/core_xline/cmd_eline.cpp | 4 ++-- src/coremods/core_xline/cmd_gline.cpp | 4 ++-- src/coremods/core_xline/cmd_kline.cpp | 4 ++-- src/modules/m_anticaps.cpp | 5 +++-- src/modules/m_clearchan.cpp | 2 +- src/modules/m_dnsbl.cpp | 12 ++++++------ src/modules/m_messageflood.cpp | 2 +- src/modules/m_repeat.cpp | 2 +- src/modules/m_shun.cpp | 2 +- src/users.cpp | 6 ++++++ 11 files changed, 28 insertions(+), 18 deletions(-) (limited to 'src/modules') diff --git a/include/users.h b/include/users.h index 04225ba6e..0862c7dd3 100644 --- a/include/users.h +++ b/include/users.h @@ -379,6 +379,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 3572a4069..13ed8a685 100644 --- a/src/coremods/core_xline/cmd_eline.cpp +++ b/src/coremods/core_xline/cmd_eline.cpp @@ -48,9 +48,9 @@ CmdResult CommandEline::Handle(User* user, const Params& parameters) User* find = ServerInstance->FindNick(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 dc4fd0986..16b7abbf4 100644 --- a/src/coremods/core_xline/cmd_gline.cpp +++ b/src/coremods/core_xline/cmd_gline.cpp @@ -49,9 +49,9 @@ CmdResult CommandGline::Handle(User* user, const Params& parameters) User* find = ServerInstance->FindNick(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 84477fda4..62538e481 100644 --- a/src/coremods/core_xline/cmd_kline.cpp +++ b/src/coremods/core_xline/cmd_kline.cpp @@ -49,9 +49,9 @@ CmdResult CommandKline::Handle(User* user, const Params& parameters) User* find = ServerInstance->FindNick(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/m_anticaps.cpp b/src/modules/m_anticaps.cpp index 7c59cc2ba..d41a4105b 100644 --- a/src/modules/m_anticaps.cpp +++ b/src/modules/m_anticaps.cpp @@ -165,8 +165,9 @@ class ModuleAntiCaps : public Module 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 592559afc..fba493960 100644 --- a/src/modules/m_clearchan.cpp +++ b/src/modules/m_clearchan.cpp @@ -118,7 +118,7 @@ class CommandClearChan : public Command 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 dc43dda3f..6cfadff59 100644 --- a/src/modules/m_dnsbl.cpp +++ b/src/modules/m_dnsbl.cpp @@ -182,11 +182,11 @@ class DNSBLResolver : public DNS::Request case DNSBLConfEntry::I_KLINE: { KLine* kl = new KLine(ServerInstance->Time(), ConfEntry->duration, 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(); } @@ -200,11 +200,11 @@ class DNSBLResolver : public DNS::Request case DNSBLConfEntry::I_GLINE: { GLine* gl = new GLine(ServerInstance->Time(), ConfEntry->duration, 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 4c79318fc..5db1e1e9d 100644 --- a/src/modules/m_messageflood.cpp +++ b/src/modules/m_messageflood.cpp @@ -161,7 +161,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, NULL, changelist); } diff --git a/src/modules/m_repeat.cpp b/src/modules/m_repeat.cpp index c114d9396..c432ae57e 100644 --- a/src/modules/m_repeat.cpp +++ b/src/modules/m_repeat.cpp @@ -413,7 +413,7 @@ class RepeatModule : public Module 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, NULL, changelist); } diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp index 671d21233..89e71e4ca 100644 --- a/src/modules/m_shun.cpp +++ b/src/modules/m_shun.cpp @@ -73,7 +73,7 @@ class CommandShun : public Command User *find = ServerInstance->FindNick(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/users.cpp b/src/users.cpp index fc66cf70c..38e677226 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -722,6 +722,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(); -- cgit v1.3.1-10-gc9f91