not running the letsencrypt-auto script as root, but use su if sudo not found

This commit is contained in:
Dev & Sec
2015-11-02 21:49:22 +00:00
parent 275f083a33
commit 8bad8de1c6
+5 -4
View File
@@ -14,15 +14,16 @@ VENV_PATH=${VENV_PATH:-"$XDG_DATA_HOME/$VENV_NAME"}
VENV_BIN=${VENV_PATH}/bin VENV_BIN=${VENV_PATH}/bin
if test "`id -u`" -ne "0" ; then if test "`id -u`" -ne "0" ; then
if type sudo &>/dev/null; then if ! type sudo &>/dev/null; then
SUDO=sudo function sudo (){
else
args=("$@") args=("$@")
for i in "${!args[@]}"; do for i in "${!args[@]}"; do
args[$i]="'$(printf "%s" "${args[$i]}" | sed -e "s/'/'\"'\"'/g")' " args[$i]="'$(printf "%s" "${args[$i]}" | sed -e "s/'/'\"'\"'/g")' "
done done
exec su root -c "$0 ${args[*]}" su root -c "${args[*]}"
}
fi fi
SUDO=sudo
else else
SUDO= SUDO=
fi fi