diff options
author | Dave Cobbley <david.j.cobbley@linux.intel.com> | 2018-08-14 20:05:37 +0300 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2018-08-23 04:26:31 +0300 |
commit | eb8dc40360f0cfef56fb6947cc817a547d6d9bc6 (patch) | |
tree | de291a73dc37168da6370e2cf16c347d1eba9df8 /poky/meta/recipes-support/rng-tools | |
parent | 9c3cf826d853102535ead04cebc2d6023eff3032 (diff) | |
download | openbmc-eb8dc40360f0cfef56fb6947cc817a547d6d9bc6.tar.xz |
[Subtree] Removing import-layers directory
As part of the move to subtrees, need to bring all the import layers
content to the top level.
Change-Id: I4a163d10898cbc6e11c27f776f60e1a470049d8f
Signed-off-by: Dave Cobbley <david.j.cobbley@linux.intel.com>
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'poky/meta/recipes-support/rng-tools')
9 files changed, 501 insertions, 0 deletions
diff --git a/poky/meta/recipes-support/rng-tools/rng-tools/0001-If-the-libc-is-lacking-argp-use-libargp.patch b/poky/meta/recipes-support/rng-tools/rng-tools/0001-If-the-libc-is-lacking-argp-use-libargp.patch new file mode 100644 index 000000000..4bd9d31c0 --- /dev/null +++ b/poky/meta/recipes-support/rng-tools/rng-tools/0001-If-the-libc-is-lacking-argp-use-libargp.patch @@ -0,0 +1,60 @@ +From 99679fda405e535a282f04a4decc2381154a749f Mon Sep 17 00:00:00 2001 +From: Christopher Larson <chris_larson@mentor.com> +Date: Mon, 15 Feb 2016 15:59:58 -0700 +Subject: [PATCH 1/2] If the libc is lacking argp, use libargp + +Patch pulled from Gentoo: + + On glibc systems, argp is provided by libc. However, on + uclibc and other systems which lack argp in their C library, + argp might be provided by a stand alone library, libargp. + This patch adds tests to the build system to find who provides + argp. + + X-Gentoo-Bug: 292191 + X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=292191 + Reported-by: Ed Wildgoose <gentoo@wildgooses.com> + Signed-off-by: Anthony G. Basile <blueness@gentoo.org> + +Upstream-Status: Pending +Signed-off-by: Christopher Larson <chris_larson@mentor.com> +--- + configure.ac | 22 ++++++++++++++++++++++ + 1 file changed, 22 insertions(+) + +diff --git a/configure.ac b/configure.ac +index 27a2dba..04fcd25 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -82,6 +82,28 @@ AS_IF( + ] + ) + ++dnl First check if we have argp available from libc ++AC_LINK_IFELSE( ++ [AC_LANG_PROGRAM( ++ [#include <argp.h>], ++ [int argc=1; char *argv[]={"test"}; argp_parse(0,argc,argv,0,0,0); return 0;] ++ )], ++ [libc_has_argp="true"], ++ [libc_has_argp="false"] ++) ++ ++dnl If libc doesn't provide argp, then test for libargp ++if test "$libc_has_argp" = "false" ; then ++ AC_MSG_WARN("libc does not have argp") ++ AC_CHECK_LIB([argp], [argp_parse], [have_argp="true"], [have_argp="false"]) ++ ++ if test "$have_argp" = "false"; then ++ AC_MSG_ERROR("no libargp found") ++ else ++ LIBS+=" -largp" ++ fi ++fi ++ + dnl ----------------- + dnl Configure options + dnl ----------------- +-- +2.2.1 + diff --git a/poky/meta/recipes-support/rng-tools/rng-tools/0002-Add-argument-to-control-the-libargp-dependency.patch b/poky/meta/recipes-support/rng-tools/rng-tools/0002-Add-argument-to-control-the-libargp-dependency.patch new file mode 100644 index 000000000..1c8a79ce0 --- /dev/null +++ b/poky/meta/recipes-support/rng-tools/rng-tools/0002-Add-argument-to-control-the-libargp-dependency.patch @@ -0,0 +1,92 @@ +From afc8712a9e6c72fbd03c36f84ecf8703e5d22a8c Mon Sep 17 00:00:00 2001 +From: Christopher Larson <chris_larson@mentor.com> +Date: Mon, 15 Feb 2016 16:11:32 -0700 +Subject: [PATCH 2/2] Add argument to control the libargp dependency + +This ensures that the builds are always deterministic. If the argument isn't +passed, the default behavior is to use libargp if the libc doesn't have argp. + +Upstream-Status: Pending +Signed-off-by: Christopher Larson <chris_larson@mentor.com> +--- + configure.ac | 55 ++++++++++++++++++++++++++++++++++++------------------- + 1 file changed, 36 insertions(+), 19 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 04fcd25..11a5321 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -32,6 +32,13 @@ AC_ARG_WITH([libgcrypt], + [with_libgcrypt=check] + ) + ++AC_ARG_WITH([libargp], ++ AS_HELP_STRING([--without-libargp], ++ [Disable libargp support. Systems whose libc lacks argp can use libargp instead. (Default: check if libc lacks argp)]), ++ [with_libargp=$withval], ++ [with_libargp=check] ++) ++ + dnl Make sure anyone changing configure.ac/Makefile.am has a clue + AM_MAINTAINER_MODE + +@@ -82,27 +89,37 @@ AS_IF( + ] + ) + +-dnl First check if we have argp available from libc +-AC_LINK_IFELSE( +- [AC_LANG_PROGRAM( +- [#include <argp.h>], +- [int argc=1; char *argv[]={"test"}; argp_parse(0,argc,argv,0,0,0); return 0;] +- )], +- [libc_has_argp="true"], +- [libc_has_argp="false"] ++dnl Determine if we need libargp: either user requested, or libc has no argp ++AS_IF( ++ [test "x$with_libargp" != "xyes"], ++ [ ++ AC_LINK_IFELSE( ++ [AC_LANG_PROGRAM( ++ [#include <argp.h>], ++ [int argc=1; char *argv[]={"test"}; argp_parse(0,argc,argv,0,0,0); return 0;] ++ )], ++ [need_libargp=no], ++ [need_libargp=yes ++ if test "x$with_libargp" = "xno"; then ++ AC_MSG_FAILURE([libargp disabled and libc does not have argp]) ++ fi] ++ ) ++ ], ++ [need_libargp=yes], + ) + +-dnl If libc doesn't provide argp, then test for libargp +-if test "$libc_has_argp" = "false" ; then +- AC_MSG_WARN("libc does not have argp") +- AC_CHECK_LIB([argp], [argp_parse], [have_argp="true"], [have_argp="false"]) +- +- if test "$have_argp" = "false"; then +- AC_MSG_ERROR("no libargp found") +- else +- LIBS+=" -largp" +- fi +-fi ++dnl Check for libargp ++AS_IF( ++ [test "x$need_libargp" = "xyes"], ++ [ ++ AC_CHECK_LIB( ++ [argp], ++ [argp_parse], ++ [LIBS="$LIBS -largp"], ++ [AC_MSG_FAILURE([libargp not found])] ++ ) ++ ] ++) + + dnl ----------------- + dnl Configure options +-- +2.2.1 + diff --git a/poky/meta/recipes-support/rng-tools/rng-tools/default b/poky/meta/recipes-support/rng-tools/rng-tools/default new file mode 100644 index 000000000..ab7cd9327 --- /dev/null +++ b/poky/meta/recipes-support/rng-tools/rng-tools/default @@ -0,0 +1,2 @@ +# Specify rng device +RNG_DEVICE=/dev/hwrng diff --git a/poky/meta/recipes-support/rng-tools/rng-tools/init b/poky/meta/recipes-support/rng-tools/rng-tools/init new file mode 100644 index 000000000..7cf78393a --- /dev/null +++ b/poky/meta/recipes-support/rng-tools/rng-tools/init @@ -0,0 +1,49 @@ +#! /bin/sh +# +# This is an init script for openembedded +# Copy it to /etc/init.d/rng-tools and type +# > update-rc.d rng-tools defaults 60 +# + +rngd=/usr/sbin/rngd +test -x "$rngd" || exit 1 + +if [ -e /etc/default/rng-tools ]; then + . /etc/default/rng-tools +fi + +if [ -n "$RNG_DEVICE" ]; then + EXTRA_ARGS="-- -r $RNG_DEVICE" +fi + + +case "$1" in + start) + echo -n "Starting random number generator daemon" + start-stop-daemon -S -q -x $rngd $EXTRA_ARGS + echo "." + ;; + stop) + echo -n "Stopping random number generator daemon" + start-stop-daemon -K -q -n rngd + echo "." + ;; + reload|force-reload) + echo -n "Signalling rng daemon restart" + start-stop-daemon -K -q -s 1 -x $rngd + start-stop-daemon -K -q -s 1 -x $rngd + ;; + restart) + echo -n "Stopping random number generator daemon" + start-stop-daemon -K -q -n rngd + echo "." + echo -n "Starting random number generator daemon" + start-stop-daemon -S -q -x $rngd $EXTRA_ARGS + echo "." + ;; + *) + echo "Usage: /etc/init.d/rng-tools {start|stop|reload|restart|force-reload}" + exit 1 +esac + +exit 0 diff --git a/poky/meta/recipes-support/rng-tools/rng-tools/read_error_msg.patch b/poky/meta/recipes-support/rng-tools/rng-tools/read_error_msg.patch new file mode 100644 index 000000000..8aa13bf8b --- /dev/null +++ b/poky/meta/recipes-support/rng-tools/rng-tools/read_error_msg.patch @@ -0,0 +1,98 @@ +rng-tools: modify 'read error' message + +Make the 'read error' message more descriptive. + +Copied from https://bugzilla.redhat.com/attachment.cgi?id=1295857 +and modified in one place to apply successfully. Error message during +bootstrap modified to show device name. + +Upstream-Status: pending + +Signed-off-by: Joe Slater <joe.slater@windriver.com> + + +--- a/rngd.c ++++ b/rngd.c +@@ -247,8 +247,11 @@ static void do_loop(int random_step) + continue; /* failed, no work */ + + retval = iter->xread(buf, sizeof buf, iter); +- if (retval) ++ if (retval) { ++ message(LOG_DAEMON|LOG_ERR, ++ "Error reading from entropy source\n"); + continue; /* failed, no work */ ++ } + + work_done = true; + +--- a/rngd_entsource.c ++++ b/rngd_entsource.c +@@ -63,10 +63,8 @@ int xread(void *buf, size_t size, struct + size -= r; + } + +- if (size) { +- message(LOG_DAEMON|LOG_ERR, "read error\n"); ++ if (size) + return -1; +- } + return 0; + } + +@@ -152,7 +150,7 @@ error_out: + } + + /* Initialize entropy source */ +-static int discard_initial_data(struct rng *ent_src) ++static int discard_initial_data(struct rng *ent_src, int *buf) + { + /* Trash 32 bits of what is probably stale (non-random) + * initial state from the RNG. For Intel's, 8 bits would +@@ -164,10 +162,12 @@ static int discard_initial_data(struct r + xread(tempbuf, sizeof(tempbuf), ent_src); + + /* Return 32 bits of bootstrap data */ +- xread(tempbuf, sizeof(tempbuf), ent_src); ++ if (xread(tempbuf, sizeof(tempbuf), ent_src) != 0) ++ return -1; + +- return tempbuf[0] | (tempbuf[1] << 8) | ++ *buf = tempbuf[0] | (tempbuf[1] << 8) | + (tempbuf[2] << 16) | (tempbuf[3] << 24); ++ return 0; + } + + /* +@@ -175,6 +175,8 @@ static int discard_initial_data(struct r + */ + int init_entropy_source(struct rng *ent_src) + { ++ int bootstrap; ++ + ent_src->rng_fd = open(ent_src->rng_name, O_RDONLY); + if (ent_src->rng_fd == -1) { + return 1; +@@ -182,7 +184,11 @@ int init_entropy_source(struct rng *ent_ + src_list_add(ent_src); + /* Bootstrap FIPS tests */ + ent_src->fipsctx = malloc(sizeof(fips_ctx_t)); +- fips_init(ent_src->fipsctx, discard_initial_data(ent_src)); ++ if (discard_initial_data(ent_src, &bootstrap) != 0) { ++ message(LOG_ERR|LOG_INFO, "Read failure in %s during bootstrap\n",ent_src->rng_name); ++ return 1; ++ } ++ fips_init(ent_src->fipsctx, bootstrap); + return 0; + } + +--- a/rngtest.c ++++ b/rngtest.c +@@ -335,6 +335,7 @@ static int discard_initial_data(void) + + return tempbuf[0] | (tempbuf[1] << 8) | + (tempbuf[2] << 16) | (tempbuf[3] << 24); ++ + } + + static void do_rng_fips_test_loop( void ) diff --git a/poky/meta/recipes-support/rng-tools/rng-tools/rng-tools-5-fix-textrels-on-PIC-x86.patch b/poky/meta/recipes-support/rng-tools/rng-tools/rng-tools-5-fix-textrels-on-PIC-x86.patch new file mode 100644 index 000000000..93a5864a4 --- /dev/null +++ b/poky/meta/recipes-support/rng-tools/rng-tools/rng-tools-5-fix-textrels-on-PIC-x86.patch @@ -0,0 +1,103 @@ +From: Francisco Blas Izquierdo Riera (klondike) <klondike@gentoo.org> +Subject: [PATCH] Fix assemby textrels on rdrand_asm.S on PIC x86 + +This patch updates the fixes in the assembly in rdrand_asm.S in +sys-apps/rng-tools-5 so it won't generate textrels on PIC systems. +The main fixes are in the use of leal in SETPTR for such systems, the rest is +the usual PIC support stuff. + +This should fix Gentoo bug #469962 and help fix #518210 + +This patch is released under the GPLv2 or a higher version license as is the +original file as long as the author and the tester are credited. + +Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=469962 +Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=518210 +Signed-off-by: Francisco Blas Izquierdo Riera (klondike) <klondike@gentoo.org> +Reported-by: cilly <cilly@cilly.mine.nu> +Reported-by: Manuel RĂ¼ger <mrueg@gentoo.org> +Tested-by: Anthony Basile <blueness@gentoo.org> + +Upstream-Status: Pending + +Index: rng-tools-5/rdrand_asm.S +=================================================================== +--- rng-tools-5.orig/rdrand_asm.S ++++ rng-tools-5/rdrand_asm.S +@@ -2,6 +2,7 @@ + * Copyright (c) 2011-2014, Intel Corporation + * Authors: Fenghua Yu <fenghua.yu@intel.com>, + * H. Peter Anvin <hpa@linux.intel.com> ++ * PIC code by: Francisco Blas Izquierdo Riera (klondike) <klondike@gentoo.org> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, +@@ -174,7 +175,19 @@ ENTRY(x86_rdseed_or_rdrand_bytes) + jmp 4b + ENDPROC(x86_rdseed_or_rdrand_bytes) + ++#if defined(__PIC__) ++#define INIT_PIC() \ ++ pushl %ebx ; \ ++ call __x86.get_pc_thunk.bx ; \ ++ addl $_GLOBAL_OFFSET_TABLE_, %ebx ++#define END_PIC() \ ++ popl %ebx ++#define SETPTR(var,ptr) leal (var)@GOTOFF(%ebx),ptr ++#else ++#define INIT_PIC() ++#define END_PIC() + #define SETPTR(var,ptr) movl $(var),ptr ++#endif + #define PTR0 %eax + #define PTR1 %edx + #define PTR2 %ecx +@@ -190,6 +203,7 @@ ENTRY(x86_aes_mangle) + movl 8(%ebp), %eax + movl 12(%ebp), %edx + push %esi ++ INIT_PIC() + #endif + movl $512, CTR3 /* Number of rounds */ + +@@ -280,6 +294,7 @@ offset = offset + 16 + movdqa %xmm7, (7*16)(PTR1) + + #ifdef __i386__ ++ END_PIC() + pop %esi + pop %ebp + #endif +@@ -294,6 +309,7 @@ ENTRY(x86_aes_expand_key) + push %ebp + mov %esp, %ebp + movl 8(%ebp), %eax ++ INIT_PIC() + #endif + + SETPTR(aes_round_keys, PTR1) +@@ -323,6 +339,7 @@ ENTRY(x86_aes_expand_key) + call 1f + + #ifdef __i386__ ++ END_PIC() + pop %ebp + #endif + ret +@@ -343,6 +360,16 @@ ENTRY(x86_aes_expand_key) + + ENDPROC(x86_aes_expand_key) + ++#if defined(__i386__) && defined(__PIC__) ++ .section .text.__x86.get_pc_thunk.bx,"axG",@progbits,__x86.get_pc_thunk.bx,comdat ++ .globl __x86.get_pc_thunk.bx ++ .hidden __x86.get_pc_thunk.bx ++ .type __x86.get_pc_thunk.bx, @function ++__x86.get_pc_thunk.bx: ++ movl (%esp), %ebx ++ ret ++#endif ++ + .bss + .balign 64 + aes_round_keys: diff --git a/poky/meta/recipes-support/rng-tools/rng-tools/rngd.service b/poky/meta/recipes-support/rng-tools/rng-tools/rngd.service new file mode 100644 index 000000000..b94ad5020 --- /dev/null +++ b/poky/meta/recipes-support/rng-tools/rng-tools/rngd.service @@ -0,0 +1,9 @@ +[Unit] +Description=Hardware RNG Entropy Gatherer Daemon + +[Service] +ExecStart=@SBINDIR@/rngd -f -r /dev/urandom +SuccessExitStatus=66 + +[Install] +WantedBy=multi-user.target diff --git a/poky/meta/recipes-support/rng-tools/rng-tools/underquote.patch b/poky/meta/recipes-support/rng-tools/rng-tools/underquote.patch new file mode 100644 index 000000000..afd08d577 --- /dev/null +++ b/poky/meta/recipes-support/rng-tools/rng-tools/underquote.patch @@ -0,0 +1,33 @@ +Fix underquoted m4 entry. This causes a failure if gcrypt isn't present: + +| configure: libgcrypt support disabled +| ../rng-tools-5/configure: line 4345: ac_fn_c_try_link: command not found +| configure: error: in `/media/build1/poky/build/tmp/work/i586-poky-linux/rng-tools/5-r0/build': + +RP +2016/2/16 + +Upstream-Status: Pending + +Index: rng-tools-5/configure.ac +=================================================================== +--- rng-tools-5.orig/configure.ac ++++ rng-tools-5/configure.ac +@@ -71,7 +71,7 @@ AS_IF( + [test "x$with_libgcrypt" != "xno"], + [ + AC_CHECK_HEADER([gcrypt.h], +- AC_CHECK_LIB( ++ [AC_CHECK_LIB( + [gcrypt], + [gcry_check_version], , + [ +@@ -80,7 +80,7 @@ AS_IF( + AC_MSG_NOTICE([libgcrypt support disabled]) + fi + ] +- ), ++ )], + [if test "x$with_libgcrypt" != "xcheck"; then + AC_MSG_FAILURE([libgcrypt headers not found]); else + AC_MSG_NOTICE([libgcrypt support disabled]) diff --git a/poky/meta/recipes-support/rng-tools/rng-tools_5.bb b/poky/meta/recipes-support/rng-tools/rng-tools_5.bb new file mode 100644 index 000000000..b3c9fd974 --- /dev/null +++ b/poky/meta/recipes-support/rng-tools/rng-tools_5.bb @@ -0,0 +1,55 @@ +SUMMARY = "Random number generator daemon" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://COPYING;md5=0b6f033afe6db235e559456585dc8cdc" + +SRC_URI = "${SOURCEFORGE_MIRROR}/gkernel/${BP}.tar.gz \ + file://0001-If-the-libc-is-lacking-argp-use-libargp.patch \ + file://0002-Add-argument-to-control-the-libargp-dependency.patch \ + file://underquote.patch \ + file://rng-tools-5-fix-textrels-on-PIC-x86.patch \ + file://read_error_msg.patch \ + file://init \ + file://default \ + file://rngd.service \ +" + +SRC_URI[md5sum] = "6726cdc6fae1f5122463f24ae980dd68" +SRC_URI[sha256sum] = "60a102b6603bbcce2da341470cad42eeaa9564a16b4490e7867026ca11a3078e" + +# As the recipe doesn't inherit systemd.bbclass, we need to set this variable +# manually to avoid unnecessary postinst/preinst generated. +python () { + if not bb.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, d): + d.setVar("INHIBIT_UPDATERCD_BBCLASS", "1") +} + +inherit autotools update-rc.d systemd + +PACKAGECONFIG = "libgcrypt" +PACKAGECONFIG_libc-musl = "libargp" +PACKAGECONFIG[libargp] = "--with-libargp,--without-libargp,argp-standalone," +PACKAGECONFIG[libgcrypt] = "--with-libgcrypt,--without-libgcrypt,libgcrypt," + +do_install_append() { + # Only install the init script when 'sysvinit' is in DISTRO_FEATURES. + if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then + install -d "${D}${sysconfdir}/init.d" + install -m 0755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/rng-tools + sed -i -e 's,/etc/,${sysconfdir}/,' -e 's,/usr/sbin/,${sbindir}/,' \ + ${D}${sysconfdir}/init.d/rng-tools + + install -d "${D}${sysconfdir}/default" + install -m 0644 ${WORKDIR}/default ${D}${sysconfdir}/default/rng-tools + fi + + if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then + install -d ${D}${systemd_unitdir}/system + install -m 644 ${WORKDIR}/rngd.service ${D}${systemd_unitdir}/system + sed -i -e 's,@SBINDIR@,${sbindir},g' ${D}${systemd_unitdir}/system/rngd.service + fi +} + +INITSCRIPT_NAME = "rng-tools" +INITSCRIPT_PARAMS = "start 30 2 3 4 5 . stop 30 0 6 1 ." + +SYSTEMD_SERVICE_${PN} = "rngd.service" |