aboutsummarylogtreecommitdiffstats
path: root/fake-su.sh
diff options
context:
space:
mode:
Diffstat (limited to 'fake-su.sh')
-rwxr-xr-xfake-su.sh40
1 files changed, 40 insertions, 0 deletions
diff --git a/fake-su.sh b/fake-su.sh
new file mode 100755
index 000000000000..dfa57878d29d
--- /dev/null
+++ b/fake-su.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+# fake-su
+
+cmd=""
+shell="/bin/sh"
+
+while [ $# -gt 0 ]; do
+ case "$1" in
+ -h|--help)
+ echo "usage: $0 [-l] [-] [<user> [<arg>...]]"
+ exit 0
+ ;;
+ -|-l|--login)
+ shell="$shell -"; shift
+ ;;
+ -c|--command)
+ cmd="$2"; shift 2
+ ;;
+ --)
+ shift
+ break
+ ;;
+ -*)
+ echo "$0: invalid option: $1" >&2
+ exit 1
+ ;;
+ *)
+ echo "$0: ignoring user=$1" >&2
+ shift
+ break
+ ;;
+ esac
+done
+
+if [ -z "$cmd" ]
+then
+ exec unshare -r -- "$shell" "$@"
+else
+ exec unshare -r -- "$shell" -c "$cmd" "$@"
+fi