From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail.mars-solutions.de ([213.239.212.107]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1XiRCl-0000KH-OH for ptxdist@pengutronix.de; Sun, 26 Oct 2014 18:02:12 +0100 Received: from localhost (localhost [127.0.0.1]) by mail.mars-solutions.de (Postfix) with ESMTP id B8A8C2A409F for ; Sun, 26 Oct 2014 18:02:02 +0100 (CET) Received: from mail.mars-solutions.de ([127.0.0.1]) by localhost (mars-solutions.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UGu3Qsf993ED for ; Sun, 26 Oct 2014 18:02:02 +0100 (CET) Received: from ws-apr.office.loc (HSI-KBW-37-49-64-252.hsi14.kabel-badenwuerttemberg.de [37.49.64.252]) by mail.mars-solutions.de (Postfix) with ESMTP id 26E9D2A409F for ; Sun, 26 Oct 2014 18:02:02 +0100 (CET) From: Andreas Pretzsch Date: Sun, 26 Oct 2014 18:02:04 +0100 Message-Id: <1414342924-19265-1-git-send-email-apr@cn-eng.de> Subject: [ptxdist] [PATCH] rng-tools: new package for rng-tools (rngd) version 5 Reply-To: ptxdist@pengutronix.de List-Id: PTXdist Development Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: ptxdist-bounces@pengutronix.de Errors-To: ptxdist-bounces@pengutronix.de To: ptxdist@pengutronix.de random number generator daemon - seed kernel random from hwrng This daemon feeds data from a random number generator to the kernel's random number entropy pool, after first checking the data to ensure that it is properly random. By default, a hardware rng at /dev/hwrng is used as entropy source. This daemon is part of the rng-tools, which can be found at http://sourceforge.net/projects/gkernel/ git://git.kernel.org/pub/scm/utils/kernel/rng-tools/rng-tools.git Signed-off-by: Andreas Pretzsch --- Start script is kept as simple as possible, as this one runs rather early and does not need much. The link default of "S00" in rc.d is intentional. rc-once is S01 by default and triggers things like ssh key generation. So while in other cases I would have set rngd to something around S10, it has to squeeze in before rc-once. As there are no udev depends (the other S00), being a kernel provided device, this should be ok. Placing the daemon in /sbin also follows this fact, beside its very system-near function. generic/etc/init.d/rngd | 40 +++++++++++++++++++++++++++++++++ rules/rng-tools-bbinit.in | 10 +++++++++ rules/rng-tools.in | 23 +++++++++++++++++++ rules/rng-tools.make | 57 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 130 insertions(+) create mode 100644 generic/etc/init.d/rngd create mode 100644 rules/rng-tools-bbinit.in create mode 100644 rules/rng-tools.in create mode 100644 rules/rng-tools.make diff --git a/generic/etc/init.d/rngd b/generic/etc/init.d/rngd new file mode 100644 index 0000000..cdae9db --- /dev/null +++ b/generic/etc/init.d/rngd @@ -0,0 +1,40 @@ +#!/bin/sh +# +# Start/stop rngd (random number generator daemon) from rng-tools +# + +# defaults are sane, normally no need to override +OPTIONS= + +# pid-file created from rngd by default +PIDFILE=/var/run/rngd.pid + +case $1 in + start) + if [ -e $PIDFILE ]; then + echo "rngd already running (found $PIDFILE)" + else + echo "starting rngd" + /sbin/rngd $OPTIONS + fi + ;; + + stop) + if [ -e $PIDFILE ]; then + echo "stopping rngd" + kill -s SIGTERM `cat $PIDFILE` + else + echo "rngd not running (no $PIDFILE)" + fi + ;; + + restart) + $0 stop + $0 start + ;; + + *) + echo "Usage: ${0} {start|stop|restart}" + exit 1 + ;; +esac diff --git a/rules/rng-tools-bbinit.in b/rules/rng-tools-bbinit.in new file mode 100644 index 0000000..7cb74aa --- /dev/null +++ b/rules/rng-tools-bbinit.in @@ -0,0 +1,10 @@ +## SECTION=initmethod_bbinit + +config RNG_TOOLS_BBINIT_LINK + string + depends on RNG_TOOLS_STARTSCRIPT + prompt "rng-tools" + default "S00rngd" + help + Order in start sequence. + Note: Start before rc-once to seed random before e.g. key creation. diff --git a/rules/rng-tools.in b/rules/rng-tools.in new file mode 100644 index 0000000..8282b93 --- /dev/null +++ b/rules/rng-tools.in @@ -0,0 +1,23 @@ +## SECTION=shell_and_console + +config RNG_TOOLS + tristate + prompt "rng-tools rngd" + help + random number generator daemon - seed kernel random from hwrng + + This daemon feeds data from a random number generator to the kernel's + random number entropy pool, after first checking the data to ensure + that it is properly random. + + By default, a hardware rng at /dev/hwrng is used as entropy source. + + This daemon is part of the rng-tools, which can be found at + http://sourceforge.net/projects/gkernel/ + git://git.kernel.org/pub/scm/utils/kernel/rng-tools/rng-tools.git + +config RNG_TOOLS_STARTSCRIPT + bool + default y + depends on RNG_TOOLS + prompt "install /etc/init.d/rngd" diff --git a/rules/rng-tools.make b/rules/rng-tools.make new file mode 100644 index 0000000..22f26fd --- /dev/null +++ b/rules/rng-tools.make @@ -0,0 +1,57 @@ +# -*-makefile-*- +# +# Copyright (C) 2014 by Andreas Pretzsch +# +# See CREDITS for details about who has contributed to this project. +# +# For further information about the PTXdist project and license conditions +# see the README file. +# + +PACKAGES-$(PTXCONF_RNG_TOOLS) += rng-tools + +RNG_TOOLS_VERSION := 5 +RNG_TOOLS_MD5 := 6726cdc6fae1f5122463f24ae980dd68 +RNG_TOOLS := rng-tools-$(RNG_TOOLS_VERSION) +RNG_TOOLS_SUFFIX := tar.gz +RNG_TOOLS_URL := $(call ptx/mirror, SF, gkernel/$(RNG_TOOLS).$(RNG_TOOLS_SUFFIX)) +RNG_TOOLS_SOURCE := $(SRCDIR)/$(RNG_TOOLS).$(RNG_TOOLS_SUFFIX) +RNG_TOOLS_DIR := $(BUILDDIR)/$(RNG_TOOLS) +RNG_TOOLS_LICENSE := GPLv2 + +# ---------------------------------------------------------------------------- +# Prepare +# ---------------------------------------------------------------------------- + +RNG_TOOLS_CONF_TOOL := autoconf +RNG_TOOLS_CONF_OPT := $(CROSS_AUTOCONF_ROOT) + +# ---------------------------------------------------------------------------- +# Target-Install +# ---------------------------------------------------------------------------- + +$(STATEDIR)/rng-tools.targetinstall: + @$(call targetinfo) + + @$(call install_init, rng-tools) + @$(call install_fixup, rng-tools,PRIORITY,optional) + @$(call install_fixup, rng-tools,SECTION,base) + @$(call install_fixup, rng-tools,AUTHOR,"Andreas Pretzsch ") + @$(call install_fixup, rng-tools,DESCRIPTION,"random number generator daemon - seed kernel random from hwrng") + + @$(call install_copy, rng-tools, 0, 0, 0755, -, /sbin/rngd) +ifdef PTXCONF_INITMETHOD_BBINIT +ifdef PTXCONF_RNG_TOOLS_STARTSCRIPT + @$(call install_alternative, rng-tools, 0, 0, 0755, /etc/init.d/rngd) +ifneq ($(call remove_quotes,$(PTXCONF_RNG_TOOLS_BBINIT_LINK)),) + @$(call install_link, rng-tools, \ + ../init.d/rngd, \ + /etc/rc.d/$(PTXCONF_RNG_TOOLS_BBINIT_LINK)) +endif +endif +endif + @$(call install_finish, rng-tools) + + @$(call touch) + +# vim: syntax=make -- 2.1.1 -- ptxdist mailing list ptxdist@pengutronix.de