From 5b3656782093955b4a946f9837582debfb5ce991 Mon Sep 17 00:00:00 2001 From: Klas Lindfors Date: Thu, 16 Jun 2016 10:07:56 +0200 Subject: [PATCH] cleanup debug_file after we're done --- pam_yubico.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/pam_yubico.c b/pam_yubico.c index 55062c8..4a23922 100644 --- a/pam_yubico.c +++ b/pam_yubico.c @@ -848,12 +848,12 @@ pam_sm_authenticate (pam_handle_t * pamh, if (cfg->mode == CHRESP) { #if HAVE_CR - return do_challenge_response(pamh, cfg, user); + retval = do_challenge_response(pamh, cfg, user); #else DBG ("no support for challenge/response"); retval = PAM_AUTH_ERR; - goto done; #endif + goto done; } if (cfg->try_first_pass || cfg->use_first_pass) @@ -1134,6 +1134,11 @@ done: free((char*)msg[0].msg); } + if(cfg->debug_file != stderr && cfg->debug_file != stdout) + { + fclose(cfg->debug_file); + } + return retval; } @@ -1156,10 +1161,17 @@ pam_sm_acct_mgmt(pam_handle_t *pamh, int flags, int argc, const char **argv) parse_cfg (flags, argc, argv, cfg); if (rc == PAM_SUCCESS && retval == PAM_SUCCESS) { DBG ("pam_sm_acct_mgmt returing PAM_SUCCESS"); - return PAM_SUCCESS; + retval = PAM_SUCCESS; + } else { + DBG ("pam_sm_acct_mgmt returing PAM_AUTH_ERR:%d", rc); + retval = PAM_AUTH_ERR; } - DBG ("pam_sm_acct_mgmt returing PAM_AUTH_ERR:%d", rc); - return PAM_AUTH_ERR; + + if(cfg->debug_file != stderr && cfg->debug_file != stdout) { + fclose(cfg->debug_file); + } + + return retval; } PAM_EXTERN int