From b383164e0644b334735f058361491b24481df5de Mon Sep 17 00:00:00 2001 From: MusiKid Date: Wed, 26 Jan 2022 12:54:12 +0100 Subject: [PATCH] fix: print message when retries limit is reached --- src/pam/main.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/pam/main.cc b/src/pam/main.cc index fbbaf66..f4f77cc 100644 --- a/src/pam/main.cc +++ b/src/pam/main.cc @@ -368,12 +368,24 @@ auto identify(pam_handle_t *pamh, int flags, int argc, const char **argv, } else { try { EnterDevice enter_device; - for (int retries = 0; + int retries; + + // We try to send it + enter_device.send_enter_press(); + + for (retries = 0; retries < MAX_RETRIES && pass_task.wait(DEFAULT_TIMEOUT) == std::future_status::timeout; retries++) { enter_device.send_enter_press(); } + + if (retries == MAX_RETRIES) { + syslog(LOG_WARNING, + "Failed to send enter input before the retries limit"); + conv_function(PAM_ERROR_MSG, S("Failed to send Enter press, waiting " + "for user to press it instead")); + } } catch (std::runtime_error &err) { syslog(LOG_WARNING, "Failed to send enter input: %s", err.what()); conv_function(PAM_ERROR_MSG, S("Failed to send Enter press, waiting "