Gentoo Archives: gentoo-commits

From: Stefan Strogin <stefan.strogin@×××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/proj/libressl:master commit in: sys-apps/kmod/, sys-apps/kmod/files/
Date: Sun, 24 Feb 2019 01:51:19
Message-Id: 1550972645.1676e6c83dc843ddccbfae6424b9cf0a454ea6fa.steils@gentoo
1 commit: 1676e6c83dc843ddccbfae6424b9cf0a454ea6fa
2 Author: Stefan Strogin <stefan.strogin <AT> gmail <DOT> com>
3 AuthorDate: Sun Feb 24 01:43:38 2019 +0000
4 Commit: Stefan Strogin <stefan.strogin <AT> gmail <DOT> com>
5 CommitDate: Sun Feb 24 01:44:05 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/proj/libressl.git/commit/?id=1676e6c8
7
8 sys-apps/kmod: add package from gentoo.git; patch for LibreSSL
9
10 Bug: https://bugs.gentoo.org/677960
11 Package-Manager: Portage-2.3.62, Repoman-2.3.12
12 Signed-off-by: Stefan Strogin <stefan.strogin <AT> gmail.com>
13
14 sys-apps/kmod/Manifest | 1 +
15 sys-apps/kmod/files/kmod-26-libressl.patch | 186 +++++++++++++++++++++++++++
16 sys-apps/kmod/files/kmod-static-nodes-r1 | 18 +++
17 sys-apps/kmod/kmod-26-r1.ebuild | 200 +++++++++++++++++++++++++++++
18 sys-apps/kmod/metadata.xml | 16 +++
19 5 files changed, 421 insertions(+)
20
21 diff --git a/sys-apps/kmod/Manifest b/sys-apps/kmod/Manifest
22 new file mode 100644
23 index 0000000..3f2e6db
24 --- /dev/null
25 +++ b/sys-apps/kmod/Manifest
26 @@ -0,0 +1 @@
27 +DIST kmod-26.tar.xz 552032 BLAKE2B 3e596d06b48599bf4919346475a036b058fb18a7b19d39953e24fa943b95fdbe34a29a5062f6b4fe3510e667ae873d3b9ae03b72350fa85ddbb40ca6a7730b34 SHA512 3ca276c6fc13c2dd2220ec528b8dc4ab4edee5d2b22e16b6f945c552e51f74342c01c33a53740e6af8c893d42bd4d6f629cd8fa6e15ef8bd8da30cb003ef0865
28
29 diff --git a/sys-apps/kmod/files/kmod-26-libressl.patch b/sys-apps/kmod/files/kmod-26-libressl.patch
30 new file mode 100644
31 index 0000000..7d70ed2
32 --- /dev/null
33 +++ b/sys-apps/kmod/files/kmod-26-libressl.patch
34 @@ -0,0 +1,186 @@
35 +From fd8b59fb8c576751aef6d59dd5ab208baee2ad49 Mon Sep 17 00:00:00 2001
36 +From: Stefan Strogin <stefan.strogin@×××××.com>
37 +Date: Fri, 15 Feb 2019 05:34:55 +0200
38 +Subject: [PATCH] libkmod-signature: use PKCS7 for LibreSSL or older OpenSSL
39 +
40 +Linux kernel uses either PKCS #7 or CMS signing modules (scripts/sign-file.c).
41 +CMS is not supported by LibreSSL, PKCS #7 is used instead.
42 +For now modinfo used CMS with no altenative requiring >=openssl-1.1.0
43 +built with CMS support.
44 +
45 +Use PKCS #7 for parsing module signature information when CMS is not available.
46 +
47 +Upstream-Status: Submitted [https://patchwork.kernel.org/patch/10814147/]
48 +Signed-off-by: Stefan Strogin <stefan.strogin@×××××.com>
49 +---
50 + libkmod/libkmod-signature.c | 78 +++++++++++++++++++++++++++++++++++--
51 + 1 file changed, 75 insertions(+), 3 deletions(-)
52 +
53 +diff --git a/libkmod/libkmod-signature.c b/libkmod/libkmod-signature.c
54 +index 48d0145..aa2a60e 100644
55 +--- a/libkmod/libkmod-signature.c
56 ++++ b/libkmod/libkmod-signature.c
57 +@@ -20,9 +20,16 @@
58 + #include <endian.h>
59 + #include <inttypes.h>
60 + #ifdef ENABLE_OPENSSL
61 +-#include <openssl/cms.h>
62 +-#include <openssl/ssl.h>
63 +-#endif
64 ++# include <openssl/ssl.h>
65 ++# if defined(LIBRESSL_VERSION_NUMBER) || \
66 ++ OPENSSL_VERSION_NUMBER < 0x10100000L || \
67 ++ defined(OPENSSL_NO_CMS)
68 ++# define USE_PKCS7
69 ++# include <openssl/pkcs7.h>
70 ++# else
71 ++# include <openssl/cms.h>
72 ++# endif /* LIBRESSL_VERSION_NUMBER */
73 ++#endif /* ENABLE_OPENSSL */
74 + #include <stdio.h>
75 + #include <stdlib.h>
76 + #include <string.h>
77 +@@ -122,7 +129,11 @@ static bool fill_default(const char *mem, off_t size,
78 + #ifdef ENABLE_OPENSSL
79 +
80 + struct pkcs7_private {
81 ++#ifndef USE_PKCS7
82 + CMS_ContentInfo *cms;
83 ++#else
84 ++ PKCS7 *pkcs7;
85 ++#endif
86 + unsigned char *key_id;
87 + BIGNUM *sno;
88 + };
89 +@@ -132,7 +143,11 @@ static void pkcs7_free(void *s)
90 + struct kmod_signature_info *si = s;
91 + struct pkcs7_private *pvt = si->private;
92 +
93 ++#ifndef USE_PKCS7
94 + CMS_ContentInfo_free(pvt->cms);
95 ++#else
96 ++ PKCS7_free(pvt->pkcs7);
97 ++#endif
98 + BN_free(pvt->sno);
99 + free(pvt->key_id);
100 + free(pvt);
101 +@@ -187,7 +202,13 @@ static const char *x509_name_to_str(X509_NAME *name)
102 + return NULL;
103 +
104 + d = X509_NAME_ENTRY_get_data(e);
105 ++#if (defined(LIBRESSL_VERSION_NUMBER) && \
106 ++ LIBRESSL_VERSION_NUMBER < 0x20700000L) || \
107 ++ OPENSSL_VERSION_NUMBER < 0x10100000L
108 ++ str = (const char *)ASN1_STRING_data(d);
109 ++#else
110 + str = (const char *)ASN1_STRING_get0_data(d);
111 ++#endif
112 +
113 + return str;
114 + }
115 +@@ -197,11 +218,18 @@ static bool fill_pkcs7(const char *mem, off_t size,
116 + struct kmod_signature_info *sig_info)
117 + {
118 + const char *pkcs7_raw;
119 ++#ifndef USE_PKCS7
120 + CMS_ContentInfo *cms;
121 + STACK_OF(CMS_SignerInfo) *sis;
122 + CMS_SignerInfo *si;
123 + int rc;
124 + ASN1_OCTET_STRING *key_id;
125 ++#else
126 ++ PKCS7 *pkcs7;
127 ++ STACK_OF(PKCS7_SIGNER_INFO) *sis;
128 ++ PKCS7_SIGNER_INFO *si;
129 ++ PKCS7_ISSUER_AND_SERIAL *is;
130 ++#endif
131 + X509_NAME *issuer;
132 + ASN1_INTEGER *sno;
133 + ASN1_OCTET_STRING *sig;
134 +@@ -220,14 +248,23 @@ static bool fill_pkcs7(const char *mem, off_t size,
135 +
136 + in = BIO_new_mem_buf(pkcs7_raw, sig_len);
137 +
138 ++#ifndef USE_PKCS7
139 + cms = d2i_CMS_bio(in, NULL);
140 + if (cms == NULL) {
141 + BIO_free(in);
142 + return false;
143 + }
144 ++#else
145 ++ pkcs7 = d2i_PKCS7_bio(in, NULL);
146 ++ if (pkcs7 == NULL) {
147 ++ BIO_free(in);
148 ++ return false;
149 ++ }
150 ++#endif
151 +
152 + BIO_free(in);
153 +
154 ++#ifndef USE_PKCS7
155 + sis = CMS_get0_SignerInfos(cms);
156 + if (sis == NULL)
157 + goto err;
158 +@@ -245,8 +282,35 @@ static bool fill_pkcs7(const char *mem, off_t size,
159 + goto err;
160 +
161 + CMS_SignerInfo_get0_algs(si, NULL, NULL, &dig_alg, &sig_alg);
162 ++#else
163 ++ sis = PKCS7_get_signer_info(pkcs7);
164 ++ if (sis == NULL)
165 ++ goto err;
166 ++
167 ++ si = sk_PKCS7_SIGNER_INFO_value(sis, 0);
168 ++ if (si == NULL)
169 ++ goto err;
170 ++
171 ++ is = si->issuer_and_serial;
172 ++ if (is == NULL)
173 ++ goto err;
174 ++ issuer = is->issuer;
175 ++ sno = is->serial;
176 ++
177 ++ sig = si->enc_digest;
178 ++ if (sig == NULL)
179 ++ goto err;
180 ++
181 ++ PKCS7_SIGNER_INFO_get0_algs(si, NULL, &dig_alg, &sig_alg);
182 ++#endif
183 +
184 ++#if (defined(LIBRESSL_VERSION_NUMBER) && \
185 ++ LIBRESSL_VERSION_NUMBER < 0x20700000L) || \
186 ++ OPENSSL_VERSION_NUMBER < 0x10100000L
187 ++ sig_info->sig = (const char *)ASN1_STRING_data(sig);
188 ++#else
189 + sig_info->sig = (const char *)ASN1_STRING_get0_data(sig);
190 ++#endif
191 + sig_info->sig_len = ASN1_STRING_length(sig);
192 +
193 + sno_bn = ASN1_INTEGER_to_BN(sno, NULL);
194 +@@ -277,7 +341,11 @@ static bool fill_pkcs7(const char *mem, off_t size,
195 + if (pvt == NULL)
196 + goto err3;
197 +
198 ++#ifndef USE_PKCS7
199 + pvt->cms = cms;
200 ++#else
201 ++ pvt->pkcs7 = pkcs7;
202 ++#endif
203 + pvt->key_id = key_id_str;
204 + pvt->sno = sno_bn;
205 + sig_info->private = pvt;
206 +@@ -290,7 +358,11 @@ err3:
207 + err2:
208 + BN_free(sno_bn);
209 + err:
210 ++#ifndef USE_PKCS7
211 + CMS_ContentInfo_free(cms);
212 ++#else
213 ++ PKCS7_free(pkcs7);
214 ++#endif
215 + return false;
216 + }
217 +
218 +--
219 +2.20.1
220 +
221
222 diff --git a/sys-apps/kmod/files/kmod-static-nodes-r1 b/sys-apps/kmod/files/kmod-static-nodes-r1
223 new file mode 100644
224 index 0000000..9362f28
225 --- /dev/null
226 +++ b/sys-apps/kmod/files/kmod-static-nodes-r1
227 @@ -0,0 +1,18 @@
228 +#!/sbin/openrc-run
229 +# Copyright 1999-2019 Gentoo Authors
230 +# Distributed under the terms of the GNU General Public License v2
231 +
232 +description="Create list of required static device nodes for the current kernel"
233 +
234 +depend() {
235 + after dev-mount
236 + before tmpfiles.dev dev
237 + keyword -lxc -systemd-nspawn
238 +}
239 +
240 +start() {
241 + ebegin "Creating list of required static device nodes for the current kernel"
242 + checkpath -q -d /run/tmpfiles.d
243 + kmod static-nodes --format=tmpfiles --output=/run/tmpfiles.d/kmod.conf
244 + eend $?
245 +}
246
247 diff --git a/sys-apps/kmod/kmod-26-r1.ebuild b/sys-apps/kmod/kmod-26-r1.ebuild
248 new file mode 100644
249 index 0000000..2752b85
250 --- /dev/null
251 +++ b/sys-apps/kmod/kmod-26-r1.ebuild
252 @@ -0,0 +1,200 @@
253 +# Copyright 1999-2019 Gentoo Authors
254 +# Distributed under the terms of the GNU General Public License v2
255 +
256 +EAPI=6
257 +
258 +PYTHON_COMPAT=( python{2_7,3_{4,5,6,7}} )
259 +
260 +inherit bash-completion-r1 multilib python-r1
261 +
262 +if [[ ${PV} == 9999* ]]; then
263 + EGIT_REPO_URI="https://git.kernel.org/pub/scm/utils/kernel/${PN}/${PN}.git"
264 + inherit autotools git-r3
265 +else
266 + SRC_URI="mirror://kernel/linux/utils/kernel/kmod/${P}.tar.xz"
267 + KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
268 + inherit libtool
269 +fi
270 +
271 +DESCRIPTION="library and tools for managing linux kernel modules"
272 +HOMEPAGE="https://git.kernel.org/?p=utils/kernel/kmod/kmod.git"
273 +
274 +LICENSE="LGPL-2"
275 +SLOT="0"
276 +IUSE="debug doc libressl lzma python ssl static-libs +tools zlib"
277 +
278 +# Upstream does not support running the test suite with custom configure flags.
279 +# I was also told that the test suite is intended for kmod developers.
280 +# So we have to restrict it.
281 +# See bug #408915.
282 +RESTRICT="test"
283 +
284 +# Block systemd below 217 for -static-nodes-indicate-that-creation-of-static-nodes-.patch
285 +RDEPEND="!sys-apps/module-init-tools
286 + !sys-apps/modutils
287 + !<sys-apps/openrc-0.13.8
288 + !<sys-apps/systemd-216-r3
289 + lzma? ( >=app-arch/xz-utils-5.0.4-r1 )
290 + python? ( ${PYTHON_DEPS} )
291 + ssl? (
292 + !libressl? ( >=dev-libs/openssl-1.1.0:0= )
293 + libressl? ( dev-libs/libressl:0= )
294 + )
295 + zlib? ( >=sys-libs/zlib-1.2.6 )" #427130
296 +DEPEND="${RDEPEND}
297 + doc? ( dev-util/gtk-doc )
298 + lzma? ( virtual/pkgconfig )
299 + python? (
300 + dev-python/cython[${PYTHON_USEDEP}]
301 + virtual/pkgconfig
302 + )
303 + zlib? ( virtual/pkgconfig )"
304 +if [[ ${PV} == 9999* ]]; then
305 + DEPEND="${DEPEND}
306 + dev-libs/libxslt"
307 +fi
308 +
309 +REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
310 +
311 +DOCS="NEWS README TODO"
312 +
313 +PATCHES=(
314 + "${FILESDIR}/${P}-libressl.patch" # bug 677960
315 +)
316 +
317 +src_prepare() {
318 + default
319 +
320 + if [[ ! -e configure ]] ; then
321 + if use doc; then
322 + gtkdocize --copy --docdir libkmod/docs || die
323 + else
324 + touch libkmod/docs/gtk-doc.make
325 + fi
326 + eautoreconf
327 + else
328 + elibtoolize
329 + fi
330 +
331 + # Restore possibility of running --enable-static wrt #472608
332 + sed -i \
333 + -e '/--enable-static is not supported by kmod/s:as_fn_error:echo:' \
334 + configure || die
335 +}
336 +
337 +src_configure() {
338 + local myeconfargs=(
339 + --bindir="${EPREFIX}/bin"
340 + --enable-shared
341 + --with-bashcompletiondir="$(get_bashcompdir)"
342 + --with-rootlibdir="${EPREFIX}/$(get_libdir)"
343 + $(use_enable debug)
344 + $(use_enable doc gtk-doc)
345 + $(use_enable static-libs static)
346 + $(use_enable tools)
347 + $(use_with lzma xz)
348 + $(use_with ssl openssl)
349 + $(use_with zlib)
350 + )
351 +
352 + local ECONF_SOURCE="${S}"
353 +
354 + kmod_configure() {
355 + mkdir -p "${BUILD_DIR}" || die
356 + run_in_build_dir econf "${myeconfargs[@]}" "$@"
357 + }
358 +
359 + BUILD_DIR="${WORKDIR}/build"
360 + kmod_configure --disable-python
361 +
362 + if use python; then
363 + python_foreach_impl kmod_configure --enable-python
364 + fi
365 +}
366 +
367 +src_compile() {
368 + emake -C "${BUILD_DIR}"
369 +
370 + if use python; then
371 + local native_builddir=${BUILD_DIR}
372 +
373 + python_compile() {
374 + emake -C "${BUILD_DIR}" -f Makefile -f - python \
375 + VPATH="${native_builddir}:${S}" \
376 + native_builddir="${native_builddir}" \
377 + libkmod_python_kmod_{kmod,list,module,_util}_la_LIBADD='$(PYTHON_LIBS) $(native_builddir)/libkmod/libkmod.la' \
378 + <<< 'python: $(pkgpyexec_LTLIBRARIES)'
379 + }
380 +
381 + python_foreach_impl python_compile
382 + fi
383 +}
384 +
385 +src_install() {
386 + emake -C "${BUILD_DIR}" DESTDIR="${D}" install
387 + einstalldocs
388 +
389 + if use python; then
390 + local native_builddir=${BUILD_DIR}
391 +
392 + python_install() {
393 + emake -C "${BUILD_DIR}" DESTDIR="${D}" \
394 + VPATH="${native_builddir}:${S}" \
395 + install-pkgpyexecLTLIBRARIES \
396 + install-dist_pkgpyexecPYTHON
397 + }
398 +
399 + python_foreach_impl python_install
400 + fi
401 +
402 + find "${ED}" -name "*.la" -delete || die
403 +
404 + if use tools; then
405 + local bincmd sbincmd
406 + for sbincmd in depmod insmod lsmod modinfo modprobe rmmod; do
407 + dosym ../bin/kmod /sbin/${sbincmd}
408 + done
409 +
410 + # These are also usable as normal user
411 + for bincmd in lsmod modinfo; do
412 + dosym kmod /bin/${bincmd}
413 + done
414 + fi
415 +
416 + cat <<-EOF > "${T}"/usb-load-ehci-first.conf
417 + softdep uhci_hcd pre: ehci_hcd
418 + softdep ohci_hcd pre: ehci_hcd
419 + EOF
420 +
421 + insinto /lib/modprobe.d
422 + doins "${T}"/usb-load-ehci-first.conf #260139
423 +
424 + newinitd "${FILESDIR}"/kmod-static-nodes-r1 kmod-static-nodes
425 +}
426 +
427 +pkg_postinst() {
428 + if [[ -L ${EROOT%/}/etc/runlevels/boot/static-nodes ]]; then
429 + ewarn "Removing old conflicting static-nodes init script from the boot runlevel"
430 + rm -f "${EROOT%/}"/etc/runlevels/boot/static-nodes
431 + fi
432 +
433 + # Add kmod to the runlevel automatically if this is the first install of this package.
434 + if [[ -z ${REPLACING_VERSIONS} ]]; then
435 + if [[ ! -d ${EROOT%/}/etc/runlevels/sysinit ]]; then
436 + mkdir -p "${EROOT%/}"/etc/runlevels/sysinit
437 + fi
438 + if [[ -x ${EROOT%/}/etc/init.d/kmod-static-nodes ]]; then
439 + ln -s /etc/init.d/kmod-static-nodes "${EROOT%/}"/etc/runlevels/sysinit/kmod-static-nodes
440 + fi
441 + fi
442 +
443 + if [[ -e ${EROOT%/}/etc/runlevels/sysinit ]]; then
444 + if [[ ! -e ${EROOT%/}/etc/runlevels/sysinit/kmod-static-nodes ]]; then
445 + ewarn
446 + ewarn "You need to add kmod-static-nodes to the sysinit runlevel for"
447 + ewarn "kernel modules to have required static nodes!"
448 + ewarn "Run this command:"
449 + ewarn "\trc-update add kmod-static-nodes sysinit"
450 + fi
451 + fi
452 +}
453
454 diff --git a/sys-apps/kmod/metadata.xml b/sys-apps/kmod/metadata.xml
455 new file mode 100644
456 index 0000000..188bf47
457 --- /dev/null
458 +++ b/sys-apps/kmod/metadata.xml
459 @@ -0,0 +1,16 @@
460 +<?xml version="1.0" encoding="UTF-8"?>
461 +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
462 +<pkgmetadata>
463 +<maintainer type="project">
464 + <email>udev-bugs@g.o</email>
465 +</maintainer>
466 +<maintainer type="project">
467 + <email>base-system@g.o</email>
468 + <name>Gentoo Base System</name>
469 +</maintainer>
470 +<use>
471 + <flag name="lzma">Enable support for XZ compressed modules</flag>
472 + <flag name="tools">Install module loading/unloading tools.</flag>
473 + <flag name="zlib">Enable support for gzipped modules</flag>
474 +</use>
475 +</pkgmetadata>