diff common-session.c @ 676:0edf08895a33

Return immediate success for blank passwords if allowed
author Matt Johnston <matt@ucc.asn.au>
date Wed, 09 May 2012 22:37:04 +0800
parents a98a2138364a
children 2e573f39b88e
line wrap: on
line diff
--- a/common-session.c	Wed May 09 21:09:34 2012 +0800
+++ b/common-session.c	Wed May 09 22:37:04 2012 +0800
@@ -453,6 +453,16 @@
 	ses.authstate.pw_name = m_strdup(pw->pw_name);
 	ses.authstate.pw_dir = m_strdup(pw->pw_dir);
 	ses.authstate.pw_shell = m_strdup(pw->pw_shell);
-	ses.authstate.pw_passwd = m_strdup(pw->pw_passwd);
+	{
+		char *passwd_crypt = pw->pw_passwd;
+#ifdef HAVE_SHADOW_H
+		/* get the shadow password if possible */
+		struct spwd *spasswd = getspnam(ses.authstate.pw_name);
+		if (spasswd && spasswd->sp_pwdp) {
+			passwd_crypt = spasswd->sp_pwdp;
+		}
+#endif
+		ses.authstate.pw_passwd = m_strdup(passwd_crypt);
+	}
 }