On Tue, Oct 17, 2017 at 09:10:38PM +0300, Lars Noodén wrote: > Here is a replacement patch.
I meant reusing the existing function rather than cloning it. It's currently static so it needs to be exported but IMO that's better than duplicating the code. Index: packet.c =================================================================== RCS file: /cvs/src/usr.bin/ssh/packet.c,v retrieving revision 1.265 diff -u -p -r1.265 packet.c --- packet.c 13 Oct 2017 21:13:54 -0000 1.265 +++ packet.c 17 Oct 2017 22:49:08 -0000 @@ -1773,8 +1773,8 @@ ssh_packet_send_debug(struct ssh *ssh, c fatal("%s: %s", __func__, ssh_err(r)); } -static void -fmt_connection_id(struct ssh *ssh, char *s, size_t l) +void +sshpkt_fmt_connection_id(struct ssh *ssh, char *s, size_t l) { snprintf(s, l, "%.200s%s%s port %d", ssh->log_preamble ? ssh->log_preamble : "", @@ -1790,7 +1790,7 @@ sshpkt_fatal(struct ssh *ssh, const char { char remote_id[512]; - fmt_connection_id(ssh, remote_id, sizeof(remote_id)); + sshpkt_fmt_connection_id(ssh, remote_id, sizeof(remote_id)); switch (r) { case SSH_ERR_CONN_CLOSED: @@ -1852,7 +1852,7 @@ ssh_packet_disconnect(struct ssh *ssh, c * Format the message. Note that the caller must make sure the * message is of limited size. */ - fmt_connection_id(ssh, remote_id, sizeof(remote_id)); + sshpkt_fmt_connection_id(ssh, remote_id, sizeof(remote_id)); va_start(args, fmt); vsnprintf(buf, sizeof(buf), fmt, args); va_end(args); Index: packet.h =================================================================== RCS file: /cvs/src/usr.bin/ssh/packet.h,v retrieving revision 1.82 diff -u -p -r1.82 packet.h --- packet.h 12 Sep 2017 06:32:07 -0000 1.82 +++ packet.h 17 Oct 2017 22:49:08 -0000 @@ -186,6 +186,7 @@ int sshpkt_get_cstring(struct ssh *ssh, int sshpkt_get_ec(struct ssh *ssh, EC_POINT *v, const EC_GROUP *g); int sshpkt_get_bignum2(struct ssh *ssh, BIGNUM *v); int sshpkt_get_end(struct ssh *ssh); +void sshpkt_fmt_connection_id(struct ssh *ssh, char *s, size_t l); const u_char *sshpkt_ptr(struct ssh *, size_t *lenp); /* OLD API */ Index: serverloop.c =================================================================== RCS file: /cvs/src/usr.bin/ssh/serverloop.c,v retrieving revision 1.198 diff -u -p -r1.198 serverloop.c --- serverloop.c 12 Sep 2017 06:35:32 -0000 1.198 +++ serverloop.c 17 Oct 2017 22:49:08 -0000 @@ -162,10 +162,12 @@ static void client_alive_check(struct ssh *ssh) { int channel_id; + char remote_id[512]; /* timeout, check to see how many we have had */ if (packet_inc_alive_timeouts() > options.client_alive_count_max) { - logit("Timeout, client not responding."); + sshpkt_fmt_connection_id(ssh, remote_id, sizeof(remote_id)); + logit("Timeout, client not responding from %s", remote_id); cleanup_exit(255); } -- Darren Tucker (dtucker at zip.com.au) GPG key 11EAA6FA / A86E 3E07 5B19 5880 E860 37F4 9357 ECEF 11EA A6FA (new) Good judgement comes with experience. Unfortunately, the experience usually comes from bad judgement.