mirror of
https://github.com/anope/anope.git
synced 2026-07-10 00:23:11 +02:00
Fixed suepradmin
This commit is contained in:
@@ -78,6 +78,7 @@ class CoreExport ChanAccess
|
||||
class AccessGroup : public std::vector<ChanAccess *>
|
||||
{
|
||||
public:
|
||||
bool SuperAdmin;
|
||||
AccessGroup();
|
||||
bool HasPriv(ChannelAccess priv) const;
|
||||
ChanAccess *Highest() const;
|
||||
|
||||
+8
-1
@@ -741,6 +741,13 @@ class CoreExport Module : public Extensible
|
||||
*/
|
||||
virtual void OnFindChan(const Anope::string &chname) { }
|
||||
|
||||
/** Checks if access has the channel privilege 'priv'.
|
||||
* @param access THe access struct
|
||||
* @param priv The privilege being checked for
|
||||
* @return EVENT_ALLOW for yes, EVENT_STOP to stop all processing
|
||||
*/
|
||||
virtual EventReturn OnCheckPriv(ChanAccess *access, ChannelAccess priv) { return EVENT_CONTINUE; }
|
||||
|
||||
/** Called when a nick is dropped
|
||||
* @param u The user dropping the nick
|
||||
* @param na The nick
|
||||
@@ -1025,7 +1032,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_OnDelChan, I_OnChannelCreate,
|
||||
I_OnChannelDelete, I_OnAkickAdd, I_OnAkickDel, I_OnCheckKick,
|
||||
I_OnChanInfo, I_OnFindChan,
|
||||
I_OnChanInfo, I_OnFindChan, I_OnCheckPriv,
|
||||
|
||||
/* BotServ */
|
||||
I_OnBotJoin, I_OnBotKick, I_OnBotCreate, I_OnBotChange, I_OnBotDelete, I_OnBotAssign, I_OnBotUnAssign,
|
||||
|
||||
+1
-2
@@ -54,8 +54,7 @@ class CoreExport User : public Extensible
|
||||
Server *server; /* Server user is connected to */
|
||||
time_t timestamp; /* Timestamp of the nick */
|
||||
time_t my_signon; /* When did _we_ see the user? */
|
||||
|
||||
int isSuperAdmin; /* is SuperAdmin on or off? */
|
||||
bool SuperAdmin; /* is SuperAdmin on or off? */
|
||||
|
||||
/* Channels the user is in */
|
||||
UChannelList chans;
|
||||
|
||||
@@ -42,7 +42,7 @@ class CommandNSLogout : public Command
|
||||
if (!nick.empty() && !param.empty() && param.equals_ci("REVALIDATE") && nickserv)
|
||||
nickserv->Validate(u2);
|
||||
|
||||
u2->isSuperAdmin = 0; /* Dont let people logout and remain a SuperAdmin */
|
||||
u2->SuperAdmin = 0; /* Dont let people logout and remain a SuperAdmin */
|
||||
Log(LOG_COMMAND, u, this) << "to logout " << u2->nick;
|
||||
|
||||
/* Remove founder status from this user in all channels */
|
||||
|
||||
@@ -81,14 +81,14 @@ class CommandOSSet : public Command
|
||||
source.Reply(_("SuperAdmin setting not enabled in services.conf"));
|
||||
else if (setting.equals_ci("ON"))
|
||||
{
|
||||
u->isSuperAdmin = 1;
|
||||
u->SuperAdmin = true;
|
||||
source.Reply(_("You are now a SuperAdmin"));
|
||||
Log(LOG_ADMIN, u, this) << "SUPERADMIN ON";
|
||||
ircdproto->SendGlobops(source.owner, _("%s is now a Super-Admin"), u->nick.c_str());
|
||||
}
|
||||
else if (setting.equals_ci("OFF"))
|
||||
{
|
||||
u->isSuperAdmin = 0;
|
||||
u->SuperAdmin = false;
|
||||
source.Reply(_("You are no longer a SuperAdmin"));
|
||||
Log(LOG_ADMIN, u, this) << "SUPERADMIN OFF";
|
||||
ircdproto->SendGlobops(source.owner, _("%s is no longer a Super-Admin"), u->nick.c_str());
|
||||
|
||||
+9
-1
@@ -75,13 +75,21 @@ bool ChanAccess::operator<=(ChanAccess &other)
|
||||
|
||||
AccessGroup::AccessGroup() : std::vector<ChanAccess *>()
|
||||
{
|
||||
this->SuperAdmin = false;
|
||||
}
|
||||
|
||||
bool AccessGroup::HasPriv(ChannelAccess priv) const
|
||||
{
|
||||
if (this->SuperAdmin)
|
||||
return true;
|
||||
for (unsigned i = this->size(); i > 0; --i)
|
||||
if (this->at(i - 1)->HasPriv(priv))
|
||||
{
|
||||
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;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -124,7 +124,7 @@ bool IsFounder(User *user, ChannelInfo *ci)
|
||||
if (!user || !ci)
|
||||
return false;
|
||||
|
||||
if (user->isSuperAdmin)
|
||||
if (user->SuperAdmin)
|
||||
return true;
|
||||
|
||||
if (user->Account() && user->Account() == ci->GetFounder())
|
||||
|
||||
+6
-1
@@ -215,6 +215,9 @@ bool ChannelInfo::HasPriv(User *u, ChannelAccess priv)
|
||||
{
|
||||
AccessGroup group = this->AccessFor(u);
|
||||
|
||||
if (u->SuperAdmin)
|
||||
return true;
|
||||
|
||||
if (this->founder && u->Account() == this->founder)
|
||||
{
|
||||
switch (priv)
|
||||
@@ -257,6 +260,8 @@ AccessGroup ChannelInfo::AccessFor(User *u)
|
||||
if (this->access[i]->Matches(u, nc))
|
||||
group.push_back(this->access[i]);
|
||||
|
||||
group.SuperAdmin = u->SuperAdmin;
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
@@ -707,7 +712,7 @@ bool ChannelInfo::CheckKick(User *user)
|
||||
if (!user || !this->c)
|
||||
return false;
|
||||
|
||||
if (user->isSuperAdmin)
|
||||
if (user->SuperAdmin)
|
||||
return false;
|
||||
|
||||
/* We don't enforce services restrictions on clients on ulined services
|
||||
|
||||
+2
-2
@@ -40,7 +40,7 @@ User::User(const Anope::string &snick, const Anope::string &sident, const Anope:
|
||||
this->ident = sident;
|
||||
this->host = shost;
|
||||
this->uid = suid;
|
||||
this->isSuperAdmin = 0;
|
||||
this->SuperAdmin = false;
|
||||
|
||||
UserListByNick[snick] = this;
|
||||
if (!suid.empty())
|
||||
@@ -815,7 +815,7 @@ User *do_nick(const Anope::string &source, const Anope::string &nick, const Anop
|
||||
Log() << "user: NICK from nonexistent nick " << source;
|
||||
return NULL;
|
||||
}
|
||||
user->isSuperAdmin = 0; /* Dont let people nick change and stay SuperAdmins */
|
||||
user->SuperAdmin = false;
|
||||
|
||||
Log(user, "nick") << "(" << user->realname << ") changed nick to " << nick;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user