diff --git a/ncat/ncat_lua.c b/ncat/ncat_lua.c index 56895cadb..d7816c08a 100644 --- a/ncat/ncat_lua.c +++ b/ncat/ncat_lua.c @@ -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); } diff --git a/ncat/ncat_lua.h b/ncat/ncat_lua.h index 7404b6b8c..0cc038976 100644 --- a/ncat/ncat_lua.h +++ b/ncat/ncat_lua.h @@ -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 diff --git a/ncat/ncat_main.c b/ncat/ncat_main.c index 6ba38312a..1e6bd1ffc 100644 --- a/ncat/ncat_main.c +++ b/ncat/ncat_main.c @@ -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)