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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user