chanroles: instead of checking for chanop + CHANROLE_UNSET combination, grant a default set of flags.

this allows ops with zero effective privilege.
This commit is contained in:
William Pitcock 2011-07-06 15:12:46 -05:00
parent 460b6d9fb2
commit f3bfe2c271
2 changed files with 8 additions and 12 deletions

View file

@ -196,6 +196,7 @@ typedef int (*ExtbanFunc)(const char *data, struct Client *client_p,
#define CHANROLE_GRANT 0x008 /* Can grant (unused atm) */
#define CHANROLE_MODE 0x010 /* Can change modes */
#define CHANROLE_TOPIC 0x020 /* Can change topic */
#define CHANROLE_INHERIT 0x040 /* Role is inherited (backwards compat) */
#define CHANROLE_INITIAL (CHANROLE_KICK | CHANROLE_STATUS | CHANROLE_GRANT | CHANROLE_MODE | CHANROLE_TOPIC)

View file

@ -202,24 +202,12 @@ get_channel_access(struct Client *source_p, struct membership *msptr, int role)
moduledata.msptr = msptr;
moduledata.target = NULL;
if (is_chanop(msptr))
{
/* Their chanrole is unset by GRANT, for backwards compat let them pass */
if(HasChanRole(msptr, CHANROLE_UNSET))
{
moduledata.approved = CHFL_CHANOP;
goto finish_access;
}
}
/* Check if they have the proper role */
if(HasChanRole(msptr, role))
moduledata.approved = CHFL_CHANOP;
else
moduledata.approved = CHFL_PEON;
finish_access:
call_hook(h_get_channel_access, &moduledata);
return moduledata.approved;
@ -915,6 +903,11 @@ chm_op(struct Client *source_p, struct Channel *chptr,
mode_changes[mode_count++].client = targ_p;
mstptr->flags |= CHFL_CHANOP;
if (msptr->roles & CHANROLE_UNSET)
{
mstptr->roles &= ~CHANROLE_UNSET;
mstptr->roles = CHANROLE_INITIAL | CHANROLE_INHERIT;
}
}
else
{
@ -935,6 +928,8 @@ chm_op(struct Client *source_p, struct Channel *chptr,
mode_changes[mode_count++].client = targ_p;
mstptr->flags &= ~CHFL_CHANOP;
if (mstptr->roles & CHANROLE_INHERIT)
mstptr->roles = CHANROLE_UNSET;
}
}