diff options
author | Kim Alvefur <zash@zash.se> | 2016-01-31 17:27:15 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2016-01-31 17:27:15 +0100 |
commit | d920df1dfb4aef67da792686e969249a72ff5f21 (patch) | |
tree | 5e631f31749467e1e57f626ae6b58a680f7db6fe /util | |
parent | acacec8e82b6228d95a715750f68ea9c4cbeeaab (diff) | |
download | prosody-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.lua | 8 |
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; |