diff --git a/extensions/override.c b/extensions/override.c index 46e8faa4..2d86f738 100644 --- a/extensions/override.c +++ b/extensions/override.c @@ -108,6 +108,7 @@ static void check_umode_change(void *vdata) { hook_data_umode_changed *data = (hook_data_umode_changed *)vdata; + bool changed = false; struct Client *source_p = data->client; if (!MyClient(source_p)) @@ -116,9 +117,7 @@ check_umode_change(void *vdata) if (data->oldumodes & UMODE_OPER && !IsOper(source_p)) source_p->umodes &= ~user_modes['p']; - /* didn't change +p umode, we don't need to do anything */ - if (!((data->oldumodes ^ source_p->umodes) & user_modes['p'])) - return; + changed = ((data->oldumodes ^ source_p->umodes) & user_modes['p']); if (source_p->umodes & user_modes['p']) { @@ -129,12 +128,14 @@ check_umode_change(void *vdata) return; } - update_session_deadline(source_p, NULL); - - sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s has enabled oper-override (+p)", - get_oper_name(source_p)); + if (changed) + { + update_session_deadline(source_p, NULL); + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s has enabled oper-override (+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; @@ -261,10 +262,19 @@ struct ev_entry *expire_override_deadlines_ev = NULL; static int _modinit(void) { + rb_dlink_node *ptr; + /* add the usermode to the available slot */ user_modes['p'] = find_umode_slot(); 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); return 0; @@ -273,10 +283,18 @@ _modinit(void) static void _moddeinit(void) { + rb_dlink_node *n, *tn; + /* disable the umode and remove it from the available list */ user_modes['p'] = 0; 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); }