From: Michael Poole Date: Sun, 1 Apr 2007 03:01:17 +0000 (+0000) Subject: Allow clients and iauth to request usermodes during registration. X-Git-Url: http://git.pk910.de/?p=ircu2.10.12-pk.git;a=commitdiff_plain;h=787ba07385499acc43314957a0243c757f5c90b5 Allow clients and iauth to request usermodes during registration. git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/branches/u2_10_12_branch@1796 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- diff --git a/ChangeLog b/ChangeLog index 9a2ba7e..6301e78 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2007-03-31 Michael Poole + + * 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 * ircd/m_mode.c (m_mode): Check and report target/source diff --git a/doc/readme.iauth b/doc/readme.iauth index ce6c672..cb2b484 100644 --- a/doc/readme.iauth +++ b/doc/readme.iauth @@ -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 + +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 : Example: C 5 192.168.1.10 23367 :In which year did Columbus sail the ocean blue? diff --git a/ircd/m_user.c b/ircd/m_user.c index 17fa100..aa172e4 100644 --- a/ircd/m_user.c +++ b/ircd/m_user.c @@ -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 @@ 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); diff --git a/ircd/s_auth.c b/ircd/s_auth.c index 71dad1a..2aeef4b 100644 --- a/ircd/s_auth.c +++ b/ircd/s_auth.c @@ -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; diff --git a/ircd/s_user.c b/ircd/s_user.c index a21f5e2..407bb3c 100644 --- a/ircd/s_user.c +++ b/ircd/s_user.c @@ -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; } diff --git a/tools/iauth-test b/tools/iauth-test index 0e8d104..7013d16 100755 --- a/tools/iauth-test +++ b/tools/iauth-test @@ -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' },