mirror of
https://github.com/nmap/nmap.git
synced 2026-08-04 06:40:48 +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:
parent
80c7b8af1b
commit
cadc08047f
1 changed files with 4 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue