unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Leo Famulari <leo@famulari.name>
Cc: 23605@debbugs.gnu.org
Subject: bug#23605: /dev/urandom not seeded across reboots
Date: Wed, 25 May 2016 18:54:58 +0200	[thread overview]
Message-ID: <87vb229ixp.fsf@gnu.org> (raw)
In-Reply-To: <20160525163815.GA19996@jasmine> (Leo Famulari's message of "Wed, 25 May 2016 12:38:15 -0400")

Leo Famulari <leo@famulari.name> skribis:

> On Tue, May 24, 2016 at 02:24:59PM +0200, Ludovic Courtès wrote:

[...]

>> Instead of spawning ‘cat’, we can do:
>> 
>>   (when (file-exists? #$%random-seed-file)
>>     (call-with-input-file #$%random-seed-file
>>       (lambda (seed)
>>         (call-with-output-file "/dev/urandom"
>>           (lambda (random)
>>             (dump-port seed random))))))
>>   #t   ;service successfully “started”
>
> I think I've done this correctly, as attached, but I can't test it yet
> since I still get an error: "service: Wrong number of arguments in form
> (service urandom-seed-service-type)".

Yes, it’s:

  (service TYPE VALUE)

but I think there’s no meaningful value for this service, so you could
do:

  (service urandom-seed-service-type #f)

[...]

> +(define (urandom-seed-shepherd-service)
> +  "Return a shepherd service for the /dev/urandom seed."
> +  (list (shepherd-service
> +         (documentation "Preserve entropy across reboots for /dev/urandom.")

I think you’ll need to specify that additional modules are needed (for
‘make-bytevector’, ‘put-bytevector’, etc.):

  (shepherd-service
    ;; …
    (modules `((rnrs bytevectors)
               (rnrs io ports)
               ,@%default-modules)))

(See (gnu services shepherd) for the definition of ‘%default-modules’.)

> +         (stop #~(lambda _
> +                   (let ((buf (make-bytevector 512)))
> +                     (call-with-input-file "/dev/urandom"
> +                       (lambda (urandom)
> +                         (get-bytevector-n! urandom buf 0 512)
> +                           (call-with-output-file #$%random-seed-file
                             ^^
Misleading indent here.

> +                             (lambda (seed)
> +                               (dump-port buf seed)))

‘dump-port’ from (guix build utils) takes an input port as its 1st
argument, and an output port as its 2nd argument.  Here BUF is a
bytevector, not a port.

So instead, this should be:

  (lambda (seed)
    (put-bytevector seed buf))

Sounds like you’re pretty much there!  :-)

Thanks,
Ludo’.

  reply	other threads:[~2016-05-25 16:56 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-23 17:58 bug#23605: /dev/urandom not seeded across reboots Leo Famulari
2016-05-24  7:05 ` Taylan Ulrich Bayırlı/Kammer
2016-05-24 16:16   ` Leo Famulari
2016-05-24 16:26     ` Thompson, David
2016-05-24 17:23       ` Leo Famulari
2016-05-24 17:29         ` Thompson, David
2016-05-25 21:53       ` Ludovic Courtès
2016-05-24 12:24 ` Ludovic Courtès
2016-05-25 16:38   ` Leo Famulari
2016-05-25 16:54     ` Ludovic Courtès [this message]
2016-05-26 16:47       ` Leo Famulari
2016-05-28 13:57         ` Ludovic Courtès
2016-05-28 18:05           ` Leo Famulari
2016-05-28 18:10             ` Leo Famulari
2016-05-28 18:26             ` Leo Famulari
2016-05-28 20:41               ` Leo Famulari
2016-05-28 20:53             ` Ludovic Courtès
2016-05-29  0:00               ` Leo Famulari
2016-05-29  0:04                 ` Leo Famulari
2016-05-29 20:23                 ` Ludovic Courtès
2016-05-28  1:12   ` Leo Famulari
2016-05-28 13:51     ` Ludovic Courtès
2016-05-28  1:05 ` Leo Famulari
2016-05-28  1:11   ` Ben Woodcroft
2016-05-28  1:45     ` Leo Famulari
2016-05-28  9:40       ` Ben Woodcroft

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

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87vb229ixp.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=23605@debbugs.gnu.org \
    --cc=leo@famulari.name \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).