Lines 503-512
Link Here
|
503 |
} |
503 |
} |
504 |
#endif |
504 |
#endif |
505 |
|
505 |
|
506 |
static int get_timestamp(void) { |
|
|
507 |
return get_time()/30; |
508 |
} |
509 |
|
510 |
static int comparator(const void *a, const void *b) { |
506 |
static int comparator(const void *a, const void *b) { |
511 |
return *(unsigned int *)a - *(unsigned int *)b; |
507 |
return *(unsigned int *)a - *(unsigned int *)b; |
512 |
} |
508 |
} |
Lines 538-543
Link Here
|
538 |
return NULL; |
534 |
return NULL; |
539 |
} |
535 |
} |
540 |
|
536 |
|
|
|
537 |
#if !defined(STEPSIZE) |
538 |
static int get_timestamp(void) { |
539 |
return get_time()/30; |
540 |
} |
541 |
#else |
542 |
static int get_timestamp(pam_handle_t *pamh, const char *secret_filename, |
543 |
const char *buf) { |
544 |
const char *value = get_cfg_value(pamh, "STEP_SIZE", buf); |
545 |
if (!value) { |
546 |
// Default step size is 30. |
547 |
free((void *)value); |
548 |
return 30; |
549 |
} else if (value == &oom) { |
550 |
// Out of memory. This is a fatal error. |
551 |
return 0; |
552 |
} |
553 |
|
554 |
char *endptr; |
555 |
errno = 0; |
556 |
int step = (int)strtoul(value, &endptr, 10); |
557 |
if (errno || !*value || value == endptr || |
558 |
(*endptr && *endptr != ' ' && *endptr != '\t' && |
559 |
*endptr != '\n' && *endptr != '\r') || |
560 |
step < 1 || step > 60) { |
561 |
free((void *)value); |
562 |
log_message(LOG_ERR, pamh, "Invalid STEP_SIZE option in \"%s\"", |
563 |
secret_filename); |
564 |
return 0; |
565 |
} |
566 |
free((void *)value); |
567 |
|
568 |
return get_time()/step; |
569 |
} |
570 |
#endif |
571 |
|
541 |
static int set_cfg_value(pam_handle_t *pamh, const char *key, const char *val, |
572 |
static int set_cfg_value(pam_handle_t *pamh, const char *key, const char *val, |
542 |
char **buf) { |
573 |
char **buf) { |
543 |
size_t key_len = strlen(key); |
574 |
size_t key_len = strlen(key); |
Lines 1162-1168
Link Here
|
1162 |
} |
1193 |
} |
1163 |
|
1194 |
|
1164 |
// Compute verification codes and compare them with user input |
1195 |
// Compute verification codes and compare them with user input |
|
|
1196 |
#if !defined(STEPSIZE) |
1165 |
const int tm = get_timestamp(); |
1197 |
const int tm = get_timestamp(); |
|
|
1198 |
#else |
1199 |
const int tm = get_timestamp(pamh, secret_filename, *buf); |
1200 |
#endif |
1166 |
const char *skew_str = get_cfg_value(pamh, "TIME_SKEW", *buf); |
1201 |
const char *skew_str = get_cfg_value(pamh, "TIME_SKEW", *buf); |
1167 |
if (skew_str == &oom) { |
1202 |
if (skew_str == &oom) { |
1168 |
// Out of memory. This is a fatal error |
1203 |
// Out of memory. This is a fatal error |