vMessage looks for the system log instance. If there is one, it uses
it; otherwise it just uses stderr or stdout.
The system log instance consists, eventually, of syslog_vlog or
logfile_vlog. Both of these functions have a fallback: if they are
properly set up they do their thing; otherwise they call vMessage.
This is wrong because in this situation they have probably been called
by vMessage so it doesn't help.
At first sight this ought to produce unbounded recursion but for
complicated reasons another bug prevents this. Instead, messages can
just vanish.
Break out the fallback mode of [v]Message into [v]MessageFallback so
that syslog_vlog and logfile_vlog can use it directly.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
uint32_t message_level=M_WARNING|M_ERR|M_SECURITY|M_FATAL;
struct log_if *system_log=NULL;
uint32_t message_level=M_WARNING|M_ERR|M_SECURITY|M_FATAL;
struct log_if *system_log=NULL;
-static void vMessage(uint32_t class, const char *message, va_list args)
+static void vMessageFallback(uint32_t class, const char *message, va_list args)
+ /* Messages go to stdout/stderr */
+ if (class & message_level) {
+ if (class&M_FATAL || class&M_ERR || class&M_WARNING) {
+ dest=stderr;
+ }
+ vfprintf(dest,message,args);
+ }
+}
+
+static void vMessage(uint32_t class, const char *message, va_list args)
+{
#define MESSAGE_BUFLEN 1023
static char buff[MESSAGE_BUFLEN+1]={0,};
size_t bp;
#define MESSAGE_BUFLEN 1023
static char buff[MESSAGE_BUFLEN+1]={0,};
size_t bp;
memmove(buff,nlp+1,strlen(nlp+1)+1);
}
} else {
memmove(buff,nlp+1,strlen(nlp+1)+1);
}
} else {
- /* Messages go to stdout/stderr */
- if (class & message_level) {
- if (class&M_FATAL || class&M_ERR || class&M_WARNING) {
- dest=stderr;
- }
- vfprintf(dest,message,args);
- }
+ vMessageFallback(class,message,args);
+static void MessageFallback(uint32_t class, const char *message, ...)
+{
+ va_list ap;
+
+ va_start(ap,message);
+ vMessageFallback(class,message,ap);
+ va_end(ap);
+}
+
static NORETURN(vfatal(int status, bool_t perror, const char *message,
va_list args));
static NORETURN(vfatal(int status, bool_t perror, const char *message,
va_list args));
fflush(st->f);
}
} else {
fflush(st->f);
}
} else {
- vMessage(class,message,args);
- Message(class,"\n");
+ vMessageFallback(class,message,args);
+ MessageFallback(class,"\n");
if (st->open)
vsyslog(msgclass_to_syslogpriority(class),message,args);
else {
if (st->open)
vsyslog(msgclass_to_syslogpriority(class),message,args);
else {
- vMessage(class,message,args);
- Message(class,"\n");
+ vMessageFallback(class,message,args);
+ MessageFallback(class,"\n");