diff options
author | Matthew Wild <mwild1@gmail.com> | 2016-02-01 21:28:07 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2016-02-01 21:28:07 +0000 |
commit | 11dcbc505b599add9294e27addaa697aa97e1e0c (patch) | |
tree | b1ba3e9f2c4c1b332f4b0264453b7b9c01952163 /util | |
parent | bebb4e7b675a3db13263c1946c16b090bcf8f4f5 (diff) | |
parent | a1e077c5e7d4f6d2768c47a6847fbe8eea0f28d8 (diff) | |
download | prosody-11dcbc505b599add9294e27addaa697aa97e1e0c.tar.gz prosody-11dcbc505b599add9294e27addaa697aa97e1e0c.zip |
Merge 0.10->trunk
Diffstat (limited to 'util')
-rw-r--r-- | util/pluginloader.lua | 15 | ||||
-rw-r--r-- | util/random.lua | 8 |
2 files changed, 22 insertions, 1 deletions
diff --git a/util/pluginloader.lua b/util/pluginloader.lua index 0d7eafa7..004855f0 100644 --- a/util/pluginloader.lua +++ b/util/pluginloader.lua @@ -55,8 +55,23 @@ local function load_code(plugin, resource, env) return f, path; end +local function load_code_ext(plugin, resource, extension, env) + local content, err = load_resource(plugin, resource.."."..extension); + if not content then + content, err = load_resource(resource, resource.."."..extension); + if not content then + return content, err; + end + end + local path = err; + local f, err = envload(content, "@"..path, env); + if not f then return f, err; end + return f, path; +end + return { load_file = load_file; load_resource = load_resource; load_code = load_code; + load_code_ext = load_code_ext; }; 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; |