landlock-lsm / landlock-test-tools

Landlock test tools
https://landlock.io
GNU General Public License v2.0
0 stars 1 forks source link

uml-init: remove host systemd dependency #13

Closed mtth-bfft closed 3 weeks ago

mtth-bfft commented 4 weeks ago

The current UML workflow depends on the host system init being systemd:

This dependency makes it complicated to run tests in a container, or on OSes with a different init system.

Replace the init with: /bin/bash /path/to/uml-init.sh <user-provided-commandline>

This only changes the commandline interface of uml-init.sh, not that of uml-run.sh. The only change required in the userspace setup is to mount /proc then link /dev/fd to /proc/self/fd/ for bash redirections to work.

There's just a little tweak to pass the commandline: a first -- is needed to tell the uml-run.sh script the split between {kernel+environment variables} and {usermode commandline}. Now a different -- is needed to tell the kernel the split between its argv[0] (/bin/bash) and argv[1..] (usermode commandline)

With this patch, dependencies are essentially bash + iproute2 (to set the loopback interface up in network tests), which makes it possible to run tests in a container environment without systemd.

mtth-bfft commented 4 weeks ago

This allows me to run tests in my setup more easily and frequently. Thought there might be a way to improve and merge this (very experimental) patch instead of keeping it locally 🤷

mtth-bfft commented 3 weeks ago

Hi Mickaël,

Yeeeep, was so focused on running the test suite more often that I forgot to look at this repo's history... 🤦 Usecase was broken and the toolchain does a great job as-is, no need to waste more time with this, sorry.