Merge pull request #278 from edk0/override
Fix various bugs in extensions/override
This commit is contained in:
commit
a9118e5b81
1 changed files with 26 additions and 8 deletions
|
@ -108,6 +108,7 @@ static void
|
||||||
check_umode_change(void *vdata)
|
check_umode_change(void *vdata)
|
||||||
{
|
{
|
||||||
hook_data_umode_changed *data = (hook_data_umode_changed *)vdata;
|
hook_data_umode_changed *data = (hook_data_umode_changed *)vdata;
|
||||||
|
bool changed = false;
|
||||||
struct Client *source_p = data->client;
|
struct Client *source_p = data->client;
|
||||||
|
|
||||||
if (!MyClient(source_p))
|
if (!MyClient(source_p))
|
||||||
|
@ -116,9 +117,7 @@ check_umode_change(void *vdata)
|
||||||
if (data->oldumodes & UMODE_OPER && !IsOper(source_p))
|
if (data->oldumodes & UMODE_OPER && !IsOper(source_p))
|
||||||
source_p->umodes &= ~user_modes['p'];
|
source_p->umodes &= ~user_modes['p'];
|
||||||
|
|
||||||
/* didn't change +p umode, we don't need to do anything */
|
changed = ((data->oldumodes ^ source_p->umodes) & user_modes['p']);
|
||||||
if (!((data->oldumodes ^ source_p->umodes) & user_modes['p']))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (source_p->umodes & user_modes['p'])
|
if (source_p->umodes & user_modes['p'])
|
||||||
{
|
{
|
||||||
|
@ -129,12 +128,14 @@ check_umode_change(void *vdata)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (changed)
|
||||||
|
{
|
||||||
update_session_deadline(source_p, NULL);
|
update_session_deadline(source_p, NULL);
|
||||||
|
|
||||||
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s has enabled oper-override (+p)",
|
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s has enabled oper-override (+p)",
|
||||||
get_oper_name(source_p));
|
get_oper_name(source_p));
|
||||||
}
|
}
|
||||||
else if (!(source_p->umodes & user_modes['p']))
|
}
|
||||||
|
else if (changed && !(source_p->umodes & user_modes['p']))
|
||||||
{
|
{
|
||||||
rb_dlink_node *n, *tn;
|
rb_dlink_node *n, *tn;
|
||||||
|
|
||||||
|
@ -261,10 +262,19 @@ struct ev_entry *expire_override_deadlines_ev = NULL;
|
||||||
static int
|
static int
|
||||||
_modinit(void)
|
_modinit(void)
|
||||||
{
|
{
|
||||||
|
rb_dlink_node *ptr;
|
||||||
|
|
||||||
/* add the usermode to the available slot */
|
/* add the usermode to the available slot */
|
||||||
user_modes['p'] = find_umode_slot();
|
user_modes['p'] = find_umode_slot();
|
||||||
construct_umodebuf();
|
construct_umodebuf();
|
||||||
|
|
||||||
|
RB_DLINK_FOREACH(ptr, lclient_list.head)
|
||||||
|
{
|
||||||
|
struct Client *client_p = ptr->data;
|
||||||
|
if (IsPerson(client_p) && (client_p->umodes & user_modes['p']))
|
||||||
|
update_session_deadline(client_p, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
expire_override_deadlines_ev = rb_event_add("expire_override_deadlines", expire_override_deadlines, NULL, 60);
|
expire_override_deadlines_ev = rb_event_add("expire_override_deadlines", expire_override_deadlines, NULL, 60);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -273,10 +283,18 @@ _modinit(void)
|
||||||
static void
|
static void
|
||||||
_moddeinit(void)
|
_moddeinit(void)
|
||||||
{
|
{
|
||||||
|
rb_dlink_node *n, *tn;
|
||||||
|
|
||||||
/* disable the umode and remove it from the available list */
|
/* disable the umode and remove it from the available list */
|
||||||
user_modes['p'] = 0;
|
user_modes['p'] = 0;
|
||||||
construct_umodebuf();
|
construct_umodebuf();
|
||||||
|
|
||||||
|
RB_DLINK_FOREACH_SAFE(n, tn, overriding_opers.head)
|
||||||
|
{
|
||||||
|
rb_dlinkDelete(n, &overriding_opers);
|
||||||
|
rb_free(n->data);
|
||||||
|
}
|
||||||
|
|
||||||
rb_event_delete(expire_override_deadlines_ev);
|
rb_event_delete(expire_override_deadlines_ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue