diff options
Diffstat (limited to 'sysdep/unix/log.c')
-rw-r--r-- | sysdep/unix/log.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/sysdep/unix/log.c b/sysdep/unix/log.c index 9c56eb24..42c933ef 100644 --- a/sysdep/unix/log.c +++ b/sysdep/unix/log.c @@ -20,6 +20,7 @@ #include <stdarg.h> #include <time.h> #include <unistd.h> +#include <errno.h> #include "nest/bird.h" #include "nest/cli.h" @@ -209,6 +210,7 @@ bug(const char *msg, ...) va_start(args, msg); vlog(L_BUG[0], msg, args); + va_end(args); abort(); } @@ -226,6 +228,7 @@ die(const char *msg, ...) va_start(args, msg); vlog(L_FATAL[0], msg, args); + va_end(args); exit(1); } @@ -285,18 +288,22 @@ log_switch(int debug, list *l, char *new_syslog_name) current_log_list = l; #ifdef HAVE_SYSLOG - char *old_syslog_name = current_syslog_name; - current_syslog_name = new_syslog_name; - - if (old_syslog_name && new_syslog_name && - !strcmp(old_syslog_name, new_syslog_name)) + if (current_syslog_name && new_syslog_name && + !strcmp(current_syslog_name, new_syslog_name)) return; - if (old_syslog_name) + if (current_syslog_name) + { closelog(); + xfree(current_syslog_name); + current_syslog_name = NULL; + } if (new_syslog_name) - openlog(new_syslog_name, LOG_CONS | LOG_NDELAY, LOG_DAEMON); + { + current_syslog_name = xstrdup(new_syslog_name); + openlog(current_syslog_name, LOG_CONS | LOG_NDELAY, LOG_DAEMON); + } #endif } @@ -312,7 +319,11 @@ log_init_debug(char *f) else if (!*f) dbgf = stderr; else if (!(dbgf = fopen(f, "a"))) - log(L_ERR "Error opening debug file `%s': %m", f); + { + /* Cannot use die() nor log() here, logging is not yet initialized */ + fprintf(stderr, "bird: Unable to open debug file %s: %s\n", f, strerror(errno)); + exit(1); + } if (dbgf) setvbuf(dbgf, NULL, _IONBF, 0); } |