aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docbook/wsluarm.asciidoc24
-rw-r--r--epan/wslua/init_wslua.c16
-rw-r--r--epan/wslua/template-init.lua6
-rw-r--r--test/lua/globals_2.2.txt2
-rw-r--r--tools/pre-commit-ignore.conf1
5 files changed, 31 insertions, 18 deletions
diff --git a/docbook/wsluarm.asciidoc b/docbook/wsluarm.asciidoc
index ab3c96bf88..7861a7d8c1 100644
--- a/docbook/wsluarm.asciidoc
+++ b/docbook/wsluarm.asciidoc
@@ -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.
-Wireshark’s 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`.
-
-After loading _init.lua_ from the data directory if Lua is enabled Wireshark
-will try to load a file named `init.lua` in the user’s directory.
-
-Wireshark will also load all files with `.lua` suffix from both the global and
-the personal plugins directory.
+Wireshark’s 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$$_.
+
+If Lua is enabled Wireshark will then try to load a file named _init.lua_
+in the user’s 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]]
diff --git a/epan/wslua/init_wslua.c b/epan/wslua/init_wslua.c
index 48a5c5e38e..caf05626cf 100644
--- a/epan/wslua/init_wslua.c
+++ b/epan/wslua/init_wslua.c
@@ -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);
diff --git a/epan/wslua/template-init.lua b/epan/wslua/template-init.lua
index 96888f83eb..9be7050fed 100644
--- a/epan/wslua/template-init.lua
+++ b/epan/wslua/template-init.lua
@@ -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
diff --git a/test/lua/globals_2.2.txt b/test/lua/globals_2.2.txt
index bde560a316..762e497238 100644
--- a/test/lua/globals_2.2.txt
+++ b/test/lua/globals_2.2.txt
@@ -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"] = {
diff --git a/tools/pre-commit-ignore.conf b/tools/pre-commit-ignore.conf
index d3f23ca057..7fd791662b 100644
--- a/tools/pre-commit-ignore.conf
+++ b/tools/pre-commit-ignore.conf
@@ -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