forked from skissane/mkjail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
addtojail
executable file
·31 lines (31 loc) · 1.19 KB
/
addtojail
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
#=============================================================================#
# SCRIPT: addtojail #
# PURPOSE: Adds executable to the chroot jail, including its dependent #
# libraries #
# AUTHOR: Simon Kissane #
# DATE: 6 December 2015 #
# LICENSE: Public Domain #
#=============================================================================#
function DerefSymLink() {
[ -L "$1" ] || { echo "$1"; return; }
local TARGET="$(readlink "$1")"
[ -n "$TARGET" ] || { echo "$1"; return; }
DerefSymLink "$TARGET"
}
RealExec="$(DerefSymLink "$0")"
RealExecDir="$(dirname "$RealExec")"
OriginalPWD="$(pwd -P)"
cd "$RealExecDir"
[ $# -ne 1 ] && {
echo "usage: $0 EXECUTABLE"
exit 1
}
[ -f "$1" ] || {
echo "ERROR: Not found: $1"
exit 1
}
ORIG="$(cat mkjail.files)"
NEW="$(./recurse $1)"
echo "$ORIG $NEW" | tr ' ' '\n' | egrep -v '^\s*$' | sort -u >mkjail.files
# vim:ts=4:sw=4:et:cc=80: