diff options
author | Jonas Smedegaard <dr@jones.dk> | 2016-10-21 23:07:49 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2016-10-21 23:07:49 +0200 |
commit | 521f599f0fc47d42c401f182e4bf9240ed300de7 (patch) | |
tree | 9d7b8a4e93b043674bd83b8d28406561bbba1c5a /xsh | |
parent | ac5b6f512db2027931028c16d0e00755f83947d0 (diff) |
Change option su to literally call su (replacing and dropping ill-named option -suu|suu, and rely on ssh syntax for direct-to-root access).
Diffstat (limited to 'xsh')
-rwxr-xr-x | xsh | 38 |
1 files changed, 14 insertions, 24 deletions
@@ -3,7 +3,7 @@ SCRIPT=$(basename $0) usage() { - echo "Usage: $SCRIPT [--x] [--verbose] [[--su] [{user}@]{host}] [--] [remote command...]" + echo "Usage: $SCRIPT [--x] [--verbose] [[su] [{user}@]{host}] [--] [remote command...]" } termwrapper() { @@ -28,16 +28,13 @@ termwrapper() { SU='' X='' V='' -SUHACK='' HOST='' ssh_opts="-t" args='' while [ $# -gt 0 ]; do case $1 in - -su|su) SU=1;; - # Become root indirectly through a regular user (same as local user if -u not used) - -suu|suu) SU=1; SUU=1;; + su) SU=1;; --x|-x|x) X=1; ssh_opts="$ssh_opts -X";; --ssh2|-2) ssh_opts="$ssh_opts -2";; --verbose|-v) V=1; ssh_opts="$ssh_opts -v";; @@ -46,7 +43,6 @@ while [ $# -gt 0 ]; do -) HOST="localhost";; --) shift; args="$args$@ "; break;; -*) usage; exit 1;; - root@*) HOST="$1"; SU=1; SUHACK=1;; *) args="$args$1 ";; esac shift @@ -70,11 +66,6 @@ if [ $# -gt 0 ]; then prg_opts=$@ fi -if [ "$X" = 1 -a "$SU" = 1 -a "$SUHACK" != 1 ]; then - args="root@$args" - SUHACK=1 -fi - if [ $HOST != "localhost" ]; then ssh_opts="-C $ssh_opts" fi @@ -102,20 +93,19 @@ fi prg="$prg_base $prg_opts" prg_su="echo -n 'Changing to root...: '; su -c \"cd; $prg\"" -if [ "$SU" != 1 ]; then - if [ $HOST = "localhost" ]; then - termwrapper $prg +case "$HOST" in + *@localhost|localhost) + if [ -n "$SU" ]; then + termwrapper $prg_su else - termwrapper ssh $ssh_opts $HOST $prg + termwrapper $prg fi -else - if [ "$SUHACK" = 1 ]; then - termwrapper ssh $ssh_opts $HOST $prg + ;; + *) + if [ -n "$SU" ]; then + termwrapper ssh $ssh_opts $HOST $prg_su else - if [ "$SUU" = 1 ]; then - termwrapper ssh $ssh_opts $HOST $prg_su - else - termwrapper ssh $ssh_opts root@$HOST $prg - fi + termwrapper ssh $ssh_opts $HOST $prg fi -fi + ;; +esac |