aboutsummarylogtreecommitdiffstats
path: root/fake-sudo.sh
diff options
context:
space:
mode:
Diffstat (limited to 'fake-sudo.sh')
-rwxr-xr-xfake-sudo.sh44
1 files changed, 44 insertions, 0 deletions
diff --git a/fake-sudo.sh b/fake-sudo.sh
new file mode 100755
index 000000000000..d17074c12ab6
--- /dev/null
+++ b/fake-sudo.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+# fake-sudo
+
+shell=""
+
+while [ $# -gt 0 ]; do
+ case "$1" in
+ --*=*)
+ # convert --a=b → --a b
+ a="${1%%=*}"; b="${1#*=}"
+ shift
+ set -- "$a" "$b" "$@"
+ ;;
+ -h|--help)
+ echo "usage: $0 [-u <user>] [<cmd> <arg>...]"
+ exit 0
+ ;;
+ -i|--login)
+ shell="/bin/sh -"
+ shift
+ ;;
+ -u|--user)
+ echo "$0: ignoring user=$1" >&2
+ shift 2
+ ;;
+ --)
+ shift
+ break
+ ;;
+ -*)
+ echo "$0: invalid option: $1" >&2
+ exit 1
+ ;;
+ *)
+ break
+ ;;
+ esac
+done
+
+if [ -n "$shell" ]
+then
+ set -- $shell "$@"
+fi
+exec unshare -r -- "$@"