diff options
author | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2016-07-11 20:22:55 +0200 |
---|---|---|
committer | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2016-07-11 20:22:55 +0200 |
commit | f0b822a831d0f0f593bbedf0a7f15b94c3ca1d43 (patch) | |
tree | 80dfdfeb463c1f3c328e0f9a2662d85a770b1b67 /sysdep/unix | |
parent | f1f39bb9d8e2260fe181240dd8194b06bdcfb54f (diff) |
Log: Fix error handling of debug file open
Logging is not yet initialized, we have to use fprintf() here.
Thanks to Pavel Tvrdik for noticing and debugging it.
Diffstat (limited to 'sysdep/unix')
-rw-r--r-- | sysdep/unix/log.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/sysdep/unix/log.c b/sysdep/unix/log.c index 631bd691..1fd64426 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" @@ -314,7 +315,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); } |