]> jfr.im git - solanum.git/blobdiff - extensions/override.c
callerid: actually the guard should be for source_p
[solanum.git] / extensions / override.c
index 4df177a0723c1034bbf789860b25f84311685172..91b3d6eb38e9e2c5fdafbabff6cff031823922b9 100644 (file)
@@ -34,10 +34,10 @@ static void handle_client_exit(void *data);
 
 mapi_hfn_list_av1 override_hfnlist[] = {
        { "umode_changed", (hookfn) check_umode_change },
-       { "get_channel_access", (hookfn) hack_channel_access },
-       { "can_join", (hookfn) hack_can_join },
-       { "can_kick", (hookfn) hack_can_kick },
-       { "can_send", (hookfn) hack_can_send },
+       { "get_channel_access", (hookfn) hack_channel_access, HOOK_HIGHEST },
+       { "can_join", (hookfn) hack_can_join, HOOK_HIGHEST },
+       { "can_kick", (hookfn) hack_can_kick, HOOK_HIGHEST },
+       { "can_send", (hookfn) hack_can_send, HOOK_HIGHEST },
        { "client_exit", (hookfn) handle_client_exit },
        { NULL, NULL }
 };
@@ -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,12 @@ 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);
+               }
        }
-       else if (!(source_p->umodes & user_modes['p']))
+       else if (changed && !(source_p->umodes & user_modes['p']))
        {
                rb_dlink_node *n, *tn;
 
@@ -145,9 +144,6 @@ check_umode_change(void *vdata)
                        if (session_p->client != source_p)
                                continue;
 
-                       sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s has disabled oper-override (+p)",
-                                              get_oper_name(session_p->client));
-
                        rb_dlinkDelete(n, &overriding_opers);
                        rb_free(session_p);
                }
@@ -201,33 +197,6 @@ hack_can_kick(void *vdata)
        hook_data_channel_approval *data = (hook_data_channel_approval *) vdata;
        int alevel;
 
-       if (data->target->umodes & user_modes['p'])
-       {
-               if (data->client->umodes & user_modes['p'])
-               {
-                       /* Using oper-override to kick an oper
-                        * who's also using oper-override, better
-                        * report what happened.
-                        */
-                       update_session_deadline(data->client, NULL);
-                       sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s is using oper-override on %s (KICK %s)",
-                                              get_oper_name(data->client), data->chptr->chname, data->target->name);
-               }
-               else
-               {
-                       /* Like cmode +M, let's report any attempt
-                        * to kick the immune oper.
-                        */
-                       update_session_deadline(data->target, NULL);
-                       sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s attempted to kick %s from %s (who is +p)",
-                               data->client->name, data->target->name, data->chptr->chname);
-                       sendto_one_numeric(data->client, ERR_ISCHANSERVICE, "%s %s :Cannot kick immune IRC operators.",
-                               data->target->name, data->chptr->chname);
-                       data->approved = 0;
-               }
-               return;
-       }
-
        alevel = get_channel_access(data->client, data->chptr, data->msptr, data->dir, NULL);
        if (alevel != CHFL_OVERRIDE)
                return;