apparmor/tests/bin/actual-profile-of
Zygmunt Krynicki 23df780544 tests: add tool for observing the profile of a given command
Using gdb in batch mode, put a breakpoint on _start and spawn the
process.  Then using the built-in python interpreter print the
confinement label on the process and terminate everything.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2025-01-23 13:53:45 +01:00

9 lines
333 B
Bash
Executable file

#!/bin/sh
exec gdb \
--quiet \
--batch \
--eval-command='set breakpoint pending on' \
--eval-command='break _start' \
--eval-command='run' \
--eval-command='python import os; os.fdopen(3, "wt").write(open("/proc/{}/attr/current".format(gdb.selected_inferior().pid), "rt").read())' \
"$@" 3>/dev/stdout 1>/dev/null 2>/dev/null