aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/gdb-firejail.sh
diff options
context:
space:
mode:
authorLibravatar Glenn Washburn <development@efficientek.com>2019-07-09 16:41:34 -0500
committerLibravatar Glenn Washburn <development@efficientek.com>2019-07-09 16:41:34 -0500
commit5e09cfb4f901d944c0418fcb041d4e96448028a2 (patch)
treea2d128dc02a152741dbb9561d2051e42d5860959 /contrib/gdb-firejail.sh
parentSort private-bin in obs.profile (#2848) (diff)
downloadfirejail-5e09cfb4f901d944c0418fcb041d4e96448028a2.tar.gz
firejail-5e09cfb4f901d944c0418fcb041d4e96448028a2.tar.zst
firejail-5e09cfb4f901d944c0418fcb041d4e96448028a2.zip
Add gdb-firejail.sh to contrib for easy debugging of firejail with gdb.
Diffstat (limited to 'contrib/gdb-firejail.sh')
-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