From 1986aa65815f061106f43a5c1e9a22bc199a2d56 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 12 Mar 2024 13:26:25 +0000 Subject: [PATCH 1/6] Fix duplicate messages when synconset/syncongroup is set. Closes #366. --- modules/commands/hs_group.cpp | 2 +- modules/commands/hs_set.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/commands/hs_group.cpp b/modules/commands/hs_group.cpp index f08c56685..b22450227 100644 --- a/modules/commands/hs_group.cpp +++ b/modules/commands/hs_group.cpp @@ -28,7 +28,7 @@ class CommandHSGroup : public Command for (unsigned i = 0; i < na->nc->aliases->size(); ++i) { NickAlias *nick = na->nc->aliases->at(i); - if (nick) + if (nick && nick != na) { nick->SetVhost(na->GetVhostIdent(), na->GetVhostHost(), na->GetVhostCreator()); FOREACH_MOD(OnSetVhost, (nick)); diff --git a/modules/commands/hs_set.cpp b/modules/commands/hs_set.cpp index 1a34266d7..b561c1e62 100644 --- a/modules/commands/hs_set.cpp +++ b/modules/commands/hs_set.cpp @@ -114,7 +114,7 @@ class CommandHSSetAll : public Command for (unsigned i = 0; i < na->nc->aliases->size(); ++i) { NickAlias *nick = na->nc->aliases->at(i); - if (nick) + if (nick && nick != na) nick->SetVhost(na->GetVhostIdent(), na->GetVhostHost(), na->GetVhostCreator()); } } From f5abcd1c4cea1c68b82e3d00a2fe479d5557b717 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 12 Mar 2024 14:02:16 +0000 Subject: [PATCH 2/6] Fix expiring nick suspensions. Closes #376. --- modules/commands/ns_suspend.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/modules/commands/ns_suspend.cpp b/modules/commands/ns_suspend.cpp index cf2b19834..fc445a1dc 100644 --- a/modules/commands/ns_suspend.cpp +++ b/modules/commands/ns_suspend.cpp @@ -222,6 +222,12 @@ class NSSuspend : public Module return source.IsOper() || std::find(show.begin(), show.end(), what) != show.end(); } + void Expire(NickAlias *na) + { + suspend.Unset(na->nc); + Log(LOG_NORMAL, "nickserv/expire", Config->GetClient("NickServ")) << "Expiring suspend for " << na->nick; + } + public: NSSuspend(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandnssuspend(this), commandnsunsuspend(this), suspend(this, "NS_SUSPENDED"), @@ -262,15 +268,10 @@ class NSSuspend : public Module expire = false; - if (!s->expires) - return; - - if (s->expires < Anope::CurTime) + if (s->expires && s->expires < Anope::CurTime) { na->last_seen = Anope::CurTime; - suspend.Unset(na->nc); - - Log(LOG_NORMAL, "nickserv/expire", Config->GetClient("NickServ")) << "Expiring suspend for " << na->nick; + Expire(na); } } @@ -280,6 +281,12 @@ class NSSuspend : public Module if (!s) return EVENT_CONTINUE; + if (s->expires && s->expires < Anope::CurTime) + { + Expire(na); + return EVENT_CONTINUE; + } + u->SendMessage(Config->GetClient("NickServ"), NICK_X_SUSPENDED, u->nick.c_str()); return EVENT_STOP; } From e725c880a9ebe862c903dfb217e055ef7cde4a93 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 12 Mar 2024 14:12:37 +0000 Subject: [PATCH 3/6] Fix expiring channel suspensions. Closes #386. --- modules/commands/cs_suspend.cpp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/modules/commands/cs_suspend.cpp b/modules/commands/cs_suspend.cpp index e4fc8afad..ae050e1c6 100644 --- a/modules/commands/cs_suspend.cpp +++ b/modules/commands/cs_suspend.cpp @@ -210,6 +210,13 @@ class CSSuspend : public Module } }; + void Expire(ChannelInfo *ci) + { + suspend.Unset(ci); + Log(this) << "Expiring suspend for " << ci->name; + } + + bool Show(CommandSource &source, const Anope::string &what) const { return source.IsOper() || std::find(show.begin(), show.end(), what) != show.end(); @@ -255,23 +262,28 @@ class CSSuspend : public Module expire = false; - if (!si->expires) - return; - - if (si->expires < Anope::CurTime) + if (si->expires && si->expires < Anope::CurTime) { ci->last_used = Anope::CurTime; - suspend.Unset(ci); - - Log(this) << "Expiring suspend for " << ci->name; + Expire(ci); } } EventReturn OnCheckKick(User *u, Channel *c, Anope::string &mask, Anope::string &reason) anope_override { - if (u->HasMode("OPER") || !c->ci || !suspend.HasExt(c->ci)) + if (u->HasMode("OPER") || !c->ci) return EVENT_CONTINUE; + CSSuspendInfo *si = suspend.Get(c->ci); + if (!si) + return EVENT_CONTINUE; + + if (si->expires && si->expires < Anope::CurTime) + { + Expire(c->ci); + return EVENT_CONTINUE; + } + reason = Language::Translate(u, _("This channel may not be used.")); return EVENT_STOP; } From 1a8bbd600498d6ac00906e130950d75e6ccd3148 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 12 Mar 2024 14:34:34 +0000 Subject: [PATCH 4/6] Respect --noexpire in cs_suspend and ns_suspend. --- modules/commands/cs_suspend.cpp | 4 ++-- modules/commands/ns_suspend.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/commands/cs_suspend.cpp b/modules/commands/cs_suspend.cpp index ae050e1c6..c9274c059 100644 --- a/modules/commands/cs_suspend.cpp +++ b/modules/commands/cs_suspend.cpp @@ -262,7 +262,7 @@ class CSSuspend : public Module expire = false; - if (si->expires && si->expires < Anope::CurTime) + if (!Anope::NoExpire && si->expires && si->expires < Anope::CurTime) { ci->last_used = Anope::CurTime; Expire(ci); @@ -278,7 +278,7 @@ class CSSuspend : public Module if (!si) return EVENT_CONTINUE; - if (si->expires && si->expires < Anope::CurTime) + if (!Anope::NoExpire && si->expires && si->expires < Anope::CurTime) { Expire(c->ci); return EVENT_CONTINUE; diff --git a/modules/commands/ns_suspend.cpp b/modules/commands/ns_suspend.cpp index fc445a1dc..0d801ab7d 100644 --- a/modules/commands/ns_suspend.cpp +++ b/modules/commands/ns_suspend.cpp @@ -268,7 +268,7 @@ class NSSuspend : public Module expire = false; - if (s->expires && s->expires < Anope::CurTime) + if (!Anope::NoExpire && s->expires && s->expires < Anope::CurTime) { na->last_seen = Anope::CurTime; Expire(na); @@ -281,7 +281,7 @@ class NSSuspend : public Module if (!s) return EVENT_CONTINUE; - if (s->expires && s->expires < Anope::CurTime) + if (!Anope::NoExpire && s->expires && s->expires < Anope::CurTime) { Expire(na); return EVENT_CONTINUE; From 7d7664444a8b91ecde082fd56e37cfef8090e72c Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 12 Mar 2024 16:26:33 +0000 Subject: [PATCH 5/6] Fix expiring forbids. --- modules/commands/os_forbid.cpp | 53 +++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 13 deletions(-) diff --git a/modules/commands/os_forbid.cpp b/modules/commands/os_forbid.cpp index 415f7f64e..ab7bba20c 100644 --- a/modules/commands/os_forbid.cpp +++ b/modules/commands/os_forbid.cpp @@ -65,6 +65,33 @@ class MyForbidService : public ForbidService inline std::vector& forbids(unsigned t) { return (*this->forbid_data)[t - 1]; } + void Expire(ForbidData *fd, unsigned ft, size_t idx) + { + Anope::string typestr; + switch (ft) + { + case FT_NICK: + typestr = "nick"; + break; + case FT_CHAN: + typestr = "chan"; + break; + case FT_EMAIL: + typestr = "email"; + break; + case FT_REGISTER: + typestr = "register"; + break; + default: + typestr = "unknown"; + break; + } + + Log(LOG_NORMAL, "expire/forbid", Config->GetClient("OperServ")) << "Expiring forbid for " << fd->mask << " type " << typestr; + this->forbids(ft).erase(this->forbids(ft).begin() + idx); + delete fd; + } + public: MyForbidService(Module *m) : ForbidService(m), forbid_data("ForbidData") { } @@ -99,6 +126,12 @@ class MyForbidService : public ForbidService { ForbidData *d = this->forbids(ftype)[i - 1]; + if (!Anope::NoExpire && d->expires && Anope::CurTime >= d->expires) + { + Expire(d, ftype, i - 1); + continue; + } + if (Anope::Match(mask, d->mask, false, true)) return d; } @@ -111,6 +144,12 @@ class MyForbidService : public ForbidService { ForbidData *d = this->forbids(ftype)[i - 1]; + if (!Anope::NoExpire && d->expires && Anope::CurTime >= d->expires) + { + Expire(d, ftype, i - 1); + continue; + } + if (d->mask.equals_ci(mask)) return d; } @@ -126,19 +165,7 @@ class MyForbidService : public ForbidService ForbidData *d = this->forbids(j).at(i - 1); if (d->expires && !Anope::NoExpire && Anope::CurTime >= d->expires) - { - Anope::string ftype = "none"; - if (d->type == FT_NICK) - ftype = "nick"; - else if (d->type == FT_CHAN) - ftype = "chan"; - else if (d->type == FT_EMAIL) - ftype = "email"; - - Log(LOG_NORMAL, "expire/forbid", Config->GetClient("OperServ")) << "Expiring forbid for " << d->mask << " type " << ftype; - this->forbids(j).erase(this->forbids(j).begin() + i - 1); - delete d; - } + Expire(d, j, i - 1); else f.push_back(d); } From f4bd43e898e6ca415e22546f554e67139e62059e Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 12 Mar 2024 16:44:35 +0000 Subject: [PATCH 6/6] Add a workaround for users matching expired sqlines. I'll fix this properly in 2.1 because I don't want to make big changes to 2.0. Closes #384. --- modules/pseudoclients/operserv.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/pseudoclients/operserv.cpp b/modules/pseudoclients/operserv.cpp index 22a02f1e3..714f3b201 100644 --- a/modules/pseudoclients/operserv.cpp +++ b/modules/pseudoclients/operserv.cpp @@ -126,6 +126,9 @@ class SQLineManager : public XLineManager { XLine *x = *it; + if (!Anope::NoExpire && x->expires && x->expires < Anope::CurTime) + continue; // Skip expired lines. + if (x->regex) { if (x->regex->Matches(c->name))