mirror of
https://github.com/anope/anope.git
synced 2026-07-10 23:23:13 +02:00
Brought back the old 1.7 behavior of a level -1 matching all users and 0 matching all identified users
This commit is contained in:
@@ -79,6 +79,7 @@ class CoreExport AccessGroup : public std::vector<ChanAccess *>
|
||||
{
|
||||
public:
|
||||
ChannelInfo *ci;
|
||||
NickCore *nc;
|
||||
bool SuperAdmin, Founder;
|
||||
AccessGroup();
|
||||
bool HasPriv(ChannelAccess priv) const;
|
||||
|
||||
+2
-1
@@ -48,8 +48,9 @@ class CoreExport BotInfo : public User, public Flags<BotFlag, BI_END>
|
||||
* @param user The ident to give the bot.
|
||||
* @param host The hostname to give the bot.
|
||||
* @param real The realname to give the bot.
|
||||
* @param bmodes The modes to give the bot.
|
||||
*/
|
||||
BotInfo(const Anope::string &nick, const Anope::string &user = "", const Anope::string &host = "", const Anope::string &real = "", const Anope::string &modes = "");
|
||||
BotInfo(const Anope::string &nick, const Anope::string &user = "", const Anope::string &host = "", const Anope::string &real = "", const Anope::string &bmodes = "");
|
||||
|
||||
/** Destroy a bot, clearing up appropriately.
|
||||
*/
|
||||
|
||||
@@ -46,7 +46,6 @@
|
||||
#define NICK_SET_DISABLED _("Sorry, nickname option setting is temporarily disabled.")
|
||||
#define NICK_SET_UNKNOWN_OPTION _("Unknown SET option \002%s%s\002.")
|
||||
#define NICK_SET_DISPLAY_CHANGED _("The new display is now \002%s\002.")
|
||||
#define NICK_INFO_OPTIONS _(" Options: %s")
|
||||
#define NICK_LIST_SYNTAX _("LIST \037pattern\037")
|
||||
#define LIST_HEADER _("List of entries matching \002%s\002:")
|
||||
#define NICK_RECOVERED _("User claiming your nick has been killed.\n" \
|
||||
|
||||
+8
-1
@@ -753,6 +753,13 @@ class CoreExport Module : public Extensible
|
||||
*/
|
||||
virtual EventReturn OnCheckPriv(ChanAccess *access, ChannelAccess priv) { return EVENT_CONTINUE; }
|
||||
|
||||
/** Check whether an access group has a privilege
|
||||
* @param group The group
|
||||
* @param priv The privilege
|
||||
* @return MOD_ALLOW to allow, MOD_STOP to stop
|
||||
*/
|
||||
virtual EventReturn OnGroupCheckPriv(const AccessGroup *group, ChannelAccess priv) { return EVENT_CONTINUE; }
|
||||
|
||||
/** Called when a nick is dropped
|
||||
* @param u The user dropping the nick
|
||||
* @param na The nick
|
||||
@@ -1037,7 +1044,7 @@ enum Implementation
|
||||
I_OnChanForbidden, I_OnChanSuspend, I_OnChanDrop, I_OnPreChanExpire, I_OnChanExpire, I_OnAccessAdd,
|
||||
I_OnAccessDel, I_OnAccessClear, I_OnLevelChange, I_OnChanRegistered, I_OnChanUnsuspend, I_OnCreateChan, I_OnDelChan, I_OnChannelCreate,
|
||||
I_OnChannelDelete, I_OnAkickAdd, I_OnAkickDel, I_OnCheckKick,
|
||||
I_OnChanInfo, I_OnFindChan, I_OnCheckPriv,
|
||||
I_OnChanInfo, I_OnFindChan, I_OnCheckPriv, I_OnGroupCheckPriv,
|
||||
|
||||
/* BotServ */
|
||||
I_OnBotJoin, I_OnBotKick, I_OnBotCreate, I_OnBotChange, I_OnBotDelete, I_OnBotAssign, I_OnBotUnAssign,
|
||||
|
||||
@@ -588,8 +588,9 @@ class CommandCSAccess : public Command
|
||||
"list specifies which users are allowed chanop status or\n"
|
||||
"access to %s commands on the channel. Different\n"
|
||||
"user levels allow for access to different subsets of\n"
|
||||
"privileges. Any nick not on the access list has\n"
|
||||
"a user level of 0."), source.owner->nick.c_str());
|
||||
"privileges. Any registered user not on the access list has\n"
|
||||
"a user level of 0, and any unregistered user has a user level\n"
|
||||
"of -1."), source.owner->nick.c_str());
|
||||
source.Reply(" ");
|
||||
source.Reply(_("The \002ACCESS ADD\002 command adds the given mask to the\n"
|
||||
"access list with the given user level; if the mask is\n"
|
||||
@@ -635,7 +636,6 @@ class CommandCSAccess : public Command
|
||||
" \002 3\002 Automatic voicing.\n"
|
||||
" \002 0\002 No special privileges; can be opped by other\n"
|
||||
" ops (unless \002secure-ops\002 is set).\n"
|
||||
" \002 <0\002 May not be opped.\n"
|
||||
" \n"
|
||||
"These levels may be changed, or new ones added, using the\n"
|
||||
"\002LEVELS\002 command; type \002%s%s HELP LEVELS\002 for\n"
|
||||
@@ -886,7 +886,7 @@ class CSAccess : public Module
|
||||
ModuleManager::RegisterService(&commandcsaccess);
|
||||
ModuleManager::RegisterService(&commandcslevels);
|
||||
|
||||
Implementation i[] = { I_OnReload, I_OnChanRegistered, I_OnCreateChan };
|
||||
Implementation i[] = { I_OnReload, I_OnChanRegistered, I_OnCreateChan, I_OnGroupCheckPriv };
|
||||
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
|
||||
|
||||
this->OnReload();
|
||||
@@ -919,6 +919,19 @@ class CSAccess : public Module
|
||||
{
|
||||
reset_levels(ci);
|
||||
}
|
||||
|
||||
EventReturn OnGroupCheckPriv(const AccessGroup *group, ChannelAccess priv)
|
||||
{
|
||||
if (group->ci == NULL)
|
||||
return EVENT_CONTINUE;
|
||||
/* Special case. Allows a level of < 0 to match anyone, and a level of 0 to match anyone identified. */
|
||||
int16 level = group->ci->levels[priv];
|
||||
if (level < 0)
|
||||
return EVENT_ALLOW;
|
||||
else if (level == 0 && group->nc)
|
||||
return EVENT_ALLOW;
|
||||
return EVENT_CONTINUE;
|
||||
}
|
||||
};
|
||||
|
||||
MODULE_INIT(CSAccess)
|
||||
|
||||
@@ -93,7 +93,7 @@ class CommandCSInfo : public Command
|
||||
CheckOptStr(optbuf, CI_PERSIST, _("Persistant"), ci, u->Account());
|
||||
CheckOptStr(optbuf, CI_NO_EXPIRE, _("No expire"), ci, u->Account());
|
||||
|
||||
source.Reply(NICK_INFO_OPTIONS, optbuf.empty() ? _("None") : optbuf.c_str());
|
||||
source.Reply(_(" Options: %s"), optbuf.empty() ? _("None") : optbuf.c_str());
|
||||
source.Reply(_(" Mode lock: %s"), ci->GetMLockAsString(true).c_str());
|
||||
|
||||
if (!ci->HasFlag(CI_NO_EXPIRE))
|
||||
|
||||
@@ -118,7 +118,7 @@ class CommandNSInfo : public Command
|
||||
CheckOptStr(optbuf, NI_MSG, _("Message mode"), na->nc);
|
||||
CheckOptStr(optbuf, NI_AUTOOP, _("Auto-op"), na->nc);
|
||||
|
||||
source.Reply(NICK_INFO_OPTIONS, optbuf.empty() ? _("None") : optbuf.c_str());
|
||||
source.Reply(_(" Options: %s"), optbuf.empty() ? _("None") : optbuf.c_str());
|
||||
|
||||
if (na->nc->HasFlag(NI_SUSPENDED))
|
||||
{
|
||||
|
||||
+5
-1
@@ -82,6 +82,7 @@ bool ChanAccess::operator<=(ChanAccess &other)
|
||||
AccessGroup::AccessGroup() : std::vector<ChanAccess *>()
|
||||
{
|
||||
this->ci = NULL;
|
||||
this->nc = NULL;
|
||||
this->SuperAdmin = this->Founder = false;
|
||||
}
|
||||
|
||||
@@ -93,10 +94,13 @@ bool AccessGroup::HasPriv(ChannelAccess priv) const
|
||||
return false;
|
||||
else if (this->Founder)
|
||||
return true;
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_OnGroupCheckPriv, OnGroupCheckPriv(this, priv));
|
||||
if (MOD_RESULT != EVENT_CONTINUE)
|
||||
return MOD_RESULT == EVENT_ALLOW;
|
||||
for (unsigned i = this->size(); i > 0; --i)
|
||||
{
|
||||
ChanAccess *access = this->at(i - 1);
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_OnCheckPriv, OnCheckPriv(access, priv));
|
||||
if (MOD_RESULT == EVENT_ALLOW || access->HasPriv(priv))
|
||||
return true;
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
Anope::insensitive_map<BotInfo *> BotListByNick;
|
||||
Anope::map<BotInfo *> BotListByUID;
|
||||
|
||||
BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const Anope::string &nhost, const Anope::string &nreal, const Anope::string &modes) : User(nnick, nuser, nhost, ts6_uid_retrieve()), Flags<BotFlag, BI_END>(BotFlagString), botmodes(modes)
|
||||
BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const Anope::string &nhost, const Anope::string &nreal, const Anope::string &bmodes) : User(nnick, nuser, nhost, ts6_uid_retrieve()), Flags<BotFlag, BI_END>(BotFlagString), botmodes(bmodes)
|
||||
{
|
||||
this->realname = nreal;
|
||||
this->server = Me;
|
||||
|
||||
@@ -220,6 +220,7 @@ AccessGroup ChannelInfo::AccessFor(User *u)
|
||||
group.SuperAdmin = u->SuperAdmin;
|
||||
group.Founder = IsFounder(u, this);
|
||||
group.ci = this;
|
||||
group.nc = u->Account();
|
||||
|
||||
for (unsigned i = 0, end = this->access.size(); i < end; ++i)
|
||||
if (this->access[i]->Matches(u, nc))
|
||||
@@ -237,6 +238,7 @@ AccessGroup ChannelInfo::AccessFor(NickCore *nc)
|
||||
|
||||
group.Founder = (this->founder && this->founder == nc);
|
||||
group.ci = this;
|
||||
group.nc = nc;
|
||||
|
||||
for (unsigned i = 0, end = this->access.size(); i < end; ++i)
|
||||
if (this->access[i]->Matches(NULL, nc))
|
||||
|
||||
Reference in New Issue
Block a user