diff options
| author | Simon Ser <contact@emersion.fr> | 2025-03-12 01:31:21 +0100 |
|---|---|---|
| committer | Kenny Levinsen <kl@kl.wtf> | 2025-03-12 11:17:13 +0100 |
| commit | 34e0aabc51074a2476d27148c4f755d558da3ec9 (patch) | |
| tree | 1a079864dd64297dee9d35f39ad8f59c2624b569 /main.c | |
| parent | a439abb8c991de1c5bbc8d5c105b56599abb9e06 (diff) | |
Better handle subprocess crashes
On my machine EOF doesn't trigger POLLHUP (not sure why), instead
read() returns zero. It just prints the following message in a
loop:
[comm.c:101] Failed to read pw result: Success
Better handle this case in read_comm_reply() by making a difference
between a failed read() and a failed authentication.
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 22 |
1 files changed, 14 insertions, 8 deletions
@@ -1035,17 +1035,23 @@ static void display_in(int fd, short mask, void *data) { } static void comm_in(int fd, short mask, void *data) { - if (read_comm_reply()) { - // Authentication succeeded - state.run_display = false; + if (mask & POLLIN) { + bool auth_success = false; + if (!read_comm_reply(&auth_success)) { + exit(EXIT_FAILURE); + } + if (auth_success) { + // Authentication succeeded + state.run_display = false; + } else { + state.auth_state = AUTH_STATE_INVALID; + schedule_auth_idle(&state); + ++state.failed_attempts; + damage_state(&state); + } } else if (mask & (POLLHUP | POLLERR)) { swaylock_log(LOG_ERROR, "Password checking subprocess crashed; exiting."); exit(EXIT_FAILURE); - } else { - state.auth_state = AUTH_STATE_INVALID; - schedule_auth_idle(&state); - ++state.failed_attempts; - damage_state(&state); } } |
