1
0
mirror of https://codeberg.org/kiss-community/kiss synced 2024-11-04 14:05:41 -07:00

kiss: use sudo if available

This commit is contained in:
Dylan Araps 2020-01-29 14:28:37 +02:00
parent 96467c3ab0
commit a688055374
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E

14
kiss
View File

@ -106,10 +106,16 @@ dosu() {
# below. Great naming of functions all around. # below. Great naming of functions all around.
# #
# Run a command as root using the cached password. The 'su' # Run a command as root using the cached password. The 'su'
# command allows you to input a password via stdin. To hide # and 'sudo' commands allow you to input a password via stdin.
# the prompt, the command's output is sent to '/dev/tty' # To hide the prompt, the command's output is sent to '/dev/tty'
# and the output of 'su' is sent to '/dev/null'. # and the output of 'su'/'sudo' is sent to '/dev/null'.
dosudo() { su "${drop_to:-root}" -c "$* >/dev/tty" >/dev/null; } dosudo() {
if command -v sudo >/dev/null 2>&1; then
sudo -SEk -- su "${drop_to:-root}" -c "$* >/dev/tty" 2>/dev/null
else
su "${drop_to:-root}" -c "$* >/dev/tty" >/dev/null
fi
}
# The code below uses the most secure method of sending # The code below uses the most secure method of sending
# data over stdin based on what is available in the system. # data over stdin based on what is available in the system.