-/* $OpenBSD: log.c,v 1.57 2021/04/03 06:18:40 djm Exp $ */
+/* $OpenBSD: log.c,v 1.58 2021/04/15 16:24:31 markus Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
}
static void
-do_log(const char *file, const char *func, int line, LogLevel level,
- int force, const char *suffix, const char *fmt, va_list args)
+do_log(LogLevel level, int force, const char *suffix, const char *fmt,
+ va_list args)
{
struct syslog_data sdata = SYSLOG_DATA_INIT;
char msgbuf[MSGBUFSIZ];
/* Avoid recursion */
tmp_handler = log_handler;
log_handler = NULL;
- tmp_handler(file, func, line, level, fmtbuf, log_handler_ctx);
+ tmp_handler(level, force, fmtbuf, log_handler_ctx);
log_handler = tmp_handler;
} else if (log_on_stderr) {
snprintf(msgbuf, sizeof msgbuf, "%.*s\r\n",
}
}
- if (log_handler == NULL && forced)
+ if (forced)
snprintf(fmt2, sizeof(fmt2), "%s: %s", tag, fmt);
else if (showfunc)
snprintf(fmt2, sizeof(fmt2), "%s: %s", func, fmt);
else
strlcpy(fmt2, fmt, sizeof(fmt2));
- do_log(file, func, line, level, forced, suffix, fmt2, args);
+ do_log(level, forced, suffix, fmt2, args);
+}
+
+void
+sshlogdirect(LogLevel level, int forced, const char *fmt, ...)
+{
+ va_list args;
+
+ va_start(args, fmt);
+ do_log(level, forced, NULL, fmt, args);
+ va_end(args);
}
-/* $OpenBSD: log.h,v 1.32 2021/04/06 23:24:30 djm Exp $ */
+/* $OpenBSD: log.h,v 1.33 2021/04/15 16:24:31 markus Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
SYSLOG_LEVEL_NOT_SET = -1
} LogLevel;
-typedef void (log_handler_fn)(const char *, const char *, int, LogLevel,
- const char *, void *);
+typedef void (log_handler_fn)(LogLevel, int, const char *, void *);
void log_init(const char *, LogLevel, SyslogFacility, int);
LogLevel log_level_get(void);
void sshfatal(const char *, const char *, int, int,
LogLevel, const char *, const char *, ...) __attribute__((noreturn))
__attribute__((format(printf, 7, 8)));
+void sshlogdirect(LogLevel, int, const char *, ...)
+ __attribute__((format(printf, 3, 4)));
#define do_log2(level, ...) sshlog(__FILE__, __func__, __LINE__, 0, level, NULL, __VA_ARGS__)
#define debug3(...) sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
-/* $OpenBSD: monitor.c,v 1.224 2021/03/03 22:41:49 djm Exp $ */
+/* $OpenBSD: monitor.c,v 1.225 2021/04/15 16:24:31 markus Exp $ */
/*
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
* Copyright 2002 Markus Friedl <markus@openbsd.org>
monitor_read_log(struct monitor *pmonitor)
{
struct sshbuf *logmsg;
- u_int len, level, line;
- char *msg, *file, *func;
+ u_int len, level, forced;
+ char *msg;
u_char *p;
int r;
fatal_fr(r, "reserve msg");
if (atomicio(read, pmonitor->m_log_recvfd, p, len) != len)
fatal_f("log fd read: %s", strerror(errno));
- if ((r = sshbuf_get_cstring(logmsg, &file, NULL)) != 0 ||
- (r = sshbuf_get_cstring(logmsg, &func, NULL)) != 0 ||
- (r = sshbuf_get_u32(logmsg, &line)) != 0 ||
- (r = sshbuf_get_u32(logmsg, &level)) != 0 ||
+ if ((r = sshbuf_get_u32(logmsg, &level)) != 0 ||
+ (r = sshbuf_get_u32(logmsg, &forced)) != 0 ||
(r = sshbuf_get_cstring(logmsg, &msg, NULL)) != 0)
fatal_fr(r, "parse");
/* Log it */
if (log_level_name(level) == NULL)
fatal_f("invalid log level %u (corrupted message?)", level);
- sshlog(file, func, line, 0, level, NULL, "%s [preauth]", msg);
+ sshlogdirect(level, forced, "%s [preauth]", msg);
sshbuf_free(logmsg);
- free(file);
- free(func);
free(msg);
return 0;
-/* $OpenBSD: monitor_wrap.c,v 1.122 2020/11/27 00:37:10 djm Exp $ */
+/* $OpenBSD: monitor_wrap.c,v 1.123 2021/04/15 16:24:31 markus Exp $ */
/*
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
* Copyright 2002 Markus Friedl <markus@openbsd.org>
extern ServerOptions options;
void
-mm_log_handler(const char *file, const char *func, int line,
- LogLevel level, const char *msg, void *ctx)
+mm_log_handler(LogLevel level, int forced, const char *msg, void *ctx)
{
struct sshbuf *log_msg;
struct monitor *mon = (struct monitor *)ctx;
fatal_f("sshbuf_new failed");
if ((r = sshbuf_put_u32(log_msg, 0)) != 0 || /* length; filled below */
- (r = sshbuf_put_cstring(log_msg, file)) != 0 ||
- (r = sshbuf_put_cstring(log_msg, func)) != 0 ||
- (r = sshbuf_put_u32(log_msg, (u_int)line)) != 0 ||
(r = sshbuf_put_u32(log_msg, level)) != 0 ||
+ (r = sshbuf_put_u32(log_msg, forced)) != 0 ||
(r = sshbuf_put_cstring(log_msg, msg)) != 0)
fatal_fr(r, "assemble");
if ((len = sshbuf_len(log_msg)) < 4 || len > 0xffffffff)
-/* $OpenBSD: monitor_wrap.h,v 1.46 2020/10/16 13:24:45 djm Exp $ */
+/* $OpenBSD: monitor_wrap.h,v 1.47 2021/04/15 16:24:31 markus Exp $ */
/*
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
struct sshauthopt;
struct sshkey_sig_details;
-void mm_log_handler(const char *, const char *, int, LogLevel,
- const char *, void *);
+void mm_log_handler(LogLevel, int, const char *, void *);
int mm_is_monitor(void);
#ifdef WITH_OPENSSL
DH *mm_choose_dh(int, int, int);