diff --git a/nse_main.cc b/nse_main.cc index 8f58d7b45..dd8fb2177 100644 --- a/nse_main.cc +++ b/nse_main.cc @@ -759,6 +759,13 @@ void open_nse (void) */ srand(get_random_uint()); + const lua_Number *version = lua_version(NULL); + double major = (*version) / 100.0; + double minor = fmod(*version, 10.0); + if (o.debugging >= 1) + log_write(LOG_STDOUT, "%s: Using Lua %.0f.%.0f.\n", SCRIPT_ENGINE, major, minor); + if (*version < 502) + fatal("%s: This version of NSE only works with Lua 5.2 or greater.", SCRIPT_ENGINE); if ((L_NSE = luaL_newstate()) == NULL) fatal("%s: failed to open a Lua state!", SCRIPT_ENGINE); lua_atpanic(L_NSE, panic); diff --git a/nse_main.lua b/nse_main.lua index 7488733da..fb695c241 100644 --- a/nse_main.lua +++ b/nse_main.lua @@ -30,6 +30,12 @@ -- cause the system to stall through improper use. -- - Of course the os and io library can cause the system to also break. +local _VERSION = _VERSION; +local MAJOR, MINOR = assert(_VERSION:match "^Lua (%d+).(%d+)$"); +if tonumber(MAJOR.."."..MINOR) < 5.2 then + error "NSE requires Lua 5.2 or newer. It looks like you're using an older version of nmap." +end + local NAME = "NSE"; -- Script Scan phases.