Merge branch 'vendor/LIBPCAP' and updated build for new version.
[dragonfly.git] / secure / usr.sbin / sshd / auth-passwd-freebsd.c
1 /*
2  * $DragonFly: src/secure/usr.sbin/sshd/auth-passwd-freebsd.c,v 1.2 2006/09/28 18:42:50 corecode Exp $
3  */
4
5 #include <unistd.h>
6
7 #include "buffer.h"
8 #include "key.h"
9 #include "hostfile.h"
10 #include "auth.h"
11
12 int
13 sys_auth_passwd(Authctxt *authctxt, const char *password)
14 {
15         struct passwd *pw = authctxt->pw;
16         char *encrypted_password;
17         char *pw_password = pw->pw_passwd;
18
19         /* Check for users with no password. */
20         if (strcmp(pw_password, "") == 0 && strcmp(password, "") == 0)
21                 return (1);
22
23         /* Encrypt the candidate password using the proper salt. */
24         encrypted_password = crypt(password,
25             (pw_password[0] && pw_password[1]) ? pw_password : "xx");
26
27         /*
28          * Authentication is accepted if the encrypted passwords
29          * are identical.
30          */
31         return (strcmp(encrypted_password, pw_password) == 0);
32 }