2007-01-07 17:26:05 +01:00
|
|
|
--- log.c
|
|
|
|
+++ log.c
|
|
|
|
@@ -50,6 +50,7 @@
|
|
|
|
|
|
|
|
#include "xmalloc.h"
|
|
|
|
#include "log.h"
|
|
|
|
+#include <signal.h>
|
|
|
|
|
|
|
|
static LogLevel log_level = SYSLOG_LEVEL_INFO;
|
|
|
|
static int log_on_stderr = 1;
|
|
|
|
@@ -313,6 +314,7 @@
|
|
|
|
char fmtbuf[MSGBUFSIZ];
|
|
|
|
char *txt = NULL;
|
|
|
|
int pri = LOG_INFO;
|
|
|
|
+ sigset_t nset, oset;
|
|
|
|
|
|
|
|
if (level > log_level)
|
|
|
|
return;
|
|
|
|
@@ -351,6 +353,15 @@
|
|
|
|
pri = LOG_ERR;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
+ /* Prevent a race between the grace_alarm
|
|
|
|
+ * which writes a log message and terminates
|
|
|
|
+ * and main sshd code that leads to deadlock
|
|
|
|
+ * as syslog is not async safe.
|
|
|
|
+ */
|
|
|
|
+ sigemptyset(&nset);
|
|
|
|
+ sigaddset(&nset, SIGALRM);
|
|
|
|
+ sigprocmask(SIG_BLOCK, &nset, &oset);
|
|
|
|
+
|
|
|
|
if (txt != NULL) {
|
|
|
|
snprintf(fmtbuf, sizeof(fmtbuf), "%s: %s", txt, fmt);
|
|
|
|
vsnprintf(msgbuf, sizeof(msgbuf), fmtbuf, args);
|
|
|
|
@@ -372,5 +383,7 @@
|
|
|
|
syslog(pri, "%.500s", fmtbuf);
|
|
|
|
closelog();
|
|
|
|
#endif
|
|
|
|
+
|
|
|
|
}
|
2007-08-28 19:18:04 +02:00
|
|
|
+ sigprocmask(SIG_SETMASK, &oset, NULL);
|
2007-01-07 17:26:05 +01:00
|
|
|
}
|