diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2024-06-19 23:24:48 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2024-06-19 23:24:48 +0000 |
commit | 9b97ad5b2383958cc18089509c9b7d4a11a659a4 (patch) | |
tree | cb8ff23318ab45e2411c78471d060acb0d097730 /usr.bin/ssh | |
parent | 742d318c40f8408b5a9ce5cff1b005e5be8bb987 (diff) |
put back reaping of preauth child process when writes from the monitor
fail. Not sure how this got lost in the avalanche of patches.
Diffstat (limited to 'usr.bin/ssh')
-rw-r--r-- | usr.bin/ssh/monitor_wrap.c | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/usr.bin/ssh/monitor_wrap.c b/usr.bin/ssh/monitor_wrap.c index 08b7b142718..97ed932b385 100644 --- a/usr.bin/ssh/monitor_wrap.c +++ b/usr.bin/ssh/monitor_wrap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: monitor_wrap.c,v 1.135 2024/06/11 02:54:51 djm Exp $ */ +/* $OpenBSD: monitor_wrap.c,v 1.136 2024/06/19 23:24:47 djm Exp $ */ /* * Copyright 2002 Niels Provos <provos@citi.umich.edu> * Copyright 2002 Markus Friedl <markus@openbsd.org> @@ -117,24 +117,6 @@ mm_is_monitor(void) return (pmonitor && pmonitor->m_pid > 0); } -void -mm_request_send(int sock, enum monitor_reqtype type, struct sshbuf *m) -{ - size_t mlen = sshbuf_len(m); - u_char buf[5]; - - debug3_f("entering, type %d", type); - - if (mlen >= 0xffffffff) - fatal_f("bad length %zu", mlen); - POKE_U32(buf, mlen + 1); - buf[4] = (u_char) type; /* 1st byte of payload is mesg-type */ - if (atomicio(vwrite, sock, buf, sizeof(buf)) != sizeof(buf)) - fatal_f("write: %s", strerror(errno)); - if (atomicio(vwrite, sock, sshbuf_mutable_ptr(m), mlen) != mlen) - fatal_f("write: %s", strerror(errno)); -} - static void mm_reap(void) { @@ -167,6 +149,29 @@ mm_reap(void) } void +mm_request_send(int sock, enum monitor_reqtype type, struct sshbuf *m) +{ + size_t mlen = sshbuf_len(m); + u_char buf[5]; + + debug3_f("entering, type %d", type); + + if (mlen >= 0xffffffff) + fatal_f("bad length %zu", mlen); + POKE_U32(buf, mlen + 1); + buf[4] = (u_char) type; /* 1st byte of payload is mesg-type */ + if (atomicio(vwrite, sock, buf, sizeof(buf)) != sizeof(buf) || + atomicio(vwrite, sock, sshbuf_mutable_ptr(m), mlen) != mlen) { + if (errno == EPIPE) { + debug3_f("monitor fd closed"); + mm_reap(); + cleanup_exit(255); + } + fatal_f("write: %s", strerror(errno)); + } +} + +void mm_request_receive(int sock, struct sshbuf *m) { u_char buf[4], *p = NULL; |