aide/backport-Use-signal-safe-write-function-in-signal-handler.patch
yixiangzhike 1fea9ef8e2 Use signal safe write function in signal handler
(cherry picked from commit 04a2a6776325267cee52c37f8ccc8f2e6e3a75e7)
2025-01-09 18:03:37 +08:00

64 lines
1.9 KiB
Diff

From f1728dc97c981d76fd913102a822c71c35c58946 Mon Sep 17 00:00:00 2001
From: Hannes von Haugwitz <hannes@vonhaugwitz.com>
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