From 96f6804b2413f9c1824f6e6f2f80fc32360a63fe Mon Sep 17 00:00:00 2001 From: Ed Kellett Date: Sun, 11 Apr 2021 23:25:49 +0100 Subject: [PATCH] m_whois: put opername/privset in RPL_WHOISOPERATOR Show just the opername if you're an oper the target is not hidden from and you don't have oper:privs. close #100 --- modules/m_whois.c | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/modules/m_whois.c b/modules/m_whois.c index ced0c44a..d6265886 100644 --- a/modules/m_whois.c +++ b/modules/m_whois.c @@ -293,25 +293,32 @@ 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((!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, - IsService(target_p) ? ConfigFileEntry.servicestring : - (IsAdmin(target_p) ? GlobalSetOptions.adminstring : - GlobalSetOptions.operstring)); - } - - if(!EmptyString(target_p->user->opername) && IsOper(target_p) && (target_p == source_p || HasPrivilege(source_p, "oper:privs"))) + if (!EmptyString(target_p->user->opername) && IsOper(target_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->user->opername, privset); - sendto_one_numeric(source_p, RPL_WHOISSPECIAL, form_str(RPL_WHOISSPECIAL), - target_p->name, buf); + char *s = NULL; + if (target_p == source_p || HasPrivilege(source_p, "oper:privs")) + { + 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->user->opername, privset); + s = buf; + } + else if (IsOper(source_p) && SeesOper(target_p, source_p)) + { + snprintf(buf, sizeof buf, "is opered as %s", target_p->user->opername); + s = buf; + } + else if (!ConfigFileEntry.hide_opers_in_whois && SeesOper(target_p, source_p)) + { + s = IsService(target_p) ? ConfigFileEntry.servicestring : + IsAdmin(target_p) ? GlobalSetOptions.adminstring : + GlobalSetOptions.operstring; + } + if (s != NULL) + sendto_one_numeric(source_p, RPL_WHOISOPERATOR, form_str(RPL_WHOISOPERATOR), + target_p->name, s); } if(IsSecureClient(target_p))