extended & fixed FAKEIDENT support
authorpk910 <philipp@zoelle1.de>
Sat, 23 Jul 2011 05:56:01 +0000 (07:56 +0200)
committerpk910 <philipp@zoelle1.de>
Sat, 23 Jul 2011 05:56:01 +0000 (07:56 +0200)
include/client.h
include/msg.h
include/struct.h
ircd/m_fakehost.c
ircd/s_user.c

index 175dd94d9c9b2c1c35a85bb7159f6ab1fd0043fc..20db7430013e16c1c68ee120e8902f79a8135d79 100644 (file)
@@ -180,6 +180,7 @@ enum Flag
     FLAG_ACCOUNT,                   /**< account name has been set */
     FLAG_HIDDENHOST,                /**< user's host is hidden */
     FLAG_FAKEHOST,                  /**< user has a fakehost */
+    FLAG_FAKEIDENT,                  /**< user has a fakeident */
     FLAG_NOCHAN,                    /**< hide user's channels for non-opers */
     FLAG_NOIDLE,                    /**< hide user's idle time for non-opers */
     FLAG_XTRAOP,                    /**< allow overriding +k */
@@ -648,6 +649,7 @@ struct Client {
 #define IsSecurityServ(x)        HasFlag(x, FLAG_SECURITY_SERV)
 /** Return non-zero if the client has a fakehost. */
 #define IsFakeHost(x)           HasFlag(x, FLAG_FAKEHOST)
+#define IsFakeIdent(x)           HasFlag(x, FLAG_FAKEIDENT)
 
 /** Return non-zero if the client has operator or server privileges. */
 #define IsPrivileged(x)         (IsAnOper(x) || IsServer(x))
@@ -696,6 +698,7 @@ struct Client {
 #define SetHiddenHost(x)        SetFlag(x, FLAG_HIDDENHOST)
 /** Mark a client as having a fakehost. */
 #define SetFakeHost(x)          SetFlag(x, FLAG_FAKEHOST)
+#define SetFakeIdent(x)          SetFlag(x, FLAG_FAKEIDENT)
 /** Mark a client as having a pending PING. */
 #define SetPingSent(x)          SetFlag(x, FLAG_PINGSENT)
 /** Mark a client as having mode +n. */
@@ -751,6 +754,7 @@ struct Client {
 #define ClearHiddenHost(x)      ClrFlag(x, FLAG_HIDDENHOST)
 /** Remove fakehost flag from the flient. */
 #define ClearFakeHost(x)        ClrFlag(x, FLAG_FAKEHOST)
+#define ClearFakeIdent(x)        ClrFlag(x, FLAG_FAKEIDENT)
 /** Clear the client's pending PING flag. */
 #define ClearPingSent(x)        ClrFlag(x, FLAG_PINGSENT)
 /** Clear the client's HUB flag. */
index eae47662d6ceb9fba9b370d4b969985521fdc99e..e4798f3878355d27a5edf031db51f2e0522589a5 100644 (file)
@@ -364,8 +364,8 @@ struct Client;
 #define TOK_FAKEHOST        "FH"
 #define CMD_FAKEHOST        MSG_FAKEHOST, TOK_FAKEHOST
 
-#define MSG_FAKEHOST2        "FAKEHOST2"
-#define TOK_FAKEHOST2        "FH2"
+#define MSG_FAKEHOST2        "NEWFAKEHOST"
+#define TOK_FAKEHOST2        "NFH"
 #define CMD_FAKEHOST2        MSG_FAKEHOST2, TOK_FAKEHOST2
 
 #define MSG_FAKEHOST_OLD    "FAKE"
index beec331f49c0e1f1925b699d1c6fe719a15cbc40..45fb6ec687e9dcee18ea65391f50811c6ea4dd7b 100644 (file)
@@ -80,6 +80,7 @@ struct User {
    * overwritten with the ident response.
    */
   char               username[USERLEN + 1];
+  char               fakeuser[USERLEN + 1];
   char               host[HOSTLEN + 1];       /**< displayed hostname */
   char               realhost[HOSTLEN + 1];   /**< actual hostname */
   char               fakehost[HOSTLEN + 1];   /**< fakehost */
index a73dd53aa19b61de48fc49dcc5b7fcb8c62c5f47..5aa559e59a80c907a240287ab34f7b10b628dd96 100644 (file)
@@ -91,8 +91,8 @@
 #include "s_bsd.h"
 #include "s_conf.h"
 #include "s_user.h"
+#include "s_debug.h"
 #include "send.h"
-
 /*
  * m_fakehost - fakehost user message handler
  *
@@ -295,15 +295,16 @@ int ms_fakehost2(struct Client *cptr, struct Client *sptr, int parc, char *parv[
     }
 
     /* Ignore the assignment if it changes nothing. */
-    if(IsFakeHost(target) && strcmp(cli_user(target)->fakehost, parv[3]) == 0 && strcmp(cli_user(target)->username, parv[2]) == 0) {
+    if(IsFakeHost(target) && strcmp(cli_user(target)->fakehost, parv[3]) == 0 && strcmp(cli_user(target)->fakeuser, parv[2]) == 0) {
         return 0;
     }
 
     /* Set fakehost and propagate the changed host. */
     ircd_strncpy(cli_user(target)->fakehost, parv[3], HOSTLEN);
-    hide_ident_hostmask(target, FLAG_FAKEHOST, parv[2]);
+    ircd_strncpy(cli_user(target)->fakeuser, parv[2], USERLEN);
+    hide_hostmask(target, FLAG_FAKEHOST | FLAG_FAKEIDENT);
 
-    sendcmdto_serv_butone(sptr, CMD_FAKEHOST2, cptr, "%C %s %s", target, parv[2], parv[3]);
+    sendcmdto_serv_butone(sptr, CMD_FAKEHOST2, cptr, "%C %s %s", target, cli_user(target)->fakeuser, cli_user(target)->fakehost);
 
     return 0;
 }
@@ -314,6 +315,7 @@ int ms_fakehost2(struct Client *cptr, struct Client *sptr, int parc, char *parv[
  * parv[0] = sender prefix
  * parv[1] = target user numeric
  * parv[2] = target user's new fake host
+ * parv[3] = target user's new fake ident
  */
 int ms_fakehost_old(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) {
     struct Client *target;
index ccaed506618724d3ff44afd914968b5f4128c30b..98274901a99323a57bbc8225e07cf722aba4c71e 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,8 +1021,8 @@ 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);
+  if(IsFakeIdent(cptr)) {
+    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);