From 364e59f82a86759738c1a0ea5362dad2a0b8c73c Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Sat, 14 Sep 2013 12:26:32 +0200 Subject: [PATCH] whowas: Use the normal rules for IP visibility. Add the flags (auth{} spoof, dynamic spoof) to struct Whowas and add a show_ip_whowas(). Normal users now see IPs of unspoofed users, and remote opers can see IPs behind dynamic spoofs. Also, general::hide_spoof_ips is now applied when the IP is shown, not when the client exits. --- doc/reference.conf | 2 -- include/client.h | 1 + include/whowas.h | 5 +++++ modules/m_whowas.c | 4 +++- src/client.c | 12 ++++++++++++ src/whowas.c | 7 +++---- 6 files changed, 24 insertions(+), 7 deletions(-) diff --git a/doc/reference.conf b/doc/reference.conf index 7e6389151..c36a36ce2 100755 --- a/doc/reference.conf +++ b/doc/reference.conf @@ -940,8 +940,6 @@ general { * If disabled, local opers can see them. * Dynamic spoofs (e.g. set by services) are unaffected by this; * any oper (local and remote) can see the real ip. - * Warning: for whowas, this is checked when the client exits, - * not when the IP is shown. */ hide_spoof_ips = yes; diff --git a/include/client.h b/include/client.h index 7b73579ec..0249e1872 100644 --- a/include/client.h +++ b/include/client.h @@ -597,6 +597,7 @@ extern void del_all_accepts(struct Client *client_p); extern void dead_link(struct Client *client_p, int sendqex); extern int show_ip(struct Client *source_p, struct Client *target_p); extern int show_ip_conf(struct ConfItem *aconf, struct Client *source_p); +extern int show_ip_whowas(struct Whowas *whowas, struct Client *source_p); extern void initUser(void); extern void free_user(struct User *, struct Client *); diff --git a/include/whowas.h b/include/whowas.h index 616badd7c..ca3dde9f7 100644 --- a/include/whowas.h +++ b/include/whowas.h @@ -55,6 +55,7 @@ struct Whowas char sockhost[HOSTIPLEN + 1]; char realname[REALLEN + 1]; char suser[NICKLEN + 1]; + unsigned char flags; const char *servername; time_t logoff; struct Client *online; /* Pointer to new nickname for chasing or NULL */ @@ -64,6 +65,10 @@ struct Whowas struct Whowas *cprev; /* for client struct linked list */ }; +/* Flags */ +#define WHOWAS_IP_SPOOFING 0x1 +#define WHOWAS_DYNSPOOF 0x2 + /* ** initwhowas */ diff --git a/modules/m_whowas.c b/modules/m_whowas.c index c0f10b66a..ec3cac354 100644 --- a/modules/m_whowas.c +++ b/modules/m_whowas.c @@ -117,7 +117,9 @@ m_whowas(struct Client *client_p, struct Client *source_p, int parc, const char sendto_one(source_p, form_str(RPL_WHOWASUSER), me.name, source_p->name, temp->name, temp->username, temp->hostname, temp->realname); - if (MyOper(source_p) && !EmptyString(temp->sockhost)) + if (!EmptyString(temp->sockhost) && + strcmp(temp->sockhost, "0") && + show_ip_whowas(temp, source_p)) #if 0 sendto_one(source_p, form_str(RPL_WHOWASREAL), me.name, source_p->name, temp->name, diff --git a/src/client.c b/src/client.c index 23436ab79..13320f66b 100644 --- a/src/client.c +++ b/src/client.c @@ -1690,6 +1690,18 @@ show_ip_conf(struct ConfItem *aconf, struct Client *source_p) return 1; } +int +show_ip_whowas(struct Whowas *whowas, struct Client *source_p) +{ + if(whowas->flags & WHOWAS_IP_SPOOFING) + if(ConfigFileEntry.hide_spoof_ips || !MyOper(source_p)) + return 0; + if(whowas->flags & WHOWAS_DYNSPOOF) + if(!IsOper(source_p)) + return 0; + return 1; +} + /* * make_user * diff --git a/src/whowas.c b/src/whowas.c index aafe91b48..716bdccd4 100644 --- a/src/whowas.c +++ b/src/whowas.c @@ -83,10 +83,9 @@ void add_history(struct Client *client_p, int online) strcpy(who->hostname, client_p->host); strcpy(who->realname, client_p->info); strcpy(who->suser, client_p->user->suser); - if (!EmptyString(client_p->sockhost) && strcmp(client_p->sockhost, "0") && show_ip(NULL, client_p)) - strcpy(who->sockhost, client_p->sockhost); - else - who->sockhost[0] = '\0'; + strcpy(who->sockhost, client_p->sockhost); + who->flags = (IsIPSpoof(client_p) ? WHOWAS_IP_SPOOFING : 0) | + (IsDynSpoof(client_p) ? WHOWAS_DYNSPOOF : 0); who->servername = scache_get_name(client_p->servptr->serv->nameinfo);