[gsi-openssh/f20: 2/2] Based on openssh-6.4p1-4.fc20

Mattias Ellert ellert at fedoraproject.org
Wed Jul 16 06:21:08 UTC 2014


commit a60f428d3d3da6791ccba09a671ab84dfc69fab4
Author: Mattias Ellert <mattias.ellert at fysast.uu.se>
Date:   Thu Jul 10 20:14:43 2014 +0200

    Based on openssh-6.4p1-4.fc20

 gsi-openssh.spec                         |   28 ++++-
 gsisshd-keygen.service                   |    2 +-
 openssh-6.1p1-log-usepam-no.patch        |    2 +-
 openssh-6.3p1-fips.patch                 |   32 +++--
 openssh-6.3p1-gsskex.patch               |    2 +-
 openssh-6.3p1-redhat.patch               |    2 +-
 openssh-6.4p1-CLOCK_BOOTTIME.patch       |   29 ++++
 openssh-6.4p1-CVE-2014-2653.patch        |   80 ++++++++++++
 openssh-6.4p1-FIPS-mode-SP800-131A.patch |  206 ++++++++++++++++++++++++++++++
 openssh-6.4p1-fromto-remote.patch        |   16 +++
 openssh-6.4p1-gsissh.patch               |    4 +-
 openssh-6.4p1-ignore-bad-env-var.patch   |   37 ++++++
 openssh-6.4p1-legacy-ssh-copy-id.patch   |   57 ++++++++
 13 files changed, 474 insertions(+), 23 deletions(-)
---
diff --git a/gsi-openssh.spec b/gsi-openssh.spec
index dde3923..b2247a7 100644
--- a/gsi-openssh.spec
+++ b/gsi-openssh.spec
@@ -29,12 +29,12 @@
 %global ldap 1
 
 %global openssh_ver 6.4p1
-%global openssh_rel 2
+%global openssh_rel 3
 
 Summary: An implementation of the SSH protocol with GSI authentication
 Name: gsi-openssh
 Version: %{openssh_ver}
-Release: %{openssh_rel}%{?dist}.1
+Release: %{openssh_rel}%{?dist}
 Provides: gsissh = %{version}-%{release}
 Obsoletes: gsissh < 5.8p2-2
 URL: http://www.openssh.com/portable.html
@@ -129,6 +129,19 @@ Patch901: openssh-6.3p1-kuserok.patch
 Patch902: openssh-6.3p1-krb5-use-default_ccache_name.patch
 # increase the size of the Diffie-Hellman groups (#1010607)
 Patch903: openssh-6.3p1-increase-size-of-DF-groups.patch
+# FIPS mode - adjust the key echange DH groups and ssh-keygen according to SP800-131A (#1001748)
+Patch904: openssh-6.4p1-FIPS-mode-SP800-131A.patch
+# Run ssh-copy-id in the legacy mode when SSH_COPY_ID_LEGACY variable is set (#969375
+Patch905: openssh-6.4p1-legacy-ssh-copy-id.patch
+# Use tty allocation for a remote scp (#985650)
+Patch906: openssh-6.4p1-fromto-remote.patch
+# Try CLOCK_BOOTTIME with fallback (#1091992)
+Patch907: openssh-6.4p1-CLOCK_BOOTTIME.patch
+# Prevents a server from skipping SSHFP lookup and forcing a new-hostkey
+# dialog by offering only certificate keys. (#1081338)
+Patch908: openssh-6.4p1-CVE-2014-2653.patch
+# ignore environment variables with embedded '=' or '\0' characters (#1077843)
+Patch909: openssh-6.4p1-ignore-bad-env-var.patch
 
 # This is the patch that adds GSI support
 # Based on http://grid.ncsa.illinois.edu/ssh/dl/patch/openssh-6.4p1.patch
@@ -278,6 +291,12 @@ This version of OpenSSH has been modified to support GSI authentication.
 %patch901 -p1 -b .kuserok
 %patch902 -p1 -b .ccache_name
 %patch903 -p1 -b .dh
+%patch904 -p1 -b .SP800-131A
+%patch905 -p1 -b .legacy-ssh-copy-id
+%patch906 -p1 -b .fromto-remote
+%patch907 -p1 -b .CLOCK_BOOTTIME
+%patch908 -p1 -b .CVE-2014-2653
+%patch909 -p1 -b .bad-env-var
 
 %patch98 -p1 -b .gsi
 
@@ -449,7 +468,7 @@ getent passwd sshd >/dev/null || \
 %defattr(-,root,root)
 %doc CREDITS ChangeLog INSTALL LICENCE LICENSE.globus_usage OVERVIEW PROTOCOL* README README.platform README.privsep README.tun README.dns README.sshd-and-gsisshd TODO
 %attr(0755,root,root) %dir %{_sysconfdir}/gsissh
