]> jfr.im git - irc/quakenet/snircd.git/blobdiff - ircd/m_pass.c
import of 2.10.12.07
[irc/quakenet/snircd.git] / ircd / m_pass.c
index 72d571a9ffae808243ed55eba29a75b3100d6951..a3a34f8228c64da0b5bc92492f36a6226cdd00f3 100644 (file)
@@ -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_pass.c,v 1.8 2004/12/11 05:13:48 klmitch Exp $
+ * $Id: m_pass.c,v 1.8.2.2 2006/06/17 13:09:14 entrope Exp $
  */
 
 /*
@@ -85,6 +85,7 @@
 #include "ircd_log.h"
 #include "ircd_reply.h"
 #include "ircd_string.h"
+#include "s_auth.h"
 #include "send.h"
 
 /* #include <assert.h> -- Now using assert in ircd_log.h */
  */
 int mr_pass(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 {
-  const char* password = parc > 1 ? parv[1] : 0;
+  char password[BUFSIZE];
+  int arg, len;
 
   assert(0 != cptr);
   assert(cptr == sptr);
   assert(!IsRegistered(sptr));
 
+  /* Some clients (brokenly) send "PASS x y" rather than "PASS :x y"
+   * when the user enters "x y" as the password.  Unsplit arguments to
+   * work around this.
+   */
+  for (arg = 1, len = 0; arg < parc; ++arg)
+  {
+    ircd_strncpy(password + len, parv[arg], sizeof(password) - len);
+    len += strlen(parv[arg]);
+    password[len++] = ' ';
+  }
+  if (len > 0)
+    --len;
+  password[len] = '\0';
+
   if (EmptyString(password))
     return need_more_params(cptr, "PASS");
 
-  /* TODO: For protocol negotiation */
-#if 0
-  if (ircd_strcmp(password,"PROT")==0) {
-       /* Do something here */
-  }
-#endif
   ircd_strncpy(cli_passwd(cptr), password, PASSWDLEN);
-  return 0;
+  return cli_auth(cptr) ? auth_set_password(cli_auth(cptr), password) : 0;
 }