Software /
code /
prosody
Changeset
7114:51cf09bb74eb
util.random: Restore friendlier error from 0.9/util.uuid
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 31 Jan 2016 17:27:15 +0100 |
parents | 7112:bd29742fa1ba |
children | 7115:805d068d2fd5 |
files | util/random.lua |
diffstat | 1 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/util/random.lua Fri Jan 29 14:52:38 2016 +0100 +++ b/util/random.lua Sun Jan 31 17:27:15 2016 +0100 @@ -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 @@ 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;