-%attr(0600,root,root) %config(noreplace) %{_sysconfdir}/gsissh/moduli
+%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/gsissh/moduli
 %attr(0755,root,root) %{_bindir}/gsissh-keygen
 %attr(0644,root,root) %{_mandir}/man1/gsissh-keygen.1*
 %attr(0755,root,root) %dir %{_libexecdir}/gsissh
@@ -491,6 +510,9 @@ getent passwd sshd >/dev/null || \
 %attr(0644,root,root) %{_unitdir}/gsisshd-keygen.service
 
 %changelog
+* Thu Jul 10 2014 Mattias Ellert <mattias.ellert at fysast.uu.se> - 6.4p1-3
+- Based on openssh-6.4p1-4.fc20
+
 * Sat Jun 07 2014 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 6.4p1-2.1
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
 
diff --git a/gsisshd-keygen.service b/gsisshd-keygen.service
index 6bd2c4f..5cb78e3 100644
--- a/gsisshd-keygen.service
+++ b/gsisshd-keygen.service
@@ -1,7 +1,7 @@
 [Unit]
 Description=gsissh Server Key Generation
 ConditionPathExists=|!/etc/gsissh/ssh_host_rsa_key
-ConditionPathExists=|!/etc/gsissh/ssh_host_dsa_key
+ConditionPathExists=|!/etc/gsissh/ssh_host_ecdsa_key
 
 [Service]
 ExecStart=/usr/sbin/gsisshd-keygen
diff --git a/openssh-6.1p1-log-usepam-no.patch b/openssh-6.1p1-log-usepam-no.patch
index 4ed52b1..64cec2c 100644
--- a/openssh-6.1p1-log-usepam-no.patch
+++ b/openssh-6.1p1-log-usepam-no.patch
@@ -15,7 +15,7 @@ diff -up openssh-6.1p1/sshd.c.log-usepam-no openssh-6.1p1/sshd.c
 diff -up openssh-6.1p1/sshd_config.log-usepam-no openssh-6.1p1/sshd_config
 --- openssh-6.1p1/sshd_config.log-usepam-no	2012-09-14 20:54:58.514255748 +0200
 +++ openssh-6.1p1/sshd_config	2012-09-14 20:54:58.551255954 +0200
-@@ -95,6 +95,8 @@ GSSAPICleanupCredentials yes
+@@ -95,6 +95,8 @@ GSSAPICleanupCredentials no
  # If you just want the PAM account and session checks to run without
  # PAM authentication, then enable this but set PasswordAuthentication
  # and ChallengeResponseAuthentication to 'no'.
diff --git a/openssh-6.3p1-fips.patch b/openssh-6.3p1-fips.patch
index acf4e82..6a5a332 100644
--- a/openssh-6.3p1-fips.patch
+++ b/openssh-6.3p1-fips.patch
@@ -527,9 +527,9 @@ diff -up openssh-6.3p1/sshconnect2.c.fips openssh-6.3p1/sshconnect2.c
  	if (options.hostkeyalgorithms != NULL)
  		myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] =
  		    options.hostkeyalgorithms;
-diff -up openssh-6.3p1/sshd.c.fips openssh-6.3p1/sshd.c
---- openssh-6.3p1/sshd.c.fips	2013-10-11 22:24:32.842031223 +0200
-+++ openssh-6.3p1/sshd.c	2013-10-11 22:24:32.873031077 +0200
+diff -up openssh-6.4p1/sshd.c.fips openssh-6.4p1/sshd.c
+--- openssh-6.4p1/sshd.c.fips	2014-01-27 16:20:12.751358484 +0100
++++ openssh-6.4p1/sshd.c	2014-01-27 16:21:12.961052163 +0100
 @@ -76,6 +76,8 @@
  #include <openssl/bn.h>
  #include <openssl/md5.h>
@@ -539,22 +539,26 @@ diff -up openssh-6.3p1/sshd.c.fips openssh-6.3p1/sshd.c
  #include "openbsd-compat/openssl-compat.h"
  
  #ifdef HAVE_SECUREWARE
-@@ -1450,6 +1452,14 @@ main(int ac, char **av)
+@@ -1450,6 +1452,18 @@ main(int ac, char **av)
  #endif
  	__progname = ssh_get_progname(av[0]);
  
 +        SSLeay_add_all_algorithms();
 +	if (access("/etc/system-fips", F_OK) == 0)
-+		if (! FIPSCHECK_verify(NULL, NULL))
-+			if (FIPS_mode())
-+				fatal("FIPS integrity verification test failed.");
++		if (! FIPSCHECK_verify(NULL, NULL)) {
++			openlog(__progname, LOG_PID, LOG_AUTHPRIV);
++			if (FIPS_mode()) {
++				syslog(LOG_CRIT, "FIPS integrity verification test failed.");
++				cleanup_exit(255);
++			}
 +			else
-+				logit("FIPS integrity verification test failed.");
-+
++				syslog(LOG_INFO, "FIPS integrity verification test failed.");
++			closelog();
++		}
  	/* Save argv. Duplicate so setproctitle emulation doesn't clobber it */
  	saved_argc = ac;
  	rexec_argc = ac;
