From 8bad8de1c673ee21f8cbdb7dcec1bc425586ba6d Mon Sep 17 00:00:00 2001 From: Dev & Sec Date: Mon, 2 Nov 2015 21:49:22 +0000 Subject: [PATCH] not running the letsencrypt-auto script as root, but use su if sudo not found --- letsencrypt-auto | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/letsencrypt-auto b/letsencrypt-auto index e14b099a9..514f03f46 100755 --- a/letsencrypt-auto +++ b/letsencrypt-auto @@ -14,15 +14,16 @@ VENV_PATH=${VENV_PATH:-"$XDG_DATA_HOME/$VENV_NAME"} VENV_BIN=${VENV_PATH}/bin if test "`id -u`" -ne "0" ; then - 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[*]}" + if ! type sudo &>/dev/null; then + function sudo (){ + args=("$@") + for i in "${!args[@]}"; do + args[$i]="'$(printf "%s" "${args[$i]}" | sed -e "s/'/'\"'\"'/g")' " + done + su root -c "${args[*]}" + } fi + SUDO=sudo else SUDO= fi