1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-15 12:19:02 +00:00

[NSE] Add the filename and runlevel globals to scripts when loaded via

Script.new. Because of the new strict.lua library being added, scripts
would look for the absent filename global at load-time and fail due to an
error (ssh-hostkey.nse).
This commit is contained in:
batrick
2009-07-21 22:21:48 +00:00
parent 80c7b8af1b
commit cadc08047f

View File

@@ -262,7 +262,10 @@ do
end
local file_closure = assert(loadfile(filename));
-- Give the closure its own environment, with global access
local env = setmetatable({}, {__index = _G});
local env = setmetatable({
filename = filename,
runlevel = 1,
}, {__index = _G});
setfenv(file_closure, env);
local co = create(file_closure); -- Create a garbage thread
assert(resume(co)); -- Get the globals it loads in env