Lua: Switch from disable_lua to enable_lua.

Deprecate "disable_lua" in favor of "enable_lua". Configuration options
typically use "true" or a similar value to enable features. Using
"disable_lua = false" to enable Lua seems odd.

Change-Id: I224acad0559d409ea0a28b5555d1eb898564328c
Reviewed-on: https://code.wireshark.org/review/28773
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Gerald Combs 2018-07-19 15:06:07 -07:00 committed by Anders Broman
parent 381ea0973f
commit 61dd06ed9f
5 changed files with 30 additions and 17 deletions

View File

@ -20,21 +20,23 @@ the Department of Computer Science.
In Wireshark Lua can be used to write dissectors, taps, and capture file readers
and writers.
Wiresharks Lua interpreter starts by loading `init.lua` that is located in the
global configuration directory of Wireshark. Lua is enabled by default. To
disable Lua the line variable _$$disable_lua$$_ should be set to _true_ in
`init.lua`.
Wiresharks Lua interpreter starts by loading a file named `init.lua` in
Wireshark's global configuration directory. It is enabled by default. To
disable Lua the line variable _$$enable_lua$$_ should be set to _false_
in _init.lua_. Wireshark 2.6 and earlier enabled and disabled Lua using
the variable _$$disable_lua$$_. It is still supported, but is deprecated
and support may be removed in a future release. _$$enable_lua$$_ takes
precedence over _$$disable_lua$$_.
After loading _init.lua_ from the data directory if Lua is enabled Wireshark
will try to load a file named `init.lua` in the users directory.
Wireshark will also load all files with `.lua` suffix from both the global and
the personal plugins directory.
If Lua is enabled Wireshark will then try to load a file named _init.lua_
in the users personal configuration directory. Wireshark will also load
all files with a _.lua_ suffix from both the global and the personal
plugins directory.
The command line option _$$-X lua_script:$$++file.lua++_ can be used to load
Lua scripts as well.
The Lua code will be executed once after all the protocol dissectors have being
The Lua code will be executed once after all the protocol dissectors have been
initialized and before reading any file.
[[wslua_dissector_example]]

View File

@ -767,6 +767,7 @@ wslua_allocf(void *ud _U_, void *ptr, size_t osize _U_, size_t nsize)
void wslua_init(register_cb cb, gpointer client_data) {
gchar* filename;
const funnel_ops_t* ops = funnel_get_funnel_ops();
gboolean enable_lua = TRUE;
gboolean run_anyway = FALSE;
expert_module_t* expert_lua;
int file_count = 1;
@ -923,16 +924,25 @@ void wslua_init(register_cb cb, gpointer client_data) {
filename = NULL;
/* check if lua is to be disabled */
lua_getglobal(L,"disable_lua");
lua_getglobal(L, "disable_lua"); // 2.6 and earlier, deprecated
if (lua_isboolean(L,-1)) {
enable_lua = ! lua_toboolean(L,-1);
}
lua_pop(L,1); /* pop the getglobal result */
if (lua_isboolean(L,-1) && lua_toboolean(L,-1)) {
lua_getglobal(L, "enable_lua"); // 3.0 and later
if (lua_isboolean(L,-1)) {
enable_lua = lua_toboolean(L,-1);
}
lua_pop(L,1); /* pop the getglobal result */
if (!enable_lua) {
/* disable lua */
lua_close(L);
L = NULL;
first_time = FALSE;
return;
}
lua_pop(L,1); /* pop the getglobal result */
/* load global scripts */
lua_load_global_plugins(cb, client_data, FALSE);

View File

@ -11,10 +11,10 @@
--
-- SPDX-License-Identifier: GPL-2.0-or-later
-- Set disable_lua to true to disable Lua support.
disable_lua = false
-- Set enable_lua to false to disable Lua support.
enable_lua = true
if disable_lua then
if not enable_lua then
return
end

View File

@ -720,8 +720,8 @@
["datafile_path"] = '<function 33>',
["debug"] = '<function 381>',
["deregister_filehandler"] = '<function 382>',
["disable_lua"] = false,
["dofile"] = '<function 383>',
["enable_lua"] = true,
["error"] = '<function 384>',
["expert"] = {
["group"] = {

View File

@ -15,6 +15,7 @@ epan/dissectors/asn1/*/*asn
epan/nghttp2/*
epan/wmem/wmem_strbuf.c
epan/wmem/wmem_strutil.c
epan/wslua/init_wslua.c
extcap/*
image/stock_icons/*
mmdbresolve.c