From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Craven Subject: [PATCH] services: Add rngd service. Date: Sun, 3 Jul 2016 02:16:23 +0200 Message-ID: <20160703001623.27550-1-david@craven.ch> Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43434) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJVPV-0007y1-V5 for guix-devel@gnu.org; Sat, 02 Jul 2016 20:37:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bJVPQ-0005qG-Vu for guix-devel@gnu.org; Sat, 02 Jul 2016 20:37:21 -0400 Received: from so254-10.mailgun.net ([198.61.254.10]:34964) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJVPP-0005pZ-Nk for guix-devel@gnu.org; Sat, 02 Jul 2016 20:37:16 -0400 List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org Cc: david@craven.ch * gnu/services/base.scm (rngd-service): New service. * gnu/packages/linux.scm (rng-tools): New package. --- gnu/packages/linux.scm | 76 +++++++++++++++++++++++++++++++------------------- gnu/services/base.scm | 43 ++++++++++++++++++++++++++-- 2 files changed, 89 insertions(+), 30 deletions(-) diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index a0c21d8..f1b2172 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -30,49 +30,49 @@ ;;; along with GNU Guix. If not, see . (define-module (gnu packages linux) - #:use-module ((guix licenses) #:prefix license:) #:use-module (gnu packages) + #:use-module (gnu packages admin) + #:use-module (gnu packages algebra) + #:use-module (gnu packages attr) + #:use-module (gnu packages autotools) + #:use-module (gnu packages base) + #:use-module (gnu packages bison) + #:use-module (gnu packages calendar) + #:use-module (gnu packages check) #:use-module (gnu packages compression) - #:use-module (gnu packages gcc) + #:use-module (gnu packages databases) + #:use-module (gnu packages docbook) + #:use-module (gnu packages documentation) + #:use-module (gnu packages elf) #:use-module (gnu packages flex) - #:use-module (gnu packages bison) - #:use-module (gnu packages admin) + #:use-module (gnu packages freedesktop) + #:use-module (gnu packages gcc) + #:use-module (gnu packages gettext) + #:use-module (gnu packages glib) #:use-module (gnu packages gperf) + #:use-module (gnu packages gtk) #:use-module (gnu packages libusb) + #:use-module (gnu packages maths) #:use-module (gnu packages ncurses) - #:use-module (gnu packages pciutils) - #:use-module (gnu packages databases) #:use-module (gnu packages perl) + #:use-module (gnu packages pciutils) #:use-module (gnu packages pkg-config) + #:use-module (gnu packages pulseaudio) #:use-module (gnu packages python) + #:use-module (gnu packages readline) + #:use-module (gnu packages rrdtool) #:use-module (gnu packages slang) - #:use-module (gnu packages algebra) - #:use-module (gnu packages gettext) - #:use-module (gnu packages glib) - #:use-module (gnu packages pulseaudio) - #:use-module (gnu packages attr) - #:use-module (gnu packages xml) - #:use-module (gnu packages autotools) #:use-module (gnu packages texinfo) - #:use-module (gnu packages check) - #:use-module (gnu packages maths) - #:use-module (gnu packages base) - #:use-module (gnu packages rrdtool) - #:use-module (gnu packages elf) - #:use-module (gnu packages gtk) - #:use-module (gnu packages docbook) - #:use-module (gnu packages documentation) - #:use-module (gnu packages readline) - #:use-module (gnu packages calendar) #:use-module (gnu packages tls) - #:use-module (gnu packages freedesktop) - #:use-module (guix packages) - #:use-module (guix download) - #:use-module (guix utils) - #:use-module (guix build-system gnu) + #:use-module (gnu packages xml) #:use-module (guix build-system cmake) + #:use-module (guix build-system gnu) #:use-module (guix build-system python) #:use-module (guix build-system trivial) + #:use-module (guix download) + #:use-module ((guix licenses) #:prefix license:) + #:use-module (guix packages) + #:use-module (guix utils) #:use-module (srfi srfi-1) #:use-module (srfi srfi-2) #:use-module (srfi srfi-26) @@ -2726,3 +2726,23 @@ from userspace.") commonly found on Microsoft Windows. It is implemented as a FUSE file system. The package provides additional NTFS tools.") (license license:gpl2+))) + +(define-public rng-tools + (package + (name "rng-tools") + (version "5") + (source (origin + (method url-fetch) + (uri (string-append + "http://downloads.sourceforge.net/sourceforge/gkernel/rng-tools-" version + ".tar.gz")) + (sha256 + (base32 + "13h7lc8wl9khhvkr0i3bl5j9bapf8anhqis1lcnwxg1vc2v058b0")))) + (build-system gnu-build-system) + (synopsis "Random number generator daemon") + (description + "Monitor a hardware random number generator, and supply entropy +from that to the system kernel's /dev/random machinery.") + (home-page "http://sourceforge.net/projects/gkernel") + (license license:gpl2))) diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 2780d12..fab287a 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -31,7 +31,7 @@ #:use-module (gnu system mapped-devices) #:use-module (gnu packages admin) #:use-module ((gnu packages linux) - #:select (eudev kbd e2fsprogs lvm2 fuse alsa-utils crda gpm)) + #:select (alsa-utils crda eudev e2fsprogs fuse gpm kbd lvm2 rng-tools)) #:use-module ((gnu packages base) #:select (canonical-package glibc)) #:use-module (gnu packages package-management) @@ -95,6 +95,7 @@ gpm-service urandom-seed-service + rngd-service %base-services)) @@ -484,7 +485,45 @@ stopped before 'kill' is called." (define (urandom-seed-service) (service urandom-seed-service-type #f)) - + +;;; +;;; Add hardware random number generator to entropy pool +;;; + +(define-record-type* + rngd-configuration make-rngd-configuration + rngd-configuration? + (rng-tools rngd-configuration-rng-tools) + (rng-device rngd-configuration-rngd-device)) + +(define rngd-service-type + (shepherd-service-type + 'rngd + (lambda (config) + (define rng-tools (rngd-configuration-rng-tools config)) + (define rng-device (rngd-configuration-rngd-device config)) + + (define rngd-command + (list #~(string-append #$rng-tools "/sbin/rngd") "-f" "-r" rng-device)) + + (shepherd-service + (documentation "Add TRNG to entropy pool.") + (requirement '(udev)) + (provision '(trng)) + (start #~(make-forkexec-constructor #$@rngd-command)) + (stop #~(make-kill-destructor)))))) + +(define* (rngd-service #:key + (rng-tools rng-tools) + (rng-device "/dev/hwrng")) + "Run the @command{rngd} program from @var{rng-tools} to add @var{rng-device} +to the kernel's entropy pool." + (service rngd-service-type + (rngd-configuration + (rng-tools rng-tools) + (rng-device rng-device)))) + + ;;; ;;; System-wide environment variables. ;;; -- 2.9.0