2 * cmd_pas2 - MD5 APOP style auth keyed off of the hash of the password
3 * plus a nonce displayed at the login banner.
5 * Copyright (c) 1994-2009 by the citadel.org team
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #if TIME_WITH_SYS_TIME
27 # include <sys/time.h>
31 # include <sys/time.h>
40 #include <libcitadel.h>
43 #include "citserver.h"
49 #include "ctdl_module.h"
52 void cmd_pas2(char *argbuf)
55 char hexstring[MD5_HEXSTRING_SIZE];
58 if (!strcmp(CC->curr_user, NLI))
60 cprintf("%d You must enter a user with the USER command first.\n", ERROR + USERNAME_REQUIRED);
66 cprintf("%d Already logged in.\n", ERROR + ALREADY_LOGGED_IN);
70 extract_token(pw, argbuf, 0, '|', sizeof pw);
72 if (getuser(&CC->user, CC->curr_user))
74 cprintf("%d Unable to find user record for %s.\n", ERROR + NO_SUCH_USER, CC->curr_user);
79 strproc(CC->user.password);
81 if (strlen(pw) != (MD5_HEXSTRING_SIZE-1))
83 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);
87 make_apop_string(CC->user.password, CC->cs_nonce, hexstring, sizeof hexstring);
89 if (!strcmp(hexstring, pw))
96 cprintf("%d Wrong password.\n", ERROR + PASSWORD_REQUIRED);
105 CTDL_MODULE_INIT(pas2)
109 CtdlRegisterProtoHook(cmd_pas2, "PAS2", "APOP-based login");
112 /* return our Subversion id for the Log */