blob: 924fc03981d3205785b9159d6f766ca7a8a323ee (
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.1 2001/08/19 13:05:57 deraadt Exp $ */
/*
* The /etc/passwd authentication routine.
*/
#include "params.h"
#if AUTH_PASSWD && !VIRTUAL_ONLY
#define _XOPEN_SOURCE
#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, char **mailbox)
{
struct passwd *pw, *result;
if ((pw = getpwnam(user))) *mailbox = user;
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
|