added gnutls backend and moved backend code into new files
[ircu2.10.12-pk.git] / ircd / m_pass.c
index 4629f691c6497ec0eee20d62b01f4884a52b0793..e34e6819aba9b17c7a183417cf5ab76632b2ee44 100644 (file)
  */
 #include "config.h"
 
-#if 0
-/*
- * No need to include handlers.h here the signatures must match
- * and we don't need to force a rebuild of all the handlers everytime
- * we add a new one to the list. --Bleep
- */
-#include "handlers.h"
-#endif /* 0 */
 #include "client.h"
+#include "ircd_log.h"
 #include "ircd_reply.h"
 #include "ircd_string.h"
+#include "s_auth.h"
 #include "send.h"
 
-#include <assert.h>
+/* #include <assert.h> -- Now using assert in ircd_log.h */
 
 /*
  * mr_pass - registration message handler
  */
 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));
 
-  if (EmptyString(password))
-    return need_more_params(cptr, "PASS");
-
-  /* TODO: For protocol negotiation */
-#if 0
-  if (ircd_strcmp(password,"PROT")==0) {
-       /* Do something here */
+  /* 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++] = ' ';
   }
-#endif
-  ircd_strncpy(cli_passwd(cptr), password, PASSWDLEN);
-  return 0;
-}
+  if (len > 0)
+    --len;
+  password[len] = '\0';
 
-#if 0
-/*
- * m_pass
- *
- * parv[0] = sender prefix
- * parv[1] = password
- */
-int m_pass(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
-{
-  char *password = parc > 1 ? parv[1] : 0;
-
-  if (EmptyString(password))
+  if (password[0] == '\0')
     return need_more_params(cptr, "PASS");
 
-  if (!MyConnect(sptr) || (!IsUnknown(cptr) && !IsHandshake(cptr)))
-  {
-    sendto_one(cptr, err_str(ERR_ALREADYREGISTRED), me.name, parv[0]); /* XXX DEAD */
-    return 0;
-  }
-  if (ircd_strcmp("PROTO",password)) {
-       proto_send_supported(sptr);
-       return 0;
-  }
-  ircd_strncpy(cptr->passwd, password, PASSWDLEN);
-  return 0;
+  ircd_strncpy(cli_passwd(cptr), password, PASSWDLEN);
+  return cli_auth(cptr) ? auth_set_password(cli_auth(cptr), password) : 0;
 }
-#endif
-