]> jfr.im git - solanum.git/blobdiff - modules/m_pass.c
ircd/packet.c: make function definition consistent with declaration (#301)
[solanum.git] / modules / m_pass.c
index b4bdf7063cd5a2e05b172967a0b3974199fe8e10..d0009de8f78035ec2a7d3b60ecd5a4dcc90af656 100644 (file)
@@ -20,8 +20,6 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
- *
- *  $Id: m_pass.c 3550 2007-08-09 06:47:26Z nenolod $
  */
 
 #include "stdinc.h"
 #include "hash.h"
 #include "s_conf.h"
 
-static int mr_pass(struct Client *, struct Client *, int, const char **);
+static const char pass_desc[] = "Provides the PASS command to authenticate clients and servers";
+
+static void mr_pass(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
 
 struct Message pass_msgtab = {
-       "PASS", 0, 0, 0, MFLG_SLOW | MFLG_UNREG,
+       "PASS", 0, 0, 0, 0,
        {{mr_pass, 2}, mg_reg, mg_ignore, mg_ignore, mg_ignore, mg_reg}
 };
 
 mapi_clist_av1 pass_clist[] = { &pass_msgtab, NULL };
-DECLARE_MODULE_AV1(pass, NULL, NULL, pass_clist, NULL, NULL, "$Revision: 3550 $");
+
+DECLARE_MODULE_AV2(pass, NULL, NULL, pass_clist, NULL, NULL, NULL, NULL, pass_desc);
 
 /*
  * m_pass() - Added Sat, 4 March 1989
@@ -56,27 +57,14 @@ DECLARE_MODULE_AV1(pass, NULL, NULL, pass_clist, NULL, NULL, "$Revision: 3550 $"
  *      parv[2] = "TS" if this server supports TS.
  *      parv[3] = optional TS version field -- needed for TS6
  */
-static int
-mr_pass(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
+static void
+mr_pass(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        char *auth_user, *pass, *buf;
        buf = LOCAL_COPY(parv[1]);
 
-       if(client_p->localClient->passwd)
-       {
-               memset(client_p->localClient->passwd, 0,
-                       strlen(client_p->localClient->passwd));
-               rb_free(client_p->localClient->passwd);
-               client_p->localClient->passwd = NULL;
-       }
-
-       if (client_p->localClient->auth_user)
-       {
-               memset(client_p->localClient->auth_user, 0,
-                      strlen(client_p->localClient->auth_user));
-               rb_free(client_p->localClient->auth_user);
-               client_p->localClient->auth_user = NULL;
-       }
+       if(client_p->localClient->passwd || client_p->localClient->auth_user)
+               return;
 
        if ((pass = strchr(buf, ':')) != NULL)
        {
@@ -95,7 +83,7 @@ mr_pass(struct Client *client_p, struct Client *source_p, int parc, const char *
                client_p->localClient->auth_user = rb_strndup(auth_user, PASSWDLEN);
 
        /* These are for servers only */
-       if(parc > 2 && client_p->user == NULL)
+       if(parc > 2 && client_p->user == NULL && client_p->preClient != NULL)
        {
                /*
                 * It looks to me as if orabidoo wanted to have more
@@ -113,13 +101,11 @@ mr_pass(struct Client *client_p, struct Client *source_p, int parc, const char *
                        /* only mark as TS6 if the SID is valid.. */
                        if(IsDigit(parv[4][0]) && IsIdChar(parv[4][1]) &&
                           IsIdChar(parv[4][2]) && parv[4][3] == '\0' &&
-                          EmptyString(client_p->id))
+                          EmptyString(client_p->preClient->id))
                        {
                                client_p->localClient->caps |= CAP_TS6;
-                               strcpy(client_p->id, parv[4]);
+                               rb_strlcpy(client_p->preClient->id, parv[4], sizeof(client_p->preClient->id));
                        }
                }
        }
-
-       return 0;
 }