ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-dev: Re: [Wireshark-dev] my purpose [for building with support for Lua in Linux (Ubun

From: Graham Bloice <graham.bloice@xxxxxxxxxxxxx>
Date: Sat, 22 May 2021 10:24:27 +0100
Some answers in-line

On Sat, 22 May 2021 at 04:03, Vincent Randal <vtrandal@xxxxxxxxx> wrote:
Hello everyone,

I've plans to use Lua to control tshark behavior in scripts, IF ... I can get Wireshark to build with support for Lua in Ubuntu 20.4, ... But so far I am not having any luck. I found this piece of documentation that says ...
"Wireshark contains an embedded Lua 5.2 interpreter ..."
I believe that's true for Windows but not Linux.

I have lots of questions:
1. Before running cmake how can I tell the appropriate "with-lua" sort of switch is enabled?

Look at CMakeOptions.txt, some options reset on a per-platform basis, but ENABLE_LUA defaults to ON.
 
2. After running cmake how can I tell I got what I wanted i.e. that it found Lua and make will build with support for Lua?

The CMake output will output the packages that were found.  Missing mandatory dependencies will cause CMake generation to fail.  Lua isn't a required dependency.

From a random MR Ubuntu build pipeline: 

-- Checking for one of the modules 'lua5.2;lua-5.2;lua52;lua5.1;lua-5.1;lua51'
-- Found LUA: /usr/lib/x86_64-linux-gnu/liblua5.2.so (found suitable version "502", minimum required is "5.1") 
 
3. If it does not find Lua how do I fix that?

Provide the required Lua packages in a location that CMake will search.  In the source tools directory there is a bash script (debian-setup.sh) that will install the required packages for Wireshark on a Debian based system.  See the Developer's Guide section on Unix Installation and Build Instructions:

 
4. When the build succeeds how do I compensate for the difference sudo and non-sudo seem to have on tshark? Non-sudo invokation runs my lua scripts. Sudo invocations don't.

I'm not sure on Linux, but I suspect that the different users will have different personal configuration file locations.  How are you invoking the Lua script?

Note that it's highly recommended to NOT run wireshark\tshark as root due to potential security issues.  To allow full use as non-root on Debian based systems see https://gitlab.com/wireshark/wireshark/-/blob/master/debian/README.Debian.
 
5. And assuming (with some help) I get past the above issues, how much control can lua scripts expert over tshark and Wireshark?

The Lua script capabilities are built around the API exposed by the Lua support, which is mainly intended to handle dissection, post-dissection tapping and some GUI facilities.  See the Developers Guide section on Lua support:



Regarding the last question above, the June,2021 InterOp/Plugfests for IEEE 1451.0 are too soon for me to implement the 1451.0 network services (on embedded hardware or in virtual machines). But thank goodness for the lack of time, because it's got me asking how I might call tshark (or Wireshark) in scripts that behave to some degree as though its a real deployment.

By the way, I do not represent the IEEE. I got involved in the IEEE 1451.0 working group because my college advisor (John Schmalzel, currently with Rowan University) from 30 years suggested it to me.

Also, Richard Sharpe has been tremendously helpful as I've struggled to learn enough about ASN.1 to get my dissectors generated and working. XDR and Thrift look like better alternatives to ASN.1 if I had more time to try those things. Thank you, Richard!

Vincent



--
Graham Bloice