Committer  : entrope
CVSROOT    : /cvsroot/undernet-ircu
Module     : ircu2.10
Branch tags: u2_10_12_branch
Commit time: 2007-04-01 03:01:29 UTC

Modified files:
  Tag: u2_10_12_branch
     tools/iauth-test ircd/s_user.c ircd/s_auth.c ircd/m_user.c
     doc/readme.iauth ChangeLog

Log message:

Allow clients and iauth to request usermodes during registration.

---------------------- diff included ----------------------
Index: ircu2.10/ChangeLog
diff -u ircu2.10/ChangeLog:1.710.2.174 ircu2.10/ChangeLog:1.710.2.175
--- ircu2.10/ChangeLog:1.710.2.174      Sat Mar 31 19:14:59 2007
+++ ircu2.10/ChangeLog  Sat Mar 31 20:01:17 2007
@@ -1,5 +1,20 @@
 2007-03-31  Michael Poole <[EMAIL PROTECTED]>
 
+       * 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 <[EMAIL PROTECTED]>
+
        * ircd/m_mode.c (m_mode): Check and report target/source
        violations before calling set_user_mode().
        (ms_mode): Likewise.
Index: ircu2.10/doc/readme.iauth
diff -u ircu2.10/doc/readme.iauth:1.1.2.4 ircu2.10/doc/readme.iauth:1.1.2.5
--- ircu2.10/doc/readme.iauth:1.1.2.4   Mon Mar 26 18:07:06 2007
+++ ircu2.10/doc/readme.iauth   Sat Mar 31 20:01:17 2007
@@ -377,6 +377,16 @@
 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: ircu2.10/ircd/m_user.c
diff -u ircu2.10/ircd/m_user.c:1.9.2.2 ircu2.10/ircd/m_user.c:1.9.2.3
--- ircu2.10/ircd/m_user.c:1.9.2.2      Mon Jan 15 17:21:37 2007
+++ ircu2.10/ircd/m_user.c      Sat Mar 31 20:01:16 2007
@@ -20,7 +20,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * $Id: m_user.c,v 1.9.2.2 2007/01/16 01:21:37 entrope Exp $
+ * $Id: m_user.c,v 1.9.2.3 2007/04/01 03:01:16 entrope Exp $
  */
 
 /*
@@ -113,7 +113,9 @@
 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 @@
   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: ircu2.10/ircd/s_auth.c
diff -u ircu2.10/ircd/s_auth.c:1.37.2.22 ircu2.10/ircd/s_auth.c:1.37.2.23
--- ircu2.10/ircd/s_auth.c:1.37.2.22    Mon Mar 26 20:37:39 2007
+++ ircu2.10/ircd/s_auth.c      Sat Mar 31 20:01:16 2007
@@ -31,7 +31,7 @@
  */
 /** @file
  * @brief Implementation of DNS and ident lookups.
- * @version $Id: s_auth.c,v 1.37.2.22 2007/03/27 03:37:39 entrope Exp $
+ * @version $Id: s_auth.c,v 1.37.2.23 2007/04/01 03:01:16 entrope Exp $
  */
 #include "config.h"
 
@@ -1904,6 +1904,25 @@
   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 @@
   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: ircu2.10/ircd/s_user.c
diff -u ircu2.10/ircd/s_user.c:1.99.2.4 ircu2.10/ircd/s_user.c:1.99.2.5
--- ircu2.10/ircd/s_user.c:1.99.2.4     Sat Mar 31 19:14:59 2007
+++ ircu2.10/ircd/s_user.c      Sat Mar 31 20:01:16 2007
@@ -22,7 +22,7 @@
  */
 /** @file
  * @brief Miscellaneous user-related helper functions.
- * @version $Id: s_user.c,v 1.99.2.4 2007/04/01 02:14:59 entrope Exp $
+ * @version $Id: s_user.c,v 1.99.2.5 2007/04/01 03:01:16 entrope Exp $
  */
 #include "config.h"
 
@@ -1189,7 +1189,8 @@
     ++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: ircu2.10/tools/iauth-test
diff -u ircu2.10/tools/iauth-test:1.1.2.3 ircu2.10/tools/iauth-test:1.1.2.4
--- ircu2.10/tools/iauth-test:1.1.2.3   Tue Apr  4 16:07:02 2006
+++ ircu2.10/tools/iauth-test   Sat Mar 31 20:01:15 2007
@@ -162,13 +162,15 @@
                 '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' },
----------------------- End of diff -----------------------
_______________________________________________
Patches mailing list
[email protected]
http://undernet.sbg.org/mailman/listinfo/patches

Reply via email to