From 4bbd6e8626475222b0aa37dde62d12d77667accb Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sat, 9 Nov 2013 13:25:03 +0100 Subject: [BB#109] Fix crash (infinite loop) when writing to log file fails. Fall back to syslog logging in that case. Signed-off-by: Michael Adam --- src/log.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/log.c b/src/log.c index ba871b2..f5a0b44 100644 --- a/src/log.c +++ b/src/log.c @@ -188,8 +188,13 @@ void log_message (int level, const char *fmt, ...) ret = write (log_file_fd, str, strlen (str)); if (ret == -1) { - log_message (LOG_WARNING, - "Could not write to log file"); + config.syslog = TRUE; + + log_message(LOG_CRIT, "ERROR: Could not write to log " + "file %s: %s.", + config.logf_name, strerror(errno)); + log_message(LOG_CRIT, + "Falling back to syslog logging"); } fsync (log_file_fd); -- cgit v1.2.3