]> jfr.im git - solanum.git/blobdiff - modules/m_whois.c
Add general::tls_ciphers_oper_only
[solanum.git] / modules / m_whois.c
index 5f7b42d134fee751196c9e46eceb8feb023226b7..796d3084d0228df8907105b4c3a316281e842267 100644 (file)
@@ -40,7 +40,6 @@
 #include "modules.h"
 #include "hook.h"
 #include "s_newconf.h"
-#include "ipv4_from_ipv6.h"
 #include "ratelimit.h"
 #include "s_assert.h"
 
@@ -234,9 +233,7 @@ single_whois(struct Client *source_p, struct Client *target_p, int operspy)
        int tlen;
        hook_data_client hdata;
        int extra_space = 0;
-#ifdef RB_IPV6
        struct sockaddr_in ip4;
-#endif
 
        if(target_p->user == NULL)
        {
@@ -312,7 +309,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) && (!ConfigFileEntry.hide_opers_in_whois || IsOper(source_p)))
+       if((!ConfigFileEntry.hide_opers_in_whois || IsOper(source_p)) && SeesOper(target_p, source_p))
        {
                sendto_one_numeric(source_p, RPL_WHOISOPERATOR, form_str(RPL_WHOISOPERATOR),
                                   target_p->name,
@@ -321,11 +318,14 @@ 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))
+       if(!EmptyString(target_p->user->opername) && IsOper(target_p) && IsOper(source_p))
        {
                char buf[512];
+               const char *privset = "(missing)";
+               if (target_p->user->privset != NULL)
+                       privset = target_p->user->privset->name;
                snprintf(buf, sizeof(buf), "is opered as %s, privset %s",
-                           target_p->localClient->opername, target_p->localClient->privset->name);
+                           target_p->user->opername, privset);
                sendto_one_numeric(source_p, RPL_WHOISSPECIAL, form_str(RPL_WHOISSPECIAL),
                                   target_p->name, buf);
        }
@@ -334,7 +334,8 @@ single_whois(struct Client *source_p, struct Client *target_p, int operspy)
        {
                char cbuf[256] = "is using a secure connection";
 
-               if (MyClient(target_p) && target_p->localClient->cipher_string != NULL)
+               if (MyClient(target_p) && target_p->localClient->cipher_string != NULL &&
+                               (!ConfigFileEntry.tls_ciphers_oper_only || source_p == target_p || IsOper(source_p)))
                        rb_snprintf_append(cbuf, sizeof(cbuf), " [%s]", target_p->localClient->cipher_string);
 
                sendto_one_numeric(source_p, RPL_WHOISSECURE, form_str(RPL_WHOISSECURE),
@@ -365,11 +366,10 @@ single_whois(struct Client *source_p, struct Client *target_p, int operspy)
                                           form_str(RPL_WHOISACTUALLY),
                                           target_p->name, target_p->sockhost);
 
-#ifdef RB_IPV6
                if (GET_SS_FAMILY(&target_p->localClient->ip) == AF_INET6 &&
                                (show_ip(source_p, target_p) ||
                                 (source_p == target_p && !IsIPSpoof(target_p))) &&
-                               ipv4_from_ipv6((struct sockaddr_in6 *)&target_p->localClient->ip, &ip4))
+                               rb_ipv4_from_ipv6((struct sockaddr_in6 *)&target_p->localClient->ip, &ip4))
                {
                        rb_inet_ntop_sock((struct sockaddr *)&ip4,
                                        buf, sizeof buf);
@@ -377,7 +377,6 @@ single_whois(struct Client *source_p, struct Client *target_p, int operspy)
                                        "%s :Underlying IPv4 is %s",
                                        target_p->name, buf);
                }
-#endif /* RB_IPV6 */
 
                sendto_one_numeric(source_p, RPL_WHOISIDLE, form_str(RPL_WHOISIDLE),
                                   target_p->name,