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
This commit is contained in:
Ed Kellett 2021-04-11 23:25:49 +01:00
parent eeaea74616
commit 96f6804b24

View file

@ -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), sendto_one_numeric(source_p, RPL_AWAY, form_str(RPL_AWAY),
target_p->name, target_p->user->away); target_p->name, target_p->user->away);
if((!ConfigFileEntry.hide_opers_in_whois || IsOper(source_p)) && SeesOper(target_p, source_p)) if (!EmptyString(target_p->user->opername) && IsOper(target_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")))
{ {
char buf[512]; char buf[512];
const char *privset = "(missing)"; char *s = NULL;
if (target_p->user->privset != NULL) if (target_p == source_p || HasPrivilege(source_p, "oper:privs"))
privset = target_p->user->privset->name; {
snprintf(buf, sizeof(buf), "is opered as %s, privset %s", const char *privset = "(missing)";
target_p->user->opername, privset); if (target_p->user->privset != NULL)
sendto_one_numeric(source_p, RPL_WHOISSPECIAL, form_str(RPL_WHOISSPECIAL), privset = target_p->user->privset->name;
target_p->name, buf); 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)) if(IsSecureClient(target_p))