aboutsummaryrefslogtreecommitdiffstats
path: root/swaylock/password.c
diff options
context:
space:
mode:
Diffstat (limited to 'swaylock/password.c')
-rw-r--r--swaylock/password.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/swaylock/password.c b/swaylock/password.c
index bb32286e..7c686b34 100644
--- a/swaylock/password.c
+++ b/swaylock/password.c
@@ -53,15 +53,15 @@ static bool attempt_password(struct swaylock_password *pw) {
53 // TODO: only call pam_start once. keep the same handle the whole time 53 // TODO: only call pam_start once. keep the same handle the whole time
54 if ((pam_err = pam_start("swaylock", username, 54 if ((pam_err = pam_start("swaylock", username,
55 &local_conversation, &local_auth_handle)) != PAM_SUCCESS) { 55 &local_conversation, &local_auth_handle)) != PAM_SUCCESS) {
56 wlr_log(L_ERROR, "PAM returned error %d", pam_err); 56 wlr_log(WLR_ERROR, "PAM returned error %d", pam_err);
57 } 57 }
58 if ((pam_err = pam_authenticate(local_auth_handle, 0)) != PAM_SUCCESS) { 58 if ((pam_err = pam_authenticate(local_auth_handle, 0)) != PAM_SUCCESS) {
59 wlr_log(L_ERROR, "pam_authenticate failed"); 59 wlr_log(WLR_ERROR, "pam_authenticate failed");
60 goto fail; 60 goto fail;
61 } 61 }
62 // TODO: only call pam_end once we succeed at authing. refresh tokens beforehand 62 // TODO: only call pam_end once we succeed at authing. refresh tokens beforehand
63 if ((pam_err = pam_end(local_auth_handle, pam_err)) != PAM_SUCCESS) { 63 if ((pam_err = pam_end(local_auth_handle, pam_err)) != PAM_SUCCESS) {
64 wlr_log(L_ERROR, "pam_end failed"); 64 wlr_log(WLR_ERROR, "pam_end failed");
65 goto fail; 65 goto fail;
66 } 66 }
67 clear_password_buffer(pw); 67 clear_password_buffer(pw);
@@ -95,9 +95,26 @@ void swaylock_handle_key(struct swaylock_state *state,
95 switch (keysym) { 95 switch (keysym) {
96 case XKB_KEY_KP_Enter: /* fallthrough */ 96 case XKB_KEY_KP_Enter: /* fallthrough */
97 case XKB_KEY_Return: 97 case XKB_KEY_Return:
98 if (state->args.ignore_empty && state->password.len == 0) {
99 break;
100 }
101
98 state->auth_state = AUTH_STATE_VALIDATING; 102 state->auth_state = AUTH_STATE_VALIDATING;
99 damage_state(state); 103 damage_state(state);
100 wl_display_roundtrip(state->display); 104 while (wl_display_dispatch(state->display) != -1 && state->run_display) {
105 bool ok = 1;
106 struct swaylock_surface *surface;
107 wl_list_for_each(surface, &state->surfaces, link) {
108 if (surface->dirty) {
109 ok = 0;
110 }
111 }
112 if (ok) {
113 break;
114 }
115 }
116 wl_display_flush(state->display);
117
101 if (attempt_password(&state->password)) { 118 if (attempt_password(&state->password)) {
102 state->run_display = false; 119 state->run_display = false;
103 break; 120 break;