aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2016-01-31 17:27:15 +0100
committerKim Alvefur <zash@zash.se>2016-01-31 17:27:15 +0100
commitd920df1dfb4aef67da792686e969249a72ff5f21 (patch)
tree5e631f31749467e1e57f626ae6b58a680f7db6fe /util
parentacacec8e82b6228d95a715750f68ea9c4cbeeaab (diff)
downloadprosody-d920df1dfb4aef67da792686e969249a72ff5f21.tar.gz
prosody-d920df1dfb4aef67da792686e969249a72ff5f21.zip
util.random: Restore friendlier error from 0.9/util.uuid
Diffstat (limited to 'util')
-rw-r--r--util/random.lua8
1 files changed, 7 insertions, 1 deletions
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;