11 Star 0 Fork 38

src-openEuler/audit

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-Use-atomic_int-if-available-for-signal-related-flags.patch 2.75 KB
一键复制 编辑 原始数据 按行查看 历史
xuraoqing 提交于 2024-05-28 10:05 +08:00 . backport patches to fix bug
From 184f20c56576300343b8f8b60a8bebb185074485 Mon Sep 17 00:00:00 2001
From: Steve Grubb <sgrubb@redhat.com>
Date: Fri, 26 Apr 2024 12:44:56 -0400
Subject: [PATCH] Use atomic_int if available for signal related flags
Conflict:src/auditd.c
Reference:https://github.com/linux-audit/audit-userspace/commit/184f20c56576300343b8f8b60a8bebb185074485
---
configure.ac | 7 ++++++-
src/auditd-event.c | 5 ++++-
src/auditd.c | 9 ++++++---
3 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/configure.ac b/configure.ac
index 8644ccc..61d32a8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -87,7 +87,12 @@ AC_LINK_IFELSE(
[AC_DEFINE(HAVE_STRNDUPA, 1, [Let us know if we have it or not])],
[]
)
-
+AC_CHECK_HEADERS([stdatomic.h], [
+ AC_DEFINE([HAVE_ATOMIC], 1, [Define to 1 if you have the <stdatomic.h> header file.])
+ AC_DEFINE([ATOMIC_INT], atomic_int, [Define atomic_int if you have the <stdatomic.h> header file.])
+ ], [
+ AC_DEFINE([ATOMIC_INT], int, [Define to the type of an int if <stdatomic.h> is not available.])
+])
AC_MSG_CHECKING(__attr_access support)
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE(
diff --git a/src/auditd-event.c b/src/auditd-event.c
index c74b420..74c4fbd 100644
--- a/src/auditd-event.c
+++ b/src/auditd-event.c
@@ -36,6 +36,9 @@
#include <limits.h> /* POSIX_HOST_NAME_MAX */
#include <ctype.h> /* toupper */
#include <libgen.h> /* dirname */
+#ifdef HAVE_ATOMIC
+#include <stdatomic.h>
+#endif
#include "auditd-event.h"
#include "auditd-dispatch.h"
#include "auditd-listen.h"
@@ -45,7 +48,7 @@
#include "auparse-idata.h"
/* This is defined in auditd.c */
-extern volatile int stop;
+extern volatile ATOMIC_INT stop;
/* Local function prototypes */
static void send_ack(const struct auditd_event *e, int ack_type,
diff --git a/src/auditd.c b/src/auditd.c
index 901f741..aebb919 100644
--- a/src/auditd.c
+++ b/src/auditd.c
@@ -38,6 +38,9 @@
#include <pthread.h>
#include <sys/utsname.h>
#include <getopt.h>
+#ifdef HAVE_ATOMIC
+#include <stdatomic.h>
+#endif
#include "libaudit.h"
#include "auditd-event.h"
@@ -62,7 +65,7 @@
#define SUBJ_LEN 4097
/* Global Data */
-volatile int stop = 0;
+volatile ATOMIC_INT stop = 0;
/* Local data */
static int fd = -1, pipefds[2] = {-1, -1};
@@ -72,8 +75,8 @@ static const char *state_file = "/var/run/auditd.state";
static int init_pipe[2];
static int do_fork = 1, opt_aggregate_only = 0, config_dir_set = 0;
static struct auditd_event *cur_event = NULL, *reconfig_ev = NULL;
-static int hup_info_requested = 0;
-static int usr1_info_requested = 0, usr2_info_requested = 0;
+static ATOMIC_INT hup_info_requested = 0;
+static ATOMIC_INT usr1_info_requested = 0, usr2_info_requested = 0;
static char subj[SUBJ_LEN];
static uint32_t session;
static int hup_flag = 0;
--
2.33.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/audit.git
git@gitee.com:src-openeuler/audit.git
src-openeuler
audit
audit
master

搜索帮助