From: David Craven <david@craven.ch>
To: guix-devel@gnu.org
Cc: David Craven <david@craven.ch>
Subject: [PATCH 3/3] services: Add rngd-service.
Date: Sun, 3 Jul 2016 04:26:29 +0200 [thread overview]
Message-ID: <20160703022629.32137-3-david@craven.ch> (raw)
In-Reply-To: <20160703014231.GA1178@jasmine>
* 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))
-\f
+
+;;;
+;;; Add hardware random number generator to entropy pool
+;;;
+
+(define-record-type* <rngd-configuration>
+ 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
next prev parent reply other threads:[~2016-07-03 2:26 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-03 0:16 [PATCH] services: Add rngd service David Craven
2016-07-03 1:42 ` Leo Famulari
2016-07-03 2:05 ` [PATCH 1/3] gnu: Reorder imports alphabetically David Craven
2016-07-03 21:31 ` Leo Famulari
2016-07-03 21:50 ` David Craven
2016-07-03 2:21 ` [PATCH] services: Add rngd service David Craven
2016-07-03 2:26 ` [PATCH 2/3] gnu: Add rng-tools 5 David Craven
2016-07-03 21:31 ` Leo Famulari
2016-07-03 2:26 ` David Craven [this message]
2016-07-03 18:25 ` [PATCH 3/4] services: Add rngd-service David Craven
2016-07-05 9:11 ` Ludovic Courtès
2016-07-03 18:25 ` [PATCH 4/4] build: Ignore texi2pdf temporary files David Craven
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160703022629.32137-3-david@craven.ch \
--to=david@craven.ch \
--cc=guix-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.