Allow clients and iauth to request usermodes during registration.
authorMichael Poole <mdpoole@troilus.org>
Sun, 1 Apr 2007 03:01:17 +0000 (03:01 +0000)
committerMichael Poole <mdpoole@troilus.org>
Sun, 1 Apr 2007 03:01:17 +0000 (03:01 +0000)
git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/branches/u2_10_12_branch@1796 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
doc/readme.iauth
ircd/m_user.c
ircd/s_auth.c
ircd/s_user.c
tools/iauth-test

index 9a2ba7edd99f4bdc38fa642a99bf9f8081b945c4..6301e785d8b4598a824ddd3be457dc4af97ae7cc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2007-03-31  Michael Poole <mdpoole@troilus.org>
+
+       * doc/readme.iauth (IAuth M): Document new command.
+
+       * ircd/m_user.c (m_user): Recognize RFC 2812 mode request and a
+       saner usermode request.
+
+       * ircd/s_auth.c (iauth_cmd_usermode): New command.
+       (iauth_parse): Dispatch to it.
+
+       * ircd/s_user.c (set_user_mode): Only broadcast usermode changes
+       for registered clients.
+
+       * tools/iauth-test (127.0.1.3): Test the new M command.
+
 2007-03-31  Michael Poole <mdpoole@troilus.org>
 
        * ircd/m_mode.c (m_mode): Check and report target/source
index ce6c67211f79af852b827e2f583d07ae5f9680dd..cb2b4849d555d2b90f5d95c6a3ac5341e8ceaa5f 100644 (file)
@@ -377,6 +377,16 @@ Comments: Indicates that the iauth instance wants the server to
 Compatibility: This is an Undernet extension and ircd does not support
   this message.
 
+M - Adjust User Mode
+Syntax: M <id> <remoteip> <remoteport> +<mode changes>
+Example: M 5 192.168.1.10 23367 +iwg
+States: REGISTER, HURRY
+Next State: -
+Comments: Indicates a set of user mode changes to be applied to the
+  client.
+Compatibility: This is an Undernet extension and ircd does not support
+  this message.
+
 C - Challenge User
 Syntax: C <id> <remoteip> <remoteport> :<challenge string>
 Example: C 5 192.168.1.10 23367 :In which year did Columbus sail the ocean blue?
index 17fa10042d7fa83e0d5391273e218cc1388c7930..aa172e49af380e4bfb336025575c0057ffe62f5f 100644 (file)
 int m_user(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
 {
   char*        username;
+  char*        term;
   const char*  info;
+  unsigned int mode_request;
 
   assert(0 != cptr);
   assert(cptr == sptr);
@@ -137,6 +139,27 @@ int m_user(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
   else
     username = "NoUser";
 
+  if ((mode_request = strtoul(parv[2], &term, 10)) != 0
+      && term != NULL && *term != '\0')
+  {
+    /* These bitmask values are codified in RFC 2812, showing
+     * ... well, something that is probably best not said.
+     */
+    if (mode_request & 8)
+      SetInvisible(cptr);
+    if (mode_request & 4)
+      SetWallops(cptr);
+  }
+  else if (parv[2][0] == '+')
+  {
+    char *user_modes[4];
+    user_modes[0] = NULL;
+    user_modes[1] = NULL;
+    user_modes[2] = parv[2];
+    user_modes[3] = NULL;
+    set_user_mode(cptr, sptr, 3, user_modes);
+  }
+
   info     = (EmptyString(parv[4])) ? "No Info" : parv[4];
 
   return auth_set_user(cli_auth(cptr), username, parv[2], parv[3], info);
index 71dad1a81558822633a6594233ac1229651f5123..2aeef4ba5323517180531f1d290a986df07d9384 100644 (file)
@@ -1904,6 +1904,25 @@ static int iauth_cmd_kill(struct IAuth *iauth, struct Client *cli,
   return 0;
 }
 
+/** Change a client's usermode.
+ * @param[in] iauth Active IAuth session.
+ * @param[in] cli Client referenced by command.
+ * @param[in] parc Number of parameters (at least one).
+ * @param[in] params Usermode arguments for client (with the first
+ *   starting with '+').
+ * @return Zero.
+ */
+static int iauth_cmd_usermode(struct IAuth *iauth, struct Client *cli,
+                              int parc, char **params)
+{
+  if (params[0][0] == '+')
+  {
+    set_user_mode(cli, cli, parc + 2, params - 2);
+  }
+  return 0;
+}
+
+
 /** Send a challenge string to the client.
  * @param[in] iauth Active IAuth session.
  * @param[in] cli Client referenced by command.
@@ -1948,6 +1967,7 @@ static void iauth_parse(struct IAuth *iauth, char *message)
   case 'u': handler = iauth_cmd_username_bad; has_cli = 1; break;
   case 'N': handler = iauth_cmd_hostname; has_cli = 1; break;
   case 'I': handler = iauth_cmd_ip_address; has_cli = 1; break;
+  case 'M': handler = iauth_cmd_usermode; has_cli = 1; break;
   case 'C': handler = iauth_cmd_challenge; has_cli = 1; break;
   case 'D': handler = iauth_cmd_done_client; has_cli = 1; break;
   case 'R': handler = iauth_cmd_done_account; has_cli = 1; break;
index a21f5e2b791db8a316ba33eb1df43d9185c8d1f5..407bb3ce27d3c2fbb67152d6c53bfe8580233c68 100644 (file)
@@ -1189,7 +1189,8 @@ int set_user_mode(struct Client *cptr, struct Client *sptr, int parc, char *parv
     ++UserStats.inv_clients;
   if (!FlagHas(&setflags, FLAG_HIDDENHOST) && do_host_hiding)
     hide_hostmask(sptr, FLAG_HIDDENHOST);
-  send_umode_out(cptr, sptr, &setflags, prop);
+  if (IsRegistered(sptr))
+    send_umode_out(cptr, sptr, &setflags, prop);
 
   return 0;
 }
index 0e8d104a8d0b8454dbada182ec238238b6284aff..7013d1650eedd2b101fdec4e565ba00fa7406529 100755 (executable)
@@ -162,13 +162,15 @@ my %handlers = (
                 '127.0.0.33' => { T_reply => 'R account-3' },
                 '127.0.0.34' => { T_reply => 'k' },
                 '127.0.0.35' => { T_reply => 'K' },
-                # 127.0.1.x: io/iU/iu functionality.
+                # 127.0.1.x: io/iU/iu/iM functionality.
                 '127.0.1.0'  => { C_reply => 'o forced',
                                   H_reply => 'D' },
                 '127.0.1.1'  => { C_reply => 'U trusted',
                                   H_reply => 'D' },
                 '127.0.1.2'  => { C_reply => 'u untrusted',
                                   H_reply => 'D' },
+                '127.0.1.3'  => { C_reply => 'M +i',
+                                  H_reply => 'D' },
                 # 127.0.2.x: iI/iN functionality.
                 '127.0.2.0'  => { C_reply => 'N iauth.assigned.host',
                                   H_reply => 'D' },