13 Star 0 Fork 35

src-openEuler/pam

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
bugfix-pam-1.1.8-faillock-systemtime.patch 2.58 KB
一键复制 编辑 原始数据 按行查看 历史
albatross 提交于 2023-07-14 16:49 . upgrade version to 1.5.3
From c58a79970f5902b5b61b8ca7e82564a7db212be0 Mon Sep 17 00:00:00 2001
From: openEuler Buildteam <buildteam@openeuler.org>
Date: Mon, 27 Jul 2020 09:34:43 +0800
Subject: [PATCH] bugfix pam 1.1.8 faillock systemtime
---
modules/pam_faillock/faillock_config.h | 1 +
modules/pam_faillock/pam_faillock.c | 20 ++++++++++++++++++--
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/modules/pam_faillock/faillock_config.h b/modules/pam_faillock/faillock_config.h
index 04bc699..d649ce1 100644
--- a/modules/pam_faillock/faillock_config.h
+++ b/modules/pam_faillock/faillock_config.h
@@ -75,6 +75,7 @@ struct options {
int is_admin;
uint64_t now;
int fatal_error;
+ int time_jumped;
unsigned int reset;
const char *progname;
diff --git a/modules/pam_faillock/pam_faillock.c b/modules/pam_faillock/pam_faillock.c
index ca1c703..8fbab77 100644
--- a/modules/pam_faillock/pam_faillock.c
+++ b/modules/pam_faillock/pam_faillock.c
@@ -76,6 +76,7 @@ args_parse(pam_handle_t *pamh, int argc, const char **argv,
opts->fail_interval = 900;
opts->unlock_time = 600;
opts->root_unlock_time = MAX_TIME_INTERVAL+1;
+ opts->time_jumped = 0;
for (i = 0; i < argc; ++i) {
const char *str = pam_str_skip_prefix(argv[i], "conf=");
@@ -219,8 +220,6 @@ check_tally(pam_handle_t *pamh, struct options *opts, struct tally_data *tallies
latest_time = tallies->records[i].time;
}
- opts->latest_time = latest_time;
-
failures = 0;
for (i = 0; i < tallies->count; i++) {
if ((tallies->records[i].status & TALLY_STATUS_VALID) &&
@@ -231,6 +230,19 @@ check_tally(pam_handle_t *pamh, struct options *opts, struct tally_data *tallies
opts->failures = failures;
+ if (latest_time > opts->now) {
+ pam_syslog(pamh, LOG_WARNING, "system time jumped about %ld seconds.", (latest_time - opts->now));
+ latest_time = opts->now;
+ opts->time_jumped = 1;
+
+ for(i = 0; i < tallies->count; i++) {
+ if (tallies->records[i].status & TALLY_STATUS_VALID)
+ tallies->records[i].time = latest_time;
+ }
+ }
+
+ opts->latest_time = latest_time;
+
if (opts->deny && failures >= opts->deny) {
if ((!opts->is_admin && opts->unlock_time && latest_time + opts->unlock_time < opts->now) ||
(opts->is_admin && opts->root_unlock_time && latest_time + opts->root_unlock_time < opts->now)) {
@@ -489,6 +501,10 @@ pam_sm_authenticate(pam_handle_t *pamh, int flags,
rv = PAM_IGNORE; /* this return value should be ignored */
write_tally(pamh, &opts, &tallies, &fd);
}
+ if (opts.time_jumped) {
+ if (update_tally(fd, &tallies) != 0)
+ rv = PAM_IGNORE;
+ }
break;
}
}
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/pam.git
git@gitee.com:src-openeuler/pam.git
src-openeuler
pam
pam
master

搜索帮助