summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan (janneke) Nieuwenhuizen <janneke@gnu.org>2020-10-30 15:01:30 +0100
committerJan (janneke) Nieuwenhuizen <janneke@gnu.org>2021-03-18 08:40:35 +0100
commita1ecd392a1f0d614f0c994129afd93fe924020ef (patch)
treeb055f407c9754efd3e3d4aaaff256db8161b105c
parentc16ac36ca6492a5a7b20951ed5bac827bb8aa3cf (diff)
mingw: Hack for missing /dev/urandom.
* web/socket/client.scm (open-entropy-port): Add hack for missing /dev/urandom.
-rw-r--r--web/socket/client.scm11
1 files changed, 8 insertions, 3 deletions
diff --git a/web/socket/client.scm b/web/socket/client.scm
index e690317..2017ab8 100644
--- a/web/socket/client.scm
+++ b/web/socket/client.scm
@@ -154,9 +154,14 @@ KEY."
(define (open-entropy-port)
"Return an open input port to a reliable source of entropy for the
current system."
- ;; XXX: This works on GNU/Linux and OS X systems, but this isn't
- ;; exactly portable.
- (open-input-file "/dev/urandom"))
+ (if (file-exists? "/dev/urandom")
+ (open-input-file "/dev/urandom")
+ ;; XXX: This works as a fall back but this isn't exactly a
+ ;; reliable source of entropy.
+ (make-soft-port (vector (const #f) (const #f) (const #f)
+ (lambda _ (let ((r (random 256))) (integer->char r)))
+ (const #f)
+ (const #t)) "r")))
(define (make-websocket uri-or-string)
"Create and establish a new WebSocket connection for the remote