Fix resetting the password after failed authentications
Patch status: merged
Patch by Sebastian Ullrich
Long description:
This has been broken by commit 661344.
To apply this patch, use:
curl http://cr.i3wm.org/patch/119/raw.patch | git am
b/i3lock.c
14 |
@@ -172,6 +172,19 @@ static void clear_pam_wrong(EV_P_ ev_timer *w, int revents) { |
15 |
clear_pam_wrong_timeout = NULL; |
16 |
} |
17 |
|
18 |
+static void clear_input(void) { |
19 |
+ input_position = 0; |
20 |
+ clear_password_memory(); |
21 |
+ password[input_position] = '\0'; |
22 |
+ |
23 |
+ /* Hide the unlock indicator after a bit if the password buffer is |
24 |
+ * empty. */ |
25 |
+ start_clear_indicator_timeout(); |
26 |
+ unlock_state = STATE_BACKSPACE_ACTIVE; |
27 |
+ redraw_screen(); |
28 |
+ unlock_state = STATE_KEY_PRESSED; |
29 |
+} |
30 |
+ |
31 |
static void input_done(void) { |
32 |
if (clear_pam_wrong_timeout) { |
33 |
ev_timer_stop(main_loop, clear_pam_wrong_timeout); |
34 |
@@ -192,6 +205,7 @@ static void input_done(void) { |
35 |
fprintf(stderr, "Authentication failure\n"); |
36 |
|
37 |
pam_state = STATE_PAM_WRONG; |
38 |
+ clear_input(); |
39 |
redraw_screen(); |
40 |
|
41 |
/* Clear this state after 2 seconds (unless the user enters another |
42 |
@@ -257,20 +271,15 @@ static void handle_key_press(xcb_key_press_event_t *event) { |
43 |
unlock_state = STATE_KEY_PRESSED; |
44 |
redraw_screen(); |
45 |
input_done(); |
46 |
+ return; |
47 |
+ |
48 |
case XKB_KEY_u: |
49 |
- if (!ctrl) |
50 |
- break; |
51 |
- case XKB_KEY_Escape: |
52 |
- input_position = 0; |
53 |
- clear_password_memory(); |
54 |
- password[input_position] = '\0'; |
55 |
+ if (ctrl) |
56 |
+ clear_input(); |
57 |
+ return; |
58 |
|
59 |
- /* Hide the unlock indicator after a bit if the password buffer is |
60 |
- * empty. */ |
61 |
- start_clear_indicator_timeout(); |
62 |
- unlock_state = STATE_BACKSPACE_ACTIVE; |
63 |
- redraw_screen(); |
64 |
- unlock_state = STATE_KEY_PRESSED; |
65 |
+ case XKB_KEY_Escape: |
66 |
+ clear_input(); |
67 |
return; |
68 |
|
69 |
case XKB_KEY_BackSpace: |