]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
upstream: Also show the duration of the current session through the
authorjob@openbsd.org <job@openbsd.org>
Mon, 13 Apr 2026 08:18:33 +0000 (08:18 +0000)
committerDamien Miller <djm@mindrot.org>
Sun, 19 Apr 2026 23:38:25 +0000 (09:38 +1000)
~I escape

OK dtucker@

OpenBSD-Commit-ID: 695c1a09c4cc8b417a1bd3eb207b0cc7fa831c7a

packet.c

index 190a579d1e5059f994d0b1785d19625603f3d301..8c1d313c2179b1bf0ff7e9faca3060963dfb695b 100644 (file)
--- a/packet.c
+++ b/packet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: packet.c,v 1.334 2026/03/03 09:57:25 dtucker Exp $ */
+/* $OpenBSD: packet.c,v 1.335 2026/04/13 08:18:33 job Exp $ */
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -161,6 +161,9 @@ struct session_state {
        /* Flag indicating whether this module has been initialized. */
        int initialized;
 
+       /* Monotonic clock timestamp when the connection was started. */
+       time_t start_time;
+
        /* Set to true if the connection is interactive. */
        int interactive_mode;
 
@@ -312,6 +315,7 @@ ssh_packet_set_connection(struct ssh *ssh, int fd_in, int fd_out)
                return NULL;
        }
        state = ssh->state;
+       state->start_time = monotime();
        state->connection_in = fd_in;
        state->connection_out = fd_out;
        if ((r = cipher_init(&state->send_context, none,
@@ -3079,6 +3083,7 @@ connection_info_message(struct ssh *ssh)
 
        xasprintf(&ret, "Connection information for %s pid %lld\r\n"
            "%s"
+           "  duration %s\r\n"
            "  kexalgorithm %s\r\n  hostkeyalgorithm %s\r\n"
            "  cipher %s\r\n  mac %s\r\n  compression %s\r\n"
            "  rekey %s %s\r\n"
@@ -3086,6 +3091,7 @@ connection_info_message(struct ssh *ssh)
            "%s",
            thishost, (long long)getpid(),
            tcp_info,
+           fmt_timeframe(monotime() - state->start_time),
            kex->name, kex->hostkey_alg,
            cipher, mac, comp,
            rekey_volume, rekey_time,