diff options
-rw-r--r-- | include/access.h | 1 | ||||
-rw-r--r-- | include/bots.h | 3 | ||||
-rw-r--r-- | include/language.h | 1 | ||||
-rw-r--r-- | include/modules.h | 9 | ||||
-rw-r--r-- | modules/commands/cs_access.cpp | 21 | ||||
-rw-r--r-- | modules/commands/cs_info.cpp | 2 | ||||
-rw-r--r-- | modules/commands/ns_info.cpp | 2 | ||||
-rw-r--r-- | src/access.cpp | 6 | ||||
-rw-r--r-- | src/bots.cpp | 2 | ||||
-rw-r--r-- | src/regchannel.cpp | 2 |
10 files changed, 38 insertions, 11 deletions
diff --git a/include/access.h b/include/access.h index c1692960d..fd2b60356 100644 --- a/include/access.h +++ b/include/access.h @@ -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; diff --git a/include/bots.h b/include/bots.h index 399ba3ea1..f5b4c528a 100644 --- a/include/bots.h +++ b/include/bots.h @@ -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. */ diff --git a/include/language.h b/include/language.h index 6c31daa4c..20bd36a77 100644 --- a/include/language.h +++ b/include/language.h @@ -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" \ diff --git a/include/modules.h b/include/modules.h index 2592b5622..e16b8150b 100644 --- a/include/modules.h +++ b/include/modules.h @@ -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, diff --git a/modules/commands/cs_access.cpp b/modules/commands/cs_access.cpp index a8e90aadd..7ec65328a 100644 --- a/modules/commands/cs_access.cpp +++ b/modules/commands/cs_access.cpp @@ -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) diff --git a/modules/commands/cs_info.cpp b/modules/commands/cs_info.cpp index 9f4a29852..5cc100c78 100644 --- a/modules/commands/cs_info.cpp +++ b/modules/commands/cs_info.cpp @@ -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)) diff --git a/modules/commands/ns_info.cpp b/modules/commands/ns_info.cpp index 15dc22546..e40f80f77 100644 --- a/modules/commands/ns_info.cpp +++ b/modules/commands/ns_info.cpp @@ -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)) { diff --git a/src/access.cpp b/src/access.cpp index 3559a8209..3c1eb8714 100644 --- a/src/access.cpp +++ b/src/access.cpp @@ -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; diff --git a/src/bots.cpp b/src/bots.cpp index 3e9af64d5..b794610e6 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -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; diff --git a/src/regchannel.cpp b/src/regchannel.cpp index 9bf3122c4..e57f555ac 100644 --- a/src/regchannel.cpp +++ b/src/regchannel.cpp @@ -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)) |