Commit 94cce8fc authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm-sh-functions: set_sudo: improve sudo checking

parent 4b2401e4
...@@ -384,10 +384,13 @@ set_sudo() ...@@ -384,10 +384,13 @@ set_sudo()
# if input is a console # if input is a console
if inputisatty && isatty && isatty2 ; then if inputisatty && isatty && isatty2 ; then
if ! $SUDO_CMD -n true ; then
info "Please enter sudo user password to use sudo in the current session."
if ! $SUDO_CMD -l >/dev/null ; then if ! $SUDO_CMD -l >/dev/null ; then
[ "$nofail" = "nofail" ] || SUDO="fatal 'Can't use sudo (only passwordless sudo is supported in non interactive using). Please run epm under root.'" [ "$nofail" = "nofail" ] || SUDO="fatal 'Can't use sudo (only passwordless sudo is supported in non interactive using). Please run epm under root.'"
return "$SUDO_TESTED" return "$SUDO_TESTED"
fi fi
fi
else else
# use sudo if one is tuned and tuned without password # use sudo if one is tuned and tuned without password
if ! $SUDO_CMD -l -n >/dev/null 2>/dev/null ; then if ! $SUDO_CMD -l -n >/dev/null 2>/dev/null ; then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment