Gentoo Archives: gentoo-commits

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