From 1fea9ef8e257626aef77530bf9e48b5cf7367d21 Mon Sep 17 00:00:00 2001 From: yixiangzhike Date: Thu, 9 Jan 2025 11:34:53 +0800 Subject: [PATCH] Use signal safe write function in signal handler (cherry picked from commit 04a2a6776325267cee52c37f8ccc8f2e6e3a75e7) --- aide.spec | 9 ++- ...afe-write-function-in-signal-handler.patch | 63 +++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 backport-Use-signal-safe-write-function-in-signal-handler.patch diff --git a/aide.spec b/aide.spec index 3ec06c6..a3aa77f 100644 --- a/aide.spec +++ b/aide.spec @@ -2,7 +2,7 @@ Name: aide Version: 0.17.4 -Release: 4 +Release: 5 Summary: Advanced Intrusion Detection Environment License: GPLv2+ URL: http://sourceforge.net/projects/aide @@ -26,6 +26,7 @@ Patch1: backport-Handle-malformed-database-lines.patch Patch2: backport-Fix-handling-of-duplicate-database-entries.patch Patch3: backport-Switch-from-PCRE-to-PCRE2-closes-116.patch Patch4: backport-Fix-condition-for-error-message-of-failing-to-open-g.patch +Patch5: backport-Use-signal-safe-write-function-in-signal-handler.patch %description AIDE (Advanced Intrusion Detection Environment, [eyd]) is a file and directory integrity checker. @@ -81,6 +82,12 @@ make check %{_mandir}/*/* %changelog +* Thu Jan 9 2025 yixiangzhike - 0.17.4-5 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC: backport upstream patch to use signal safe write function in signal handler + * Thu Jul 4 2024 yixiangzhike - 0.17.4-4 - Type:bugfix - ID:NA diff --git a/backport-Use-signal-safe-write-function-in-signal-handler.patch b/backport-Use-signal-safe-write-function-in-signal-handler.patch new file mode 100644 index 0000000..0fe5254 --- /dev/null +++ b/backport-Use-signal-safe-write-function-in-signal-handler.patch @@ -0,0 +1,63 @@ +From f1728dc97c981d76fd913102a822c71c35c58946 Mon Sep 17 00:00:00 2001 +From: Hannes von Haugwitz +Date: Sat, 9 Jul 2022 23:06:36 +0200 +Subject: [PATCH] Use signal-safe write function in signal handler + +* closes: #100 +--- + src/aide.c | 20 +++--- + 1 files changed, 12 insertions(+), 8 deletions(-) + +diff --git a/src/aide.c b/src/aide.c +index 30e2942..e935794 100644 +--- a/src/aide.c ++++ b/src/aide.c +@@ -103,33 +103,37 @@ static void init_sighandler() + + static void sig_handler(int signum) + { ++ char *str; + switch(signum){ + case SIGBUS : { + if(conf->catch_mmap==1){ +- log_msg(LOG_LEVEL_NOTICE, "Caught SIGBUS while mmapping. File was truncated while aide was running?"); ++ str = "Caught SIGBUS while mmapping. File was truncated while aide was running?\n"; ++ write(STDERR_FILENO ,str, strlen(str)); + conf->catch_mmap=0; + } else { +- log_msg(LOG_LEVEL_ERROR, "Caught SIGBUS. Exiting"); ++ str = "Caught SIGBUS. Exiting\n"; ++ write(STDERR_FILENO ,str, strlen(str)); + exit(EXIT_FAILURE); + } + break; + } + case SIGHUP : { +- log_msg(LOG_LEVEL_INFO, "Caught SIGHUP"); ++ str = "Caught SIGHUP. Ignoring\n"; ++ write(STDERR_FILENO ,str, strlen(str)); + break; + } + case SIGTERM : { +- log_msg(LOG_LEVEL_INFO, "Caught SIGTERM. Use SIGKILL to terminate"); ++ str = "Caught SIGTERM. Use SIGKILL to terminate\n"; ++ write(STDERR_FILENO ,str, strlen(str)); + break; + } + case SIGUSR1 : { +- log_msg(LOG_LEVEL_INFO, "Caught SIGUSR1, toggle debug level: set log level to %s", get_log_level_name(toogle_log_level(LOG_LEVEL_DEBUG))); ++ str = "Caught SIGUSR1, toggle debug level\n"; ++ write(STDERR_FILENO ,str, strlen(str)); ++ toogle_log_level(LOG_LEVEL_DEBUG); + break; + } + } +- init_sighandler(); +- +- return; + } + + static void print_version(void) +-- +2.33.0 + -- Gitee