X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=ircd%2Fm_whois.c;h=01c9db55db3d1d8311a6b89f76bc40ffa79a9930;hb=refs%2Fheads%2Fupstream;hp=51d0354812b203f030dfed41c4477c88f29b536b;hpb=d04a3bf6279f414736e6caae2c6035a648ac63be;p=ircu2.10.12-pk.git diff --git a/ircd/m_whois.c b/ircd/m_whois.c index 51d0354..01c9db5 100644 --- a/ircd/m_whois.c +++ b/ircd/m_whois.c @@ -79,19 +79,14 @@ * note: it is guaranteed that parv[0]..parv[parc-1] are all * non-NULL pointers. */ -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ +#include "config.h" + #include "channel.h" #include "client.h" #include "hash.h" #include "ircd.h" -#include "ircd_policy.h" +#include "ircd_features.h" +#include "ircd_log.h" #include "ircd_reply.h" #include "ircd_string.h" #include "match.h" @@ -102,13 +97,13 @@ #include "send.h" #include "whocmds.h" -#include +/* #include -- Now using assert in ircd_log.h */ #include /* * 2000-07-01: Isomer * * Rewritten to make this understandable - * * You can nolonger /whois unregistered clients. + * * You can no longer /whois unregistered clients. * * * General rules: @@ -132,7 +127,7 @@ /* * Send whois information for acptr to sptr */ -static void do_whois(struct Client* sptr, struct Client *acptr) +static void do_whois(struct Client* sptr, struct Client *acptr, int parc) { struct Client *a2cptr=0; struct Channel *chptr=0; @@ -142,7 +137,8 @@ static void do_whois(struct Client* sptr, struct Client *acptr) const struct User* user = cli_user(acptr); const char* name = (!*(cli_name(acptr))) ? "?" : cli_name(acptr); - a2cptr = user->server; + a2cptr = feature_bool(FEAT_HIS_WHOIS_SERVERNAME) && !IsAnOper(sptr) + && sptr != acptr ? &his : user->server; assert(user); send_reply(sptr, RPL_WHOISUSER, name, user->username, user->host, cli_info(acptr)); @@ -158,13 +154,21 @@ static void do_whois(struct Client* sptr, struct Client *acptr) { chptr = chan->channel; - if (!ShowChannel(sptr, chptr)) + if (!ShowChannel(sptr, chptr) + && !(IsOper(sptr) && IsLocalChannel(chptr->chname))) continue; - + if (acptr != sptr && IsZombie(chan)) continue; - - if (len+strlen(chptr->chname) + mlen > BUFSIZE - 5) + + /* Don't show local channels when HIS is defined, unless it's a + * remote WHOIS --ULtimaTe_ + */ + if (IsLocalChannel(chptr->chname) && (acptr != sptr) && (parc == 2) + && feature_bool(FEAT_HIS_WHOIS_LOCALCHAN) && !IsAnOper(sptr)) + continue; + + if (len+strlen(chptr->chname) + mlen > BUFSIZE - 5) { send_reply(sptr, SND_EXPLICIT | RPL_WHOISCHANNELS, "%s :%s", name, buf); *buf = '\0'; @@ -172,9 +176,13 @@ static void do_whois(struct Client* sptr, struct Client *acptr) } if (IsDeaf(acptr)) *(buf + len++) = '-'; - if (is_chan_op(acptr, chptr)) + if (!ShowChannel(sptr, chptr)) + *(buf + len++) = '*'; + if (IsDelayedJoin(chan) && (sptr != acptr)) + *(buf + len++) = '<'; + else if (IsChanOp(chan)) *(buf + len++) = '@'; - else if (has_voice(acptr, chptr)) + else if (HasVoice(chan)) *(buf + len++) = '+'; else if (IsZombie(chan)) *(buf + len++) = '!'; @@ -189,30 +197,31 @@ static void do_whois(struct Client* sptr, struct Client *acptr) send_reply(sptr, RPL_WHOISCHANNELS, name, buf); } -#ifdef HEAD_IN_SAND_WHOIS_SERVERNAME - if (!IsOper(sptr)) - send_reply(sptr, RPL_WHOISSERVER, name, "*.undernet.org", - "The Undernet Underworld"); - else -#endif - send_reply(sptr, RPL_WHOISSERVER, name, cli_name(a2cptr), - cli_info(a2cptr)); + send_reply(sptr, RPL_WHOISSERVER, name, cli_name(a2cptr), + cli_info(a2cptr)); if (user) { if (user->away) send_reply(sptr, RPL_AWAY, name, user->away); - if (IsAnOper(acptr) && (HasPriv(acptr, PRIV_DISPLAY) || - HasPriv(sptr, PRIV_SEE_OPERS))) + if (SeeOper(sptr,acptr)) send_reply(sptr, RPL_WHOISOPERATOR, name); - + + if (IsAccount(acptr)) + send_reply(sptr, RPL_WHOISACCOUNT, name, user->account); + + if (HasHiddenHost(acptr) && (IsAnOper(sptr) || acptr == sptr)) + send_reply(sptr, RPL_WHOISACTUALLY, name, user->username, + user->realhost, ircd_ntoa(&cli_ip(acptr))); + /* Hint: if your looking to add more flags to a user, eg +h, here's * probably a good place to add them :) */ - - if (MyConnect(acptr)) - send_reply(sptr, RPL_WHOISIDLE, name, CurrentTime - user->last, + + if (MyConnect(acptr) && (!feature_bool(FEAT_HIS_WHOIS_IDLETIME) || + (sptr == acptr || IsAnOper(sptr) || parc >= 3))) + send_reply(sptr, RPL_WHOISIDLE, name, CurrentTime - user->last, cli_firsttime(acptr)); } } @@ -222,18 +231,17 @@ static void do_whois(struct Client* sptr, struct Client *acptr) * returns the number of people found (or, obviously, 0, if none where * found). */ -static int do_wilds(struct Client* sptr,char *nick,int count) +static int do_wilds(struct Client* sptr, char *nick, int count, int parc) { - struct Client *acptr; /* Current client we're concidering */ + struct Client *acptr; /* Current client we're considering */ struct User *user; /* the user portion of the client */ - char *name; /* the name of this client */ struct Membership* chan; int invis; /* does +i apply? */ int member; /* Is this user on any channels? */ int showperson; /* Should we show this person? */ int found = 0 ; /* How many were found? */ - /* Ech! This is hidious! */ + /* Ech! This is hideous! */ for (acptr = GlobalClientList; (acptr = next_client(acptr, nick)); acptr = cli_next(acptr)) { @@ -245,7 +253,7 @@ static int do_wilds(struct Client* sptr,char *nick,int count) /* * I'm always last :-) and acptr->next == 0!! * - * Isomer: Does this strike anyone else as being a horrible hidious + * Isomer: Does this strike anyone else as being a horrible hideous * hack? */ if (IsMe(acptr)) { @@ -256,15 +264,14 @@ static int do_wilds(struct Client* sptr,char *nick,int count) /* * 'Rules' established for sending a WHOIS reply: * - * - if wildcards are being used dont send a reply if - * the querier isnt any common channels and the + * - if wildcards are being used don't send a reply if + * the querier isn't any common channels and the * client in question is invisible. * * - only send replies about common or public channels * the target user(s) are on; */ user = cli_user(acptr); - name = (!*(cli_name(acptr))) ? "?" : cli_name(acptr); assert(user); invis = (acptr != sptr) && IsInvisible(acptr); @@ -274,7 +281,7 @@ static int do_wilds(struct Client* sptr,char *nick,int count) /* Should we show this person now? */ if (showperson) { found++; - do_whois(sptr,acptr); + do_whois(sptr, acptr, parc); if (count+found>MAX_WHOIS_LINES) return found; continue; @@ -316,7 +323,7 @@ static int do_wilds(struct Client* sptr,char *nick,int count) if (!showperson) continue; - do_whois(sptr,acptr); + do_whois(sptr, acptr, parc); found++; if (count+found>MAX_WHOIS_LINES) return found; @@ -343,6 +350,7 @@ int m_whois(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) char* p = 0; int found = 0; int total = 0; + int wildscount = 0; if (parc < 2) { @@ -352,17 +360,31 @@ int m_whois(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) if (parc > 2) { - struct Client *acptr; /* For convenience: Accept a nickname as first parameter, by replacing * it with the correct servername - as is needed by hunt_server(). * This is the secret behind the /whois nick nick trick. */ - acptr = FindUser(parv[1]); - if (acptr) - parv[1] = cli_name(cli_user(acptr)->server); + if (feature_int(FEAT_HIS_REMOTE)) + { + /* If remote queries are disabled, then use the *second* parameter of + * of whois, so /whois nick nick still works. + */ + if (!IsAnOper(sptr)) + { + if (!FindUser(parv[2])) + { + send_reply(sptr, ERR_NOSUCHNICK, parv[2]); + send_reply(sptr, RPL_ENDOFWHOIS, parv[2]); + return 0; + } + parv[1] = parv[2]; + } + } + if (hunt_server_cmd(sptr, CMD_WHOIS, cptr, 0, "%C :%s", 1, parc, parv) != - HUNTED_ISME) - return 0; + HUNTED_ISME) + return 0; + parv[1] = parv[2]; } @@ -380,12 +402,18 @@ int m_whois(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) /* No wildcards */ acptr = FindUser(nick); if (acptr && !IsServer(acptr)) { - do_whois(sptr,acptr); + do_whois(sptr, acptr, parc); found = 1; } } else /* wilds */ - found=do_wilds(sptr,nick,total); + { + if (++wildscount > 3) { + send_reply(sptr, ERR_QUERYTOOLONG, parv[1]); + break; + } + found=do_wilds(sptr, nick, total, parc); + } if (!found) send_reply(sptr, ERR_NOSUCHNICK, nick); @@ -429,14 +457,6 @@ int ms_whois(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) if (parc > 2) { - struct Client *acptr; - /* For convenience: Accept a nickname as first parameter, by replacing - * it with the correct servername - as is needed by hunt_server(). - * This is the secret behind the /whois nick nick trick. - */ - acptr = FindUser(parv[1]); - if (acptr) - parv[1] = cli_name(cli_user(acptr)->server); if (hunt_server_cmd(sptr, CMD_WHOIS, cptr, 0, "%C :%s", 1, parc, parv) != HUNTED_ISME) return 0; @@ -457,7 +477,7 @@ int ms_whois(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) acptr = FindUser(nick); if (acptr && !IsServer(acptr)) { found++; - do_whois(sptr,acptr); + do_whois(sptr, acptr, parc); } if (!found) @@ -477,3 +497,4 @@ int ms_whois(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) return 0; } +