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 bool auth(const char *user
, struct timespec
*timeout
)
43 /* format the prompt */
44 if (asprintf(&msg
, "%s's Password: ", user
) < 0)
47 if ((pwd
= prompt_echo_off(msg
, timeout
)) == NULL
)
50 /* get the shadow password */
51 if ((spw
= getspnam(user
)) == NULL
)
54 /* hash the password */
55 if ((cryptpw
= crypt(pwd
, spw
->sp_pwdp
)) == NULL
) {
56 perror("vlock-auth: crypt()");
60 result
= (strcmp(cryptpw
, spw
->sp_pwdp
) == 0);
64 fprintf(stderr
, "vlock-auth: Authentication error\n");
68 /* deallocate shadow resources */
71 /* free the password */