aboutsummaryrefslogtreecommitdiffstats
path: root/util/random.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2016-02-01 21:28:07 +0000
committerMatthew Wild <mwild1@gmail.com>2016-02-01 21:28:07 +0000
commit6cb4a340b97827f572c55b87b254352e20e38f4a (patch)
treeb1ba3e9f2c4c1b332f4b0264453b7b9c01952163 /util/random.lua
parent83d80d03ff08842f1d36a38136ad778ba9ff3a25 (diff)
parentd0c5e1571fcd0d0242815c1076d56ecf917eec13 (diff)
downloadprosody-6cb4a340b97827f572c55b87b254352e20e38f4a.tar.gz
prosody-6cb4a340b97827f572c55b87b254352e20e38f4a.zip
Merge 0.10->trunk
Diffstat (limited to 'util/random.lua')
-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;