-@@ -1601,8 +1611,6 @@ main(int ac, char **av)
+@@ -1601,8 +1615,6 @@ main(int ac, char **av)
  	else
  		closefrom(REEXEC_DEVCRYPTO_RESERVED_FD);
  
@@ -563,7 +567,7 @@ diff -up openssh-6.3p1/sshd.c.fips openssh-6.3p1/sshd.c
  	/* If requested, redirect the logs to the specified logfile. */
  	if (logfile != NULL) {
  		log_redirect_stderr_to(logfile);
-@@ -1773,6 +1781,10 @@ main(int ac, char **av)
+@@ -1773,6 +1785,10 @@ main(int ac, char **av)
  		debug("private host key: #%d type %d %s", i, keytype,
  		    key_type(key ? key : pubkey));
  	}
@@ -574,7 +578,7 @@ diff -up openssh-6.3p1/sshd.c.fips openssh-6.3p1/sshd.c
  	if ((options.protocol & SSH_PROTO_1) && !sensitive_data.have_ssh1_key) {
  		logit("Disabling protocol version 1. Could not load host key");
  		options.protocol &= ~SSH_PROTO_1;
-@@ -1936,6 +1948,10 @@ main(int ac, char **av)
+@@ -1936,6 +1952,10 @@ main(int ac, char **av)
  	/* Initialize the random number generator. */
  	arc4random_stir();
  
@@ -585,7 +589,7 @@ diff -up openssh-6.3p1/sshd.c.fips openssh-6.3p1/sshd.c
  	/* Chdir to the root directory so that the current disk can be
  	   unmounted if desired. */
  	if (chdir("/") == -1)
-@@ -2498,6 +2514,9 @@ do_ssh2_kex(void)
+@@ -2498,6 +2518,9 @@ do_ssh2_kex(void)
  	if (options.ciphers != NULL) {
  		myproposal[PROPOSAL_ENC_ALGS_CTOS] =
  		myproposal[PROPOSAL_ENC_ALGS_STOC] = options.ciphers;
@@ -595,7 +599,7 @@ diff -up openssh-6.3p1/sshd.c.fips openssh-6.3p1/sshd.c
  	}
  	myproposal[PROPOSAL_ENC_ALGS_CTOS] =
  	    compat_cipher_proposal(myproposal[PROPOSAL_ENC_ALGS_CTOS]);
-@@ -2507,6 +2526,9 @@ do_ssh2_kex(void)
+@@ -2507,6 +2530,9 @@ do_ssh2_kex(void)
  	if (options.macs != NULL) {
  		myproposal[PROPOSAL_MAC_ALGS_CTOS] =
  		myproposal[PROPOSAL_MAC_ALGS_STOC] = options.macs;
diff --git a/openssh-6.3p1-gsskex.patch b/openssh-6.3p1-gsskex.patch
index eefd792..0c54d38 100644
--- a/openssh-6.3p1-gsskex.patch
+++ b/openssh-6.3p1-gsskex.patch
@@ -2892,7 +2892,7 @@ diff -up openssh-6.3p1/sshd_config.gsskex openssh-6.3p1/sshd_config
 @@ -92,6 +92,8 @@ ChallengeResponseAuthentication no
  GSSAPIAuthentication yes
  #GSSAPICleanupCredentials yes
- GSSAPICleanupCredentials yes
+ GSSAPICleanupCredentials no
 +#GSSAPIStrictAcceptorCheck yes
 +#GSSAPIKeyExchange no
  
diff --git a/openssh-6.3p1-redhat.patch b/openssh-6.3p1-redhat.patch
index d85244d..98df47d 100644
--- a/openssh-6.3p1-redhat.patch
+++ b/openssh-6.3p1-redhat.patch
@@ -96,7 +96,7 @@ diff -up openssh-6.3p1/sshd_config.redhat openssh-6.3p1/sshd_config
  #GSSAPIAuthentication no
 +GSSAPIAuthentication yes
  #GSSAPICleanupCredentials yes
-+GSSAPICleanupCredentials yes
++GSSAPICleanupCredentials no
  
  # Set this to 'yes' to enable PAM authentication, account processing, 
  # and session processing. If this is enabled, PAM authentication will 
diff --git a/openssh-6.4p1-CLOCK_BOOTTIME.patch b/openssh-6.4p1-CLOCK_BOOTTIME.patch
new file mode 100644
index 0000000..1073a77
--- /dev/null
+++ b/openssh-6.4p1-CLOCK_BOOTTIME.patch
@@ -0,0 +1,29 @@
+--- a/misc.c
++++ b/misc.c
+@@ -865,17 +865,24 @@ ms_to_timeval(struct timeval *tv, int ms
+ time_t
+ monotime(void)
+ {
+-#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
++#if defined(HAVE_CLOCK_GETTIME) && \
++    (defined(CLOCK_MONOTONIC) || defined(CLOCK_BOOTTIME))
+ 	struct timespec ts;
+ 	static int gettime_failed = 0;
+ 
+ 	if (!gettime_failed) {
++#if defined(CLOCK_BOOTTIME)
++		if (clock_gettime(CLOCK_BOOTTIME, &ts) == 0)
++			return (ts.tv_sec);
++#endif
++#if defined(CLOCK_MONOTONIC)
+ 		if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
+ 			return (ts.tv_sec);
++#endif
+ 		debug3("clock_gettime: %s", strerror(errno));
+ 		gettime_failed = 1;
+ 	}
+-#endif
++#endif /* HAVE_CLOCK_GETTIME && (CLOCK_MONOTONIC || CLOCK_BOOTTIME */
+ 
+ 	return time(NULL);
+ }
diff --git a/openssh-6.4p1-CVE-2014-2653.patch b/openssh-6.4p1-CVE-2014-2653.patch
new file mode 100644
index 0000000..27f3fa3
--- /dev/null
+++ b/openssh-6.4p1-CVE-2014-2653.patch
@@ -0,0 +1,80 @@
+diff --git a/ChangeLog b/ChangeLog
+index 29d70ec..a0fb67e 100644
+--- a/ChangeLog
++++ b/ChangeLog
+@@ -1,3 +1,14 @@
++20140420
++   - djm at cvs.openbsd.org 2014/04/01 03:34:10
++     [sshconnect.c]
++     When using VerifyHostKeyDNS with a DNSSEC resolver, down-convert any
++     certificate keys to plain keys and attempt SSHFP resolution.
++     
++     Prevents a server from skipping SSHFP lookup and forcing a new-hostkey
++     dialog by offering only certificate keys.
++     
++     Reported by mcv21 AT cam.ac.uk
++
+ 20131010
+  - dtucker at cvs.openbsd.org 2013/10/08 11:42:13
+    [dh.c dh.h]
+diff --git a/sshconnect.c b/sshconnect.c
+index ddc167e..4d8c718 100644
+--- a/sshconnect.c
++++ b/sshconnect.c
+@@ -1136,30 +1136,40 @@ verify_host_key(char *host, struct sockaddr *hostaddr, Key *host_key)
+ {
+ 	int flags = 0;
+ 	char *fp;
++	Key *plain = NULL;
+ 
+ 	fp = key_selected_fingerprint(host_key, SSH_FP_HEX);
+ 	debug("Server host key: %s %s%s", key_type(host_key),
+ 	    key_fingerprint_prefix(), fp);
+ 	free(fp);
+ 
+-	/* XXX certs are not yet supported for DNS */
+-	if (!key_is_cert(host_key) && options.verify_host_key_dns &&
+-	    verify_host_key_dns(host, hostaddr, host_key, &flags) == 0) {
+-		if (flags & DNS_VERIFY_FOUND) {
+-
+-			if (options.verify_host_key_dns == 1 &&
+-			    flags & DNS_VERIFY_MATCH &&
+-			    flags & DNS_VERIFY_SECURE)
+-				return 0;
+-
+-			if (flags & DNS_VERIFY_MATCH) {
+-				matching_host_key_dns = 1;
+-			} else {
+-				warn_changed_key(host_key);
+-				error("Update the SSHFP RR in DNS with the new "
+-				    "host key to get rid of this message.");
++	if (options.verify_host_key_dns) {
++		/*
++		 * XXX certs are not yet supported for DNS, so downgrade
++		 * them and try the plain key.
++		 */
++		plain = key_from_private(host_key);
++		if (key_is_cert(plain))
++			key_drop_cert(plain);
++		if (verify_host_key_dns(host, hostaddr, plain, &flags) == 0) {
++			if (flags & DNS_VERIFY_FOUND) {
++				if (options.verify_host_key_dns == 1 &&
++				    flags & DNS_VERIFY_MATCH &&
++				    flags & DNS_VERIFY_SECURE) {
++					key_free(plain);
++					return 0;
++				}
++				if (flags & DNS_VERIFY_MATCH) {
++					matching_host_key_dns = 1;
++				} else {
++					warn_changed_key(plain);
++					error("Update the SSHFP RR in DNS "
++					    "with the new host key to get rid "
++					    "of this message.");
++				}
+ 			}
+ 		}
++		key_free(plain);
+ 	}
+ 
+ 	return check_host_key(host, hostaddr, options.port, host_key, RDRW,
diff --git a/openssh-6.4p1-FIPS-mode-SP800-131A.patch b/openssh-6.4p1-FIPS-mode-SP800-131A.patch
new file mode 100644
index 0000000..cf632d8
--- /dev/null
+++ b/openssh-6.4p1-FIPS-mode-SP800-131A.patch
@@ -0,0 +1,206 @@
+diff --git a/dh.h b/dh.h
+index 48f7b68..9ff39f4 100644
+--- a/dh.h
++++ b/dh.h
+@@ -45,6 +45,7 @@ int	 dh_estimate(int);
+ 
+ /* Min and max values from RFC4419. */
+ #define DH_GRP_MIN	1024
++#define DH_GRP_MIN_FIPS	2048
+ #define DH_GRP_MAX	8192
+ 
+ /*
+diff --git a/kex.c b/kex.c
+index a468805..3a0eb16 100644
+--- a/kex.c
++++ b/kex.c
+@@ -34,6 +34,7 @@
+ #include <string.h>
+ 
+ #include <openssl/crypto.h>
++#include <openssl/fips.h>
+ 
+ #include "xmalloc.h"
+ #include "ssh2.h"
+@@ -93,6 +94,20 @@ static const struct kexalg kexalgs[] = {
+ 	{ NULL, -1, -1, NULL},
+ };
+ 
++static const struct kexalg kexalgs_fips[] = {
++	{ KEX_DH14, KEX_DH_GRP14_SHA1, 0, EVP_sha1 },
++	{ KEX_DHGEX_SHA1, KEX_DH_GEX_SHA1, 0, EVP_sha1 },
++#ifdef HAVE_EVP_SHA256
++	{ KEX_DHGEX_SHA256, KEX_DH_GEX_SHA256, 0, EVP_sha256 },
++#endif
++#ifdef OPENSSL_HAS_ECC
++	{ KEX_ECDH_SHA2_NISTP256, KEX_ECDH_SHA2, NID_X9_62_prime256v1, EVP_sha256 },
++	{ KEX_ECDH_SHA2_NISTP384, KEX_ECDH_SHA2, NID_secp384r1, EVP_sha384 },
++	{ KEX_ECDH_SHA2_NISTP521, KEX_ECDH_SHA2, NID_secp521r1, EVP_sha512 },
++#endif
++	{ NULL, -1, -1, NULL},
++};
++
+ char *
+ kex_alg_list(void)
+ {
+@@ -116,7 +131,7 @@ kex_alg_by_name(const char *name)
+ {
+ 	const struct kexalg *k;
+ 
+-	for (k = kexalgs; k->name != NULL; k++) {
++	for (k = (FIPS_mode() ? kexalgs_fips : kexalgs); k->name != NULL; k++) {
+ 		if (strcmp(k->name, name) == 0)
+ 			return k;
+ #ifdef GSSAPI
+@@ -141,7 +156,10 @@ kex_names_valid(const char *names)
+ 	for ((p = strsep(&cp, ",")); p && *p != '\0';
+ 	    (p = strsep(&cp, ","))) {
+ 		if (kex_alg_by_name(p) == NULL) {
+-			error("Unsupported KEX algorithm \"%.100s\"", p);
++			if (FIPS_mode())
++				error("\"%.100s\" is not allowed in FIPS mode", p);
++			else
++				error("Unsupported KEX algorithm \"%.100s\"", p);
+ 			free(s);
+ 			return 0;
+ 		}
+diff --git a/kexecdhc.c b/kexecdhc.c
+index 6193836..d435f1f 100644
+--- a/kexecdhc.c
++++ b/kexecdhc.c
+@@ -154,6 +154,7 @@ kexecdh_client(Kex *kex)
+ 
+ 	kex_derive_keys(kex, hash, hashlen, shared_secret);
+ 	BN_clear_free(shared_secret);
++	memset(hash, 0, hashlen);
+ 	kex_finish(kex);
+ }
+ #else /* OPENSSL_HAS_ECC */
+diff --git a/kexecdhs.c b/kexecdhs.c
+index 3a580aa..9a06905 100644
+--- a/kexecdhs.c
++++ b/kexecdhs.c
+@@ -155,6 +155,7 @@ kexecdh_server(Kex *kex)
+ 
+ 	kex_derive_keys(kex, hash, hashlen, shared_secret);
+ 	BN_clear_free(shared_secret);
++	memset(hash, 0, hashlen);
+ 	kex_finish(kex);
+ }
+ #else /* OPENSSL_HAS_ECC */
+diff --git a/kexgexc.c b/kexgexc.c
+index 5a3be20..a931b6e 100644
+--- a/kexgexc.c
++++ b/kexgexc.c
+@@ -26,6 +26,8 @@
+ 
+ #include "includes.h"
+ 
++#include <openssl/fips.h>
++
+ #include <sys/types.h>
+ 
+ #include <openssl/dh.h>
+@@ -64,13 +66,13 @@ kexgex_client(Kex *kex)
+ 		/* Old GEX request */
+ 		packet_start(SSH2_MSG_KEX_DH_GEX_REQUEST_OLD);
+ 		packet_put_int(nbits);
+-		min = DH_GRP_MIN;
++		min = FIPS_mode() ? DH_GRP_MIN_FIPS : DH_GRP_MIN;
+ 		max = DH_GRP_MAX;
+ 
+ 		debug("SSH2_MSG_KEX_DH_GEX_REQUEST_OLD(%u) sent", nbits);
+ 	} else {
+ 		/* New GEX request */
+-		min = DH_GRP_MIN;
++		min = FIPS_mode() ? DH_GRP_MIN_FIPS : DH_GRP_MIN;
+ 		max = DH_GRP_MAX;
+ 		packet_start(SSH2_MSG_KEX_DH_GEX_REQUEST);
+ 		packet_put_int(min);
+diff --git a/kexgexs.c b/kexgexs.c
+index 4e473fc..2ed49bd 100644
+--- a/kexgexs.c
++++ b/kexgexs.c
+@@ -76,16 +76,16 @@ kexgex_server(Kex *kex)
+ 		omin = min = packet_get_int();
+ 		onbits = nbits = packet_get_int();
+ 		omax = max = packet_get_int();
+-		min = MAX(DH_GRP_MIN, min);
++		min = MAX(FIPS_mode() ? DH_GRP_MIN_FIPS : DH_GRP_MIN, min);
+ 		max = MIN(DH_GRP_MAX, max);
+-		nbits = MAX(DH_GRP_MIN, nbits);
++		nbits = MAX(FIPS_mode() ? DH_GRP_MIN_FIPS : DH_GRP_MIN, nbits);
+ 		nbits = MIN(DH_GRP_MAX, nbits);
+ 		break;
+ 	case SSH2_MSG_KEX_DH_GEX_REQUEST_OLD:
+ 		debug("SSH2_MSG_KEX_DH_GEX_REQUEST_OLD received");
+ 		onbits = nbits = packet_get_int();
+ 		/* unused for old GEX */
+-		omin = min = DH_GRP_MIN;
++		omin = min = FIPS_mode() ? DH_GRP_MIN_FIPS : DH_GRP_MIN;
+ 		omax = max = DH_GRP_MAX;
+ 		break;
+ 	default:
+diff --git a/myproposal.h b/myproposal.h
+index ee69ea2..1b68c5b 100644
+--- a/myproposal.h
++++ b/myproposal.h
+@@ -72,6 +72,12 @@
+ 	"diffie-hellman-group14-sha1," \
+ 	"diffie-hellman-group1-sha1"
+ 
++#define KEX_DEFAULT_KEX_FIPS		\
++	KEX_ECDH_METHODS \
++	KEX_SHA256_METHODS \
++	"diffie-hellman-group-exchange-sha1," \
++	"diffie-hellman-group14-sha1"
++
+ #define	KEX_DEFAULT_PK_ALG	\
+ 	HOSTKEY_ECDSA_CERT_METHODS \
+ 	"ssh-rsa-cert-v01 at openssh.com," \
+diff --git a/ssh-keygen.c b/ssh-keygen.c
+index cac6762..2569016 100644
+--- a/ssh-keygen.c
++++ b/ssh-keygen.c
+@@ -183,8 +183,14 @@ type_bits_valid(int type, u_int32_t *bitsp)
+ 		fprintf(stderr, "key bits exceeds maximum %d\n", maxbits);
+ 		exit(1);
+ 	}
+-	if (type == KEY_DSA && *bitsp != 1024)
++	if (type == KEY_DSA && FIPS_mode())
++		fatal("DSA keys are not allowed in FIPS mode");
++	else if (type == KEY_DSA && *bitsp != 1024)
+ 		fatal("DSA keys must be 1024 bits");
++	else if (type == KEY_RSA && bits < DEFAULT_BITS && FIPS_mode()) {
++		fprintf(stderr, "RSA keys must be at least %d bits in FIPS mode\n", DEFAULT_BITS);
++		exit(1);
++	}
+ 	else if (type != KEY_ECDSA && *bitsp < 768)
+ 		fatal("Key must at least be 768 bits");
+ 	else if (type == KEY_ECDSA && key_ecdsa_bits_to_nid(*bitsp) == -1)
+diff --git a/sshconnect2.c b/sshconnect2.c
+index 7e48880..3179d82 100644
+--- a/sshconnect2.c
++++ b/sshconnect2.c
+@@ -231,6 +231,8 @@ ssh_kex2(char *host, struct sockaddr *hostaddr, u_short port)
+ 	}
+ 	if (options.kex_algorithms != NULL)
+ 		myproposal[PROPOSAL_KEX_ALGS] = options.kex_algorithms;
++	else if (FIPS_mode())
++		myproposal[PROPOSAL_KEX_ALGS] = KEX_DEFAULT_KEX_FIPS;
+ 
+ #ifdef GSSAPI
+ 	/* If we've got GSSAPI algorithms, then we also support the
+diff --git a/sshd.c b/sshd.c
+index 11adbf6..f5e98bc 100644
+--- a/sshd.c
++++ b/sshd.c
+@@ -2605,6 +2605,8 @@ do_ssh2_kex(void)
+ 	}
+ 	if (options.kex_algorithms != NULL)
+ 		myproposal[PROPOSAL_KEX_ALGS] = options.kex_algorithms;
++	else if (FIPS_mode())
++		myproposal[PROPOSAL_KEX_ALGS] = KEX_DEFAULT_KEX_FIPS;
+ 
+ 	if (options.rekey_limit || options.rekey_interval)
+ 		packet_set_rekey_limits((u_int32_t)options.rekey_limit,
diff --git a/openssh-6.4p1-fromto-remote.patch b/openssh-6.4p1-fromto-remote.patch
new file mode 100644
index 0000000..4a7d849
--- /dev/null
+++ b/openssh-6.4p1-fromto-remote.patch
@@ -0,0 +1,16 @@
+diff --git a/scp.c b/scp.c
+index d98fa67..25d347b 100644
+--- a/scp.c
++++ b/scp.c
+@@ -638,7 +638,10 @@ toremote(char *targ, int argc, char **argv)
+ 			addargs(&alist, "%s", ssh_program);
+ 			addargs(&alist, "-x");
+ 			addargs(&alist, "-oClearAllForwardings=yes");
+-			addargs(&alist, "-n");
++			if (isatty(fileno(stdin)))
++				addargs(&alist, "-t");
++			else
++				addargs(&alist, "-n");
+ 			for (j = 0; j < remote_remote_args.num; j++) {
+ 				addargs(&alist, "%s",
+ 				    remote_remote_args.list[j]);
diff --git a/openssh-6.4p1-gsissh.patch b/openssh-6.4p1-gsissh.patch
index edd513a..0e23d7f 100644
--- a/openssh-6.4p1-gsissh.patch
+++ b/openssh-6.4p1-gsissh.patch
@@ -2253,7 +2253,7 @@ diff -Nur openssh-6.4p1.orig/sshd.c openssh-6.4p1/sshd.c
 diff -Nur openssh-6.4p1.orig/sshd_config openssh-6.4p1/sshd_config
 --- openssh-6.4p1.orig/sshd_config	2013-11-26 14:25:47.983371579 +0100
 +++ openssh-6.4p1/sshd_config	2013-11-26 14:26:35.183803047 +0100
-@@ -89,12 +89,11 @@
+@@ -89,12 +89,12 @@
  #KerberosUseKuserok yes
  
  # GSSAPI options
@@ -2262,7 +2262,7 @@ diff -Nur openssh-6.4p1.orig/sshd_config openssh-6.4p1/sshd_config
 +#GSSAPIAuthentication yes
 +#GSSAPIDelegateCredentials yes
  #GSSAPICleanupCredentials yes
--GSSAPICleanupCredentials yes
+ GSSAPICleanupCredentials no
  #GSSAPIStrictAcceptorCheck yes
 -#GSSAPIKeyExchange no
 +#GSSAPIKeyExchange yes
diff --git a/openssh-6.4p1-ignore-bad-env-var.patch b/openssh-6.4p1-ignore-bad-env-var.patch
new file mode 100644
index 0000000..3bb49c2
--- /dev/null
+++ b/openssh-6.4p1-ignore-bad-env-var.patch
@@ -0,0 +1,37 @@
+diff -U0 openssh-6.4p1/ChangeLog.bad-env-var openssh-6.4p1/ChangeLog
+--- openssh-6.4p1/ChangeLog.bad-env-var	2014-03-19 21:37:36.270509907 +0100
++++ openssh-6.4p1/ChangeLog	2014-03-19 21:37:36.276509878 +0100
+@@ -0,0 +1,7 @@
++20140304
++ - OpenBSD CVS Sync
++   - djm at cvs.openbsd.org 2014/03/03 22:22:30
++     [session.c]
++     ignore enviornment variables with embedded '=' or '\0' characters;
++     spotted by Jann Horn; ok deraadt@
++
+diff -up openssh-6.4p1/session.c.bad-env-var openssh-6.4p1/session.c
+--- openssh-6.4p1/session.c.bad-env-var	2014-03-19 21:37:36.233510090 +0100
++++ openssh-6.4p1/session.c	2014-03-19 21:37:36.277509873 +0100
+@@ -990,6 +990,11 @@ child_set_env(char ***envp, u_int *envsi
+ 	u_int envsize;
+ 	u_int i, namelen;
+ 
++	if (strchr(name, '=') != NULL) {
++		error("Invalid environment variable \"%.100s\"", name);
++		return;
++	}
++
+ 	/*
+ 	 * If we're passed an uninitialized list, allocate a single null
+ 	 * entry before continuing.
+@@ -2255,8 +2260,8 @@ session_env_req(Session *s)
+ 	char *name, *val;
+ 	u_int name_len, val_len, i;
+ 
+-	name = packet_get_string(&name_len);
+-	val = packet_get_string(&val_len);
++	name = packet_get_cstring(&name_len);
++	val = packet_get_cstring(&val_len);
+ 	packet_check_eom();
+ 
+ 	/* Don't set too many environment variables */
diff --git a/openssh-6.4p1-legacy-ssh-copy-id.patch b/openssh-6.4p1-legacy-ssh-copy-id.patch
new file mode 100644
index 0000000..ba8d949
--- /dev/null
+++ b/openssh-6.4p1-legacy-ssh-copy-id.patch
@@ -0,0 +1,57 @@
+diff -up openssh-6.4p1/contrib/ssh-copy-id.1.legacy-ssh-copy-id openssh-6.4p1/contrib/ssh-copy-id.1
+--- openssh-6.4p1/contrib/ssh-copy-id.1.legacy-ssh-copy-id	2013-03-22 00:17:37.000000000 +0100
++++ openssh-6.4p1/contrib/ssh-copy-id.1	2014-01-28 17:12:49.197542425 +0100
+@@ -180,6 +180,19 @@ should prove enlightening (N.B. the mode
+ .Fl W
+ option, rather than
+ .Xr nc 1 ) .
++.Sh ENVIRONMENT
++.Bl -tag -width Ds
++.Pp
++.It Pa SSH_COPY_ID_LEGACY
++If the 
++.Cm SSH_COPY_ID_LEGACY
++environment variable is set, the
++.Nm
++is run in a legacy mode. In this mode, the 
++.Nm
++doesn't check an existence of a private key and doesn't do remote checks
++of the remote server versions or if public keys are already installed.
++.El
+ .Sh "SEE ALSO"
+ .Xr ssh 1 ,
+ .Xr ssh-agent 1 ,
+diff -up openssh-6.4p1/contrib/ssh-copy-id.legacy-ssh-copy-id openssh-6.4p1/contrib/ssh-copy-id
+--- openssh-6.4p1/contrib/ssh-copy-id.legacy-ssh-copy-id	2013-06-05 14:48:45.000000000 +0200
++++ openssh-6.4p1/contrib/ssh-copy-id	2014-01-28 17:11:51.538833032 +0100
+@@ -77,7 +77,7 @@ use_id_file() {
+     PUB_ID_FILE="$L_ID_FILE.pub"
+   fi
+ 
+-  PRIV_ID_FILE=$(dirname "$PUB_ID_FILE")/$(basename "$PUB_ID_FILE" .pub)
++  [ "x$SSH_COPY_ID_LEGACY" != "x" ] || PRIV_ID_FILE=$(dirname "$PUB_ID_FILE")/$(basename "$PUB_ID_FILE" .pub)
+ 
+   # check that the files are readable
+   for f in $PUB_ID_FILE $PRIV_ID_FILE ; do
+@@ -243,7 +243,7 @@ populate_new_ids() {
+   printf '%s: INFO: %d key(s) remain to be installed -- if you are prompted now it is to install the new keys\n' "$0" "$(printf '%s\n' "$NEW_IDS" | wc -l)" >&2
+ }
+ 
+-REMOTE_VERSION=$(ssh -v -o PreferredAuthentications=',' "$@" 2>&1 |
++[ "x$SSH_COPY_ID_LEGACY" != "x" ] || REMOTE_VERSION=$(ssh -v -o PreferredAuthentications=',' "$@" 2>&1 |
+                  sed -ne 's/.*remote software version //p')
+ 
+ case "$REMOTE_VERSION" in
+@@ -268,7 +268,11 @@ case "$REMOTE_VERSION" in
+     ;;
+   *)
+     # Assuming that the remote host treats ~/.ssh/authorized_keys as one might expect
+-    populate_new_ids 0
++    if [ "x$SSH_COPY_ID_LEGACY" != "x" ]; then
++      NEW_IDS=`eval "$GET_ID"`
++    else
++      populate_new_ids 0
++    fi
+     [ "$DRY_RUN" ] || printf '%s\n' "$NEW_IDS" | ssh "$@" "
+ 		umask 077 ;
+ 		mkdir -p .ssh && cat >> .ssh/authorized_keys || exit 1 ;


More information about the scm-commits mailing list