fix: pam_end in cleanup in main, not in event loop (#257)

Thanks to joanbm for an incredible bug report.

fixes #254
pull/259/head
Michael Stapelberg 2020-01-20 22:49:10 +01:00 committed by GitHub
parent 1b9b2bd7f8
commit 656fa39f82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -64,6 +64,7 @@ xcb_window_t win;
static xcb_cursor_t cursor;
#ifndef __OpenBSD__
static pam_handle_t *pam_handle;
static bool pam_cleanup;
#endif
int input_position = 0;
/* Holds the password you enter (in UTF-8). */
@ -298,7 +299,7 @@ static void input_done(void) {
* credentials like kerberos /tmp/krb5cc_pam_* files which may of been left behind if the
* refresh of the credentials failed. */
pam_setcred(pam_handle, PAM_REFRESH_CRED);
pam_end(pam_handle, PAM_SUCCESS);
pam_cleanup = true;
ev_break(EV_DEFAULT, EVBREAK_ALL);
return;
@ -1296,6 +1297,12 @@ int main(int argc, char *argv[]) {
ev_invoke(main_loop, xcb_check, 0);
ev_loop(main_loop, 0);
#ifndef __OpenBSD__
if (pam_cleanup) {
pam_end(pam_handle, PAM_SUCCESS);
}
#endif
if (stolen_focus == XCB_NONE) {
return 0;
}