From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Craven Subject: [PATCH 3/3] services: Add rngd-service. Date: Sun, 3 Jul 2016 04:26:29 +0200 Message-ID: <20160703022629.32137-3-david@craven.ch> References: <20160703014231.GA1178@jasmine> Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52138) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJX7a-0005BU-Jq for guix-devel@gnu.org; Sat, 02 Jul 2016 22:26:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bJX7W-0005YQ-Vk for guix-devel@gnu.org; Sat, 02 Jul 2016 22:26:57 -0400 Received: from so254-10.mailgun.net ([198.61.254.10]:59697) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJX7V-0005YG-PY for guix-devel@gnu.org; Sat, 02 Jul 2016 22:26:54 -0400 In-Reply-To: <20160703014231.GA1178@jasmine> 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 * gnu/services/base.scm: New service. --- gnu/services/base.scm | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/gnu/services/base.scm b/gnu/services/base.scm index f304bf8..67f3961 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) @@ -97,6 +97,7 @@ urandom-seed-service-type urandom-seed-service + rngd-service %base-services)) @@ -486,7 +487,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