Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/readme.who
Original file line number Diff line number Diff line change
Expand Up @@ -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[,<querytype>]]], is as it
has always been since the first who.patch, the <fields> part specifies
wich fields to include in the output as:
Expand Down
3 changes: 2 additions & 1 deletion include/whocmds.h
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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 */
18 changes: 14 additions & 4 deletions ircd/m_who.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 !.
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
}
Expand All @@ -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);
}
}
}
Expand Down Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -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);
}
}

Expand Down
9 changes: 6 additions & 3 deletions ircd/whocmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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++)));
}
Expand All @@ -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++)));
}
Expand Down
Loading