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 <troglobit@gmail.com>
This commit is contained in:
parent
05c5b6752d
commit
280b5fd3ec
@ -1183,11 +1183,6 @@ static void logmsg(struct buf_msg *buffer)
|
|||||||
textpri(buffer->pri), buffer->flags, buffer->hostname, buffer->app_name,
|
textpri(buffer->pri), buffer->flags, buffer->hostname, buffer->app_name,
|
||||||
buffer->proc_id, buffer->msgid, buffer->sd, buffer->msg);
|
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);
|
(void)gettimeofday(&tv, NULL);
|
||||||
now = tv.tv_sec;
|
now = tv.tv_sec;
|
||||||
if (!memcmp(&buffer->timestamp, &zero, sizeof(zero))) {
|
if (!memcmp(&buffer->timestamp, &zero, sizeof(zero))) {
|
||||||
@ -1208,6 +1203,11 @@ static void logmsg(struct buf_msg *buffer)
|
|||||||
|
|
||||||
prilev = LOG_PRI(buffer->pri);
|
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 */
|
/* log the message to the particular outputs */
|
||||||
if (!Initialized) {
|
if (!Initialized) {
|
||||||
f = &consfile;
|
f = &consfile;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user