From 58a6a4b140a317a9e77c803dfda08c5e4770e3fa Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 22 Feb 2016 17:30:12 +0100 Subject: util.sql: Localize unpack() in Lua 5.2 compatible way --- util/sql.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util') diff --git a/util/sql.lua b/util/sql.lua index b4d14537..9981ac3c 100644 --- a/util/sql.lua +++ b/util/sql.lua @@ -1,6 +1,6 @@ local setmetatable, getmetatable = setmetatable, getmetatable; -local ipairs, unpack, select = ipairs, unpack, select; +local ipairs, unpack, select = ipairs, table.unpack or unpack, select; --luacheck: ignore 113 local tonumber, tostring = tonumber, tostring; local assert, xpcall, debug_traceback = assert, xpcall, debug.traceback; local t_concat = table.concat; -- cgit v1.2.3 From 5a4948a7447c459b604465d412759c44afc4362e Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 22 Feb 2016 17:32:11 +0100 Subject: util.session: Fix luacheck warnings --- util/session.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'util') diff --git a/util/session.lua b/util/session.lua index fda7fccd..b2a726ce 100644 --- a/util/session.lua +++ b/util/session.lua @@ -9,13 +9,13 @@ local function new_session(typ) end local function set_id(session) - local id = typ .. tostring(session):match("%x+$"):lower(); + local id = session.type .. tostring(session):match("%x+$"):lower(); session.id = id; return session; end local function set_logger(session) - local log = logger.init(id); + local log = logger.init(session.id); session.log = log; return session; end @@ -30,7 +30,7 @@ local function set_send(session) local conn = session.conn; if not conn then function session.send(data) - log("debug", "Discarding data sent to unconnected session: %s", tostring(data)); + session.log("debug", "Discarding data sent to unconnected session: %s", tostring(data)); return false; end return session; -- cgit v1.2.3 From 847ba75e55404bc8d386e1edf80699c921520aca Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 22 Feb 2016 17:34:42 +0100 Subject: util.debug: Silence luacheck warning about modifying 'debug' lib --- util/debug.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'util') diff --git a/util/debug.lua b/util/debug.lua index a78524a9..00f476d0 100644 --- a/util/debug.lua +++ b/util/debug.lua @@ -1,6 +1,9 @@ -- Variables ending with these names will not -- have their values printed ('password' includes -- 'new_password', etc.) +-- +-- luacheck: ignore 122/debug + local censored_names = { password = true; passwd = true; -- cgit v1.2.3 From 792b0e8d798c02f811d2dc0428a3babcd80f558f Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 22 Feb 2016 17:37:55 +0100 Subject: util.import: Localize unpack() in Lua 5.2 compatible way --- util/import.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'util') diff --git a/util/import.lua b/util/import.lua index 174da0ca..c2b9dce1 100644 --- a/util/import.lua +++ b/util/import.lua @@ -8,6 +8,7 @@ +local unpack = table.unpack or unpack; --luacheck: ignore 113 local t_insert = table.insert; function import(module, ...) local m = package.loaded[module] or require(module); -- cgit v1.2.3 From a2c0f6d6458193baa67e1df44a9c94fec357011b Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 22 Feb 2016 17:38:46 +0100 Subject: util.iterators: Localize unpack() in Lua 5.2 compatible way --- util/iterators.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'util') diff --git a/util/iterators.lua b/util/iterators.lua index aa9c3ec0..e688980b 100644 --- a/util/iterators.lua +++ b/util/iterators.lua @@ -11,7 +11,8 @@ local it = {}; local t_insert = table.insert; -local select, unpack, next = select, unpack, next; +local select, next = select, next; +local unpack = table.unpack or unpack; --luacheck: ignore 113 local function pack(...) return { n = select("#", ...), ... }; end -- Reverse an iterator -- cgit v1.2.3 From 29c6aed489216d03ecc070ee262d0943465441a7 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 22 Feb 2016 17:40:42 +0100 Subject: util.multitable: Localize unpack() in Lua 5.2 compatible way --- util/multitable.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'util') diff --git a/util/multitable.lua b/util/multitable.lua index 7a2d2b2a..e4321d3d 100644 --- a/util/multitable.lua +++ b/util/multitable.lua @@ -8,7 +8,8 @@ local select = select; local t_insert = table.insert; -local unpack, pairs, next, type = unpack, pairs, next, type; +local pairs, next, type = pairs, next, type; +local unpack = table.unpack or unpack; --luacheck: ignore 113 local _ENV = nil; -- cgit v1.2.3 From 11ebf4f1dc56644712e12e451e9b37c472c69238 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 22 Feb 2016 17:43:40 +0100 Subject: util.iterators: Use table.pack() on Lua 5.2 --- util/iterators.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util') diff --git a/util/iterators.lua b/util/iterators.lua index e688980b..868ba786 100644 --- a/util/iterators.lua +++ b/util/iterators.lua @@ -13,7 +13,7 @@ local it = {}; local t_insert = table.insert; local select, next = select, next; local unpack = table.unpack or unpack; --luacheck: ignore 113 -local function pack(...) return { n = select("#", ...), ... }; end +local pack = table.pack or function (...) return { n = select("#", ...), ... }; end -- Reverse an iterator function it.reverse(f, s, var) -- cgit v1.2.3 From ed8199402ff2a84e57f256818ebc2c505c2ac41d Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 22 Feb 2016 18:44:43 +0100 Subject: util.crand: C binding to one of OpenSSL, Linux getrandom() or OpenBSD arc4random() CSPRNG --- util/random.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'util') diff --git a/util/random.lua b/util/random.lua index e4b4a700..574e2e1c 100644 --- a/util/random.lua +++ b/util/random.lua @@ -6,6 +6,9 @@ -- COPYING file in the source package for more information. -- +local ok, crand = pcall(require, "util.crand"); +if ok then return crand; end + local urandom, urandom_err = io.open("/dev/urandom", "r"); local function seed() -- cgit v1.2.3