# HG changeset patch # User Matthew Wild # Date 1454362087 0 # Node ID ecba5fee4867e932d582ba29b1ddd014b195fe8a # Parent ecebc821225dc8952c0f7a13724e66d066bf126f# Parent 805d068d2fd533fa0d88150e5a09d13364e31aef Merge 0.10->trunk diff -r ecebc821225d -r ecba5fee4867 core/moduleapi.lua --- a/core/moduleapi.lua Sat Jan 30 14:18:42 2016 +0100 +++ b/core/moduleapi.lua Mon Feb 01 21:28:07 2016 +0000 @@ -137,10 +137,7 @@ end function api:require(lib) - local f, n = pluginloader.load_code(self.name, lib..".lib.lua", self.environment); - if not f then - f, n = pluginloader.load_code(lib, lib..".lib.lua", self.environment); - end + local f, n = pluginloader.load_code_ext(self.name, lib, "lib.lua", self.environment); if not f then error("Failed to load plugin library '"..lib.."', error: "..n); end -- FIXME better error message return f(); end diff -r ecebc821225d -r ecba5fee4867 util/pluginloader.lua --- a/util/pluginloader.lua Sat Jan 30 14:18:42 2016 +0100 +++ b/util/pluginloader.lua Mon Feb 01 21:28:07 2016 +0000 @@ -55,8 +55,23 @@ 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 -r ecebc821225d -r ecba5fee4867 util/random.lua --- a/util/random.lua Sat Jan 30 14:18:42 2016 +0100 +++ b/util/random.lua Mon Feb 01 21:28:07 2016 +0000 @@ -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;