diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2020-10-16 13:24:46 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2020-10-16 13:24:46 +0000 |
commit | effdc23547e89f8a21e72903868c44d29aa66b93 (patch) | |
tree | 3cf1f2ee4db354967fea20915c5145d8c0df890f /usr.bin/ssh/monitor.c | |
parent | f5a0ce89e9bcddedac89ee63ac2435f3b73c5466 (diff) |
revised log infrastructure for OpenSSH
log functions receive function, filename and line number of caller.
We can use this to selectively enable logging via pattern-lists.
ok markus@
Diffstat (limited to 'usr.bin/ssh/monitor.c')
-rw-r--r-- | usr.bin/ssh/monitor.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/usr.bin/ssh/monitor.c b/usr.bin/ssh/monitor.c index 98bef2909bb..85125f3ff60 100644 --- a/usr.bin/ssh/monitor.c +++ b/usr.bin/ssh/monitor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: monitor.c,v 1.214 2020/08/27 01:07:09 djm Exp $ */ +/* $OpenBSD: monitor.c,v 1.215 2020/10/16 13:24:45 djm Exp $ */ /* * Copyright 2002 Niels Provos <provos@citi.umich.edu> * Copyright 2002 Markus Friedl <markus@openbsd.org> @@ -354,8 +354,8 @@ static int monitor_read_log(struct monitor *pmonitor) { struct sshbuf *logmsg; - u_int len, level; - char *msg; + u_int len, level, line; + char *msg, *file, *func; u_char *p; int r; @@ -386,7 +386,10 @@ monitor_read_log(struct monitor *pmonitor) fatal("%s: reserve: %s", __func__, ssh_err(r)); if (atomicio(read, pmonitor->m_log_recvfd, p, len) != len) fatal("%s: log fd read: %s", __func__, strerror(errno)); - if ((r = sshbuf_get_u32(logmsg, &level)) != 0 || + 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 || (r = sshbuf_get_cstring(logmsg, &msg, NULL)) != 0) fatal("%s: decode: %s", __func__, ssh_err(r)); @@ -394,9 +397,11 @@ monitor_read_log(struct monitor *pmonitor) if (log_level_name(level) == NULL) fatal("%s: invalid log level %u (corrupted message?)", __func__, level); - do_log2(level, "%s [preauth]", msg); + sshlog(file, func, line, 0, level, "%s [preauth]", msg); sshbuf_free(logmsg); + free(file); + free(func); free(msg); return 0; |