From owner-svn-src-stable@FreeBSD.ORG Sun Jun 3 18:00:39 2012 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A1805106564A; Sun, 3 Jun 2012 18:00:39 +0000 (UTC) (envelope-from rea@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8BA0E8FC0C; Sun, 3 Jun 2012 18:00:39 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q53I0dsm075988; Sun, 3 Jun 2012 18:00:39 GMT (envelope-from rea@svn.freebsd.org) Received: (from rea@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q53I0dUD075982; Sun, 3 Jun 2012 18:00:39 GMT (envelope-from rea@svn.freebsd.org) Message-Id: <201206031800.q53I0dUD075982@svn.freebsd.org> From: Eygene Ryabinkin Date: Sun, 3 Jun 2012 18:00:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236520 - stable/9/crypto/openssh X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2012 18:00:39 -0000 Author: rea (ports committer) Date: Sun Jun 3 18:00:38 2012 New Revision: 236520 URL: http://svn.freebsd.org/changeset/base/236520 Log: OpenSSH: allow VersionAddendum to be used again Prior to this, setting VersionAddendum will be a no-op: one will always have BASE_VERSION + " " + VERSION_HPN for VersionAddendum set in the config and a bare BASE_VERSION + VERSION_HPN when there is no VersionAddendum is set. HPN patch requires both parties to have the "hpn" inside their advertized versions, so we add VERSION_HPN to the VERSION_BASE if HPN is enabled and omitting it if HPN is disabled. VersionAddendum now uses the following logics: * unset (default value): append " " and VERSION_ADDENDUM; * VersionAddendum is set and isn't empty: append " " and VersionAddendum; * VersionAddendum is set and empty: don't append anything. Approved by: des Reviewed by: bz Modified: stable/9/crypto/openssh/ssh.c stable/9/crypto/openssh/sshconnect.c stable/9/crypto/openssh/sshd.c stable/9/crypto/openssh/version.c stable/9/crypto/openssh/version.h Directory Properties: stable/9/crypto/openssh/ (props changed) Modified: stable/9/crypto/openssh/ssh.c ============================================================================== --- stable/9/crypto/openssh/ssh.c Sun Jun 3 17:51:53 2012 (r236519) +++ stable/9/crypto/openssh/ssh.c Sun Jun 3 18:00:38 2012 (r236520) @@ -405,7 +405,8 @@ main(int ac, char **av) /* FALLTHROUGH */ case 'V': fprintf(stderr, "%s, %s\n", - SSH_RELEASE, SSLeay_version(SSLEAY_VERSION)); + ssh_version_get(options.hpn_disabled), + SSLeay_version(SSLEAY_VERSION)); if (opt == 'V') exit(0); break; Modified: stable/9/crypto/openssh/sshconnect.c ============================================================================== --- stable/9/crypto/openssh/sshconnect.c Sun Jun 3 17:51:53 2012 (r236519) +++ stable/9/crypto/openssh/sshconnect.c Sun Jun 3 18:00:38 2012 (r236520) @@ -585,7 +585,7 @@ ssh_exchange_identification(int timeout_ snprintf(buf, sizeof buf, "SSH-%d.%d-%.100s%s", compat20 ? PROTOCOL_MAJOR_2 : PROTOCOL_MAJOR_1, compat20 ? PROTOCOL_MINOR_2 : minor1, - SSH_RELEASE, compat20 ? "\r\n" : "\n"); + ssh_version_get(options.hpn_disabled), compat20 ? "\r\n" : "\n"); if (roaming_atomicio(vwrite, connection_out, buf, strlen(buf)) != strlen(buf)) fatal("write: %.100s", strerror(errno)); Modified: stable/9/crypto/openssh/sshd.c ============================================================================== --- stable/9/crypto/openssh/sshd.c Sun Jun 3 17:51:53 2012 (r236519) +++ stable/9/crypto/openssh/sshd.c Sun Jun 3 18:00:38 2012 (r236520) @@ -430,7 +430,7 @@ sshd_exchange_identification(int sock_in minor = PROTOCOL_MINOR_1; } snprintf(buf, sizeof buf, "SSH-%d.%d-%.100s%s", major, minor, - SSH_RELEASE, newline); + ssh_version_get(options.hpn_disabled), newline); server_version_string = xstrdup(buf); /* Send our protocol version identification. */ @@ -871,7 +871,7 @@ static void usage(void) { fprintf(stderr, "%s, %s\n", - SSH_RELEASE, SSLeay_version(SSLEAY_VERSION)); + ssh_version_get(0), SSLeay_version(SSLEAY_VERSION)); fprintf(stderr, "usage: sshd [-46DdeiqTt] [-b bits] [-C connection_spec] [-c host_cert_file]\n" " [-f config_file] [-g login_grace_time] [-h host_key_file]\n" @@ -1561,7 +1561,7 @@ main(int ac, char **av) exit(1); } - debug("sshd version %.100s", SSH_RELEASE); + debug("sshd version %.100s", ssh_version_get(options.hpn_disabled)); /* Store privilege separation user for later use if required. */ if ((privsep_pw = getpwnam(SSH_PRIVSEP_USER)) == NULL) { Modified: stable/9/crypto/openssh/version.c ============================================================================== --- stable/9/crypto/openssh/version.c Sun Jun 3 17:51:53 2012 (r236519) +++ stable/9/crypto/openssh/version.c Sun Jun 3 18:00:38 2012 (r236520) @@ -1,5 +1,6 @@ /*- * Copyright (c) 2001 Brian Fundakowski Feldman + * Copyright (c) 2012 Eygene Ryabinkin * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -35,30 +36,60 @@ __RCSID("$FreeBSD$"); static char *version = NULL; +/* NULL means "use default value", empty string means "unset" */ +static const char *addendum = NULL; +static unsigned char update_version = 1; +/* + * Constructs the version string if it is empty or needs updating. + * + * HPN patch we're running requires both parties + * to have the "hpn" string inside the advertized version + * (see compat.c::compat_datafellows), so we should + * include it to the generated string if HPN is enabled. + */ const char * -ssh_version_get(void) { +ssh_version_get(int hpn_disabled) +{ + const char *hpn = NULL, *add = NULL; + char *newvers = NULL; + size_t size = 0; + + if (version != NULL && !update_version) + return (version); + + hpn = (hpn_disabled ? NULL : SSH_VERSION_HPN); + add = (addendum == NULL ? SSH_VERSION_ADDENDUM : + (addendum[0] == '\0' ? NULL : addendum)); + + size = strlen(SSH_VERSION_BASE) + (hpn ? strlen(hpn) : 0) + + (add ? strlen(add) + 1 : 0) + 1; + newvers = xmalloc(size); + strcpy(newvers, SSH_VERSION_BASE); + if (hpn) + strcat(newvers, hpn); + if (add) { + strcat(newvers, " "); + strcat(newvers, add); + } + + if (version) + xfree(version); + version = newvers; + update_version = 0; - if (version == NULL) - version = xstrdup(SSH_VERSION); return (version); } void -ssh_version_set_addendum(const char *add) { - char *newvers; - size_t size; - - if (add != NULL) { - size = strlen(SSH_VERSION_BASE) + strlen(SSH_VERSION_HPN) + 1 + - strlen(add) + 1; - newvers = xmalloc(size); - snprintf(newvers, size, "%s %s", SSH_VERSION_BASE, - SSH_VERSION_HPN, add); - } else { - newvers = xstrdup(SSH_VERSION_BASE SSH_VERSION_HPN); - } - if (version != NULL) - xfree(version); - version = newvers; +ssh_version_set_addendum(const char *add) +{ + if (add && addendum && !strcmp(add, addendum)) + return; + + if (addendum) + xfree((void *)addendum); + addendum = (add ? xstrdup(add) : xstrdup("")); + + update_version = 1; } Modified: stable/9/crypto/openssh/version.h ============================================================================== --- stable/9/crypto/openssh/version.h Sun Jun 3 17:51:53 2012 (r236519) +++ stable/9/crypto/openssh/version.h Sun Jun 3 18:00:38 2012 (r236520) @@ -1,14 +1,14 @@ /* $OpenBSD: version.h,v 1.61 2011/02/04 00:44:43 djm Exp $ */ /* $FreeBSD$ */ -#ifndef SSH_VERSION +#ifndef _VERSION_H_ +#define _VERSION_H_ + #define SSH_VERSION_BASE "OpenSSH_5.8p2" #define SSH_VERSION_ADDENDUM "FreeBSD-20110503" #define SSH_VERSION_HPN "_hpn13v11" -#define SSH_VERSION SSH_VERSION_BASE SSH_VERSION_HPN " " SSH_VERSION_ADDENDUM -#define SSH_RELEASE (ssh_version_get()) -const char *ssh_version_get(void); +const char *ssh_version_get(int hpn_disabled); void ssh_version_set_addendum(const char *); -#endif /* SSH_VERSION */ +#endif /* _VERSION_H_ */