#include "includes.h"
-#ifndef HAVE_LIBPAM
+#ifndef USE_PAM
RCSID("$Id$");
#include "xmalloc.h"
#ifdef HAVE_SHADOW_H
-#include <shadow.h>
-#endif
-
-#ifdef HAVE_MD5_PASSWORDS
-#include "md5crypt.h"
+# include <shadow.h>
#endif
+#if defined(HAVE_CRYPT_H) && !defined(CRYPT_H_BREAKS_BUILD)
+# include <crypt.h>
+#endif /* defined(HAVE_CRYPT_H) && !defined(CRYPT_H_BREAKS_BUILD) */
+#if defined(HAVE_MD5_PASSWORDS) && !defined(HAVE_MD5_CRYPT)
+# include "md5crypt.h"
+#endif /* defined(HAVE_MD5_PASSWORDS) && !defined(HAVE_MD5_CRYPT) */
/*
* Tries to authenticate the user using password. Returns true if
struct spwd *spw;
#endif
+ /* deny if no user. */
+ if (pw == NULL)
+ return 0;
if (pw->pw_uid == 0 && options.permit_root_login == 2)
return 0;
if (*password == '\0' && options.permit_empty_passwd == 0)
return 0;
- /* deny if no user. */
- if (pw == NULL)
- return 0;
#ifdef SKEY
if (options.skey_authentication == 1) {
#if defined(HAVE_SHADOW_H) && !defined(DISABLE_SHADOW)
spw = getspnam(pw->pw_name);
- if (spw == NULL)
- return(0);
-
- /* Check for users with no password. */
- if (strcmp(password, "") == 0 && strcmp(spw->sp_pwdp, "") == 0)
- return 1;
+ 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;
+ pw_password = spw->sp_pwdp;
+ }
#endif /* defined(HAVE_SHADOW_H) && !defined(DISABLE_SHADOW) */
if (pw_password[0] != '\0')
/* Authentication is accepted if the encrypted passwords are identical. */
return (strcmp(encrypted_password, pw_password) == 0);
}
-#endif /* !HAVE_LIBPAM */
+#endif /* !USE_PAM */