7 Commits

2 changed files with 22 additions and 7 deletions

View File

@ -1,5 +1,5 @@
project('fprintd', 'c', project('fprintd', 'c',
version: '1.94.1', version: '1.94.2',
license: 'GPLv2+', license: 'GPLv2+',
default_options: [ default_options: [
'buildtype=debugoptimized', 'buildtype=debugoptimized',
@ -154,7 +154,7 @@ python3_available_modules = []
foreach module, required : python3_test_modules foreach module, required : python3_test_modules
if required and run_command(python3, '-c', 'import @0@'.format(module)).returncode() != 0 if required and run_command(python3, '-c', 'import @0@'.format(module)).returncode() != 0
error('Python3 module \'' + module + '\' required by test suite not found') warning('Python3 module \'' + module + '\' required by test suite not found')
endif endif
endforeach endforeach

View File

@ -19,8 +19,10 @@
*/ */
#include <config.h> #include <config.h>
#include <security/_pam_types.h>
#define _GNU_SOURCE #define _GNU_SOURCE
#include <limits.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
@ -38,6 +40,7 @@
#include <signal.h> #include <signal.h>
#include <sys/signalfd.h> #include <sys/signalfd.h>
#include <poll.h> #include <poll.h>
#include <termios.h>
#define PAM_SM_AUTH #define PAM_SM_AUTH
#include <security/pam_modules.h> #include <security/pam_modules.h>
@ -453,13 +456,15 @@ do_verify (sd_bus *bus, verify_data *data)
sigemptyset (&signals); sigemptyset (&signals);
sigaddset (&signals, SIGINT); sigaddset (&signals, SIGINT);
signal (SIGUSR1, handle_sigusr1);
sigaddset (&signals, SIGUSR1); sigaddset (&signals, SIGUSR1);
signal_fd = signalfd (signal_fd, &signals, SFD_NONBLOCK); signal_fd = signalfd (signal_fd, &signals, SFD_NONBLOCK);
while (data->max_tries > 0) while (data->max_tries > 0)
{ {
uint64_t verification_end = now () + (timeout * USEC_PER_SEC); uint64_t verification_end = ULONG_MAX;
if (timeout != UINT_MAX)
verification_end = now () + (timeout * USEC_PER_SEC);
data->timed_out = false; data->timed_out = false;
data->verify_started = false; data->verify_started = false;
@ -733,7 +738,7 @@ prompt_pw (void *d)
{ {
verify_data *data = d; verify_data *data = d;
char *pw; char *pw;
pam_prompt (data->pamh, PAM_PROMPT_ECHO_OFF, &pw, "Enter Password or Place finger on fingerprint reader: "); pam_prompt (data->pamh, PAM_PROMPT_ECHO_OFF, &pw, "Enter Password or Place finger on fingerprint reader: \n");
pam_set_item (data->pamh, PAM_AUTHTOK, pw); pam_set_item (data->pamh, PAM_AUTHTOK, pw);
data->stop_got_pw = true; data->stop_got_pw = true;
if (debug) if (debug)
@ -781,6 +786,8 @@ do_auth (pam_handle_t *pamh, const char *username)
data->stop_got_pw = false; data->stop_got_pw = false;
data->ppid = getpid(); data->ppid = getpid();
signal (SIGUSR1, handle_sigusr1);
pthread_t pw_prompt_thread; pthread_t pw_prompt_thread;
if (pthread_create (&pw_prompt_thread, NULL, (void*) &prompt_pw, data) != 0) if (pthread_create (&pw_prompt_thread, NULL, (void*) &prompt_pw, data) != 0)
send_err_msg (pamh, _("Failed to create thread")); send_err_msg (pamh, _("Failed to create thread"));
@ -788,6 +795,12 @@ do_auth (pam_handle_t *pamh, const char *username)
int ret = do_verify(bus, data); int ret = do_verify(bus, data);
pthread_cancel (pw_prompt_thread); pthread_cancel (pw_prompt_thread);
/* Authenticating with fingerprint doesn't re-enable echo, so we have to */
struct termios term;
tcgetattr(fileno(stdin), &term);
term.c_lflag |= ECHO;
tcsetattr(fileno(stdin), 0, &term);
/* Simply disconnect from bus if we return PAM_SUCCESS */ /* Simply disconnect from bus if we return PAM_SUCCESS */
if (ret != PAM_SUCCESS) if (ret != PAM_SUCCESS)
release_device (pamh, bus, data->dev); release_device (pamh, bus, data->dev);
@ -872,7 +885,8 @@ pam_sm_authenticate (pam_handle_t *pamh, int flags, int argc,
} }
else if (str_has_prefix (argv[i], MAX_TRIES_MATCH) && strlen (argv[i]) > strlen (MAX_TRIES_MATCH)) else if (str_has_prefix (argv[i], MAX_TRIES_MATCH) && strlen (argv[i]) > strlen (MAX_TRIES_MATCH))
{ {
max_tries = atoi (argv[i] + strlen (MAX_TRIES_MATCH)); int opt_max_tries = atoi (argv[i] + strlen (MAX_TRIES_MATCH));
max_tries = (opt_max_tries < 0 ? UINT_MAX : (unsigned) opt_max_tries);
if (max_tries < 1) if (max_tries < 1)
{ {
if (debug) if (debug)
@ -885,7 +899,8 @@ pam_sm_authenticate (pam_handle_t *pamh, int flags, int argc,
} }
else if (str_has_prefix (argv[i], TIMEOUT_MATCH) && strlen (argv[i]) <= strlen (TIMEOUT_MATCH) + 2) else if (str_has_prefix (argv[i], TIMEOUT_MATCH) && strlen (argv[i]) <= strlen (TIMEOUT_MATCH) + 2)
{ {
timeout = atoi (argv[i] + strlen (TIMEOUT_MATCH)); int opt_timeout = atoi (argv[i] + strlen (TIMEOUT_MATCH));
timeout = (opt_timeout < 0 ? UINT_MAX : (unsigned) opt_timeout);
if (timeout < MIN_TIMEOUT) if (timeout < MIN_TIMEOUT)
{ {
if (debug) if (debug)