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