aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/syscalls.sh
diff options
context:
space:
mode:
authorLibravatar curiosity-seeker <my-github@mailbox.org>2019-06-14 12:49:21 +0200
committerLibravatar Vincent43 <31109921+Vincent43@users.noreply.github.com>2019-06-14 10:49:21 +0000
commitcedf414da537cc308f4e5a909266ad2555ecfb86 (patch)
treeebdd6a760bda376bbe44a444c97b4eaf4be86f75 /contrib/syscalls.sh
parentNew profiles: newsbeuter, keepassxc-{cli,proxy} (diff)
downloadfirejail-cedf414da537cc308f4e5a909266ad2555ecfb86.tar.gz
firejail-cedf414da537cc308f4e5a909266ad2555ecfb86.tar.zst
firejail-cedf414da537cc308f4e5a909266ad2555ecfb86.zip
Create syscalls file (#2754)
* Create syscalls file A little script to determine the necessary syscalls for a program.
Diffstat (limited to 'contrib/syscalls.sh')
-rw-r--r--contrib/syscalls.sh30
1 files changed, 30 insertions, 0 deletions
diff --git a/contrib/syscalls.sh b/contrib/syscalls.sh
new file mode 100644
index 000000000..9ab6acf5b
--- /dev/null
+++ b/contrib/syscalls.sh
@@ -0,0 +1,30 @@
1#!/bin/bash
2
3STRACE_OUTPUT_FILE="$(pwd)/strace_output.txt"
4SYSCALLS_OUTPUT_FILE="$(pwd)/syscalls.txt"
5
6if [ $# -eq 0 ]
7then
8echo
9echo " *** No program specified!!! ***"
10echo
11echo -e "Make this file executable and execute it as:\\n"
12echo -e "\\e[96m syscalls.sh /full/path/to/program\\n"
13echo -e "\\e[39mif you saved this script in a directory in your PATH (e.g., in ${HOME}/bin), otherwise as:\\n"
14echo -e "\\e[96m ./syscalls.sh /full/path/to/program\\n"
15echo -e "\\e[39mUse the full path to the respective program to avoid executing it sandboxed with Firejail\\n(if a Firejail profile for it already exits and 'sudo firecfg' was executed earlier)\\nin order to determine the necessary system calls."
16echo
17exit 0
18
19else
20
21strace -cfo "$STRACE_OUTPUT_FILE" "$@" && awk '{print $NF}' "$STRACE_OUTPUT_FILE" | sed '/syscall\|-\|total/d' | sort -u | awk -vORS=, '{ print $1 }' | sed 's/,$/\n/' > "$SYSCALLS_OUTPUT_FILE"
22echo
23echo -e "\e[39mThese are the sorted syscalls:\n\e[93m"
24cat "$SYSCALLS_OUTPUT_FILE"
25echo
26echo -e "\e[39mThe sorted syscalls were saved to:\n\n\e[96m$SYSCALLS_OUTPUT_FILE"
27echo
28exit 0
29
30fi