diff --git a/nse_main.lua b/nse_main.lua index b135bc8a3..62530add8 100644 --- a/nse_main.lua +++ b/nse_main.lua @@ -117,10 +117,17 @@ local nmap = require "nmap"; local cnse, rules = ...; -- The NSE C library and Script Rules -do -- Append the nselib directory to the Lua search path - local t, path = assert(cnse.fetchfile_absolute("nselib/")); - assert(t == "directory", "could not locate nselib directory!"); - package.path = path.."?.lua;"..package.path; +do -- Add loader to look in nselib/?.lua (nselib/ can be in multiple places) + local function loader (lib) + local name = "nselib/"..lib..".lua"; + local type, path = cnse.fetchfile_absolute(name); + if type == "file" then + return loadfile(path); + else + return "\n\tNSE failed to find "..name.." in search paths."; + end + end + insert(package.loaders, loader); end local script_database_type, script_database_path =