]> jfr.im git - solanum.git/blobdiff - modules/m_whois.c
LIST: plug memory leak
[solanum.git] / modules / m_whois.c
index a5515ed0934619eae193d6a0115b85b182ad2165..aadb0e28d66a2ffd6ce35d347722c98b664ffdd2 100644 (file)
@@ -60,11 +60,13 @@ struct Message whois_msgtab = {
 
 int doing_whois_hook;
 int doing_whois_global_hook;
+int doing_whois_channel_visibility_hook;
 
 mapi_clist_av1 whois_clist[] = { &whois_msgtab, NULL };
 mapi_hlist_av1 whois_hlist[] = {
-       { "doing_whois",        &doing_whois_hook },
-       { "doing_whois_global", &doing_whois_global_hook },
+       { "doing_whois",                        &doing_whois_hook },
+       { "doing_whois_global",                 &doing_whois_global_hook },
+       { "doing_whois_channel_visibility",     &doing_whois_channel_visibility_hook },
        { NULL, NULL }
 };
 
@@ -236,7 +238,6 @@ single_whois(struct Client *source_p, struct Client *target_p, int operspy)
        char *t;
        int tlen;
        hook_data_client hdata;
-       int visible;
        int extra_space = 0;
 #ifdef RB_IPV6
        struct sockaddr_in ip4;
@@ -271,6 +272,9 @@ single_whois(struct Client *source_p, struct Client *target_p, int operspy)
 
        t = buf + mlen;
 
+       hdata.client = source_p;
+       hdata.target = target_p;
+
        if (!IsService(target_p))
        {
                RB_DLINK_FOREACH(ptr, target_p->user->channel.head)
@@ -278,9 +282,12 @@ single_whois(struct Client *source_p, struct Client *target_p, int operspy)
                        msptr = ptr->data;
                        chptr = msptr->chptr;
 
-                       visible = ShowChannel(source_p, chptr);
+                       hdata.chptr = chptr;
+
+                       hdata.approved = ShowChannel(source_p, chptr);
+                       call_hook(doing_whois_channel_visibility_hook, &hdata);
 
-                       if(visible || operspy)
+                       if(hdata.approved || operspy)
                        {
                                if((cur_len + strlen(chptr->chname) + 3) > (BUFSIZE - 5))
                                {
@@ -290,7 +297,7 @@ single_whois(struct Client *source_p, struct Client *target_p, int operspy)
                                }
 
                                tlen = rb_sprintf(t, "%s%s%s ",
-                                               visible ? "" : "!",
+                                               hdata.approved ? "" : "!",
                                                find_channel_status(msptr, 1),
                                                chptr->chname);
                                t += tlen;
@@ -310,7 +317,7 @@ single_whois(struct Client *source_p, struct Client *target_p, int operspy)
                sendto_one_numeric(source_p, RPL_AWAY, form_str(RPL_AWAY),
                                   target_p->name, target_p->user->away);
 
-       if(IsOper(target_p))
+       if(IsOper(target_p) && (!ConfigFileEntry.hide_opers_in_whois || IsOper(source_p)))
        {
                sendto_one_numeric(source_p, RPL_WHOISOPERATOR, form_str(RPL_WHOISOPERATOR),
                                   target_p->name,
@@ -319,14 +326,30 @@ single_whois(struct Client *source_p, struct Client *target_p, int operspy)
                                    GlobalSetOptions.operstring));
        }
 
+       if(MyClient(target_p) && !EmptyString(target_p->localClient->opername) && IsOper(source_p))
+       {
+               char buf[512];
+               rb_snprintf(buf, sizeof(buf), "is opered as %s, privset %s",
+                           target_p->localClient->opername, target_p->localClient->privset->name);
+               sendto_one_numeric(source_p, RPL_WHOISSPECIAL, form_str(RPL_WHOISSPECIAL),
+                                  target_p->name, buf);
+       }
+
        if(IsSSLClient(target_p))
+       {
+               char cbuf[256] = "is using a secure connection";
+
+               if (MyClient(target_p) && target_p->localClient->cipher_string != NULL)
+                       rb_snprintf_append(cbuf, sizeof(cbuf), " [%s]", target_p->localClient->cipher_string);
+
                sendto_one_numeric(source_p, RPL_WHOISSECURE, form_str(RPL_WHOISSECURE),
-                                  target_p->name);
-       if((source_p == target_p || IsOper(source_p)) &&
-                       target_p->certfp != NULL)
-               sendto_one_numeric(source_p, RPL_WHOISCERTFP,
-                               form_str(RPL_WHOISCERTFP),
-                               target_p->name, target_p->certfp);
+                                  target_p->name, cbuf);
+               if((source_p == target_p || IsOper(source_p)) &&
+                               target_p->certfp != NULL)
+                       sendto_one_numeric(source_p, RPL_WHOISCERTFP,
+                                       form_str(RPL_WHOISCERTFP),
+                                       target_p->name, target_p->certfp);
+       }
 
        if(MyClient(target_p))
        {
@@ -387,9 +410,6 @@ single_whois(struct Client *source_p, struct Client *target_p, int operspy)
                }
        }
 
-       hdata.client = source_p;
-       hdata.target = target_p;
-
        /* doing_whois_hook must only be called for local clients,
         * doing_whois_global_hook must only be called for local targets
         */