blob: d0503ac7aa784f45d1c0a16cb4baf586f39d0a6b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
/* $OpenBSD: auth_passwd.c,v 1.2 2001/09/21 20:22:06 camield Exp $ */
/*
* The /etc/passwd authentication routine.
*/
#include "params.h"
#if AUTH_PASSWD && !VIRTUAL_ONLY
#define _XOPEN_SOURCE 4
#define _XOPEN_SOURCE_EXTENDED
#define _XOPEN_VERSION 4
#define _XPG4_2
#include <unistd.h>
#include <string.h>
#include <pwd.h>
#include <sys/types.h>
struct passwd *auth_userpass(char *user, char *pass, int *known)
{
struct passwd *pw, *result;
*known = (pw = getpwnam(user)) != NULL;
endpwent();
result = NULL;
if (!pw || !*pw->pw_passwd ||
*pw->pw_passwd == '*' || *pw->pw_passwd == '!')
crypt(pass, AUTH_DUMMY_SALT);
else
if (!strcmp(crypt(pass, pw->pw_passwd), pw->pw_passwd))
result = pw;
if (pw)
memset(pw->pw_passwd, 0, strlen(pw->pw_passwd));
return result;
}
#endif
|