Add patch to fix crasher bug triggered on hardened x86_64 machines with USE=X509...
authorPatrick McLean <chutzpah@gentoo.org>
Fri, 27 Feb 2015 22:07:09 +0000 (22:07 +0000)
committerPatrick McLean <chutzpah@gentoo.org>
Fri, 27 Feb 2015 22:07:09 +0000 (22:07 +0000)
Package-Manager: portage-2.2.17/cvs/Linux x86_64
Manifest-Sign-Key: 0xE3F69979BB4B8928DA78E3D17CBF44EF

net-misc/openssh/ChangeLog
net-misc/openssh/Manifest
net-misc/openssh/files/openssh-6.7_p1-xmalloc-include.patch [new file with mode: 0644]
net-misc/openssh/openssh-6.7_p1-r4.ebuild [new file with mode: 0644]

index a16dffc0cc125dcd166efc325831478154661098..b04934afe1d9c653cf48d1b9323874874b3d14ad 100644 (file)
@@ -1,6 +1,13 @@
 # ChangeLog for net-misc/openssh
 # Copyright 1999-2015 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/net-misc/openssh/ChangeLog,v 1.543 2015/01/31 18:05:34 polynomial-c Exp $
+# $Header: /var/cvsroot/gentoo-x86/net-misc/openssh/ChangeLog,v 1.544 2015/02/27 22:06:53 chutzpah Exp $
+
+*openssh-6.7_p1-r4 (27 Feb 2015)
+
+  27 Feb 2015; Patrick McLean <chutzpah@gentoo.org>
+  +files/openssh-6.7_p1-xmalloc-include.patch, +openssh-6.7_p1-r4.ebuild:
+  Add patch to fix crasher bug triggered on hardened x86_64 machines with
+  USE=X509 and ancient clients.
 
   31 Jan 2015; Lars Wendler <polynomial-c@gentoo.org>
   -openssh-6.6_p1-r1.ebuild, -openssh-6.6.1_p1-r4.ebuild,
index 79711c9c44fc6da0f0cd3efda8cf79af72f7f377..2a7a9ff085ae7d5fefb286e487fdd900ca604d69 100644 (file)
@@ -9,6 +9,7 @@ AUX openssh-6.7_p1-openssl-ignore-status.patch 765 SHA256 b068cc30d4bce5c457cea7
 AUX openssh-6.7_p1-sctp-x509-glue.patch 1326 SHA256 42eb87eda1685e19add23c1304f17dabd99a1a38a57bfe2bfbb70ab85f6d385e SHA512 7f014e2b1893a5240680e2e14475d61b9b6047d1be3fe404d5971a899c122cc624546e9e5b31bfee5905cf7b4605a0871c3b00ed5c2bd28d84755a49392e1a69 WHIRLPOOL 8d6888163068dbc486bc4eff0dd7d4053f68b9848347eb520dd7d382b0b8c74e3016f7f3ed401c2c2dfd48e73a9077fb9777d39c0f236cc500c53393be426b42
 AUX openssh-6.7_p1-sshd-gssapi-multihomed.patch 5489 SHA256 d2a1735b523709a4b4ceaa57862ecb21a95656678bacc5b7da59dc46187ad997 SHA512 a8b8d2c2ab4520c8c7315f6130ee44fec48935a129ce7c7e51a068a4de2c7528980437246b61e4abc4cff614466f8054c554cdbaad4eb0d1f4afcfb434c30bbc WHIRLPOOL e4b97398c324360576a04792357f66be3ed9f17e4113f75275f8422ee0b7ecf28073c7cde01a63e24fa0901b14db822d22d7d2c5936bbee3bd5874a867066967
 AUX openssh-6.7_p1-x509-glue.patch 1633 SHA256 58031e90e0bf220028934ab590af6ccfc45722629b2416df13d84f10c9b94478 SHA512 364ca0280be5cc83d1dedf7727323fd5fc0093c6dbcf9cc8ccaa30ee754b866584be28da1166953f03faf8745d6364e33fad7daad9be9a29681a8674eb9d292b WHIRLPOOL b79a6cff897be78793bbf2ca03154103aa1380647b8c53e104155fd68122568a8e7dea23996213b192e4269f980b1035d3ca395dbd2c318fd81a45f44d110c31
