From cadc08047f521e0fda060fb259cb5c04d541561b Mon Sep 17 00:00:00 2001 From: batrick Date: Tue, 21 Jul 2009 22:21:48 +0000 Subject: [PATCH] [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). --- nse_main.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nse_main.lua b/nse_main.lua index d04c19d8c..3f83f2068 100644 --- a/nse_main.lua +++ b/nse_main.lua @@ -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