Gentoo Archives: gentoo-commits

From: Thomas Deutschmann <whissi@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: net-misc/openssh/
Date: Sun, 03 Mar 2019 02:47:00
Message-Id: 1551581201.40935d5171a88ca21159ee9db7c2d780b4473a22.whissi@gentoo
1 commit: 40935d5171a88ca21159ee9db7c2d780b4473a22
2 Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
3 AuthorDate: Sun Mar 3 02:46:29 2019 +0000
4 Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
5 CommitDate: Sun Mar 3 02:46:41 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=40935d51
7
8 net-misc/openssh: add some patches, including CVE-2019-6111
9
10 Bug: https://bugs.gentoo.org/show_bug.cgi?id=675522
11 Package-Manager: Portage-2.3.62, Repoman-2.3.12
12 Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>
13
14 net-misc/openssh/Manifest | 2 +
15 net-misc/openssh/openssh-7.9_p1-r3.ebuild | 468 ++++++++++++++++++++++++++++++
16 2 files changed, 470 insertions(+)
17
18 diff --git a/net-misc/openssh/Manifest b/net-misc/openssh/Manifest
19 index e0c1d3402c2..42d69025fbd 100644
20 --- a/net-misc/openssh/Manifest
21 +++ b/net-misc/openssh/Manifest
22 @@ -12,7 +12,9 @@ DIST openssh-7.8p1-sctp-1.1.patch.xz 7548 BLAKE2B d74010028f097812f554f9e788aa5e
23 DIST openssh-7.8p1.tar.gz 1548026 BLAKE2B 938428408596d24d497f245e3662a0cff3d462645683bf75cd29a0ea56fa6c280e7fa866bedf0928dd5bc4085b82d5a4ce74b7eea0b45b86f879b69f74db1642 SHA512 8e5b0c8682a9243e4e8b7c374ec989dccd1a752eb6f84e593b67141e8b23dcc8b9a7322b1f7525d18e2ce8830a767d0d9793f997486339db201a57986b910705
24 DIST openssh-7.9p1+x509-11.5.diff.gz 594995 BLAKE2B 2c44df224e4114da0473cbbdfdcc4bd84b0b0235f80b43517d70fe1071f219d2631f784015ab1470eebcf8f3b6b5f8744862acebb22f217c6e76f79e6a49c099 SHA512 4d2fd950dee9721add822fdb54ff8c20fd18da85081ce8a2bd2a1050d3ff7900a7213782c479691de9dcfe4e2f91061e124d34b365edb3831e8bfe4aef3744f9
25 DIST openssh-7.9p1+x509-11.6.diff.gz 655819 BLAKE2B f442bb993f89782b74b0cd28906c91edfcf5b1d42a4c8135a5ccf5045e7eb000eb7aa301685b748f707506ba20e3b842d684db436872ed82b6d9b9c086879515 SHA512 0ff6ed2822aaa43cf352134b90975fb663662c5ea3d73b690601f24342ea207aecda8cdb9c1bdc3e3656fb059d842dfb3bf22646b626c303240808286103d8bc
26 +DIST openssh-7.9p1-patches-1.0.tar.xz 9080 BLAKE2B c14106a875b6ea0672a03f6cb292386daba96da23fed4ebd04a75f712e252bc88a25116b0b3b27446421aadf112451cb3b8a96d2f7d437e6728fe782190bc69e SHA512 7903cdb4ce5be0f1b1b741788fb372e68b0c9c1d6da0d854d8bc62e4743ad7cd13101b867b541828d3786b0857783377457e5e87ba9b63bfd9afcdbfd93ac103
27 DIST openssh-7.9p1-sctp-1.1.patch.xz 7552 BLAKE2B 0eeda7c8a50c0c98433b5ee0734b9f79043067be376a9ca724d574d4a595c3f7aed0626342300467b73ad9003392e22fda8abe778158ba5be5a50a57eeef79f8 SHA512 6cad32c40dd3901c4eadb0c463a35ec2d901e61220c333d3df7759f672259f66fc83e2b1ace8b0ef84cbc1a65397f00f9c670ffa23726d8309fa5060512d2c21
28 +DIST openssh-7.9p1-sctp-1.2.patch.xz 7360 BLAKE2B 60e209371ecac24d0b60e48459d4d4044c0f364a2eea748cc4edd1501faec69a3c5b9e0b7db336968399ec684b6c8aceeac9196ba1ecf563ae3d660682cbc9a0 SHA512 d4d37a49cd43a3b9b7b173b0935267b84133b9b0954b7f71714ba781a6129c6d424f8b7a528dd7d4f287784c5517d57b1d6d7c6df8b5d738e34eb6dc7eae7191
29 DIST openssh-7.9p1.tar.gz 1565384 BLAKE2B de15795e03d33d4f9fe4792f6b14500123230b6c00c1e5bd7207bb6d6bf6df0b2e057c1b1de0fee709f58dd159203fdd69fe1473118a6baedebaa0c1c4c55b59 SHA512 0412c9c429c9287f0794023951469c8e6ec833cdb55821bfa0300dd90d0879ff60484f620cffd93372641ab69bf0b032c2d700ccc680950892725fb631b7708e
30 DIST openssh-7_8_P1-hpn-AES-CTR-14.16.diff 29231 BLAKE2B e25877c5e22f674e6db5a0bc107e5daa2509fe762fb14ce7bb2ce9a115e8177a93340c1d19247b6c2c854b7e1f9ae9af9fd932e5fa9c0a6b2ba438cd11a42991 SHA512 1867fb94c29a51294a71a3ec6a299757565a7cda5696118b0b346ed9c78f2c81bb1b888cff5e3418776b2fa277a8f070c5eb9327bb005453e2ffd72d35cdafa7
31 DIST openssh-7_8_P1-hpn-DynWinNoneSwitch-14.16.diff 43356 BLAKE2B 776fa140d64a16c339b46a7c773258d2f4fe44e48b16abccad1a8757a51cb6362722fc5f42c39159af12849f5c88cf574de64815085c97157e16653f18d4909b SHA512 53f2752b7aa02719c8dfe0fe0ef16e874101ba2ba87924aa1122cd445ece218ca09c22abaa3377307f25d459579bc28d3854e2402c71b794db65d58cdd1ebc08
32
33 diff --git a/net-misc/openssh/openssh-7.9_p1-r3.ebuild b/net-misc/openssh/openssh-7.9_p1-r3.ebuild
34 new file mode 100644
35 index 00000000000..ce31e554fdf
36 --- /dev/null
37 +++ b/net-misc/openssh/openssh-7.9_p1-r3.ebuild
38 @@ -0,0 +1,468 @@
39 +# Copyright 1999-2019 Gentoo Authors
40 +# Distributed under the terms of the GNU General Public License v2
41 +
42 +EAPI=6
43 +
44 +inherit user flag-o-matic multilib autotools pam systemd
45 +
46 +# Make it more portable between straight releases
47 +# and _p? releases.
48 +PARCH=${P/_}
49 +#HPN_PV="${PV^^}"
50 +HPN_PV="7.8_P1"
51 +
52 +HPN_VER="14.16"
53 +HPN_PATCHES=(
54 + ${PN}-${HPN_PV/./_}-hpn-DynWinNoneSwitch-${HPN_VER}.diff
55 + ${PN}-${HPN_PV/./_}-hpn-AES-CTR-${HPN_VER}.diff
56 +)
57 +
58 +SCTP_VER="1.2" SCTP_PATCH="${PARCH}-sctp-${SCTP_VER}.patch.xz"
59 +X509_VER="11.6" X509_PATCH="${PARCH}+x509-${X509_VER}.diff.gz"
60 +
61 +PATCH_SET="openssh-7.9p1-patches-1.0"
62 +
63 +DESCRIPTION="Port of OpenBSD's free SSH release"
64 +HOMEPAGE="https://www.openssh.com/"
65 +SRC_URI="mirror://openbsd/OpenSSH/portable/${PARCH}.tar.gz
66 + https://dev.gentoo.org/~whissi/dist/${PN}/${PATCH_SET}.tar.xz
67 + ${SCTP_PATCH:+sctp? ( https://dev.gentoo.org/~whissi/dist/openssh/${SCTP_PATCH} )}
68 + ${HPN_VER:+hpn? ( $(printf "mirror://sourceforge/hpnssh/HPN-SSH%%20${HPN_VER/./v}%%20${HPN_PV/_}/%s\n" "${HPN_PATCHES[@]}") )}
69 + ${X509_PATCH:+X509? ( https://roumenpetrov.info/openssh/x509-${X509_VER}/${X509_PATCH} )}
70 + "
71 +
72 +LICENSE="BSD GPL-2"
73 +SLOT="0"
74 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~ppc-aix ~x64-cygwin ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
75 +# Probably want to drop ssl defaulting to on in a future version.
76 +IUSE="abi_mips_n32 audit bindist debug hpn kerberos kernel_linux ldns libedit libressl livecd pam +pie sctp selinux +ssl static test X X509"
77 +RESTRICT="!test? ( test )"
78 +REQUIRED_USE="ldns? ( ssl )
79 + pie? ( !static )
80 + static? ( !kerberos !pam )
81 + X509? ( !sctp ssl )
82 + test? ( ssl )"
83 +
84 +LIB_DEPEND="
85 + audit? ( sys-process/audit[static-libs(+)] )
86 + ldns? (
87 + net-libs/ldns[static-libs(+)]
88 + !bindist? ( net-libs/ldns[ecdsa,ssl(+)] )
89 + bindist? ( net-libs/ldns[-ecdsa,ssl(+)] )
90 + )
91 + libedit? ( dev-libs/libedit:=[static-libs(+)] )
92 + sctp? ( net-misc/lksctp-tools[static-libs(+)] )
93 + selinux? ( >=sys-libs/libselinux-1.28[static-libs(+)] )
94 + ssl? (
95 + !libressl? (
96 + || (
97 + (
98 + >=dev-libs/openssl-1.0.1:0[bindist=]
99 + <dev-libs/openssl-1.1.0:0[bindist=]
100 + )
101 + >=dev-libs/openssl-1.1.0g:0[bindist=]
102 + )
103 + dev-libs/openssl:0=[static-libs(+)]
104 + )
105 + libressl? ( dev-libs/libressl:0=[static-libs(+)] )
106 + )
107 + >=sys-libs/zlib-1.2.3:=[static-libs(+)]"
108 +RDEPEND="
109 + !static? ( ${LIB_DEPEND//\[static-libs(+)]} )
110 + pam? ( virtual/pam )
111 + kerberos? ( virtual/krb5 )"
112 +DEPEND="${RDEPEND}
113 + static? ( ${LIB_DEPEND} )
114 + virtual/pkgconfig
115 + virtual/os-headers
116 + sys-devel/autoconf"
117 +RDEPEND="${RDEPEND}
118 + pam? ( >=sys-auth/pambase-20081028 )
119 + userland_GNU? ( virtual/shadow )
120 + X? ( x11-apps/xauth )"
121 +
122 +S="${WORKDIR}/${PARCH}"
123 +
124 +pkg_pretend() {
125 + # this sucks, but i'd rather have people unable to `emerge -u openssh`
126 + # than not be able to log in to their server any more
127 + maybe_fail() { [[ -z ${!2} ]] && echo "$1" ; }
128 + local fail="
129 + $(use hpn && maybe_fail hpn HPN_VER)
130 + $(use sctp && maybe_fail sctp SCTP_PATCH)
131 + $(use X509 && maybe_fail X509 X509_PATCH)
132 + "
133 + fail=$(echo ${fail})
134 + if [[ -n ${fail} ]] ; then
135 + eerror "Sorry, but this version does not yet support features"
136 + eerror "that you requested: ${fail}"
137 + eerror "Please mask ${PF} for now and check back later:"
138 + eerror " # echo '=${CATEGORY}/${PF}' >> /etc/portage/package.mask"
139 + die "booooo"
140 + fi
141 +
142 + # Make sure people who are using tcp wrappers are notified of its removal. #531156
143 + if grep -qs '^ *sshd *:' "${EROOT%/}"/etc/hosts.{allow,deny} ; then
144 + ewarn "Sorry, but openssh no longer supports tcp-wrappers, and it seems like"
145 + ewarn "you're trying to use it. Update your ${EROOT}etc/hosts.{allow,deny} please."
146 + fi
147 +}
148 +
149 +src_prepare() {
150 + sed -i \
151 + -e "/_PATH_XAUTH/s:/usr/X11R6/bin/xauth:${EPREFIX%/}/usr/bin/xauth:" \
152 + pathnames.h || die
153 +
154 + # don't break .ssh/authorized_keys2 for fun
155 + sed -i '/^AuthorizedKeysFile/s:^:#:' sshd_config || die
156 +
157 + eapply "${FILESDIR}"/${PN}-7.9_p1-openssl-1.0.2-compat.patch
158 + eapply "${FILESDIR}"/${PN}-7.9_p1-include-stdlib.patch
159 + eapply "${FILESDIR}"/${PN}-7.8_p1-GSSAPI-dns.patch #165444 integrated into gsskex
160 + eapply "${FILESDIR}"/${PN}-6.7_p1-openssl-ignore-status.patch
161 + eapply "${FILESDIR}"/${PN}-7.5_p1-disable-conch-interop-tests.patch
162 +
163 + if use X509 ; then
164 + # patch doesn't apply due to X509 modifications
165 + rm \
166 + "${WORKDIR}"/patches/0001-fix-key-type-check.patch \
167 + "${WORKDIR}"/patches/0002-request-rsa-sha2-cert-signatures.patch \
168 + || die
169 + else
170 + eapply "${FILESDIR}"/${PN}-7.9_p1-CVE-2018-20685.patch # X509 patch set includes this patch
171 + fi
172 +
173 + [[ -d ${WORKDIR}/patches ]] && eapply "${WORKDIR}"/patches
174 +
175 + local PATCHSET_VERSION_MACROS=()
176 +
177 + if use X509 ; then
178 + pushd "${WORKDIR}" || die
179 + eapply "${FILESDIR}/${P}-X509-glue-${X509_VER}.patch"
180 + eapply "${FILESDIR}/${P}-X509-dont-make-piddir-${X509_VER}.patch"
181 + popd || die
182 +
183 + if use hpn ; then
184 + einfo "Will disable MT AES cipher due to incompatbility caused by X509 patch set"
185 + HPN_DISABLE_MTAES=1
186 + fi
187 +
188 + eapply "${WORKDIR}"/${X509_PATCH%.*}
189 + eapply "${FILESDIR}"/${P}-X509-${X509_VER}-tests.patch
190 +
191 + # We need to patch package version or any X.509 sshd will reject our ssh client
192 + # with "userauth_pubkey: could not parse key: string is too large [preauth]"
193 + # error
194 + einfo "Patching package version for X.509 patch set ..."
195 + sed -i \
196 + -e "s/^AC_INIT(\[OpenSSH\], \[Portable\]/AC_INIT([OpenSSH], [${X509_VER}]/" \
197 + "${S}"/configure.ac || die "Failed to patch package version for X.509 patch"
198 +
199 + einfo "Patching version.h to expose X.509 patch set ..."
200 + sed -i \
201 + -e "/^#define SSH_PORTABLE.*/a #define SSH_X509 \"-PKIXSSH-${X509_VER}\"" \
202 + "${S}"/version.h || die "Failed to sed-in X.509 patch version"
203 + PATCHSET_VERSION_MACROS+=( 'SSH_X509' )
204 + fi
205 +
206 + if use sctp ; then
207 + eapply "${WORKDIR}"/${SCTP_PATCH%.*}
208 +
209 + einfo "Patching version.h to expose SCTP patch set ..."
210 + sed -i \
211 + -e "/^#define SSH_PORTABLE/a #define SSH_SCTP \"-sctp-${SCTP_VER}\"" \
212 + "${S}"/version.h || die "Failed to sed-in SCTP patch version"
213 + PATCHSET_VERSION_MACROS+=( 'SSH_SCTP' )
214 +
215 + einfo "Disabling know failing test (cfgparse) caused by SCTP patch ..."
216 + sed -i \
217 + -e "/\t\tcfgparse \\\/d" \
218 + "${S}"/regress/Makefile || die "Failed to disable known failing test (cfgparse) caused by SCTP patch"
219 + fi
220 +
221 + if use hpn ; then
222 + local hpn_patchdir="${T}/${P}-hpn${HPN_VER}"
223 + mkdir "${hpn_patchdir}"
224 + cp $(printf -- "${DISTDIR}/%s\n" "${HPN_PATCHES[@]}") "${hpn_patchdir}"
225 + pushd "${hpn_patchdir}"
226 + eapply "${FILESDIR}"/${P}-hpn-glue.patch
227 + use X509 && eapply "${FILESDIR}"/${P}-hpn-X509-glue.patch
228 + use sctp && eapply "${FILESDIR}"/${P}-hpn-sctp-glue.patch
229 + popd
230 +
231 + eapply "${hpn_patchdir}"
232 + eapply "${FILESDIR}/openssh-7.9_p1-hpn-openssl-1.1.patch"
233 +
234 + einfo "Patching Makefile.in for HPN patch set ..."
235 + sed -i \
236 + -e "/^LIBS=/ s/\$/ -lpthread/" \
237 + "${S}"/Makefile.in || die "Failed to patch Makefile.in"
238 +
239 + einfo "Patching version.h to expose HPN patch set ..."
240 + sed -i \
241 + -e "/^#define SSH_PORTABLE/a #define SSH_HPN \"-hpn${HPN_VER//./v}\"" \
242 + "${S}"/version.h || die "Failed to sed-in HPN patch version"
243 + PATCHSET_VERSION_MACROS+=( 'SSH_HPN' )
244 +
245 + if [[ -n "${HPN_DISABLE_MTAES}" ]] ; then
246 + einfo "Disabling known non-working MT AES cipher per default ..."
247 +
248 + cat > "${T}"/disable_mtaes.conf <<- EOF
249 +
250 + # HPN's Multi-Threaded AES CTR cipher is currently known to be broken
251 + # and therefore disabled per default.
252 + DisableMTAES yes
253 + EOF
254 + sed -i \
255 + -e "/^#HPNDisabled.*/r ${T}/disable_mtaes.conf" \
256 + "${S}"/sshd_config || die "Failed to disabled MT AES ciphers in sshd_config"
257 +
258 + sed -i \
259 + -e "/AcceptEnv.*_XXX_TEST$/a \\\tDisableMTAES\t\tyes" \
260 + "${S}"/regress/test-exec.sh || die "Failed to disable MT AES ciphers in test config"
261 + fi
262 + fi
263 +
264 + if use X509 || use sctp || use hpn ; then
265 + einfo "Patching sshconnect.c to use SSH_RELEASE in send_client_banner() ..."
266 + sed -i \
267 + -e "s/PROTOCOL_MAJOR_2, PROTOCOL_MINOR_2, SSH_VERSION/PROTOCOL_MAJOR_2, PROTOCOL_MINOR_2, SSH_RELEASE/" \
268 + "${S}"/sshconnect.c || die "Failed to patch send_client_banner() to use SSH_RELEASE (sshconnect.c)"
269 +
270 + einfo "Patching sshd.c to use SSH_RELEASE in sshd_exchange_identification() ..."
271 + sed -i \
272 + -e "s/PROTOCOL_MAJOR_2, PROTOCOL_MINOR_2, SSH_VERSION/PROTOCOL_MAJOR_2, PROTOCOL_MINOR_2, SSH_RELEASE/" \
273 + "${S}"/sshd.c || die "Failed to patch sshd_exchange_identification() to use SSH_RELEASE (sshd.c)"
274 +
275 + einfo "Patching version.h to add our patch sets to SSH_RELEASE ..."
276 + sed -i \
277 + -e "s/^#define SSH_RELEASE.*/#define SSH_RELEASE SSH_VERSION SSH_PORTABLE ${PATCHSET_VERSION_MACROS[*]}/" \
278 + "${S}"/version.h || die "Failed to patch SSH_RELEASE (version.h)"
279 + fi
280 +
281 + sed -i \
282 + -e "/#UseLogin no/d" \
283 + "${S}"/sshd_config || die "Failed to remove removed UseLogin option (sshd_config)"
284 +
285 + eapply_user #473004
286 +
287 + tc-export PKG_CONFIG
288 + local sed_args=(
289 + -e "s:-lcrypto:$(${PKG_CONFIG} --libs openssl):"
290 + # Disable PATH reset, trust what portage gives us #254615
291 + -e 's:^PATH=/:#PATH=/:'
292 + # Disable fortify flags ... our gcc does this for us
293 + -e 's:-D_FORTIFY_SOURCE=2::'
294 + )
295 +
296 + # The -ftrapv flag ICEs on hppa #505182
297 + use hppa && sed_args+=(
298 + -e '/CFLAGS/s:-ftrapv:-fdisable-this-test:'
299 + -e '/OSSH_CHECK_CFLAG_LINK.*-ftrapv/d'
300 + )
301 + # _XOPEN_SOURCE causes header conflicts on Solaris
302 + [[ ${CHOST} == *-solaris* ]] && sed_args+=(
303 + -e 's/-D_XOPEN_SOURCE//'
304 + )
305 + sed -i "${sed_args[@]}" configure{.ac,} || die
306 +
307 + eautoreconf
308 +}
309 +
310 +src_configure() {
311 + addwrite /dev/ptmx
312 +
313 + use debug && append-cppflags -DSANDBOX_SECCOMP_FILTER_DEBUG
314 + use static && append-ldflags -static
315 +
316 + local myconf=(
317 + --with-ldflags="${LDFLAGS}"
318 + --disable-strip
319 + --with-pid-dir="${EPREFIX}"$(usex kernel_linux '' '/var')/run
320 + --sysconfdir="${EPREFIX%/}"/etc/ssh
321 + --libexecdir="${EPREFIX%/}"/usr/$(get_libdir)/misc
322 + --datadir="${EPREFIX%/}"/usr/share/openssh
323 + --with-privsep-path="${EPREFIX%/}"/var/empty
324 + --with-privsep-user=sshd
325 + $(use_with audit audit linux)
326 + $(use_with kerberos kerberos5 "${EPREFIX%/}"/usr)
327 + # We apply the sctp patch conditionally, so can't pass --without-sctp
328 + # unconditionally else we get unknown flag warnings.
329 + $(use sctp && use_with sctp)
330 + $(use_with ldns)
331 + $(use_with libedit)
332 + $(use_with pam)
333 + $(use_with pie)
334 + $(use_with selinux)
335 + $(use_with ssl openssl)
336 + $(use_with ssl md5-passwords)
337 + $(use_with ssl ssl-engine)
338 + $(use_with !elibc_Cygwin hardening) #659210
339 + )
340 +
341 + # stackprotect is broken on musl x86
342 + use elibc_musl && use x86 && myconf+=( --without-stackprotect )
343 +
344 + # The seccomp sandbox is broken on x32, so use the older method for now. #553748
345 + use amd64 && [[ ${ABI} == "x32" ]] && myconf+=( --with-sandbox=rlimit )
346 +
347 + econf "${myconf[@]}"
348 +}
349 +
350 +src_test() {
351 + local t skipped=() failed=() passed=()
352 + local tests=( interop-tests compat-tests )
353 +
354 + local shell=$(egetshell "${UID}")
355 + if [[ ${shell} == */nologin ]] || [[ ${shell} == */false ]] ; then
356 + elog "Running the full OpenSSH testsuite requires a usable shell for the 'portage'"
357 + elog "user, so we will run a subset only."
358 + skipped+=( tests )
359 + else
360 + tests+=( tests )
361 + fi
362 +
363 + # It will also attempt to write to the homedir .ssh.
364 + local sshhome=${T}/homedir
365 + mkdir -p "${sshhome}"/.ssh
366 + for t in "${tests[@]}" ; do
367 + # Some tests read from stdin ...
368 + HOMEDIR="${sshhome}" HOME="${sshhome}" \
369 + emake -k -j1 ${t} </dev/null \
370 + && passed+=( "${t}" ) \
371 + || failed+=( "${t}" )
372 + done
373 +
374 + einfo "Passed tests: ${passed[*]}"
375 + [[ ${#skipped[@]} -gt 0 ]] && ewarn "Skipped tests: ${skipped[*]}"
376 + [[ ${#failed[@]} -gt 0 ]] && die "Some tests failed: ${failed[*]}"
377 +}
378 +
379 +# Gentoo tweaks to default config files.
380 +tweak_ssh_configs() {
381 + local locale_vars=(
382 + # These are language variables that POSIX defines.
383 + # http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_02
384 + LANG LC_ALL LC_COLLATE LC_CTYPE LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME
385 +
386 + # These are the GNU extensions.
387 + # https://www.gnu.org/software/autoconf/manual/html_node/Special-Shell-Variables.html
388 + LANGUAGE LC_ADDRESS LC_IDENTIFICATION LC_MEASUREMENT LC_NAME LC_PAPER LC_TELEPHONE
389 + )
390 +
391 + # First the server config.
392 + cat <<-EOF >> "${ED%/}"/etc/ssh/sshd_config
393 +
394 + # Allow client to pass locale environment variables. #367017
395 + AcceptEnv ${locale_vars[*]}
396 +
397 + # Allow client to pass COLORTERM to match TERM. #658540
398 + AcceptEnv COLORTERM
399 + EOF
400 +
401 + # Then the client config.
402 + cat <<-EOF >> "${ED%/}"/etc/ssh/ssh_config
403 +
404 + # Send locale environment variables. #367017
405 + SendEnv ${locale_vars[*]}
406 +
407 + # Send COLORTERM to match TERM. #658540
408 + SendEnv COLORTERM
409 + EOF
410 +
411 + if use pam ; then
412 + sed -i \
413 + -e "/^#UsePAM /s:.*:UsePAM yes:" \
414 + -e "/^#PasswordAuthentication /s:.*:PasswordAuthentication no:" \
415 + -e "/^#PrintMotd /s:.*:PrintMotd no:" \
416 + -e "/^#PrintLastLog /s:.*:PrintLastLog no:" \
417 + "${ED%/}"/etc/ssh/sshd_config || die
418 + fi
419 +
420 + if use livecd ; then
421 + sed -i \
422 + -e '/^#PermitRootLogin/c# Allow root login with password on livecds.\nPermitRootLogin Yes' \
423 + "${ED%/}"/etc/ssh/sshd_config || die
424 + fi
425 +}
426 +
427 +src_install() {
428 + emake install-nokeys DESTDIR="${D}"
429 + fperms 600 /etc/ssh/sshd_config
430 + dobin contrib/ssh-copy-id
431 + newinitd "${FILESDIR}"/sshd.initd sshd
432 + newconfd "${FILESDIR}"/sshd-r1.confd sshd
433 +
434 + newpamd "${FILESDIR}"/sshd.pam_include.2 sshd
435 +
436 + tweak_ssh_configs
437 +
438 + doman contrib/ssh-copy-id.1
439 + dodoc CREDITS OVERVIEW README* TODO sshd_config
440 + use hpn && dodoc HPN-README
441 + use X509 || dodoc ChangeLog
442 +
443 + diropts -m 0700
444 + dodir /etc/skel/.ssh
445 +
446 + keepdir /var/empty
447 +
448 + systemd_dounit "${FILESDIR}"/sshd.{service,socket}
449 + systemd_newunit "${FILESDIR}"/sshd_at.service 'sshd@.service'
450 +}
451 +
452 +pkg_preinst() {
453 + enewgroup sshd 22
454 + enewuser sshd 22 -1 /var/empty sshd
455 +}
456 +
457 +pkg_postinst() {
458 + if has_version "<${CATEGORY}/${PN}-5.8_p1" ; then
459 + elog "Starting with openssh-5.8p1, the server will default to a newer key"
460 + elog "algorithm (ECDSA). You are encouraged to manually update your stored"
461 + elog "keys list as servers update theirs. See ssh-keyscan(1) for more info."
462 + fi
463 + if has_version "<${CATEGORY}/${PN}-7.0_p1" ; then
464 + elog "Starting with openssh-6.7, support for USE=tcpd has been dropped by upstream."
465 + elog "Make sure to update any configs that you might have. Note that xinetd might"
466 + elog "be an alternative for you as it supports USE=tcpd."
467 + fi
468 + if has_version "<${CATEGORY}/${PN}-7.1_p1" ; then #557388 #555518
469 + elog "Starting with openssh-7.0, support for ssh-dss keys were disabled due to their"
470 + elog "weak sizes. If you rely on these key types, you can re-enable the key types by"
471 + elog "adding to your sshd_config or ~/.ssh/config files:"
472 + elog " PubkeyAcceptedKeyTypes=+ssh-dss"
473 + elog "You should however generate new keys using rsa or ed25519."
474 +
475 + elog "Starting with openssh-7.0, the default for PermitRootLogin changed from 'yes'"
476 + elog "to 'prohibit-password'. That means password auth for root users no longer works"
477 + elog "out of the box. If you need this, please update your sshd_config explicitly."
478 + fi
479 + if has_version "<${CATEGORY}/${PN}-7.6_p1" ; then
480 + elog "Starting with openssh-7.6p1, openssh upstream has removed ssh1 support entirely."
481 + elog "Furthermore, rsa keys with less than 1024 bits will be refused."
482 + fi
483 + if has_version "<${CATEGORY}/${PN}-7.7_p1" ; then
484 + elog "Starting with openssh-7.7p1, we no longer patch openssh to provide LDAP functionality."
485 + elog "Install sys-auth/ssh-ldap-pubkey and use OpenSSH's \"AuthorizedKeysCommand\" option"
486 + elog "if you need to authenticate against LDAP."
487 + elog "See https://wiki.gentoo.org/wiki/SSH/LDAP_migration for more details."
488 + fi
489 + if ! use ssl && has_version "${CATEGORY}/${PN}[ssl]" ; then
490 + elog "Be aware that by disabling openssl support in openssh, the server and clients"
491 + elog "no longer support dss/rsa/ecdsa keys. You will need to generate ed25519 keys"
492 + elog "and update all clients/servers that utilize them."
493 + fi
494 +
495 + if use hpn && [[ -n "${HPN_DISABLE_MTAES}" ]] ; then
496 + elog ""
497 + elog "HPN's multi-threaded AES CTR cipher is currently known to be broken"
498 + elog "and therefore disabled at runtime per default."
499 + elog "Make sure your sshd_config is up to date and contains"
500 + elog ""
501 + elog " DisableMTAES yes"
502 + elog ""
503 + elog "Otherwise you maybe unable to connect to this sshd using any AES CTR cipher."
504 + elog ""
505 + fi
506 +}