aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xcontrib/gdb-firejail.sh21
1 files changed, 21 insertions, 0 deletions
diff --git a/contrib/gdb-firejail.sh b/contrib/gdb-firejail.sh
new file mode 100755
index 000000000..3ee3fffb3
--- /dev/null
+++ b/contrib/gdb-firejail.sh
@@ -0,0 +1,21 @@
1#!/bin/bash
2set -x
3
4# gdb setuid helper script.
5# This script forks a background process as the current user which will
6# immediately send itself a `STOP` signal. Then gdb running as root will
7# attach to that process, which will send it the `CONT` signal to continue
8# execution. Then the backgrounded process will exec the program with the
9# given arguments. This will allow the root gdb to trace the unprivileged
10# setuid firejail process from the absolute beginning.
11
12if [ -z "${1##*/firejail}" ]; then
13 FIREJAIL=$1
14else
15 # First argument is not named firejail, then add default unless environment
16 # variable already set.
17 set -- ${FIREJAIL:=$(which firejail)} "$@"
18fi
19
20bash -c "kill -STOP \$\$; exec \"\$0\" \"\$@\"" "$@" &
21sudo gdb -e "$FIREJAIL" -p "$!" \ No newline at end of file