version 1.28, 2003/07/22 13:35:22 |
version 1.29, 2003/08/26 09:58:43 |
|
|
auth_password(Authctxt *authctxt, const char *password) |
auth_password(Authctxt *authctxt, const char *password) |
{ |
{ |
struct passwd * pw = authctxt->pw; |
struct passwd * pw = authctxt->pw; |
|
int ok = authctxt->valid; |
|
|
/* deny if no user. */ |
/* deny if no user. */ |
if (pw == NULL) |
if (pw == NULL) |
return 0; |
return 0; |
if (pw->pw_uid == 0 && options.permit_root_login != PERMIT_YES) |
if (pw->pw_uid == 0 && options.permit_root_login != PERMIT_YES) |
return 0; |
ok = 0; |
if (*password == '\0' && options.permit_empty_passwd == 0) |
if (*password == '\0' && options.permit_empty_passwd == 0) |
return 0; |
return 0; |
#ifdef KRB5 |
#ifdef KRB5 |
if (options.kerberos_authentication == 1) { |
if (options.kerberos_authentication == 1) { |
int ret = auth_krb5_password(authctxt, password); |
int ret = auth_krb5_password(authctxt, password); |
if (ret == 1 || ret == 0) |
if (ret == 1 || ret == 0) |
return ret; |
return ret && ok; |
/* Fall back to ordinary passwd authentication. */ |
/* Fall back to ordinary passwd authentication. */ |
} |
} |
#endif |
#endif |
|
|
(char *)password) == 0) |
(char *)password) == 0) |
return 0; |
return 0; |
else |
else |
return 1; |
return ok; |
#else |
#else |
/* Check for users with no password. */ |
/* Check for users with no password. */ |
if (strcmp(password, "") == 0 && strcmp(pw->pw_passwd, "") == 0) |
if (strcmp(password, "") == 0 && strcmp(pw->pw_passwd, "") == 0) |
return 1; |
return ok; |
else { |
else { |
/* Encrypt the candidate password using the proper salt. */ |
/* Encrypt the candidate password using the proper salt. */ |
char *encrypted_password = crypt(password, |
char *encrypted_password = crypt(password, |
|
|
* Authentication is accepted if the encrypted passwords |
* Authentication is accepted if the encrypted passwords |
* are identical. |
* are identical. |
*/ |
*/ |
return (strcmp(encrypted_password, pw->pw_passwd) == 0); |
return (strcmp(encrypted_password, pw->pw_passwd) == 0) && ok; |
} |
} |
#endif |
#endif |
} |
} |