[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
01/05: services: Add rngd-service.
From: |
Ludovic Courtès |
Subject: |
01/05: services: Add rngd-service. |
Date: |
Tue, 5 Jul 2016 09:14:21 +0000 (UTC) |
civodul pushed a commit to branch master
in repository guix.
commit b58cbf9ac507f58ef3031305ce8c13ea889de2d2
Author: David Craven <address@hidden>
Date: Sun Jul 3 20:25:09 2016 +0200
services: Add rngd-service.
* gnu/services/base.scm (<rngd-configuration>): New record type.
(rngd-service-type): New variable.
(rngd-service): New procedure.
* doc/guix.texi (Base Services): Document it.
Signed-off-by: Ludovic Courtès <address@hidden>
---
doc/guix.texi | 7 +++++++
gnu/services/base.scm | 47 +++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 52 insertions(+), 2 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index 62c0d34..c9d9bd8 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -7494,6 +7494,13 @@ created by @command{guix archive --generate-key}
(@pxref{Invoking guix
archive}). If that is not the case, the service will fail to start.
@end deffn
address@hidden
address@hidden {Scheme Procedure} rngd-service [#:rng-tools @var{rng-tools}] @
+ [#:device "/dev/hwrng"]
+Return a service that runs the @command{rngd} program from @var{rng-tools}
+to add @var{device} to the kernel's entropy pool. The service will fail if
address@hidden does not exist.
address@hidden deffn
@node Scheduled Job Execution
@subsubsection Scheduled Job Execution
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index f304bf8..5eabfec 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -4,6 +4,7 @@
;;; Copyright © 2015 Mark H Weaver <address@hidden>
;;; Copyright © 2015 Sou Bunnbu <address@hidden>
;;; Copyright © 2016 Leo Famulari <address@hidden>
+;;; Copyright © 2016 David Craven <address@hidden>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -31,7 +32,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 +98,8 @@
urandom-seed-service-type
urandom-seed-service
+ rngd-service-type
+ rngd-service
%base-services))
@@ -486,7 +489,47 @@ 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>
+ rngd-configuration make-rngd-configuration
+ rngd-configuration?
+ (rng-tools rngd-configuration-rng-tools) ;package
+ (device rngd-configuration-device)) ;string
+
+(define rngd-service-type
+ (shepherd-service-type
+ 'rngd
+ (lambda (config)
+ (define rng-tools (rngd-configuration-rng-tools config))
+ (define device (rngd-configuration-device config))
+
+ (define rngd-command
+ (list #~(string-append #$rng-tools "/sbin/rngd")
+ "-f" "-r" device))
+
+ (shepherd-service
+ (documentation "Add TRNG to entropy pool.")
+ (requirement '(udev))
+ (provision '(trng))
+ (start #~(make-forkexec-constructor address@hidden))
+ (stop #~(make-kill-destructor))))))
+
+(define* (rngd-service #:key
+ (rng-tools rng-tools)
+ (device "/dev/hwrng"))
+ "Return a service that runs the @command{rngd} program from @var{rng-tools}
+to add @var{device} to the kernel's entropy pool. The service will fail if
address@hidden does not exist."
+ (service rngd-service-type
+ (rngd-configuration
+ (rng-tools rng-tools)
+ (device device))))
+
+
;;;
;;; System-wide environment variables.
;;;