]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
upstream: include arguments the command was invoked with, and
authordjm@openbsd.org <djm@openbsd.org>
Mon, 10 Feb 2025 23:19:26 +0000 (23:19 +0000)
committerDamien Miller <djm@mindrot.org>
Mon, 10 Feb 2025 23:30:30 +0000 (10:30 +1100)
operating system name, version and architecture in startup debugging output;
ok dtucker

OpenBSD-Commit-ID: 2a509d319aaf31a6bf9998e1842832883fbc3edd

ssh.c
sshd.c

diff --git a/ssh.c b/ssh.c
index 5cd6a603cdfc3f875edf3b536603969b69f9de0a..d82f2fb8f252483866ee5d58cb8867025a654ab7 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh.c,v 1.602 2024/12/06 16:21:48 djm Exp $ */
+/* $OpenBSD: ssh.c,v 1.603 2025/02/10 23:19:26 djm Exp $ */
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -50,6 +50,7 @@
 #include <sys/ioctl.h>
 #include <sys/socket.h>
 #include <sys/wait.h>
+#include <sys/utsname.h>
 
 #include <ctype.h>
 #include <errno.h>
@@ -670,7 +671,7 @@ main(int ac, char **av)
        struct ssh *ssh = NULL;
        int i, r, opt, exit_status, use_syslog, direct, timeout_ms;
        int was_addr, config_test = 0, opt_terminated = 0, want_final_pass = 0;
-       char *p, *cp, *line, *argv0, *logfile;
+       char *p, *cp, *line, *argv0, *logfile, *args;
        char cname[NI_MAXHOST], thishost[NI_MAXHOST];
        struct stat st;
        struct passwd *pw;
@@ -680,6 +681,7 @@ main(int ac, char **av)
        struct addrinfo *addrs = NULL;
        size_t n, len;
        u_int j;
+       struct utsname utsname;
        struct ssh_conn_info *cinfo = NULL;
 
        /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
@@ -738,7 +740,9 @@ main(int ac, char **av)
                fatal("Couldn't allocate session state");
        channel_init_channels(ssh);
 
+
        /* Parse command-line arguments. */
+       args = argv_assemble(ac, av); /* logged later */
        host = NULL;
        use_syslog = 0;
        logfile = NULL;
@@ -1201,8 +1205,15 @@ main(int ac, char **av)
            SYSLOG_FACILITY_USER : options.log_facility,
            !use_syslog);
 
-       if (debug_flag)
-               logit("%s, %s", SSH_RELEASE, SSH_OPENSSL_VERSION);
+       debug("%s, %s", SSH_RELEASE, SSH_OPENSSL_VERSION);
+       if (uname(&utsname) != 0) {
+               memset(&utsname, 0, sizeof(utsname));
+               strlcpy(utsname.sysname, "UNKNOWN", sizeof(utsname.sysname));
+       }
+       debug3("Running on %s %s %s %s", utsname.sysname, utsname.release,
+           utsname.version, utsname.machine);
+       debug3("Started with: %s", args);
+       free(args);
 
        /* Parse the configuration files */
        process_config_files(options.host_arg, pw, 0, &want_final_pass);
diff --git a/sshd.c b/sshd.c
index 9cf519cf7b1c69bec334780a15f41a93cba4affc..862023e257fad7e32c6842cabfccc25d003a2a72 100644 (file)
--- a/sshd.c
+++ b/sshd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sshd.c,v 1.614 2024/12/07 10:12:19 djm Exp $ */
+/* $OpenBSD: sshd.c,v 1.615 2025/02/10 23:19:26 djm Exp $ */
 /*
  * Copyright (c) 2000, 2001, 2002 Markus Friedl.  All rights reserved.
  * Copyright (c) 2002 Niels Provos.  All rights reserved.
@@ -38,6 +38,7 @@
 #include "openbsd-compat/sys-tree.h"
 #include "openbsd-compat/sys-queue.h"
 #include <sys/wait.h>
+#include <sys/utsname.h>
 
 #include <errno.h>
 #include <fcntl.h>
@@ -1185,13 +1186,14 @@ main(int ac, char **av)
        int sock_in = -1, sock_out = -1, newsock = -1, rexec_argc = 0;
        int devnull, config_s[2] = { -1 , -1 }, have_connection_info = 0;
        int need_chroot = 1;
-       char *fp, *line, *logfile = NULL, **rexec_argv = NULL;
+       char *args, *fp, *line, *logfile = NULL, **rexec_argv = NULL;
        struct stat sb;
        u_int i, j;
        mode_t new_umask;
        struct sshkey *key;
        struct sshkey *pubkey;
        struct connection_info connection_info;
+       struct utsname utsname;
        sigset_t sigmask;
 
        memset(&connection_info, 0, sizeof(connection_info));
@@ -1227,6 +1229,7 @@ main(int ac, char **av)
        initialize_server_options(&options);
 
        /* Parse command-line arguments. */
+       args = argv_assemble(ac, av); /* logged later */
        while ((opt = getopt(ac, av,
            "C:E:b:c:f:g:h:k:o:p:u:46DGQRTdeiqrtV")) != -1) {
                switch (opt) {
@@ -1396,6 +1399,16 @@ main(int ac, char **av)
                fatal("Config test connection parameter (-C) provided without "
                    "test mode (-T)");
 
+       debug("sshd version %s, %s", SSH_VERSION, SSH_OPENSSL_VERSION);
+       if (uname(&utsname) != 0) {
+               memset(&utsname, 0, sizeof(utsname));
+               strlcpy(utsname.sysname, "UNKNOWN", sizeof(utsname.sysname));
+       }
+       debug3("Running on %s %s %s %s", utsname.sysname, utsname.release,
+           utsname.version, utsname.machine);
+       debug3("Started with: %s", args);
+       free(args);
+
        /* Fetch our configuration */
        if ((cfg = sshbuf_new()) == NULL)
                fatal("sshbuf_new config failed");
@@ -1443,8 +1456,6 @@ main(int ac, char **av)
                exit(1);
        }
 
-       debug("sshd version %s, %s", SSH_VERSION, SSH_OPENSSL_VERSION);
-
        if (do_dump_cfg)
                print_config(&connection_info);