fix: print message when retries limit is reached

This commit is contained in:
MusiKid 2022-01-26 12:54:12 +01:00 committed by musikid
parent ab79c5b674
commit b383164e06
No known key found for this signature in database
GPG key ID: 7567D43648C6E2F4

View file

@ -368,12 +368,24 @@ auto identify(pam_handle_t *pamh, int flags, int argc, const char **argv,
} else { } else {
try { try {
EnterDevice enter_device; 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 && retries < MAX_RETRIES &&
pass_task.wait(DEFAULT_TIMEOUT) == std::future_status::timeout; pass_task.wait(DEFAULT_TIMEOUT) == std::future_status::timeout;
retries++) { retries++) {
enter_device.send_enter_press(); 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) { } catch (std::runtime_error &err) {
syslog(LOG_WARNING, "Failed to send enter input: %s", err.what()); syslog(LOG_WARNING, "Failed to send enter input: %s", err.what());
conv_function(PAM_ERROR_MSG, S("Failed to send Enter press, waiting " conv_function(PAM_ERROR_MSG, S("Failed to send Enter press, waiting "