From 275f083a33402821f789d8f4ebaff75b796dc0c2 Mon Sep 17 00:00:00 2001 From: Dev & Sec Date: Mon, 2 Nov 2015 00:55:29 +0000 Subject: [PATCH] Use su if sudo is not available, this fixes #1148 --- letsencrypt-auto | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/letsencrypt-auto b/letsencrypt-auto index d163998aa..e14b099a9 100755 --- a/letsencrypt-auto +++ b/letsencrypt-auto @@ -14,7 +14,15 @@ VENV_PATH=${VENV_PATH:-"$XDG_DATA_HOME/$VENV_NAME"} VENV_BIN=${VENV_PATH}/bin if test "`id -u`" -ne "0" ; then - SUDO=sudo + if type sudo &>/dev/null; then + SUDO=sudo + else + args=("$@") + for i in "${!args[@]}"; do + args[$i]="'$(printf "%s" "${args[$i]}" | sed -e "s/'/'\"'\"'/g")' " + done + exec su root -c "$0 ${args[*]}" + fi else SUDO= fi