From 684aa3187fc5d2a759bd98459d829cf3ed7f04df Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 31 Jan 2016 17:27:15 +0100 Subject: util.random: Restore friendlier error from 0.9/util.uuid --- util/random.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'util/random.lua') diff --git a/util/random.lua b/util/random.lua index 05f36aba..e4b4a700 100644 --- a/util/random.lua +++ b/util/random.lua @@ -6,7 +6,7 @@ -- COPYING file in the source package for more information. -- -local urandom = assert(io.open("/dev/urandom", "r")); +local urandom, urandom_err = io.open("/dev/urandom", "r"); local function seed() end @@ -15,6 +15,12 @@ local function bytes(n) return urandom:read(n); end +if not urandom then + function bytes() + error("Unable to obtain a secure random number generator, please see https://prosody.im/doc/random ("..urandom_err..")"); + end +end + return { seed = seed; bytes = bytes; -- cgit v1.2.3