From ebb99399899de2b0859ab5e926c95a10eb2291a6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Fri, 11 Nov 2016 15:19:27 +0100 Subject: [PATCH] lua sandbox: export the list of original names That will allow us to discover the top-level symbols for completion. For others we can e.g.: for n in pairs(net) do print(n); end I must admit I fail to understand some of the related lua magic. --- daemon/lua/sandbox.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/daemon/lua/sandbox.lua b/daemon/lua/sandbox.lua index 4a5b3cb6d..743dfaa0e 100644 --- a/daemon/lua/sandbox.lua +++ b/daemon/lua/sandbox.lua @@ -160,7 +160,14 @@ end -- Make sandboxed environment local function make_sandbox(defined) local __protected = { modules = true, cache = true, net = true, trust_anchors = true } - return setmetatable({}, { + + -- Compute and export the list of top-level names (hidden otherwise) + local nl = "" + for n in pairs(defined) do + nl = nl .. n .. "\n" + end + + return setmetatable({ __orig_name_list = nl }, { __index = defined, __newindex = function (t, k, v) if __protected[k] then -- 2.47.3