From cb6fd4594d11e531fdb0f666b6651919d27e32ff Mon Sep 17 00:00:00 2001 From: "Kevin L. Mitchell" Date: Wed, 3 Apr 2002 15:23:48 +0000 Subject: [PATCH] Author: Alex Badea (by way of Kev ) Log message: Fix bug 43, where /who %i would reveal IP addresses for hidden hosts. Also fixed searching on those IP addresses... (pull-up from u2_10_11 branch) git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@711 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- ChangeLog | 28 ++++++++++++++++++++++++++++ doc/example.conf | 1 + doc/readme.features | 7 +++++++ include/ircd_features.h | 1 + include/s_user.h | 2 +- ircd/ircd_features.c | 1 + ircd/m_userhost.c | 2 +- ircd/m_userip.c | 6 ++++-- ircd/m_who.c | 2 ++ ircd/s_user.c | 2 +- ircd/whocmds.c | 4 +++- 11 files changed, 50 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 736291d..bc1c512 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,31 @@ +2002-04-03 Alex Badea + + * include/s_user.h: added a sptr parameter to InfoFormatter + function type + + * ircd/m_who.c: don't match IPs for clients which have a hidden host, + except when the inquiring user is an oper + + * ircd/whocmds.c: show the fake IP from FEAT_HIDDEN_IP if the + target has a hidden host, but show real IP to opers + + * ircd/m_userip.c (userip_formatter): add sptr parameter; show the + fake IP from FEAT_HIDDEN_IP if the target has a hidden host, but + show real IP to opers + + * ircd/m_userhost.c (userhost_formatter): add (unused) sptr parameter + + * ircd/s_user.c (send_user_info): pass sptr to the formatting function + + * include/ircd_features.h: new feature FEAT_HIDDEN_IP (stores which + fake IP to show for clients with a hidden host) + + * ircd/ircd_features.c: new feature FEAT_HIDDEN_IP + + * doc/example.conf: default value for FEAT_HIDDEN_IP + + * doc/readme.features: documented FEAT_HIDDEN_IP + 2002-04-03 Andrew Miller * doc/example.conf: Cleaned up some comments that ended up in strange places due to problems in the merge process. diff --git a/doc/example.conf b/doc/example.conf index 0e1e2ac..3fec2e3 100644 --- a/doc/example.conf +++ b/doc/example.conf @@ -701,6 +701,7 @@ features # "NICKNAMEHISTORYLENGTH"="800"; # "HOST_HIDING"="FALSE"; # "HIDDEN_HOST"="users.undernet.org"; +# "HIDDEN_IP"="127.0.0.1"; # "KILLCHASETIMELIMIT"="30"; # "MAXCHANNELSPERUSER"="10"; # "AVBANLEN"="40"; diff --git a/doc/readme.features b/doc/readme.features index 4faac70..5d9aea6 100644 --- a/doc/readme.features +++ b/doc/readme.features @@ -235,6 +235,13 @@ HIDDEN_HOST This selects the suffix for the hidden hostmask (see HOST_HIDING). +HIDDEN_IP + * Type: string + * Default: 127.0.0.1 + +This selects a fake IP to be shown on /USERIP and /WHO %i when the +target has a hidden host (see HOST_HIDING). + KILLCHASETIMELIMIT * Type: integer * Default: 30 diff --git a/include/ircd_features.h b/include/ircd_features.h index 82397bb..b274512 100644 --- a/include/ircd_features.h +++ b/include/ircd_features.h @@ -44,6 +44,7 @@ enum Feature { FEAT_NICKNAMEHISTORYLENGTH, FEAT_HOST_HIDING, FEAT_HIDDEN_HOST, + FEAT_HIDDEN_IP, /* features that probably should not be touched */ FEAT_KILLCHASETIMELIMIT, diff --git a/include/s_user.h b/include/s_user.h index f9d9e4c..5615abb 100644 --- a/include/s_user.h +++ b/include/s_user.h @@ -49,7 +49,7 @@ struct MsgBuf; extern struct SLink *opsarray[]; -typedef void (*InfoFormatter)(struct Client* who, struct MsgBuf* buf); +typedef void (*InfoFormatter)(struct Client* who, struct Client *sptr, struct MsgBuf* buf); /* * Prototypes diff --git a/ircd/ircd_features.c b/ircd/ircd_features.c index f46c48e..2c4b966 100644 --- a/ircd/ircd_features.c +++ b/ircd/ircd_features.c @@ -251,6 +251,7 @@ static struct FeatureDesc { F_I(NICKNAMEHISTORYLENGTH, 0, 800, whowas_realloc), F_B(HOST_HIDING, 0, 0, 0), F_S(HIDDEN_HOST, FEAT_CASE, "users.undernet.org", 0), + F_S(HIDDEN_IP, 0, "127.0.0.1", 0), /* features that probably should not be touched */ F_I(KILLCHASETIMELIMIT, 0, 30, 0), diff --git a/ircd/m_userhost.c b/ircd/m_userhost.c index cf862e9..694b111 100644 --- a/ircd/m_userhost.c +++ b/ircd/m_userhost.c @@ -91,7 +91,7 @@ #include -static void userhost_formatter(struct Client* cptr, struct MsgBuf* mb) +static void userhost_formatter(struct Client* cptr, struct Client *sptr, struct MsgBuf* mb) { assert(IsUser(cptr)); msgq_append(0, mb, "%s%s=%c%s@%s", cli_name(cptr), diff --git a/ircd/m_userip.c b/ircd/m_userip.c index a42cbcc..27be218 100644 --- a/ircd/m_userip.c +++ b/ircd/m_userip.c @@ -84,6 +84,7 @@ #include "client.h" #include "ircd_reply.h" #include "ircd_string.h" +#include "ircd_features.h" #include "msgq.h" #include "numeric.h" #include "s_user.h" @@ -91,13 +92,14 @@ #include -static void userip_formatter(struct Client* cptr, struct MsgBuf* mb) +static void userip_formatter(struct Client* cptr, struct Client *sptr, struct MsgBuf* mb) { assert(IsUser(cptr)); msgq_append(0, mb, "%s%s=%c%s@%s", cli_name(cptr), HasPriv(cptr, PRIV_DISPLAY) ? "*" : "", cli_user(cptr)->away ? '-' : '+', cli_user(cptr)->username, - HasHiddenHost(cptr) ? "127.0.0.1" : + HasHiddenHost(cptr) && !IsAnOper(sptr) ? + feature_str(FEAT_HIDDEN_IP) : ircd_ntoa((const char*) &(cli_ip(cptr)))); } diff --git a/ircd/m_who.c b/ircd/m_who.c index 0622667..271946b 100644 --- a/ircd/m_who.c +++ b/ircd/m_who.c @@ -401,6 +401,7 @@ int m_who(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) && ((!(matchsel & WHO_FIELD_REN)) || matchexec(cli_info(acptr), mymask, minlen)) && ((!(matchsel & WHO_FIELD_NIP)) + || (HasHiddenHost(acptr) && !IsAnOper(sptr)) || ((((cli_ip(acptr).s_addr & imask.mask.s_addr) != imask.bits.s_addr)) || (imask.fall && matchexec(ircd_ntoa((const char*) &(cli_ip(acptr))), mymask, minlen))))) @@ -440,6 +441,7 @@ int m_who(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) && ((!(matchsel & WHO_FIELD_REN)) || matchexec(cli_info(acptr), mymask, minlen)) && ((!(matchsel & WHO_FIELD_NIP)) + || (HasHiddenHost(acptr) && !IsAnOper(sptr)) || ((((cli_ip(acptr).s_addr & imask.mask.s_addr) != imask.bits.s_addr)) || (imask.fall && matchexec(ircd_ntoa((const char*) &(cli_ip(acptr))), mymask, minlen))))) diff --git a/ircd/s_user.c b/ircd/s_user.c index 2e7b49c..467bea6 100644 --- a/ircd/s_user.c +++ b/ircd/s_user.c @@ -1036,7 +1036,7 @@ void send_user_info(struct Client* sptr, char* names, int rpl, InfoFormatter fmt if ((acptr = FindUser(name))) { if (users_found++) msgq_append(0, mb, " "); - (*fmt)(acptr, mb); + (*fmt)(acptr, sptr, mb); } if (5 == ++arg_count) break; diff --git a/ircd/whocmds.c b/ircd/whocmds.c index 1f4fb1a..fa8def4 100644 --- a/ircd/whocmds.c +++ b/ircd/whocmds.c @@ -122,7 +122,9 @@ void do_who(struct Client* sptr, struct Client* acptr, struct Channel* repchan, if (fields & WHO_FIELD_NIP) { - const char* p2 = ircd_ntoa((const char*) &(cli_ip(acptr))); + const char* p2 = HasHiddenHost(acptr) && !IsAnOper(sptr) ? + feature_str(FEAT_HIDDEN_IP) : + ircd_ntoa((const char*) &(cli_ip(acptr))); *(p1++) = ' '; while ((*p2) && (*(p1++) = *(p2++))); } -- 2.20.1