mirror of
https://github.com/nmap/nmap.git
synced 2026-01-20 05:09:02 +00:00
Don't use global o.cmdexec in lua_setup.
Pass the name of the file to read as a parameter.
This commit is contained in:
@@ -148,16 +148,16 @@ static int traceback (lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
lua_State *lua_setup(void)
|
||||
lua_State *lua_setup(const char *filename)
|
||||
{
|
||||
lua_State *L;
|
||||
|
||||
ncat_assert(o.cmdexec != NULL);
|
||||
ncat_assert(filename != NULL);
|
||||
|
||||
L = luaL_newstate();
|
||||
luaL_openlibs(L);
|
||||
|
||||
if (luaL_loadfile(L, o.cmdexec) != 0)
|
||||
if (luaL_loadfile(L, filename) != 0)
|
||||
report(L, "Error loading the Lua script");
|
||||
|
||||
return L;
|
||||
@@ -173,7 +173,7 @@ void lua_run(lua_State *L)
|
||||
report(L, "Error running the Lua script");
|
||||
} else {
|
||||
if (o.debug)
|
||||
logdebug("%s returned successfully.\n", o.cmdexec);
|
||||
logdebug("Lua script returned successfully.\n");
|
||||
lua_close(L);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ extern "C" {
|
||||
}
|
||||
#endif
|
||||
|
||||
lua_State *lua_setup(void);
|
||||
lua_State *lua_setup(const char *filename);
|
||||
void lua_run(lua_State *L);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -545,8 +545,7 @@ int main(int argc, char *argv[])
|
||||
perror("Cannot set mode");
|
||||
#endif
|
||||
ncat_assert(argc == 3);
|
||||
o.cmdexec = argv[2];
|
||||
L = lua_setup();
|
||||
L = lua_setup(argv[2]);
|
||||
ncat_assert(L != NULL);
|
||||
lua_run(L);
|
||||
}
|
||||
@@ -872,7 +871,7 @@ connection brokering should work.");
|
||||
|
||||
#ifdef HAVE_LUA
|
||||
if (o.execmode == EXEC_LUA)
|
||||
o.lua_exec_state = lua_setup();
|
||||
o.lua_exec_state = lua_setup(o.cmdexec);
|
||||
#endif
|
||||
|
||||
if (o.listen)
|
||||
|
||||
Reference in New Issue
Block a user