blob: d10b3a57b9011c604e5ad0c56af9118bbed70053 (
plain) (
blame)
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
|
/* OPENBSD ORIGINAL: lib/libc/crypt/cryptutil.c */
#include "includes.h"
#include <errno.h>
#ifdef HAVE_CRYPT_H
#include <crypt.h>
#endif
#include <string.h>
#include <unistd.h>
int
crypt_checkpass(const char *pass, const char *goodhash)
{
char *c;
if (goodhash == NULL)
goto fail;
/* empty password */
if (strlen(goodhash) == 0 && strlen(pass) == 0)
return 0;
c = crypt(pass, goodhash);
if (c == NULL)
goto fail;
if (strcmp(c, goodhash) == 0)
return 0;
fail:
errno = EACCES;
return -1;
}
|