]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
upstream: support VersionAddendum in the client, mirroring the
authordjm@openbsd.org <djm@openbsd.org>
Fri, 6 Dec 2024 16:21:48 +0000 (16:21 +0000)
committerDamien Miller <djm@mindrot.org>
Sat, 7 Dec 2024 10:16:02 +0000 (21:16 +1100)
option of the same name in the server; bz2745 ok dtucker@

OpenBSD-Commit-ID: 6ff7905b3f9806649bde750515786553fb89cdf4

readconf.c
readconf.h
ssh.c
ssh_config.5
sshconnect.c

index 777739d6a8c44d9a8308db5ad87ee57dfad53ecb..aa64658874348d174a60ddb7bf157c246863d94f 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: readconf.c,v 1.393 2024/11/27 16:07:08 djm Exp $ */
+/* $OpenBSD: readconf.c,v 1.394 2024/12/06 16:21:48 djm Exp $ */
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -179,6 +179,7 @@ typedef enum {
        oPubkeyAcceptedAlgorithms, oCASignatureAlgorithms, oProxyJump,
        oSecurityKeyProvider, oKnownHostsCommand, oRequiredRSASize,
        oEnableEscapeCommandline, oObscureKeystrokeTiming, oChannelTimeout,
+       oVersionAddendum,
        oIgnore, oIgnoredUnknownOption, oDeprecated, oUnsupported
 } OpCodes;
 
@@ -329,6 +330,7 @@ static struct {
        { "enableescapecommandline", oEnableEscapeCommandline },
        { "obscurekeystroketiming", oObscureKeystrokeTiming },
        { "channeltimeout", oChannelTimeout },
+       { "versionaddendum", oVersionAddendum },
 
        { NULL, oBadOption }
 };
@@ -2440,6 +2442,28 @@ parse_pubkey_algos:
                }
                break;
 
+       case oVersionAddendum:
+               if (str == NULL || *str == '\0')
+                       fatal("%s line %d: %s missing argument.",
+                           filename, linenum, keyword);
+               len = strspn(str, WHITESPACE);
+               if (strchr(str + len, '\r') != NULL) {
+                       fatal("%.200s line %d: Invalid %s argument",
+                           filename, linenum, keyword);
+               }
+               if ((arg = strchr(line, '#')) != NULL) {
+                       *arg = '\0';
+                       rtrim(line);
+               }
+               if (*activep && options->version_addendum == NULL) {
+                       if (strcasecmp(str + len, "none") == 0)
+                               options->version_addendum = xstrdup("");
+                       else
+                               options->version_addendum = xstrdup(str + len);
+               }
+               argv_consume(&ac);
+               break;
+
        case oDeprecated:
                debug("%s line %d: Deprecated option \"%s\"",
                    filename, linenum, keyword);
@@ -2696,6 +2720,7 @@ initialize_options(Options * options)
        options->tag = NULL;
        options->channel_timeouts = NULL;
        options->num_channel_timeouts = 0;
+       options->version_addendum = NULL;
 }
 
 /*
@@ -3649,6 +3674,7 @@ dump_client_config(Options *o, const char *host)
        dump_cfg_string(oXAuthLocation, o->xauth_location);
        dump_cfg_string(oKnownHostsCommand, o->known_hosts_command);
        dump_cfg_string(oTag, o->tag);
+       dump_cfg_string(oVersionAddendum, o->version_addendum);
 
        /* Forwards */
        dump_cfg_forwards(oDynamicForward, o->num_local_forwards, o->local_forwards);
index a1e43852cbc8db97ca5f7f0c80159797190e45ed..2922dcb2409fdbc46b28e36c527aa95da3f0d767 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: readconf.h,v 1.157 2024/09/25 23:01:39 jsg Exp $ */
+/* $OpenBSD: readconf.h,v 1.158 2024/12/06 16:21:48 djm Exp $ */
 
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -184,6 +184,8 @@ typedef struct {
        char    **channel_timeouts;     /* inactivity timeout by channel type */
        u_int   num_channel_timeouts;
 
+       char    *version_addendum;
+
        char    *ignored_unknown; /* Pattern list of unknown tokens to ignore */
 }       Options;
 
diff --git a/ssh.c b/ssh.c
index 112845bea6ad46ee4fcb1d9ad4a646d05f5f155a..5cd6a603cdfc3f875edf3b536603969b69f9de0a 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh.c,v 1.601 2024/10/18 05:03:34 djm Exp $ */
+/* $OpenBSD: ssh.c,v 1.602 2024/12/06 16:21:48 djm Exp $ */
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1494,6 +1494,13 @@ main(int ac, char **av)
                }
        }
 
+       if (options.version_addendum != NULL) {
+               cp = default_client_percent_dollar_expand(
+                   options.version_addendum, cinfo);
+               free(options.version_addendum);
+               options.version_addendum = cp;
+       }
+
        if (options.num_system_hostfiles > 0 &&
            strcasecmp(options.system_hostfiles[0], "none") == 0) {
                if (options.num_system_hostfiles > 1)
index fed1a5caab5a086c050004a19c065f37a423dab2..570bf65127455d1b8f1acd5d7d48392e3305316c 100644 (file)
@@ -33,8 +33,8 @@
 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.\" $OpenBSD: ssh_config.5,v 1.406 2024/12/05 22:45:03 naddy Exp $
-.Dd $Mdocdate: December 5 2024 $
+.\" $OpenBSD: ssh_config.5,v 1.407 2024/12/06 16:21:48 djm Exp $
+.Dd $Mdocdate: December 6 2024 $
 .Dt SSH_CONFIG 5
 .Os
 .Sh NAME
@@ -2149,6 +2149,11 @@ See also
 .Sx VERIFYING HOST KEYS
 in
 .Xr ssh 1 .
+.It Cm VersionAddendum
+Optionally specifies additional text to append to the SSH protocol banner
+sent by the client upon connection.
+The default is
+.Cm none .
 .It Cm VisualHostKey
 If this flag is set to
 .Cm yes ,
@@ -2294,8 +2299,9 @@ The local username.
 .Cm RemoteCommand ,
 .Cm RemoteForward ,
 .Cm RevokedHostKeys ,
-and
 .Cm UserKnownHostsFile
+and
+.Cm VersionAddendum
 accept the tokens %%, %C, %d, %h, %i, %j, %k, %L, %l, %n, %p, %r, and %u.
 .Pp
 .Cm KnownHostsCommand
index 7cf6b638674c7eb7c8a08b6ca1904a8b762d5bb8..c86182d13673940ea902acb4200f5d431cf102b7 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: sshconnect.c,v 1.368 2024/04/30 02:10:49 djm Exp $ */
+/* $OpenBSD: sshconnect.c,v 1.369 2024/12/06 16:21:48 djm Exp $ */
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1604,7 +1604,8 @@ ssh_login(struct ssh *ssh, Sensitive *sensitive, const char *orighost,
        lowercase(host);
 
        /* Exchange protocol version identification strings with the server. */
-       if ((r = kex_exchange_identification(ssh, timeout_ms, NULL)) != 0)
+       if ((r = kex_exchange_identification(ssh, timeout_ms,
+           options.version_addendum)) != 0)
                sshpkt_fatal(ssh, r, "banner exchange");
 
        /* Put the connection into non-blocking mode. */