+AUX openssh-6.7_p1-xmalloc-include.patch 390 SHA256 ea43a6a211d8cae4a078b748736f43d4a9d11804ace65886dec826b878dec28e SHA512 b51d9149418217828bdc53c234e248f8be1703b480ccf808814d37cd2589bccdbecff0046d2f2d0e4626420d0d4c2e02d25a9cc07ae31b365cd0b848ccc02035 WHIRLPOOL 04b298eb481fef585b055eb3d706cca55ad6efed6168246f0031e5f614085ae5e70cbb77717047d6c70d7d13a6846657e4a0089d4b8cdf5d9d05652ee22f7209
 AUX sshd.confd 396 SHA256 29c6d57ac3ec6018cadc6ba6cd9b90c9ed46e20049b970fdcc68ee2481a2ee41 SHA512 b9ae816af54a55e134a9307e376f05367b815f1b3fd545c2a2c312d18aedcf907f413e8bad8db980cdd9aad4011a72a79e1e94594f69500939a9cb46287f2f81 WHIRLPOOL 69f43e6192e009a4663d130f7e40ee8b13c6eb9cc7d960b5e0e22f5d477649c88806a9d219efef211f4346582c2bb51e40d230a8191e5953dbe08bfff976ae53
 AUX sshd.pam_include.2 156 SHA256 166136e27d653e0bf481a6ca79fecb7d9fa2fc3d597d041f97df595f65a8193c SHA512 d3f7e6ca8c9f2b5060ebccb259316bb59c9a7e158e8ef9466765a20db263a4043a590811f1a3ab072b718dbd70898bc69b77e0b19603d7f394b5ac1bd0a4a56c WHIRLPOOL ba7a0a8c3bb39c5fda69de34b822a19696398e0a8789211ac1faae787ee34f9639eb35efe29c67f874b5f9fe674742503e570f441c005974f4a0c93468b8970b
 AUX sshd.rc6.4 2313 SHA256 97221a017d8ee9de996277c5a794d973a0b5e8180c29c97b3652bd1984a7b5d0 SHA512 88826bc9923299ac4c1502e7076483d6c197fd5a0e693bc2e1690f82bcd7d1bbd144aae2ffd92acb28d6fe912233aa93346e00c72917de65c22811ce9cd5bff7 WHIRLPOOL a77bad5891eb74770ae12e79131a99e5645a83841d14f1d60e39581a23b9d86e66b2e5fb7d0c989afac410eb5c6a627b83389d54085d1b78c89fc07852f8eb66
@@ -21,23 +22,24 @@ DIST openssh-6.7p1-hpnssh14v5.tar.xz 25652 SHA256 7284db65548b6b04142930da86972f
 DIST openssh-6.7p1.tar.gz 1351367 SHA256 b2f8394eae858dabbdef7dac10b99aec00c95462753e80342e530bbb6f725507 SHA512 2469dfcd289948374843311dd9e5f7e144ce1cebd4bfce0d387d0b75cb59f3e1af1b9ebf96bd4ab6407dfa77a013c5d25742971053e61cae2541054aeaca559d WHIRLPOOL ac8ce86d0f6c78c4cb3624b480f189f951d508db38b22d7a5550b7302d5277c1c7d18eaa713d52139abc0f77edacfdb03ced2603125e3ddf9bc09c69e6b70518
 DIST openssh-lpk-6.7p1-0.3.14.patch.xz 16920 SHA256 0203e6e44e41d58ec46d1611d7efc985134e662bbee51632c29f43ae809003f0 SHA512 344ccde4a04aeb1500400f779e64b2d8a5ad2970de3c4c343ca9605758e22d3812ef5453cd3221b18ad74a9762583c62417879107e4e1dda1398a6a65bcd04b2 WHIRLPOOL 5b6beeb743d04deea70c8b471a328b5f056fd4651e1370c7882e5d12f54fa2170486dcd6f97aa8c58e80af9a2d4012e2dfbcf53185317976d309783ca8d6cf73
 EBUILD openssh-6.7_p1-r3.ebuild 10078 SHA256 1a58e95c28b5b938f2f15b3fec5688dc9509bb038805b0348b11ac31ed3c57e0 SHA512 add8eaebb3c91983a7bac78011700c110917dea6409bf46e784d7e17b1891facb3baacaa0bda71eb2c9b6017fbf1a21b5846434fba8d588724da871e7824f498 WHIRLPOOL 47e04a0644a592e29aaa9ac00b03a377e81cdb1d886119c21a77a0a351c0cea34018a24406449faa814c2f06e1c03b43ac16a78983bb4a9f57c36834ad7babcb
