From 00a14d873ba92dfaf90fe82cd6d0c8f7e6cc0744 Mon Sep 17 00:00:00 2001 From: Didier Raboud Date: Mon, 14 May 2012 17:29:56 +0200 Subject: [PATCH] pam: Make max_tries and timeout arguments. --- pam/pam_fprintd.c | 30 +++++++++++++++++++++++------- 1 files changed, 23 insertions(+), 7 deletions(-) diff --git a/pam/pam_fprintd.c b/pam/pam_fprintd.c index 52fce32..1b38c2c 100644 --- a/pam/pam_fprintd.c +++ b/pam/pam_fprintd.c @@ -39,8 +39,8 @@ #include "fingerprint-strings.h" -#define MAX_TRIES 3 -#define TIMEOUT 30 +#define DEFAULT_MAX_TRIES 3 +#define DEFAULT_TIMEOUT 30 #define D(pamh, ...) { \ if (debug) { \ @@ -53,6 +53,8 @@ static gboolean debug = FALSE; +static guint max_tries = DEFAULT_MAX_TRIES; +static guint timeout = DEFAULT_TIMEOUT; static gboolean send_info_msg(pam_handle_t *pamh, const char *msg) { @@ -271,7 +273,7 @@ static int do_verify(GMainLoop *loop, pam_handle_t *pamh, DBusGProxy *dev, gbool int ret; data = g_new0 (verify_data, 1); - data->max_tries = MAX_TRIES; + data->max_tries = max_tries; data->pamh = pamh; data->loop = loop; @@ -304,7 +306,7 @@ static int do_verify(GMainLoop *loop, pam_handle_t *pamh, DBusGProxy *dev, gbool GSource *source; /* Set up the timeout on our non-default context */ - source = g_timeout_source_new_seconds (TIMEOUT); + source = g_timeout_source_new_seconds (timeout); g_source_attach (source, g_main_loop_get_context (loop)); g_source_set_callback (source, verify_timeout_cb, data, NULL); @@ -429,9 +431,23 @@ PAM_EXTERN int pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, return PAM_AUTHINFO_UNAVAIL; for (i = 0; i < argc; i++) { - if (argv[i] != NULL && g_str_equal (argv[i], "debug")) { - g_message ("debug on"); - debug = TRUE; + if (argv[i] != NULL) { + if(g_str_equal (argv[i], "debug")) { + g_message ("debug on"); + debug = TRUE; + } + else if (strncmp(argv[i], "max_tries=", 10) == 0 && strlen(argv[i]) == 11){ + char max_tries_l[1]; + strncpy(max_tries_l,argv[i] + 10,1); + sscanf(max_tries_l,"%d", &max_tries); + D(pamh, "max_tries specified as: %d",max_tries); + } + else if (strncmp(argv[i], "timeout=", 8) == 0 && strlen(argv[i]) <= 10){ + char timeout_l[2]; + strncpy(timeout_l,argv[i] + 8,strlen(argv[i]) - 8); + sscanf(timeout_l,"%d", &timeout); + D(pamh, "timeout specified as: %d",timeout); + } } } -- 1.7.2.5