summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2024-12-06 17:21:48 +0100
committerDamien Miller <djm@mindrot.org>2024-12-07 11:16:02 +0100
commit9a9ffee6e10bcd039f1f9385599577441ebe542a (patch)
treeffc8d70baf96f5a4dc226a1d56be410dcd191c15
parentupstream: clarify encoding of options/extensions; bz2389 (diff)
downloadopenssh-9a9ffee6e10bcd039f1f9385599577441ebe542a.tar.xz
openssh-9a9ffee6e10bcd039f1f9385599577441ebe542a.zip
upstream: support VersionAddendum in the client, mirroring the
option of the same name in the server; bz2745 ok dtucker@ OpenBSD-Commit-ID: 6ff7905b3f9806649bde750515786553fb89cdf4
-rw-r--r--readconf.c28
-rw-r--r--readconf.h4
-rw-r--r--ssh.c9
-rw-r--r--ssh_config.512
-rw-r--r--sshconnect.c5
5 files changed, 50 insertions, 8 deletions
diff --git a/readconf.c b/readconf.c
index 777739d6a..aa6465887 100644
--- a/readconf.c
+++ b/readconf.c
@@ -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);
diff --git a/readconf.h b/readconf.h
index a1e43852c..2922dcb24 100644
--- a/readconf.h
+++ b/readconf.h
@@ -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 112845bea..5cd6a603c 100644
--- 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)
diff --git a/ssh_config.5 b/ssh_config.5
index fed1a5caa..570bf6512 100644
--- a/ssh_config.5
+++ b/ssh_config.5
@@ -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
diff --git a/sshconnect.c b/sshconnect.c
index 7cf6b6386..c86182d13 100644
--- a/sshconnect.c
+++ b/sshconnect.c
@@ -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. */