From 650404f32c5d673168b8b79b5a0688fa6ce4dea1 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sun, 21 Oct 2018 09:29:17 +0100 Subject: [PATCH] Server prep: pass "implementation name" to ssh_verstring_new. The word 'PuTTY' in the outgoing SSH version string has always represented the name of the *SSH implementation* as opposed to the name of the specific program containing it (for example, PSCP and PSFTP don't announce themselves with a different banner). But I think that a change from client to server merits a change in that implementation name, so I'm removing the prefix "PuTTY" from the constant string sshver[], and moving it to a parameter passed in separately to ssh_verstring_new, so that the upcoming server can pass in a different one. --- Buildscr | 8 ++++---- ssh.c | 2 +- sshbpp.h | 3 ++- sshverstring.c | 10 +++++++--- version.h | 2 +- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Buildscr b/Buildscr index 12ff2fcf..4656dde4 100644 --- a/Buildscr +++ b/Buildscr @@ -63,10 +63,10 @@ set Docmakever VERSION="$(Puttytextver)" # make sure it's under 40 characters, which is a hard limit in the SSH # protocol spec (and enforced by a compile-time assertion in # version.c). -ifneq "$(RELEASE)" "" set Sshver PuTTY-Release-$(RELEASE) -ifneq "$(PRERELEASE)" "" set Sshver PuTTY-Prerelease-$(PRERELEASE):$(Ndate).$(vcsid) -ifneq "$(SNAPSHOT)" "" set Sshver PuTTY-Snapshot-$(Date).$(vcsid) -ifeq "$(RELEASE)$(PRERELEASE)$(SNAPSHOT)" "" set Sshver PuTTY-Custom-$(Date).$(vcsid) +ifneq "$(RELEASE)" "" set Sshver -Release-$(RELEASE) +ifneq "$(PRERELEASE)" "" set Sshver -Prerelease-$(PRERELEASE):$(Ndate).$(vcsid) +ifneq "$(SNAPSHOT)" "" set Sshver -Snapshot-$(Date).$(vcsid) +ifeq "$(RELEASE)$(PRERELEASE)$(SNAPSHOT)" "" set Sshver -Custom-$(Date).$(vcsid) # Set up the filename suffix for the Unix source archive. ifneq "$(RELEASE)" "" set Uxarcsuffix -$(RELEASE) diff --git a/ssh.c b/ssh.c index 2f81d9f6..1a881c80 100644 --- a/ssh.c +++ b/ssh.c @@ -717,7 +717,7 @@ static const char *connect_to_host(Ssh *ssh, const char *host, int port, ssh->version_receiver.got_ssh_version = ssh_got_ssh_version; ssh->bpp = ssh_verstring_new( ssh->conf, ssh->logctx, ssh->bare_connection, - ssh->version == 1 ? "1.5" : "2.0", &ssh->version_receiver); + ssh->version == 1 ? "1.5" : "2.0", &ssh->version_receiver, "PuTTY"); ssh_connect_bpp(ssh); queue_idempotent_callback(&ssh->bpp->ic_in_raw); diff --git a/sshbpp.h b/sshbpp.h index e1b4622d..264c37c4 100644 --- a/sshbpp.h +++ b/sshbpp.h @@ -136,7 +136,8 @@ struct ssh_version_receiver { }; BinaryPacketProtocol *ssh_verstring_new( Conf *conf, LogContext *logctx, int bare_connection_mode, - const char *protoversion, struct ssh_version_receiver *rcv); + const char *protoversion, struct ssh_version_receiver *rcv, + const char *impl_name); const char *ssh_verstring_get_remote(BinaryPacketProtocol *); const char *ssh_verstring_get_local(BinaryPacketProtocol *); int ssh_verstring_get_bugs(BinaryPacketProtocol *); diff --git a/sshverstring.c b/sshverstring.c index d68954c7..f11c35ea 100644 --- a/sshverstring.c +++ b/sshverstring.c @@ -27,6 +27,7 @@ struct ssh_verstring_state { int major_protoversion; int remote_bugs; char prefix[PREFIX_MAXLEN]; + char *impl_name; char *vstring; int vslen, vstrsize; char *protoversion; @@ -59,7 +60,8 @@ static int ssh_version_includes_v2(const char *ver); BinaryPacketProtocol *ssh_verstring_new( Conf *conf, LogContext *logctx, int bare_connection_mode, - const char *protoversion, struct ssh_version_receiver *rcv) + const char *protoversion, struct ssh_version_receiver *rcv, + const char *impl_name) { struct ssh_verstring_state *s = snew(struct ssh_verstring_state); @@ -90,6 +92,7 @@ BinaryPacketProtocol *ssh_verstring_new( s->bpp.logctx = logctx; s->our_protoversion = dupstr(protoversion); s->receiver = rcv; + s->impl_name = dupstr(impl_name); /* * We send our version string early if we can. But if it includes @@ -108,6 +111,7 @@ void ssh_verstring_free(BinaryPacketProtocol *bpp) struct ssh_verstring_state *s = container_of(bpp, struct ssh_verstring_state, bpp); conf_free(s->conf); + sfree(s->impl_name); sfree(s->vstring); sfree(s->protoversion); sfree(s->our_vstring); @@ -155,9 +159,9 @@ static void ssh_verstring_send(struct ssh_verstring_state *s) * Construct our outgoing version string. */ s->our_vstring = dupprintf( - "%.*s%s-%s", + "%.*s%s-%s%s", (int)s->prefix_wanted.len, (const char *)s->prefix_wanted.ptr, - s->our_protoversion, sshver); + s->our_protoversion, s->impl_name, sshver); sv_pos = s->prefix_wanted.len + strlen(s->our_protoversion) + 1; /* Convert minus signs and spaces in the software version string diff --git a/version.h b/version.h index 26242ad6..74be18f4 100644 --- a/version.h +++ b/version.h @@ -9,7 +9,7 @@ */ #define TEXTVER "Unidentified build" -#define SSHVER "PuTTY-Unidentified-Local-Build" +#define SSHVER "-Unidentified-Local-Build" #define BINARY_VERSION 0,0,0,0 #ifndef SOURCE_COMMIT