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