diff options
author | dylan.araps@gmail.com <dylan.araps@gmail.com> | 2020-01-29 12:28:36 +0000 |
---|---|---|
committer | dylan.araps@gmail.com <dylan.araps@gmail.com> | 2020-01-29 12:28:36 +0000 |
commit | 5dfb5281936d717164a33341fab7575c8b6e4b5b (patch) | |
tree | 82ba5d4b5d8db51b8c6e30cf885372b9afc072b4 /kiss | |
parent | b13665f2994dc1ffd653d986ae87174344eaed75 (diff) | |
download | cpt-5dfb5281936d717164a33341fab7575c8b6e4b5b.tar.gz |
kiss: use sudo if available
FossilOrigin-Name: ddd32854892c5d23a520d9f17fc11599b2e9895a927d606244e6130ae8c3fa69
Diffstat (limited to 'kiss')
-rwxr-xr-x | kiss | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -106,10 +106,16 @@ dosu() { # below. Great naming of functions all around. # # Run a command as root using the cached password. The 'su' - # command allows you to input a password via stdin. To hide - # the prompt, the command's output is sent to '/dev/tty' - # and the output of 'su' is sent to '/dev/null'. - dosudo() { su "${drop_to:-root}" -c "$* >/dev/tty" >/dev/null; } + # and 'sudo' commands allow you to input a password via stdin. + # To hide the prompt, the command's output is sent to '/dev/tty' + # and the output of 'su'/'sudo' is sent to '/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 # data over stdin based on what is available in the system. |