mirror of
https://gitlab.com/mishakmak/pam-fprint-grosshack.git
synced 2026-04-08 20:03:34 +02:00
pam: Add monotonic clock helper
This commit is contained in:
@ -23,6 +23,7 @@
|
||||
#define _GNU_SOURCE
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
@ -61,6 +62,17 @@ static gboolean debug = FALSE;
|
||||
static guint max_tries = DEFAULT_MAX_TRIES;
|
||||
static guint timeout = DEFAULT_TIMEOUT;
|
||||
|
||||
#define USEC_PER_SEC ((uint64_t) 1000000ULL)
|
||||
#define NSEC_PER_USEC ((uint64_t) 1000ULL)
|
||||
|
||||
static uint64_t
|
||||
now (void)
|
||||
{
|
||||
struct timespec ts;
|
||||
clock_gettime (CLOCK_MONOTONIC, &ts);
|
||||
return (uint64_t) ts.tv_sec * USEC_PER_SEC + (uint64_t) ts.tv_nsec / NSEC_PER_USEC;
|
||||
}
|
||||
|
||||
static gboolean send_info_msg(pam_handle_t *pamh, const char *msg)
|
||||
{
|
||||
const struct pam_message mymsg = {
|
||||
|
||||
Reference in New Issue
Block a user