version 1.3, 1999/09/29 21:14:15 |
version 1.4, 1999/09/29 22:22:16 |
|
|
struct passwd *pw; |
struct passwd *pw; |
char *encrypted_password; |
char *encrypted_password; |
char correct_passwd[200]; |
char correct_passwd[200]; |
|
char *saved_pw_name, *saved_pw_passwd; |
|
|
if (*password == '\0' && options.permit_empty_passwd == 0) |
if (*password == '\0' && options.permit_empty_passwd == 0) |
{ |
{ |
|
|
if (!pw) |
if (!pw) |
return 0; |
return 0; |
|
|
|
saved_pw_name = xstrdup(pw->pw_name); |
|
saved_pw_passwd = xstrdup(pw->pw_passwd); |
|
|
#if defined(KRB4) |
#if defined(KRB4) |
/* Support for Kerberos v4 authentication - Dug Song <dugsong@UMICH.EDU> */ |
/* Support for Kerberos v4 authentication - Dug Song <dugsong@UMICH.EDU> */ |
if (options.kerberos_authentication) |
if (options.kerberos_authentication) |
|
|
#endif /* HAVE_SECURID */ |
#endif /* HAVE_SECURID */ |
|
|
/* Save the encrypted password. */ |
/* Save the encrypted password. */ |
strlcpy(correct_passwd, pw->pw_passwd, sizeof(correct_passwd)); |
strlcpy(correct_passwd, saved_pw_passwd, sizeof(correct_passwd)); |
|
|
#ifdef HAVE_OSF1_C2_SECURITY |
#ifdef HAVE_OSF1_C2_SECURITY |
osf1c2_getprpwent(correct_passwd, pw->pw_name, sizeof(correct_passwd)); |
osf1c2_getprpwent(correct_passwd, saved_pw_name, sizeof(correct_passwd)); |
#else /* HAVE_OSF1_C2_SECURITY */ |
#else /* HAVE_OSF1_C2_SECURITY */ |
/* If we have shadow passwords, lookup the real encrypted password from |
/* If we have shadow passwords, lookup the real encrypted password from |
the shadow file, and replace the saved encrypted password with the |
the shadow file, and replace the saved encrypted password with the |
real encrypted password. */ |
real encrypted password. */ |
#ifdef HAVE_SCO_ETC_SHADOW |
#ifdef HAVE_SCO_ETC_SHADOW |
{ |
{ |
struct pr_passwd *pr = getprpwnam(pw->pw_name); |
struct pr_passwd *pr = getprpwnam(saved_pw_name); |
pr = getprpwnam(pw->pw_name); |
pr = getprpwnam(saved_pw_name); |
if (pr) |
if (pr) |
strlcpy(correct_passwd, pr->ufld.fd_encrypt, sizeof(correct_passwd)); |
strlcpy(correct_passwd, pr->ufld.fd_encrypt, sizeof(correct_passwd)); |
endprpwent(); |
endprpwent(); |
|
|
#else /* HAVE_SCO_ETC_SHADOW */ |
#else /* HAVE_SCO_ETC_SHADOW */ |
#ifdef HAVE_ETC_SHADOW |
#ifdef HAVE_ETC_SHADOW |
{ |
{ |
struct spwd *sp = getspnam(pw->pw_name); |
struct spwd *sp = getspnam(saved_pw_name); |
if (sp) |
if (sp) |
strlcpy(correct_passwd, sp->sp_pwdp, sizeof(correct_passwd)); |
strlcpy(correct_passwd, sp->sp_pwdp, sizeof(correct_passwd)); |
endspent(); |
endspent(); |
|
|
#else /* HAVE_ETC_SHADOW */ |
#else /* HAVE_ETC_SHADOW */ |
#ifdef HAVE_ETC_SECURITY_PASSWD_ADJUNCT |
#ifdef HAVE_ETC_SECURITY_PASSWD_ADJUNCT |
{ |
{ |
struct passwd_adjunct *sp = getpwanam(pw->pw_name); |
struct passwd_adjunct *sp = getpwanam(saved_pw_name); |
if (sp) |
if (sp) |
strnlpy(correct_passwd, sp->pwa_passwd, sizeof(correct_passwd)); |
strnlpy(correct_passwd, sp->pwa_passwd, sizeof(correct_passwd)); |
endpwaent(); |
endpwaent(); |
|
|
return 1; /* The user has no password and an empty password was tried. */ |
return 1; /* The user has no password and an empty password was tried. */ |
} |
} |
|
|
|
xfree(saved_pw_name); |
|
xfree(saved_pw_passwd); |
|
|
/* Encrypt the candidate password using the proper salt. */ |
/* Encrypt the candidate password using the proper salt. */ |
#ifdef HAVE_OSF1_C2_SECURITY |
#ifdef HAVE_OSF1_C2_SECURITY |
encrypted_password = (char *)osf1c2crypt(password, |
encrypted_password = (char *)osf1c2crypt(password, |