diff --git a/doc/readme.who b/doc/readme.who index f0b5c4d3..4111df99 100644 --- a/doc/readme.who +++ b/doc/readme.who @@ -84,6 +84,11 @@ in which: means that the query is almost certainly logged and the admin might (rightfully) ask you an explanation on why you did. + e If this is specified, operators see the real username and real + hostname in the user and host output fields instead of the visible + forms. Non-operators specifying e are ignored. As with 'x', the + query is logged. + The rest, what follows the %, that is [%[fields[,]]], is as it has always been since the first who.patch, the part specifies wich fields to include in the output as: diff --git a/include/whocmds.h b/include/whocmds.h index 357a1752..5dd254fa 100644 --- a/include/whocmds.h +++ b/include/whocmds.h @@ -24,6 +24,7 @@ struct Channel; #define WHOSELECT_OPER 1 /**< Flag for /WHO: Show IRC operators. */ #define WHOSELECT_EXTRA 2 /**< Flag for /WHO: Pull rank to see users. */ #define WHOSELECT_DELAY 4 /**< Flag for /WHO: Show join-delayed users. */ +#define WHOSELECT_REAL 8 /**< Flag for /WHO: Show real username and host. */ #define WHO_FIELD_QTY 1 /**< Display query type. */ #define WHO_FIELD_CHA 2 /**< Show common channel name. */ @@ -87,6 +88,6 @@ struct Channel; * Prototypes */ extern void do_who(struct Client* sptr, struct Client* acptr, struct Channel* repchan, - int fields, char* qrt); + int fields, char* qrt, int bitsel); #endif /* INCLUDED_whocmds_h */ diff --git a/ircd/m_who.c b/ircd/m_who.c index 175dd978..e7bae17b 100644 --- a/ircd/m_who.c +++ b/ircd/m_who.c @@ -132,6 +132,7 @@ static void move_marker(void) * and %flags to specify what fields to output * plus a ,querytype if the t flag is specified * so the final thing will be like o%tnchu,777 + * Special flags before %: o, d, x, e (e = exact/real user@host) * parv[3] = _optional_ parameter that overrides parv[1] * This can be used as "/quote who foo % :The Black Hacker * to find me, parv[3] _can_ contain spaces !. @@ -191,6 +192,15 @@ int m_who(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) (BadPtr(parv[3]) ? parv[1] : parv[3]), parv[2]); } continue; + case 'e': + case 'E': + /* Show exact/real username and host (opers only). */ + if (IsAnOper(sptr)) { + bitsel |= WHOSELECT_REAL; + log_write(LS_WHO, L_INFO, LOG_NOSNOTICE, "%#C WHO %s %s", sptr, + (BadPtr(parv[3]) ? parv[1] : parv[3]), parv[2]); + } + continue; case 'n': case 'N': matchsel |= WHO_FIELD_NIC; @@ -344,7 +354,7 @@ int m_who(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) continue; if (!(isthere || (SHOW_MORE(sptr, counter)))) break; - do_who(sptr, acptr, chptr, fields, qrt); + do_who(sptr, acptr, chptr, fields, qrt, bitsel); } } } @@ -354,7 +364,7 @@ int m_who(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) ((!(bitsel & WHOSELECT_OPER)) || SeeOper(sptr,acptr)) && Process(acptr) && SHOW_MORE(sptr, counter)) { - do_who(sptr, acptr, 0, fields, qrt); + do_who(sptr, acptr, 0, fields, qrt, bitsel); } } } @@ -428,7 +438,7 @@ int m_who(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) continue; if (!SHOW_MORE(sptr, counter)) break; - do_who(sptr, acptr, chptr, fields, qrt); + do_who(sptr, acptr, chptr, fields, qrt, bitsel); } } } @@ -470,7 +480,7 @@ int m_who(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) continue; if (!SHOW_MORE(sptr, counter)) break; - do_who(sptr, acptr, 0, fields, qrt); + do_who(sptr, acptr, 0, fields, qrt, bitsel); } } diff --git a/ircd/whocmds.c b/ircd/whocmds.c index 883e9a7d..bacc78ba 100644 --- a/ircd/whocmds.c +++ b/ircd/whocmds.c @@ -67,9 +67,10 @@ * @param[in] repchan Shared channel that provides visibility. * @param[in] fields Bitmask of WHO_FIELD_* values, indicating what to show. * @param[in] qrt Query type string (ignored unless \a fields & WHO_FIELD_QTY). + * @param[in] bitsel Bitmask of WHOSELECT_* values (e.g. WHOSELECT_REAL). */ void do_who(struct Client* sptr, struct Client* acptr, struct Channel* repchan, - int fields, char* qrt) + int fields, char* qrt, int bitsel) { char *p1; struct Membership *chan = 0; @@ -122,7 +123,8 @@ void do_who(struct Client* sptr, struct Client* acptr, struct Channel* repchan, if (!fields || (fields & WHO_FIELD_UID)) { - const char *p2 = visible_username(acptr); + const char *p2 = (bitsel & WHOSELECT_REAL) ? + cli_user(acptr)->username : visible_username(acptr); *(p1++) = ' '; while ((*p2) && (*(p1++) = *(p2++))); } @@ -138,7 +140,8 @@ void do_who(struct Client* sptr, struct Client* acptr, struct Channel* repchan, if (!fields || (fields & WHO_FIELD_HOS)) { - char *p2 = cli_user(acptr)->host; + char *p2 = (bitsel & WHOSELECT_REAL) ? + cli_user(acptr)->realhost : cli_user(acptr)->host; *(p1++) = ' '; while ((*p2) && (*(p1++) = *(p2++))); }