diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2019-01-22 17:00:14 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2019-01-22 17:04:16 +0100 |
commit | db5a6daa7f6fe92cdb70e53aec2f3717b6892b2a (patch) | |
tree | ea86b8ad680dec04a5b3e0f3dfe6574775d36c0b /loginutils | |
parent | 414be6c1112f8fa5d444f902ca0061f631a46522 (diff) |
login: close PAM session on errors as well, not only on success
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'loginutils')
-rw-r--r-- | loginutils/login.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/loginutils/login.c b/loginutils/login.c index 25bb5203b..4df651cc6 100644 --- a/loginutils/login.c +++ b/loginutils/login.c @@ -245,7 +245,9 @@ static void login_pam_end(pam_handle_t *pamh) pam_strerror(pamh, pamret), pamret); } } -#endif /* ENABLE_PAM */ +#else +# define login_pam_end(pamh) ((void)0) +#endif static void get_username_or_die(char *buf, int size_buf) { @@ -471,6 +473,7 @@ int login_main(int argc UNUSED_PARAM, char **argv) * to know _why_ login failed */ syslog(LOG_WARNING, "pam_%s call failed: %s (%d)", failed_msg, pam_strerror(pamh, pamret), pamret); + login_pam_end(pamh); safe_strncpy(username, "UNKNOWN", sizeof(username)); #else /* not PAM */ pw = getpwnam(username); @@ -528,8 +531,7 @@ int login_main(int argc UNUSED_PARAM, char **argv) if (child_pid < 0) bb_perror_msg("vfork"); else { - if (safe_waitpid(child_pid, NULL, 0) == -1) - bb_perror_msg("waitpid"); + wait_for_exitstatus(child_pid); update_utmp_DEAD_PROCESS(child_pid); } IF_PAM(login_pam_end(pamh);) |