Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 29 Dec 2024 12:26:59 +0100
From:      Matthias Petermann <matthias@d2ux.net>
To:        FreeBSD questions <freebsd-questions@freebsd.org>
Subject:   Using the jail Module with (Base-)Lua on FreeBSD
Message-ID:  <1de29b99-b23d-4aad-9bbd-2b9df298008b@d2ux.net>

next in thread | raw e-mail | index | archive | help
Dear FreeBSD Community,

I am currently working on a FreeBSD system where I am managing multiple 
Jails using Bastille. Here's a snapshot of the active Jails for context:

```
user@microserver:~ $ jls
    JID  IP Address      Hostname                      Path
      1  10.0.0.1        dns /usr/local/bastille/jails/dns/root
      2  10.0.0.10       redmine /usr/local/bastille/jails/redmine/root
      ... (truncated for brevity) ...
     63  10.0.0.18       webproxy /usr/local/bastille/jails/webproxy/root
```

I attempted to use the jail module with Lua (via /usr/libexec/flua), but 
I encountered issues when trying to load or interact with it. Below are 
the steps and results:

```
user@microserver:~ $ /usr/libexec/flua
Lua 5.4.6  Copyright (C) 1994-2023 Lua.org, PUC-Rio
> package.cpath
/usr/lib/flua/?.so;/usr/lib/flua/loadall.so;./?.so
> local jail = require("jail")
> print(jail)
nil
> jail.list()
stdin:1: attempt to index a nil value (global 'jail')
stack traceback:
         stdin:1: in main chunk
         [C]: in ?
> local path = package.searchpath("jail", package.path)
> print(path)
nil
> local path = package.searchpath("jail", package.cpath)
> print(path)
nil
```

It seems that the jail module is not accessible through Lua’s require() 
function, and package.searchpath doesn't locate it either in 
package.path or package.cpath.

Questions:

- Is the jail module supposed to be available by default in 
/usr/libexec/flua?
- If not, what are the steps to install or enable it?
- Are there any specific dependencies or configurations needed for Lua 
to interact with the jail subsystem on FreeBSD?

I’d appreciate any guidance, as I am trying to leverage Lua scripting 
for automating jail management tasks.

Thank you in advance for your time and help!

Best regards
Matthias



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1de29b99-b23d-4aad-9bbd-2b9df298008b>