Log PAM authentication procedure in logfile.

This commit is contained in:
Jan Christoph Terasa 2019-02-19 16:24:55 +01:00
parent cb161f4911
commit 93e092db13

View File

@ -461,6 +461,7 @@ int auth_verify_password_pam(LOGBOOK *lbs, const char *user, const char *passwor
{ {
pam_handle_t *pamh; pam_handle_t *pamh;
int retval; int retval;
char str[256];
int verified = 0; int verified = 0;
/* use our custom conversation function */ /* use our custom conversation function */
@ -473,6 +474,8 @@ int auth_verify_password_pam(LOGBOOK *lbs, const char *user, const char *passwor
elog_pam_conv.appdata_ptr = password; elog_pam_conv.appdata_ptr = password;
/* start PAM auth procedure */ /* start PAM auth procedure */
sprintf(str, "[PAM] Starting authentication for user %s", user);
write_logfile(lbs, str);
retval = pam_start("elogd", user, &elog_pam_conv, &pamh); retval = pam_start("elogd", user, &elog_pam_conv, &pamh);
/* if we can use PAM, try to authenticate using our conversation method */ /* if we can use PAM, try to authenticate using our conversation method */
@ -487,6 +490,12 @@ int auth_verify_password_pam(LOGBOOK *lbs, const char *user, const char *passwor
verified = (retval == PAM_SUCCESS); verified = (retval == PAM_SUCCESS);
if(verified)
sprintf(str, "[PAM] Authentication successful for user %s", user);
else
sprintf(str, "[PAM] Authentication not successful for user %s", user);
write_logfile(lbs, str);
if(pam_end(pamh, retval) != PAM_SUCCESS) { if(pam_end(pamh, retval) != PAM_SUCCESS) {
pamh = NULL; pamh = NULL;
strlcpy(error_str, "PAM: Error releasing authenticator", error_size); strlcpy(error_str, "PAM: Error releasing authenticator", error_size);