Add override support to ban/quiet, owner, op, halfop and voice.
This commit is contained in:
parent
c6fa55060c
commit
4ed822ed95
66
src/chmode.c
66
src/chmode.c
|
@ -64,6 +64,7 @@ static int mode_count;
|
||||||
static int mode_limit;
|
static int mode_limit;
|
||||||
static int mode_limit_simple;
|
static int mode_limit_simple;
|
||||||
static int mask_pos;
|
static int mask_pos;
|
||||||
|
static int no_override_deop;
|
||||||
|
|
||||||
char cflagsbuf[256];
|
char cflagsbuf[256];
|
||||||
char cflagsmyinfo[256];
|
char cflagsmyinfo[256];
|
||||||
|
@ -621,6 +622,7 @@ chm_staff(struct Client *source_p, struct Channel *chptr,
|
||||||
mode_changes[mode_count].nocaps = 0;
|
mode_changes[mode_count].nocaps = 0;
|
||||||
mode_changes[mode_count].id = NULL;
|
mode_changes[mode_count].id = NULL;
|
||||||
mode_changes[mode_count].mems = ALL_MEMBERS;
|
mode_changes[mode_count].mems = ALL_MEMBERS;
|
||||||
|
mode_changes[mode_count].override = 0;
|
||||||
mode_changes[mode_count++].arg = NULL;
|
mode_changes[mode_count++].arg = NULL;
|
||||||
}
|
}
|
||||||
else if((dir == MODE_DEL) && (chptr->mode.mode & mode_type))
|
else if((dir == MODE_DEL) && (chptr->mode.mode & mode_type))
|
||||||
|
@ -632,6 +634,7 @@ chm_staff(struct Client *source_p, struct Channel *chptr,
|
||||||
mode_changes[mode_count].caps = 0;
|
mode_changes[mode_count].caps = 0;
|
||||||
mode_changes[mode_count].nocaps = 0;
|
mode_changes[mode_count].nocaps = 0;
|
||||||
mode_changes[mode_count].mems = ALL_MEMBERS;
|
mode_changes[mode_count].mems = ALL_MEMBERS;
|
||||||
|
mode_changes[mode_count].override = 0;
|
||||||
mode_changes[mode_count].id = NULL;
|
mode_changes[mode_count].id = NULL;
|
||||||
mode_changes[mode_count++].arg = NULL;
|
mode_changes[mode_count++].arg = NULL;
|
||||||
}
|
}
|
||||||
|
@ -652,6 +655,7 @@ chm_ban(struct Client *source_p, struct Channel *chptr,
|
||||||
int rpl_endlist;
|
int rpl_endlist;
|
||||||
int caps;
|
int caps;
|
||||||
int mems;
|
int mems;
|
||||||
|
int override = 0;
|
||||||
|
|
||||||
switch (mode_type)
|
switch (mode_type)
|
||||||
{
|
{
|
||||||
|
@ -725,12 +729,18 @@ chm_ban(struct Client *source_p, struct Channel *chptr,
|
||||||
if(alevel != CHFL_CHANOP && alevel != CHFL_OWNER && alevel != CHFL_HALFOP && mode_type != CHFL_BAN &&
|
if(alevel != CHFL_CHANOP && alevel != CHFL_OWNER && alevel != CHFL_HALFOP && mode_type != CHFL_BAN &&
|
||||||
mode_type != CHFL_QUIET)
|
mode_type != CHFL_QUIET)
|
||||||
{
|
{
|
||||||
|
if(IsOverride(source_p))
|
||||||
|
override = 1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
if(!(*errors & SM_ERR_NOOPS))
|
if(!(*errors & SM_ERR_NOOPS))
|
||||||
sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
|
sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
|
||||||
me.name, source_p->name, chptr->chname);
|
me.name, source_p->name, chptr->chname);
|
||||||
*errors |= SM_ERR_NOOPS;
|
*errors |= SM_ERR_NOOPS;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RB_DLINK_FOREACH(ptr, list->head)
|
RB_DLINK_FOREACH(ptr, list->head)
|
||||||
{
|
{
|
||||||
|
@ -748,12 +758,18 @@ chm_ban(struct Client *source_p, struct Channel *chptr,
|
||||||
|
|
||||||
if(alevel != CHFL_CHANOP && alevel != CHFL_OWNER && alevel != CHFL_HALFOP)
|
if(alevel != CHFL_CHANOP && alevel != CHFL_OWNER && alevel != CHFL_HALFOP)
|
||||||
{
|
{
|
||||||
|
if(IsOverride(source_p))
|
||||||
|
override = 1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
if(!(*errors & SM_ERR_NOOPS))
|
if(!(*errors & SM_ERR_NOOPS))
|
||||||
sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
|
sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
|
||||||
me.name, source_p->name, chptr->chname);
|
me.name, source_p->name, chptr->chname);
|
||||||
*errors |= SM_ERR_NOOPS;
|
*errors |= SM_ERR_NOOPS;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(MyClient(source_p) && (++mode_limit > MAXMODEPARAMS))
|
if(MyClient(source_p) && (++mode_limit > MAXMODEPARAMS))
|
||||||
return;
|
return;
|
||||||
|
@ -804,6 +820,7 @@ chm_ban(struct Client *source_p, struct Channel *chptr,
|
||||||
mode_changes[mode_count].nocaps = 0;
|
mode_changes[mode_count].nocaps = 0;
|
||||||
mode_changes[mode_count].mems = mems;
|
mode_changes[mode_count].mems = mems;
|
||||||
mode_changes[mode_count].id = NULL;
|
mode_changes[mode_count].id = NULL;
|
||||||
|
mode_changes[mode_count].override = override;
|
||||||
mode_changes[mode_count++].arg = mask;
|
mode_changes[mode_count++].arg = mask;
|
||||||
}
|
}
|
||||||
else if(dir == MODE_DEL)
|
else if(dir == MODE_DEL)
|
||||||
|
@ -821,6 +838,7 @@ chm_ban(struct Client *source_p, struct Channel *chptr,
|
||||||
mode_changes[mode_count].nocaps = 0;
|
mode_changes[mode_count].nocaps = 0;
|
||||||
mode_changes[mode_count].mems = mems;
|
mode_changes[mode_count].mems = mems;
|
||||||
mode_changes[mode_count].id = NULL;
|
mode_changes[mode_count].id = NULL;
|
||||||
|
mode_changes[mode_count].override = override;
|
||||||
mode_changes[mode_count++].arg = mask;
|
mode_changes[mode_count++].arg = mask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -833,6 +851,7 @@ chm_owner(struct Client *source_p, struct Channel *chptr,
|
||||||
struct membership *mstptr;
|
struct membership *mstptr;
|
||||||
const char *ownernick;
|
const char *ownernick;
|
||||||
struct Client *targ_p;
|
struct Client *targ_p;
|
||||||
|
int override = 0;
|
||||||
|
|
||||||
if(!ConfigChannel.use_owner)
|
if(!ConfigChannel.use_owner)
|
||||||
{
|
{
|
||||||
|
@ -845,12 +864,18 @@ chm_owner(struct Client *source_p, struct Channel *chptr,
|
||||||
|
|
||||||
if(alevel != CHFL_OWNER)
|
if(alevel != CHFL_OWNER)
|
||||||
{
|
{
|
||||||
|
if(IsOverride(source_p))
|
||||||
|
override = 1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
if(!(*errors & SM_ERR_NOOPS))
|
if(!(*errors & SM_ERR_NOOPS))
|
||||||
sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
|
sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
|
||||||
me.name, source_p->name, chptr->chname);
|
me.name, source_p->name, chptr->chname);
|
||||||
*errors |= SM_ERR_NOOPS;
|
*errors |= SM_ERR_NOOPS;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if((dir == MODE_QUERY) || (parc <= *parn))
|
if((dir == MODE_QUERY) || (parc <= *parn))
|
||||||
return;
|
return;
|
||||||
|
@ -887,7 +912,11 @@ chm_owner(struct Client *source_p, struct Channel *chptr,
|
||||||
if(dir == MODE_ADD)
|
if(dir == MODE_ADD)
|
||||||
{
|
{
|
||||||
if(targ_p == source_p)
|
if(targ_p == source_p)
|
||||||
|
{
|
||||||
|
no_override_deop = 1;
|
||||||
|
if(!override)
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
mode_changes[mode_count].letter = c;
|
mode_changes[mode_count].letter = c;
|
||||||
mode_changes[mode_count].dir = MODE_ADD;
|
mode_changes[mode_count].dir = MODE_ADD;
|
||||||
|
@ -896,6 +925,7 @@ chm_owner(struct Client *source_p, struct Channel *chptr,
|
||||||
mode_changes[mode_count].mems = ALL_MEMBERS;
|
mode_changes[mode_count].mems = ALL_MEMBERS;
|
||||||
mode_changes[mode_count].id = targ_p->id;
|
mode_changes[mode_count].id = targ_p->id;
|
||||||
mode_changes[mode_count].arg = targ_p->name;
|
mode_changes[mode_count].arg = targ_p->name;
|
||||||
|
mode_changes[mode_count].override = override;
|
||||||
mode_changes[mode_count++].client = targ_p;
|
mode_changes[mode_count++].client = targ_p;
|
||||||
|
|
||||||
mstptr->flags |= CHFL_OWNER;
|
mstptr->flags |= CHFL_OWNER;
|
||||||
|
@ -916,6 +946,7 @@ chm_owner(struct Client *source_p, struct Channel *chptr,
|
||||||
mode_changes[mode_count].mems = ALL_MEMBERS;
|
mode_changes[mode_count].mems = ALL_MEMBERS;
|
||||||
mode_changes[mode_count].id = targ_p->id;
|
mode_changes[mode_count].id = targ_p->id;
|
||||||
mode_changes[mode_count].arg = targ_p->name;
|
mode_changes[mode_count].arg = targ_p->name;
|
||||||
|
mode_changes[mode_count].override = override;
|
||||||
mode_changes[mode_count++].client = targ_p;
|
mode_changes[mode_count++].client = targ_p;
|
||||||
|
|
||||||
mstptr->flags &= ~CHFL_OWNER;
|
mstptr->flags &= ~CHFL_OWNER;
|
||||||
|
@ -930,15 +961,22 @@ chm_op(struct Client *source_p, struct Channel *chptr,
|
||||||
struct membership *mstptr;
|
struct membership *mstptr;
|
||||||
const char *opnick;
|
const char *opnick;
|
||||||
struct Client *targ_p;
|
struct Client *targ_p;
|
||||||
|
int override = 0;
|
||||||
|
|
||||||
if(alevel != CHFL_CHANOP && alevel != CHFL_OWNER)
|
if(alevel != CHFL_CHANOP && alevel != CHFL_OWNER)
|
||||||
{
|
{
|
||||||
|
if(IsOverride(source_p))
|
||||||
|
override = 1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
if(!(*errors & SM_ERR_NOOPS))
|
if(!(*errors & SM_ERR_NOOPS))
|
||||||
sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
|
sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
|
||||||
me.name, source_p->name, chptr->chname);
|
me.name, source_p->name, chptr->chname);
|
||||||
*errors |= SM_ERR_NOOPS;
|
*errors |= SM_ERR_NOOPS;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if((dir == MODE_QUERY) || (parc <= *parn))
|
if((dir == MODE_QUERY) || (parc <= *parn))
|
||||||
return;
|
return;
|
||||||
|
@ -975,7 +1013,11 @@ chm_op(struct Client *source_p, struct Channel *chptr,
|
||||||
if(dir == MODE_ADD)
|
if(dir == MODE_ADD)
|
||||||
{
|
{
|
||||||
if(targ_p == source_p)
|
if(targ_p == source_p)
|
||||||
|
{
|
||||||
|
no_override_deop = 1;
|
||||||
|
if(!override)
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
mode_changes[mode_count].letter = c;
|
mode_changes[mode_count].letter = c;
|
||||||
mode_changes[mode_count].dir = MODE_ADD;
|
mode_changes[mode_count].dir = MODE_ADD;
|
||||||
|
@ -984,6 +1026,7 @@ chm_op(struct Client *source_p, struct Channel *chptr,
|
||||||
mode_changes[mode_count].mems = ALL_MEMBERS;
|
mode_changes[mode_count].mems = ALL_MEMBERS;
|
||||||
mode_changes[mode_count].id = targ_p->id;
|
mode_changes[mode_count].id = targ_p->id;
|
||||||
mode_changes[mode_count].arg = targ_p->name;
|
mode_changes[mode_count].arg = targ_p->name;
|
||||||
|
mode_changes[mode_count].override = override;
|
||||||
mode_changes[mode_count++].client = targ_p;
|
mode_changes[mode_count++].client = targ_p;
|
||||||
|
|
||||||
mstptr->flags |= CHFL_CHANOP;
|
mstptr->flags |= CHFL_CHANOP;
|
||||||
|
@ -1004,6 +1047,7 @@ chm_op(struct Client *source_p, struct Channel *chptr,
|
||||||
mode_changes[mode_count].mems = ALL_MEMBERS;
|
mode_changes[mode_count].mems = ALL_MEMBERS;
|
||||||
mode_changes[mode_count].id = targ_p->id;
|
mode_changes[mode_count].id = targ_p->id;
|
||||||
mode_changes[mode_count].arg = targ_p->name;
|
mode_changes[mode_count].arg = targ_p->name;
|
||||||
|
mode_changes[mode_count].override = override;
|
||||||
mode_changes[mode_count++].client = targ_p;
|
mode_changes[mode_count++].client = targ_p;
|
||||||
|
|
||||||
mstptr->flags &= ~CHFL_CHANOP;
|
mstptr->flags &= ~CHFL_CHANOP;
|
||||||
|
@ -1018,6 +1062,7 @@ chm_halfop(struct Client *source_p, struct Channel *chptr,
|
||||||
struct membership *mstptr;
|
struct membership *mstptr;
|
||||||
const char *halfopnick;
|
const char *halfopnick;
|
||||||
struct Client *targ_p;
|
struct Client *targ_p;
|
||||||
|
int override = 0;
|
||||||
|
|
||||||
if(!ConfigChannel.use_halfop)
|
if(!ConfigChannel.use_halfop)
|
||||||
{
|
{
|
||||||
|
@ -1030,12 +1075,18 @@ chm_halfop(struct Client *source_p, struct Channel *chptr,
|
||||||
|
|
||||||
if(alevel != CHFL_CHANOP && alevel != CHFL_OWNER)
|
if(alevel != CHFL_CHANOP && alevel != CHFL_OWNER)
|
||||||
{
|
{
|
||||||
|
if(IsOverride(source_p))
|
||||||
|
override = 1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
if(!(*errors & SM_ERR_NOOPS))
|
if(!(*errors & SM_ERR_NOOPS))
|
||||||
sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
|
sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
|
||||||
me.name, source_p->name, chptr->chname);
|
me.name, source_p->name, chptr->chname);
|
||||||
*errors |= SM_ERR_NOOPS;
|
*errors |= SM_ERR_NOOPS;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if((dir == MODE_QUERY) || (parc <= *parn))
|
if((dir == MODE_QUERY) || (parc <= *parn))
|
||||||
return;
|
return;
|
||||||
|
@ -1072,7 +1123,11 @@ chm_halfop(struct Client *source_p, struct Channel *chptr,
|
||||||
if(dir == MODE_ADD)
|
if(dir == MODE_ADD)
|
||||||
{
|
{
|
||||||
if(targ_p == source_p)
|
if(targ_p == source_p)
|
||||||
|
{
|
||||||
|
no_override_deop = 1;
|
||||||
|
if(!override)
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
mode_changes[mode_count].letter = c;
|
mode_changes[mode_count].letter = c;
|
||||||
mode_changes[mode_count].dir = MODE_ADD;
|
mode_changes[mode_count].dir = MODE_ADD;
|
||||||
|
@ -1081,6 +1136,7 @@ chm_halfop(struct Client *source_p, struct Channel *chptr,
|
||||||
mode_changes[mode_count].mems = ALL_MEMBERS;
|
mode_changes[mode_count].mems = ALL_MEMBERS;
|
||||||
mode_changes[mode_count].id = targ_p->id;
|
mode_changes[mode_count].id = targ_p->id;
|
||||||
mode_changes[mode_count].arg = targ_p->name;
|
mode_changes[mode_count].arg = targ_p->name;
|
||||||
|
mode_changes[mode_count].override = override;
|
||||||
mode_changes[mode_count++].client = targ_p;
|
mode_changes[mode_count++].client = targ_p;
|
||||||
|
|
||||||
mstptr->flags |= CHFL_HALFOP;
|
mstptr->flags |= CHFL_HALFOP;
|
||||||
|
@ -1101,6 +1157,7 @@ chm_halfop(struct Client *source_p, struct Channel *chptr,
|
||||||
mode_changes[mode_count].mems = ALL_MEMBERS;
|
mode_changes[mode_count].mems = ALL_MEMBERS;
|
||||||
mode_changes[mode_count].id = targ_p->id;
|
mode_changes[mode_count].id = targ_p->id;
|
||||||
mode_changes[mode_count].arg = targ_p->name;
|
mode_changes[mode_count].arg = targ_p->name;
|
||||||
|
mode_changes[mode_count].override = override;
|
||||||
mode_changes[mode_count++].client = targ_p;
|
mode_changes[mode_count++].client = targ_p;
|
||||||
|
|
||||||
mstptr->flags &= ~CHFL_HALFOP;
|
mstptr->flags &= ~CHFL_HALFOP;
|
||||||
|
@ -1115,15 +1172,22 @@ chm_voice(struct Client *source_p, struct Channel *chptr,
|
||||||
struct membership *mstptr;
|
struct membership *mstptr;
|
||||||
const char *opnick;
|
const char *opnick;
|
||||||
struct Client *targ_p;
|
struct Client *targ_p;
|
||||||
|
int override = 0;
|
||||||
|
|
||||||
if(alevel != CHFL_CHANOP && alevel != CHFL_OWNER && alevel != CHFL_HALFOP)
|
if(alevel != CHFL_CHANOP && alevel != CHFL_OWNER && alevel != CHFL_HALFOP)
|
||||||
{
|
{
|
||||||
|
if(IsOverride(source_p))
|
||||||
|
override = 1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
if(!(*errors & SM_ERR_NOOPS))
|
if(!(*errors & SM_ERR_NOOPS))
|
||||||
sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
|
sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
|
||||||
me.name, source_p->name, chptr->chname);
|
me.name, source_p->name, chptr->chname);
|
||||||
*errors |= SM_ERR_NOOPS;
|
*errors |= SM_ERR_NOOPS;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if((dir == MODE_QUERY) || parc <= *parn)
|
if((dir == MODE_QUERY) || parc <= *parn)
|
||||||
return;
|
return;
|
||||||
|
@ -1166,6 +1230,7 @@ chm_voice(struct Client *source_p, struct Channel *chptr,
|
||||||
mode_changes[mode_count].mems = ALL_MEMBERS;
|
mode_changes[mode_count].mems = ALL_MEMBERS;
|
||||||
mode_changes[mode_count].id = targ_p->id;
|
mode_changes[mode_count].id = targ_p->id;
|
||||||
mode_changes[mode_count].arg = targ_p->name;
|
mode_changes[mode_count].arg = targ_p->name;
|
||||||
|
mode_changes[mode_count].override = override;
|
||||||
mode_changes[mode_count++].client = targ_p;
|
mode_changes[mode_count++].client = targ_p;
|
||||||
|
|
||||||
mstptr->flags |= CHFL_VOICE;
|
mstptr->flags |= CHFL_VOICE;
|
||||||
|
@ -1179,6 +1244,7 @@ chm_voice(struct Client *source_p, struct Channel *chptr,
|
||||||
mode_changes[mode_count].mems = ALL_MEMBERS;
|
mode_changes[mode_count].mems = ALL_MEMBERS;
|
||||||
mode_changes[mode_count].id = targ_p->id;
|
mode_changes[mode_count].id = targ_p->id;
|
||||||
mode_changes[mode_count].arg = targ_p->name;
|
mode_changes[mode_count].arg = targ_p->name;
|
||||||
|
mode_changes[mode_count].override = override;
|
||||||
mode_changes[mode_count++].client = targ_p;
|
mode_changes[mode_count++].client = targ_p;
|
||||||
|
|
||||||
mstptr->flags &= ~CHFL_VOICE;
|
mstptr->flags &= ~CHFL_VOICE;
|
||||||
|
|
Loading…
Reference in New Issue