]> code.citadel.org Git - citadel.git/blobdiff - citadel/serv_pas2.c
mk_module_init.sh now tests to see if echo supports -e and -E
[citadel.git] / citadel / serv_pas2.c
index b988af94e81b17f24a8d0a9053fa706638d25b1a..fd7fbf246dc94513c684bffe5a28ca3264ccfa9b 100644 (file)
 #include <ctype.h>
 #include <string.h>
 #include <errno.h>
-#include "sysdep_decls.h"
 #include "citadel.h"
 #include "server.h"
 #include "citserver.h"
 #include "support.h"
-#include "dynloader.h"
 #include "user_ops.h"
 #include "md5.h"
 #include "tools.h"
 
 
+#include "ctdl_module.h"
+
+
 void cmd_pas2(char *argbuf)
 {
-       char pw[SIZ];
+       char pw[256];
        char hexstring[MD5_HEXSTRING_SIZE];
        
 
        if (!strcmp(CC->curr_user, NLI))
        {
-               cprintf("%d You must enter a user with the USER command first.\n", ERROR);
+               cprintf("%d You must enter a user with the USER command first.\n", ERROR + USERNAME_REQUIRED);
                return;
        }
        
        if (CC->logged_in)
        {
-               cprintf("%d Already logged in.\n", ERROR);
+               cprintf("%d Already logged in.\n", ERROR + ALREADY_LOGGED_IN);
                return;
        }
        
-       extract(pw, argbuf, 0);
+       extract_token(pw, argbuf, 0, '|', sizeof pw);
        
-       if (getuser(&CC->usersupp, CC->curr_user))
+       if (getuser(&CC->user, CC->curr_user))
        {
-               cprintf("%d Unable to find user record for %s.\n", ERROR, CC->curr_user);
+               cprintf("%d Unable to find user record for %s.\n", ERROR + NO_SUCH_USER, CC->curr_user);
                return;
        }
        
        strproc(pw);
-       strproc(CC->usersupp.password);
+       strproc(CC->user.password);
        
        if (strlen(pw) != (MD5_HEXSTRING_SIZE-1))
        {
-               cprintf("%d Auth string of length %ld is the wrong length (should be %d).\n", ERRORstrlen(pw), MD5_HEXSTRING_SIZE-1);
+               cprintf("%d Auth string of length %ld is the wrong length (should be %d).\n", ERROR + ILLEGAL_VALUE, (long)strlen(pw), MD5_HEXSTRING_SIZE-1);
                return;
        }
        
-       make_apop_string(CC->usersupp.password, CC->cs_nonce, hexstring);
+       make_apop_string(CC->user.password, CC->cs_nonce, hexstring, sizeof hexstring);
        
        if (!strcmp(hexstring, pw))
        {
@@ -76,7 +77,7 @@ void cmd_pas2(char *argbuf)
        }
        else
        {
-               cprintf("%d Wrong password.\n", ERROR);
+               cprintf("%d Wrong password.\n", ERROR + PASSWORD_REQUIRED);
                return;
        }
 }
@@ -85,8 +86,10 @@ void cmd_pas2(char *argbuf)
 
 
 
-char *Dynamic_Module_Init(void)
+CTDL_MODULE_INIT(pas2)
 {
         CtdlRegisterProtoHook(cmd_pas2, "PAS2", "APOP-based login");
+
+       /* return our Subversion id for the Log */
         return "$Id$";
 }