+EBUILD openssh-6.7_p1-r4.ebuild 10138 SHA256 e4f6c4e80485352cc75e62c0212670a0d7f4a19bcf1eed9972bbeaff8b7a2743 SHA512 fdcd7759a85412bdf05be5003d20289a862f13f945e1972e56a36602df426641ef3497399e06ff0da9a51cf2bd54831b6208ac399d42d3ce3e3b1493ffa7655c WHIRLPOOL ae24dbcc182627c356961f4ce290cb1b489e29fa13beaf27212bd4847a36f02af53a8508320cf2a76be88741297ac7533faf53c1d3b15d70299cff536ae8502f
 EBUILD openssh-6.7_p1.ebuild 10067 SHA256 970be3a06c0293262f6c59d068d290cc71935fe91f4295b1352b6c41c46c3bf7 SHA512 f2b689767c8da075f16e9e5d9fe258e22fb4019034539883d63632c1543d3141787883ec7013f87c23d709a554b4f994c4c2f41b1829e5301b55f7a5da3fbf46 WHIRLPOOL 8d70fd99a1f3307b801999a9c80be4bcc603cbc151170160d78a2fa8a50ceb701657cbb0b0eb9ccfe1287bff9299dcffb36f884b860a5ca88ac4a9936b21a574
-MISC ChangeLog 90257 SHA256 f7a985af1600728237b9b3c1b92b5c9ff25cda98fa445644091fee446975c8fb SHA512 8542aa9484ebcccb8db829eacf7a61dba1595280c5d6df163bee351720fd1e00437d5890853defc15e2516920d3980eaec50251f129a8aec2b5d03d7ec50803c WHIRLPOOL e349aec362a4d5d702650454fca7560af686a5d428cc9eff233c01b7f6145cfe5eb556ebe72726183aaf264055005574274faaa58b3b75475532b75aafbd8a7c
+MISC ChangeLog 90520 SHA256 7c454f72794840d7da66364b62442136c3e91daf02055252c4f92b7cd9199c47 SHA512 572532d5c72adeff37a120419dc58e8d56252dafbc5f1bd8cdb8bf0547b81ddc2878a0b1944d9ff6d51fbabbee61f22c0283b38e09a60293c6ea7303cd4f94c2 WHIRLPOOL bc29ceca24b297a1f3cb2739bd0806564f792d1d58c2c781cbec437a75436b775ac2baf8985404a47fdf3129c9157ee35de18e7d8a50de5c66561df58d50e56b
 MISC metadata.xml 1912 SHA256 7b838285f09ad395f237a0d0b9963eee86d0e85b58e6e5b4d5edb093fa888a0a SHA512 e55c10ffd12488720c3da19e55942cfedec63fe767fc1608439b5a3932eeb5488086ad7ef4e1f858c89381e737426f035845ea5e8bede4ed8a0ccabdc656d9b5 WHIRLPOOL 5c07b3dd4a4002cff5df62133ecf570bf79f58e9477d0ad25d60f185ee029183d11118147e3adfec373542659d921e99e787054cfe9284031c974d694de6e9ed
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
-iQIcBAEBCAAGBQJUzRlwAAoJEPiazRVxLXTFZ/0P/1CQN5gQLw4B04ZxRhu3YsDw
-FB1B7v9N8f4X66sodjeKvdbYoAMfru7zQIfsQgL2+TTDU8X15fDKabXeDRCOi/1G
-sfGoX3eqr6z0XWUk6NuNiOhO3QHsa++4py3gnzkI/qQTb6ih0c6rIIEElz9e0u1G
-9bDodeMZi5cQDdUHYGVPdmwk+7hucMKG//vn13SpVQXNB2FsH8FWqoH1ZfgRWX/g
-R73YNGveE6mZGzOGkvWsvAETOF4OTwqikYmkZRYias/7fLOuTVpJGLRaocH7xduE
-WpnNF9ADPwVqnWfRoRVG+BLMpU/P7RU8yGuwit0gmijbnJGVGmVzLwKgEv8LhNOo
-HORJK45kpQq1Q8wQRdrz6xXbE7NhKL+Wj2Kvu/CeGvWayoWNXVYepAOrms9eq6VY
-HFgJ3f9de54pF5/dxYq4BG7+ndOYKnCod8d/q6HnoZmiZOhJwKy2r9bTsHpmb9gi
-YWpXCUJ2MUPxBVbNHWXTa/TFoig6t75qylV2Qfhnkg52n2qouaXicQM1fmTcFkaj
-i8EEppUdEVWywGIXvv2ZkoGGaslyaETWmBH0Iy7i0B3b8Ox1b4kMiKPDScnEjdkh
-TrwY5Shv+q1wjjukkrvT8tQU9kHvn8Fdvj2zfAdfuv+O44pI/vKvrKfqvEMMQy26
-rK7P3i/fnMguMgL0jrlh
-=rApf
+iQIcBAEBCAAGBQJU8OqIAAoJEHy/RO9cNQiDxxsQAKcwgw0LRAp0fN2tCyitm0sW
+EQJfzjXV8bzPW1PRIVsru3SR5gkTaeig139jPDswmcxm3EDj+AEvQZW8UU9YnF4P
+o/RXaGkuwquOpvDEoJ4cE1qjIYzUIIsCiaMdBshweD/Gkur+gUOYI892kHuJXPUs
++nTpCMyhcj7mW8Ueu65xvYXxndoJq3z5ULGivex1HEGz2lPLA1TAhIaPoxIjx/dj
+9IVLqw8pZiHYY3pgqqdA880xqIXWNmPPGPFFitt3jUrCR6kisiBLdGF1edIH5+4V
+3aogwWyvdoziiRN9iPtOetZT/q0KRewHUdYyEeKndtXNzb0naINOcR3IjX1RMg0V
+3Qcda+RwOnvG2NfsvkcYK59Ar8thQag3+xLEhTHV7K1Sgl7ndXmRA0e/Obj7TH5M
+0Ql7L/kLkNakpZ8GNv0ZjqX2dAsjdUe0eVYKn/I+2PxIR+aw7Hjz1dtfZnXKKQM1
+LMoVvQHJz4qR7fFu67edz3PybtOS+4BRy1Lw88I3eg1ql9hhsqQtneD2xXp8us03
+SbuKR3GLnW1o6Ax5VDMkkW0oY2VB9FQQ3pJybkFUzjejo8hn5PG6OiM6aP15iI/Z
+0GG7VGKasywc52HEj0hq3FI/sgJDmrqk0vPBfxdsdp5e0z8uMZCBhLV5I0MVBTbK
+Jdi46gtdvo7eCnXY8+Fk
+=nfVc
 -----END PGP SIGNATURE-----
