From 280b5fd3ec83fdb97b9bc25ac56d663459fb0f60 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Fri, 29 Nov 2019 10:20:54 +0100 Subject: [PATCH] syslogd: Fix blocking of SIGHUP/ALRM during logmsg() Only block signals *after* all sanity checking of log message has been completed, otherwise we will end up with blocked SIGHUP and SIGALRM. Signed-off-by: Joachim Nilsson --- src/syslogd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/syslogd.c b/src/syslogd.c index 9f49c05..0bb5ec1 100644 --- a/src/syslogd.c +++ b/src/syslogd.c @@ -1183,11 +1183,6 @@ static void logmsg(struct buf_msg *buffer) textpri(buffer->pri), buffer->flags, buffer->hostname, buffer->app_name, buffer->proc_id, buffer->msgid, buffer->sd, buffer->msg); - sigemptyset(&mask); - sigaddset(&mask, SIGHUP); - sigaddset(&mask, SIGALRM); - sigprocmask(SIG_BLOCK, &mask, NULL); - (void)gettimeofday(&tv, NULL); now = tv.tv_sec; if (!memcmp(&buffer->timestamp, &zero, sizeof(zero))) { @@ -1208,6 +1203,11 @@ static void logmsg(struct buf_msg *buffer) prilev = LOG_PRI(buffer->pri); + sigemptyset(&mask); + sigaddset(&mask, SIGHUP); + sigaddset(&mask, SIGALRM); + sigprocmask(SIG_BLOCK, &mask, NULL); + /* log the message to the particular outputs */ if (!Initialized) { f = &consfile;