Browse Source

Simplify code

pull/2574/head
rewqazxv 5 years ago
parent
commit
79ad0ff56b
  1. 17
      acme.sh

17
acme.sh

@ -6362,18 +6362,11 @@ _checkSudo() {
#it's root using sudo, no matter it's using sudo or not, just fine
return 0
fi
case "$SUDO_COMMAND" in
*/su)
#it's a normal user doing `sudo su`, no problem
return 0
;;
esac
for i in $(cat /etc/shells); do
if [ "$SUDO_COMMAND" = "$i" ]; then
#it's a normal user running `sudo -i` or `sudo -s`, fine
return 0
fi
done
if [ -n "$SUDO_COMMAND" ]; then
#it's a normal user doing "sudo su", or `sudo -i` or `sudo -s`
_endswith "$SUDO_COMMAND" /bin/su || grep "^$SUDO_COMMAND\$" /etc/shells >/dev/null 2>&1
return $?
fi
#otherwise
return 1
fi

Loading…
Cancel
Save