1 Star 0 Fork 36

jinlun/audit

forked from src-openEuler/audit 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
bugfix-audit-reload-coredump.patch 2.44 KB
一键复制 编辑 原始数据 按行查看 历史
zgzxx 提交于 2023-02-02 15:28 . update version to 3.0.9
From 2a7404291e431757bc417c9c3250f2ca84a82d89 Mon Sep 17 00:00:00 2001
From: Leo Fang <leofang_94@163.com>
Date: Mon, 24 May 2021 19:16:02 +0800
Subject: [PATCH] bugfix-audit-reload-coredump
---
src/auditd-reconfig.c | 2 ++
src/auditd.c | 26 ++++++++++++++++++++++++--
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/src/auditd-reconfig.c b/src/auditd-reconfig.c
index 37e0adc..66ded38 100644
--- a/src/auditd-reconfig.c
+++ b/src/auditd-reconfig.c
@@ -35,6 +35,7 @@
/* externs we need to know about */
extern void reconfig_ready(void);
+extern void reconfig_pthread_failed(void);
/* This is the configuration manager code */
static pthread_t config_thread;
@@ -122,6 +123,7 @@ static void *config_thread_main(void *arg)
//send_audit_event(AUDIT_DAEMON_CONFIG, txt);
free_config(&new_config);
free(e);
+ reconfig_pthread_failed();
}
pthread_mutex_unlock(&config_lock);
diff --git a/src/auditd.c b/src/auditd.c
index 5933703..53f4803 100644
--- a/src/auditd.c
+++ b/src/auditd.c
@@ -76,6 +76,7 @@ static int hup_info_requested = 0;
static int usr1_info_requested = 0, usr2_info_requested = 0;
static char subj[SUBJ_LEN];
static uint32_t session;
+static int hup_flag = 0;
/* Local function prototypes */
int send_audit_event(int type, const char *str);
@@ -525,8 +526,23 @@ static void netlink_handler(struct ev_loop *loop, struct ev_io *io,
char hup[MAX_AUDIT_MESSAGE_LENGTH];
audit_msg(LOG_DEBUG,
"HUP detected, starting config manager");
- reconfig_ev = cur_event;
- if (start_config_manager(cur_event)) {
+ if(hup_flag == 0)
+ {
+ hup_flag = 1;
+ reconfig_ev = cur_event;
+ if (start_config_manager(cur_event)) {
+ audit_format_signal_info(hup,
+ sizeof(hup),
+ "reconfigure state=no-change",
+ &cur_event->reply,
+ "failed");
+ send_audit_event(AUDIT_DAEMON_CONFIG,
+ hup);
+ hup_flag = 0;
+ }
+ }
+ else
+ {
audit_format_signal_info(hup,
sizeof(hup),
"reconfigure state=no-change",
@@ -576,9 +592,15 @@ static void pipe_handler(struct ev_loop *loop, struct ev_io *io,
// Drain the pipe - won't block because libev sets non-blocking mode
read(pipefds[0], buf, sizeof(buf));
enqueue_event(reconfig_ev);
+ hup_flag = 0;
reconfig_ev = NULL;
}
+void reconfig_pthread_failed(void)
+{
+ hup_flag = 0;
+}
+
void reconfig_ready(void)
{
const char *msg = "ready\n";
--
2.27.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jinlun123123/audit.git
git@gitee.com:jinlun123123/audit.git
jinlun123123
audit
audit
master

搜索帮助