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