i3lock-color

The world's most popular non-default computer lockscreen.
Index Commits Files Refs README LICENSE
commit 656fa39f82107441c978a9a7397ebbea58e06a0d
parent 1b9b2bd7f8184fdaf554457c4a84f37eab94378e
Author: Michael Stapelberg <stapelberg@users.noreply.github.com>
Date:   Mon, 20 Jan 2020 22:49:10 +0100

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

Thanks to joanbm for an incredible bug report.

fixes #254
Diffstat:
Mi3lock.c | 9++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/i3lock.c b/i3lock.c
@@ -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;
     }