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