aboutsummaryrefslogtreecommitdiffstats
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
commit684aa3187fc5d2a759bd98459d829cf3ed7f04df (patch)
tree5e631f31749467e1e57f626ae6b58a680f7db6fe
parent2c45793d230c3adc5c3d0c955ad98e019fde98de (diff)
downloadprosody-684aa3187fc5d2a759bd98459d829cf3ed7f04df.tar.gz
prosody-684aa3187fc5d2a759bd98459d829cf3ed7f04df.zip
util.random: Restore friendlier error from 0.9/util.uuid
-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;