upstream: do not pass file/func to monitor; noted by Ilja van Sprundel;
ok djm@ OpenBSD-Commit-ID: 85ae5c063845c410283cbdce685515dcd19479fa
This commit is contained in:
parent
2dc328023f
commit
faf2b86a46
22
log.c
22
log.c
|
@ -1,4 +1,4 @@
|
|||
/* $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
|
||||
|
@ -334,8 +334,8 @@ set_log_handler(log_handler_fn *handler, void *ctx)
|
|||
}
|
||||
|
||||
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)
|
||||
{
|
||||
#if defined(HAVE_OPENLOG_R) && defined(SYSLOG_DATA_INIT)
|
||||
struct syslog_data sdata = SYSLOG_DATA_INIT;
|
||||
|
@ -400,7 +400,7 @@ do_log(const char *file, const char *func, int line, LogLevel level,
|
|||
/* 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",
|
||||
|
@ -475,12 +475,22 @@ sshlogv(const char *file, const char *func, int line, int showfunc,
|
|||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
7
log.h
7
log.h
|
@ -1,4 +1,4 @@
|
|||
/* $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>
|
||||
|
@ -49,8 +49,7 @@ typedef enum {
|
|||
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);
|
||||
|
@ -82,6 +81,8 @@ void sshlogdie(const char *, const char *, int, int,
|
|||
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__)
|
||||
|
|
16
monitor.c
16
monitor.c
|
@ -1,4 +1,4 @@
|
|||
/* $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>
|
||||
|
@ -417,8 +417,8 @@ static int
|
|||
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;
|
||||
|
||||
|
@ -449,21 +449,17 @@ monitor_read_log(struct monitor *pmonitor)
|
|||
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;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $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>
|
||||
|
@ -82,8 +82,7 @@ extern struct sshbuf *loginmsg;
|
|||
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;
|
||||
|
@ -97,10 +96,8 @@ mm_log_handler(const char *file, const char *func, int line,
|
|||
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)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $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>
|
||||
|
@ -40,8 +40,7 @@ struct sshkey;
|
|||
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);
|
||||
|
|
Loading…
Reference in New Issue