From 6089ba6f40b1411ab3eea0a9472ddc94151b2799 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Fri, 24 Jan 2020 00:48:56 +0100 Subject: [PATCH] pam: Better debug when timeout is invalid --- pam/pam_fprintd.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pam/pam_fprintd.c b/pam/pam_fprintd.c index ab17282..015d6a8 100644 --- a/pam/pam_fprintd.c +++ b/pam/pam_fprintd.c @@ -45,6 +45,7 @@ #define DEFAULT_MAX_TRIES 3 #define DEFAULT_TIMEOUT 30 +#define MIN_TIMEOUT 10 #define DEBUG_MATCH "debug=" #define MAX_TRIES_MATCH "max-tries=" @@ -654,10 +655,15 @@ PAM_EXTERN int pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, pam_syslog (pamh, LOG_DEBUG, "max_tries specified as: %d", max_tries); } else if (str_has_prefix (argv[i], TIMEOUT_MATCH) && strlen(argv[i]) <= strlen (TIMEOUT_MATCH) + 2) { timeout = atoi (argv[i] + strlen (TIMEOUT_MATCH)); - if (timeout < 10) - timeout = DEFAULT_TIMEOUT; - if (debug) - pam_syslog (pamh, LOG_DEBUG, "timeout specified as: %d", timeout); + if (timeout < MIN_TIMEOUT) { + if (debug) { + pam_syslog (pamh, LOG_DEBUG, "timeout %d secs too low, using %d", + timeout, MIN_TIMEOUT); + } + timeout = MIN_TIMEOUT; + } else if (debug) { + pam_syslog (pamh, LOG_DEBUG, "timeout specified as: %d secs", timeout); + } } } }