copy fakeuser also into Client struct
[ircu2.10.12-pk.git] / ircd / s_user.c
index ccaed506618724d3ff44afd914968b5f4128c30b..c10eb72360d8b152f0241489e197f3346f2bbb77 100644 (file)
@@ -974,12 +974,7 @@ void send_user_info(struct Client* sptr, char* names, int rpl, InfoFormatter fmt
  */
  
 int
-hide_hostmask(struct Client *cptr, unsigned int flag) {
-  return hide_ident_hostmask(cptr, flag, NULL);
-}
-
-int
-hide_ident_hostmask(struct Client *cptr, unsigned int flag, char *username)
+hide_hostmask(struct Client *cptr, unsigned int flag)
 {
   struct Membership *chan;
   char buf[HOSTLEN];
@@ -992,6 +987,7 @@ hide_ident_hostmask(struct Client *cptr, unsigned int flag, char *username)
     break;
   case FLAG_ACCOUNT:
   case FLAG_FAKEHOST:
+  case FLAG_FAKEIDENT:
     /* Invalidate all bans against the user so we check them again */
     for (chan = (cli_user(cptr))->channel; chan;
          chan = chan->next_channel)
@@ -1011,7 +1007,7 @@ hide_ident_hostmask(struct Client *cptr, unsigned int flag, char *username)
   if(IsFakeHost(cptr)) ircd_strncpy(buf, cli_user(cptr)->fakehost, HOSTLEN);
   else if (IsAccount(cptr)) ircd_snprintf(0, buf, HOSTLEN, "%s.%s", cli_user(cptr)->account, feature_str(FEAT_HIDDEN_HOST));
   else return 0;
-  if(strncmp(buf, cli_user(cptr)->host, HOSTLEN) == 0) return 0;
+  if(strncmp(buf, cli_user(cptr)->host, HOSTLEN) == 0 && (!IsFakeIdent(cptr) || strncmp(cli_user(cptr)->fakeuser, cli_user(cptr)->username, USERLEN) == 0)) return 0;
 
   /* Remove all "valid" marks on the bans. This forces them to be
    * rechecked if the ban is accessed again.
@@ -1025,9 +1021,12 @@ hide_ident_hostmask(struct Client *cptr, unsigned int flag, char *username)
   ircd_strncpy(cli_user(cptr)->host, buf, HOSTLEN);
 
   /* spoof also the username if username is passed */
-  if(username) {
-    ircd_strncpy(cli_user(cptr)->username, username, USERLEN);
-     /* ok, the client is now fully hidden, so let them know -- hikari */
+  if(IsFakeIdent(cptr)) {
+    if(strncmp(cli_user(cptr)->username, cli_user(cptr)->fakeuser, USERLEN) != 0) {
+      ircd_strncpy(cli_username(cptr), cli_user(cptr)->fakeuser, USERLEN);
+      ircd_strncpy(cli_user(cptr)->username, cli_user(cptr)->fakeuser, USERLEN);
+    }
+    /* ok, the client is now fully hidden, so let them know -- hikari */
     if (MyConnect(cptr))
       send_reply(cptr, RPL_HOSTUSERHIDDEN, cli_user(cptr)->username, cli_user(cptr)->host);
   } else {