- if (strcmp(password, "") == 0 && strcmp(pw_password, "") == 0)
- return 1;
-
-#if defined(HAVE_SHADOW_H) && !defined(DISABLE_SHADOW)
- spw = getspnam(pw->pw_name);
- if (spw != NULL)
- {
- /* Check for users with no password. */
- if (strcmp(password, "") == 0 && strcmp(spw->sp_pwdp, "") == 0)
- return 1;
-
- pw_password = spw->sp_pwdp;
- }
-#endif /* defined(HAVE_SHADOW_H) && !defined(DISABLE_SHADOW) */
-#if defined(HAVE_GETPWANAM) && !defined(DISABLE_SHADOW)
- if (issecure() && (spw = getpwanam(pw->pw_name)) != NULL)
- {
- /* Check for users with no password. */
- if (strcmp(password, "") == 0 && strcmp(spw->pwa_passwd, "") == 0)
- return 1;
-
- pw_password = spw->pwa_passwd;
- }
-#endif /* defined(HAVE_GETPWANAM) && !defined(DISABLE_SHADOW) */
-
- if (pw_password[0] != '\0')
- salt = pw_password;
- else
- salt = "xx";
-
-#ifdef HAVE_MD5_PASSWORDS
- if (is_md5_salt(salt))
- encrypted_password = md5_crypt(password, salt);
- else
- encrypted_password = crypt(password, salt);
-#else /* HAVE_MD5_PASSWORDS */
-# ifdef HAVE_HPUX_TRUSTED_SYSTEM_PW
- encrypted_password = bigcrypt(password, salt);
-# else
- encrypted_password = crypt(password, salt);
-# endif /* HAVE_HPUX_TRUSTED_SYSTEM_PW */
-#endif /* HAVE_MD5_PASSWORDS */
-
- /* Authentication is accepted if the encrypted passwords are identical. */
+ if (strcmp(pw_password, "") == 0 && strcmp(password, "") == 0)
+ return (1);
+
+ /* Encrypt the candidate password using the proper salt. */
+ encrypted_password = xcrypt(password,
+ (pw_password[0] && pw_password[1]) ? pw_password : "xx");
+
+ /*
+ * Authentication is accepted if the encrypted passwords
+ * are identical.
+ */