1 /* auth-shadow.c -- shadow authentification routine for vlock,
2 * the VT locking program for linux
4 * This program is copyright (C) 2007 Frank Benkstein, and is free
5 * software which is freely distributable under the terms of the
6 * GNU General Public License version 2, included as the file COPYING in this
7 * distribution. It is NOT public domain software, and any
8 * redistribution not permitted by the GNU General Public License is
9 * expressly forbidden without prior written permission from
35 int auth(const char *user
, const struct timespec
*timeout
) {
42 /* format the prompt */
43 (void) asprintf(&msg
, "%s's Password: ", user
);
45 if ((pwd
= prompt_echo_off(msg
, timeout
)) == NULL
)
48 /* get the shadow password */
49 if ((spw
= getspnam(user
)) == NULL
)
52 /* hash the password */
53 if ((cryptpw
= crypt(pwd
, spw
->sp_pwdp
)) == NULL
) {
54 perror("vlock-auth: crypt()");
58 result
= (strcmp(cryptpw
, spw
->sp_pwdp
) == 0);
62 fprintf(stderr
, "vlock-auth: Authentication error\n");
66 /* deallocate shadow resources */
73 /* free the password */