diff options
author | Damien Miller <djm@mindrot.org> | 1999-12-21 11:03:09 +0100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 1999-12-21 11:03:09 +0100 |
commit | cb7e5f9ae15a78baee4ad10a102f2d93ab99909a (patch) | |
tree | 093abf64cb1db4a2f1939d3f8b263fc891f72393 /auth-passwd.c | |
parent | - OpenBSD CVS update: (diff) | |
download | openssh-cb7e5f9ae15a78baee4ad10a102f2d93ab99909a.tar.xz openssh-cb7e5f9ae15a78baee4ad10a102f2d93ab99909a.zip |
- Fix DISABLE_SHADOW support
- Allow MD5 passwords even if shadow passwords are disabled
Diffstat (limited to 'auth-passwd.c')
-rw-r--r-- | auth-passwd.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/auth-passwd.c b/auth-passwd.c index d197840e8..fc0809e16 100644 --- a/auth-passwd.c +++ b/auth-passwd.c @@ -11,7 +11,7 @@ #ifndef HAVE_PAM -RCSID("$Id: auth-passwd.c,v 1.9 1999/12/16 04:10:45 damien Exp $"); +RCSID("$Id: auth-passwd.c,v 1.10 1999/12/21 10:03:09 damien Exp $"); #include "packet.h" #include "ssh.h" @@ -68,7 +68,7 @@ auth_password(struct passwd * pw, const char *password) if (strcmp(password, "") == 0 && strcmp(pw->pw_passwd, "") == 0) return 1; -#ifdef HAVE_SHADOW_H +#if defined(HAVE_SHADOW_H) && !defined(DISABLE_SHADOW) spw = getspnam(pw->pw_name); if (spw == NULL) return(0); @@ -94,12 +94,22 @@ auth_password(struct passwd * pw, const char *password) #endif /* HAVE_MD5_PASSWORDS */ /* Authentication is accepted if the encrypted passwords are identical. */ return (strcmp(encrypted_password, spw->sp_pwdp) == 0); -#else /* !HAVE_SHADOW_H */ - encrypted_password = crypt(password, - (pw->pw_passwd[0] && pw->pw_passwd[1]) ? pw->pw_passwd : "xx"); +#else /* defined(HAVE_SHADOW_H) && !defined(DISABLE_SHADOW) */ + + if (strlen(pw->pw_passwd) < 3) + return(0); + +#ifdef HAVE_MD5_PASSWORDS + if (is_md5_salt(pw->pw_passwd)) + encrypted_password = md5_crypt(password, pw->pw_passwd); + else + encrypted_password = crypt(password, pw->pw_passwd); +#else /* HAVE_MD5_PASSWORDS */ + encrypted_password = crypt(password, pw->pw_passwd); +#endif /* HAVE_MD5_PASSWORDS */ /* Authentication is accepted if the encrypted passwords are identical. */ return (strcmp(encrypted_password, pw->pw_passwd) == 0); -#endif /* !HAVE_SHADOW_H */ +#endif /* defined(HAVE_SHADOW_H) && !defined(DISABLE_SHADOW) */ } #endif /* !HAVE_PAM */ |