mirror of
https://github.com/bjc/prosody.git
synced 2025-04-01 20:27:39 +03:00
util.random: Test whether util.crand works before using it (fix #1734)
util.crand can be configured at compile time to use the Linux getrandom() system call, available from Linux 3.17, but it is still possible to load it with an older kernel lacking that system call, where attempting to use it throws an ENOSYS error. By testing for this on load we can fall back to /dev/urandom in this case.
This commit is contained in:
parent
f19f1088b7
commit
1e2d4026f9
1 changed files with 1 additions and 1 deletions
|
@ -7,7 +7,7 @@
|
|||
--
|
||||
|
||||
local ok, crand = pcall(require, "util.crand");
|
||||
if ok then return crand; end
|
||||
if ok and pcall(crand.bytes, 1) then return crand; end
|
||||
|
||||
local urandom, urandom_err = io.open("/dev/urandom", "r");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue