build - Rewire secure, remove conflicts from libmd, libcrypt
[dragonfly.git] / 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 <string.h>
6 #include <unistd.h>
7
8 #include "buffer.h"
9 #include "key.h"
10 #include "hostfile.h"
11 #include "auth.h"
12
13 int
14 sys_auth_passwd(Authctxt *authctxt, const char *password)
15 {
16         struct passwd *pw = authctxt->pw;
17         char *encrypted_password;
18         char *pw_password = pw->pw_passwd;
19
20         /* Check for users with no password. */
21         if (strcmp(pw_password, "") == 0 && strcmp(password, "") == 0)
22                 return (1);
23
24         /* Encrypt the candidate password using the proper salt. */
25         encrypted_password = crypt(password,
26             (pw_password[0] && pw_password[1]) ? pw_password : "xx");
27
28         /*
29          * Authentication is accepted if the encrypted passwords
30          * are identical.
31          */
32         return (strcmp(encrypted_password, pw_password) == 0);
33 }