mirror of
https://github.com/nmap/nmap.git
synced 2026-11-20 08:40:36 +08:00
Exert more control over NSE library search path
This commit is contained in:
@@ -957,6 +957,13 @@ void open_nse (void)
|
||||
lua_atpanic(L_NSE, panic);
|
||||
lua_settop(L_NSE, 0);
|
||||
|
||||
/* Do not allow environment variables to override the module search path.
|
||||
* We do this here instead of in init_main to ensure we control all
|
||||
* standard library loads as well.
|
||||
*/
|
||||
lua_pushboolean(L_NSE, 1);
|
||||
lua_setfield(L_NSE, LUA_REGISTRYINDEX, "LUA_NOENV");
|
||||
|
||||
lua_pushcfunction(L_NSE, nseU_traceback);
|
||||
lua_pushcfunction(L_NSE, init_main);
|
||||
lua_pushlightuserdata(L_NSE, &o.chosenScripts);
|
||||
|
||||
+5
-1
@@ -144,7 +144,11 @@ do -- Add loader to look in nselib/?.lua (nselib/ can be in multiple places)
|
||||
return "\n\tNSE failed to find "..name.." in search paths.";
|
||||
end
|
||||
end
|
||||
insert(package.searchers, 1, loader);
|
||||
-- Replace all file-path searchers with our fetchfile searcher
|
||||
package.searchers = {
|
||||
package.searchers[1], -- Original preload searcher
|
||||
loader, -- Our fetchfile searcher
|
||||
}
|
||||
end
|
||||
|
||||
local lpeg = require "lpeg";
|
||||
|
||||
Reference in New Issue
Block a user