diff --git a/net-misc/openssh/files/openssh-6.7_p1-xmalloc-include.patch b/net-misc/openssh/files/openssh-6.7_p1-xmalloc-include.patch
new file mode 100644 (file)
index 0000000..170031d
--- /dev/null
@@ -0,0 +1,11 @@
+diff -ur openssh-6.7p1.orig/ssh-rsa.c openssh-6.7p1/ssh-rsa.c
+--- openssh-6.7p1.orig/ssh-rsa.c       2015-02-24 14:52:54.512197868 -0800
++++ openssh-6.7p1/ssh-rsa.c    2015-02-27 11:48:54.173951646 -0800
+@@ -34,6 +34,7 @@
+ #include "sshkey.h"
+ #include "digest.h"
+ #include "evp-compat.h"
++#include "xmalloc.h"
+ 
+ /*NOTE: Do not define USE_LEGACY_RSA_... if build
+   is with FIPS capable OpenSSL */
diff --git a/net-misc/openssh/openssh-6.7_p1-r4.ebuild b/net-misc/openssh/openssh-6.7_p1-r4.ebuild
new file mode 100644 (file)
index 0000000..2ed2a26
--- /dev/null
@@ -0,0 +1,324 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-misc/openssh/openssh-6.7_p1-r4.ebuild,v 1.1 2015/02/27 22:06:53 chutzpah Exp $
+
+EAPI="4"
+inherit eutils user flag-o-matic multilib autotools pam systemd versionator
+
+# Make it more portable between straight releases
+# and _p? releases.
+PARCH=${P/_}
+
+HPN_PATCH="${PN}-6.7p1-hpnssh14v5.tar.xz"
+LDAP_PATCH="${PN}-lpk-6.7p1-0.3.14.patch.xz"
+X509_VER="8.2" X509_PATCH="${PARCH}+x509-${X509_VER}.diff.gz"
+
+DESCRIPTION="Port of OpenBSD's free SSH release"
+HOMEPAGE="http://www.openssh.org/"
+SRC_URI="mirror://openbsd/OpenSSH/portable/${PARCH}.tar.gz
+       mirror://gentoo/${P}-sctp.patch.xz
+       ${HPN_PATCH:+hpn? (
+               mirror://gentoo/${HPN_PATCH}
+               http://dev.gentoo.org/~vapier/dist/${HPN_PATCH}
+               mirror://sourceforge/hpnssh/${HPN_PATCH}
+       )}
+       ${LDAP_PATCH:+ldap? ( mirror://gentoo/${LDAP_PATCH} )}
+       ${X509_PATCH:+X509? ( http://roumenpetrov.info/openssh/x509-${X509_VER}/${X509_PATCH} )}
+       "
+
+LICENSE="BSD GPL-2"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~arm-linux ~x86-linux"
+IUSE="bindist ${HPN_PATCH:++}hpn kerberos kernel_linux ldap ldns libedit pam +pie sctp selinux skey static X X509"
+REQUIRED_USE="pie? ( !static )"
+
+LIB_DEPEND="sctp? ( net-misc/lksctp-tools[static-libs(+)] )
+       selinux? ( >=sys-libs/libselinux-1.28[static-libs(+)] )
+       skey? ( >=sys-auth/skey-1.1.5-r1[static-libs(+)] )
+       libedit? ( dev-libs/libedit[static-libs(+)] )
+       >=dev-libs/openssl-0.9.6d:0[bindist=]
+       dev-libs/openssl[static-libs(+)]
+       >=sys-libs/zlib-1.2.3[static-libs(+)]"
+RDEPEND="
+       !static? (
+               ${LIB_DEPEND//\[static-libs(+)]}
+               ldns? (
+                       !bindist? ( net-libs/ldns[ecdsa,ssl] )
+                       bindist? ( net-libs/ldns[-ecdsa,ssl] )
+               )
+       )
+       pam? ( virtual/pam )
+       kerberos? ( virtual/krb5 )
+       ldap? ( net-nds/openldap )"
+DEPEND="${RDEPEND}
+       static? (
+               ${LIB_DEPEND}
+               ldns? (
+                       !bindist? ( net-libs/ldns[ecdsa,ssl,static-libs(+)] )
+                       bindist? ( net-libs/ldns[-ecdsa,ssl,static-libs(+)] )
+               )
+       )
+       virtual/pkgconfig
+       virtual/os-headers
+       sys-devel/autoconf"
+RDEPEND="${RDEPEND}
+       pam? ( >=sys-auth/pambase-20081028 )
+       userland_GNU? ( virtual/shadow )
+       X? ( x11-apps/xauth )"
+
+S=${WORKDIR}/${PARCH}
+
+pkg_setup() {
+       # this sucks, but i'd rather have people unable to `emerge -u openssh`
+       # than not be able to log in to their server any more
+       maybe_fail() { [[ -z ${!2} ]] && echo "$1" ; }
+       local fail="
+               $(use X509 && maybe_fail X509 X509_PATCH)
+               $(use ldap && maybe_fail ldap LDAP_PATCH)
+               $(use hpn && maybe_fail hpn HPN_PATCH)
+       "
+       fail=$(echo ${fail})
+       if [[ -n ${fail} ]] ; then
+               eerror "Sorry, but this version does not yet support features"
+               eerror "that you requested:      ${fail}"
+               eerror "Please mask ${PF} for now and check back later:"
+               eerror " # echo '=${CATEGORY}/${PF}' >> /etc/portage/package.mask"
+               die "booooo"
+       fi
+}
+
+save_version() {
+       # version.h patch conflict avoidence
+       mv version.h version.h.$1
+       cp -f version.h.pristine version.h
+}
+
+src_prepare() {
+       sed -i \
+               -e "/_PATH_XAUTH/s:/usr/X11R6/bin/xauth:${EPREFIX}/usr/bin/xauth:" \
+               pathnames.h || die
+       # keep this as we need it to avoid the conflict between LPK and HPN changing
+       # this file.
+       cp version.h version.h.pristine
+
+       # don't break .ssh/authorized_keys2 for fun
+       sed -i '/^AuthorizedKeysFile/s:^:#:' sshd_config || die
+
+       epatch "${FILESDIR}"/${PN}-6.7_p1-sshd-gssapi-multihomed.patch #378361
+       if use X509 ; then
+               pushd .. >/dev/null
+               epatch "${FILESDIR}"/${P}-x509-glue.patch
+               epatch "${FILESDIR}"/${P}-sctp-x509-glue.patch
+               popd >/dev/null
+               epatch "${WORKDIR}"/${X509_PATCH%.*}
+               epatch "${FILESDIR}"/${PN}-6.3_p1-x509-hpn14v2-glue.patch
+               epatch "${FILESDIR}"/${PN}-6.7_p1-xmalloc-include.patch
+               save_version X509
+       fi
+       if ! use X509 ; then
+               if [[ -n ${LDAP_PATCH} ]] && use ldap ; then
+                       epatch "${WORKDIR}"/${LDAP_PATCH%.*}
+                       save_version LPK
+               fi
+       else
+               use ldap && ewarn "Sorry, X509 and LDAP conflict internally, disabling LDAP"
+       fi
+       epatch "${FILESDIR}"/${PN}-4.7_p1-GSSAPI-dns.patch #165444 integrated into gsskex
+       epatch "${FILESDIR}"/${PN}-6.7_p1-openssl-ignore-status.patch
+       epatch "${WORKDIR}"/${PN}-6.7_p1-sctp.patch
+       if [[ -n ${HPN_PATCH} ]] && use hpn; then
+               epatch "${WORKDIR}"/${HPN_PATCH%.*}/*
+               save_version HPN
+       fi
+
+       tc-export PKG_CONFIG
+       local sed_args=(
+               -e "s:-lcrypto:$(${PKG_CONFIG} --libs openssl):"
+               # Disable PATH reset, trust what portage gives us #254615
+               -e 's:^PATH=/:#PATH=/:'
+               # Disable fortify flags ... our gcc does this for us
+               -e 's:-D_FORTIFY_SOURCE=2::'
+       )
+       # The -ftrapv flag ICEs on hppa #505182
+       use hppa && sed_args+=(
+               -e '/CFLAGS/s:-ftrapv:-fdisable-this-test:'
+               -e '/OSSH_CHECK_CFLAG_LINK.*-ftrapv/d'
+       )
+       sed -i "${sed_args[@]}" configure{.ac,} || die
+
+       epatch_user #473004
+
+       # Now we can build a sane merged version.h
+       (
+               sed '/^#define SSH_RELEASE/d' version.h.* | sort -u
+               macros=()
+               for p in HPN LPK X509 ; do [ -e version.h.${p} ] && macros+=( SSH_${p} ) ; done
+               printf '#define SSH_RELEASE SSH_VERSION SSH_PORTABLE %s\n' "${macros}"
+       ) > version.h
+
+       eautoreconf
+}
+
+static_use_with() {
+       local flag=$1
+       if use static && use ${flag} ; then
+               ewarn "Disabling '${flag}' support because of USE='static'"
+               # rebuild args so that we invert the first one (USE flag)
+               # but otherwise leave everything else working so we can
+               # just leverage use_with
+               shift
+               [[ -z $1 ]] && flag="${flag} ${flag}"
+               set -- !${flag} "$@"
+       fi
+       use_with "$@"
+}
+
+src_configure() {
+       local myconf=()
+       addwrite /dev/ptmx
+       addpredict /etc/skey/skeykeys #skey configure code triggers this
+
+       use static && append-ldflags -static
+
+       # Special settings for Gentoo/FreeBSD 9.0 or later (see bug #391011)
+       if use elibc_FreeBSD && version_is_at_least 9.0 "$(uname -r|sed 's/\(.\..\).*/\1/')" ; then
+               myconf+=( --disable-utmp --disable-wtmp --disable-wtmpx )
+               append-ldflags -lutil
+       fi
+
+       econf \
+               --with-ldflags="${LDFLAGS}" \
+               --disable-strip \
+               --with-pid-dir="${EPREFIX}"$(usex kernel_linux '' '/var')/run \
+               --sysconfdir="${EPREFIX}"/etc/ssh \
+               --libexecdir="${EPREFIX}"/usr/$(get_libdir)/misc \
+               --datadir="${EPREFIX}"/usr/share/openssh \
+               --with-privsep-path="${EPREFIX}"/var/empty \
+               --with-privsep-user=sshd \
+               --with-md5-passwords \
+               --with-ssl-engine \
+               $(static_use_with pam) \
+               $(static_use_with kerberos kerberos5 "${EPREFIX}"/usr) \
+               ${LDAP_PATCH:+$(use X509 || ( use ldap && use_with ldap ))} \
+               $(use_with ldns) \
+               $(use_with libedit) \
+               $(use_with pie) \
+               $(use_with sctp) \
+               $(use_with selinux) \
+               $(use_with skey) \
+               "${myconf[@]}"
+}
+
+src_install() {
+       emake install-nokeys DESTDIR="${D}"
+       fperms 600 /etc/ssh/sshd_config
+       dobin contrib/ssh-copy-id
+       newinitd "${FILESDIR}"/sshd.rc6.4 sshd
+       newconfd "${FILESDIR}"/sshd.confd sshd
+       keepdir /var/empty
+
+       # not all openssl installs support ecc, or are functional #352645
+       if ! grep -q '#define OPENSSL_HAS_ECC 1' config.h ; then
+               elog "dev-libs/openssl was built with 'bindist' - disabling ecdsa support"
+               sed -i 's:&& gen_key ecdsa::' "${ED}"/etc/init.d/sshd || die
+       fi
+
+       newpamd "${FILESDIR}"/sshd.pam_include.2 sshd
+       if use pam ; then
+               sed -i \
+                       -e "/^#UsePAM /s:.*:UsePAM yes:" \
+                       -e "/^#PasswordAuthentication /s:.*:PasswordAuthentication no:" \
+                       -e "/^#PrintMotd /s:.*:PrintMotd no:" \
+                       -e "/^#PrintLastLog /s:.*:PrintLastLog no:" \
+                       "${ED}"/etc/ssh/sshd_config || die "sed of configuration file failed"
+       fi
+
+       # Gentoo tweaks to default config files
+       cat <<-EOF >> "${ED}"/etc/ssh/sshd_config
+
+       # Allow client to pass locale environment variables #367017
+       AcceptEnv LANG LC_*
+       EOF
+       cat <<-EOF >> "${ED}"/etc/ssh/ssh_config
+
+       # Send locale environment variables #367017
+       SendEnv LANG LC_*
+       EOF
+
+       # This instruction is from the HPN webpage,
+       # Used for the server logging functionality
+       if [[ -n ${HPN_PATCH} ]] && use hpn ; then
+               keepdir /var/empty/dev
+       fi
+
+       if ! use X509 && [[ -n ${LDAP_PATCH} ]] && use ldap ; then
+               insinto /etc/openldap/schema/
+               newins openssh-lpk_openldap.schema openssh-lpk.schema
+       fi
+
+       doman contrib/ssh-copy-id.1
+       dodoc ChangeLog CREDITS OVERVIEW README* TODO sshd_config
+
+       diropts -m 0700
+       dodir /etc/skel/.ssh
+
+       systemd_dounit "${FILESDIR}"/sshd.{service,socket}
+       systemd_newunit "${FILESDIR}"/sshd_at.service 'sshd@.service'
+}
+
+src_test() {
+       local t tests skipped failed passed shell
+       tests="interop-tests compat-tests"
+       skipped=""
+       shell=$(egetshell ${UID})
+       if [[ ${shell} == */nologin ]] || [[ ${shell} == */false ]] ; then
+               elog "Running the full OpenSSH testsuite"
+               elog "requires a usable shell for the 'portage'"
+               elog "user, so we will run a subset only."
+               skipped="${skipped} tests"
+       else
+               tests="${tests} tests"
+       fi
+       # It will also attempt to write to the homedir .ssh
+       local sshhome=${T}/homedir
+       mkdir -p "${sshhome}"/.ssh
+       for t in ${tests} ; do
+               # Some tests read from stdin ...
+               HOMEDIR="${sshhome}" \
+               emake -k -j1 ${t} </dev/null \
+                       && passed="${passed}${t} " \
+                       || failed="${failed}${t} "
+       done
+       einfo "Passed tests: ${passed}"
+       ewarn "Skipped tests: ${skipped}"
+       if [[ -n ${failed} ]] ; then
+               ewarn "Failed tests: ${failed}"
+               die "Some tests failed: ${failed}"
+       else
+               einfo "Failed tests: ${failed}"
+               return 0
+       fi
+}
+
+pkg_preinst() {
+       enewgroup sshd 22
+       enewuser sshd 22 -1 /var/empty sshd
+}
+
+pkg_postinst() {
+       if has_version "<${CATEGORY}/${PN}-5.8_p1" ; then
+               elog "Starting with openssh-5.8p1, the server will default to a newer key"
+               elog "algorithm (ECDSA).  You are encouraged to manually update your stored"
+               elog "keys list as servers update theirs.  See ssh-keyscan(1) for more info."
+       fi
+       ewarn "Remember to merge your config files in /etc/ssh/ and then"
+       ewarn "reload sshd: '/etc/init.d/sshd reload'."
+       # This instruction is from the HPN webpage,
+       # Used for the server logging functionality
+       if [[ -n ${HPN_PATCH} ]] && use hpn ; then
+               einfo "For the HPN server logging patch, you must ensure that"
+               einfo "your syslog application also listens at /var/empty/dev/log."
+       fi
+       elog "Note: openssh-6.7 versions no longer support USE=tcpd as upstream has"
+       elog "      dropped it.  Make sure to update any configs that you might have."
+}