wok-next rev 11597

dropbear/sshx: allow arguments
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Jan 13 22:30:26 2012 +0100 (2012-01-13)
parents 5ee7ba5d5f57
children bdff68e2cdc7
files dropbear/stuff/sshx
line diff
     1.1 --- a/dropbear/stuff/sshx	Fri Jan 13 12:27:55 2012 +0100
     1.2 +++ b/dropbear/stuff/sshx	Fri Jan 13 22:30:26 2012 +0100
     1.3 @@ -4,13 +4,24 @@
     1.4  {
     1.5  	read host type data
     1.6  	svr=$(echo $DISPLAY | sed 's/.*:\([0-9]*\).*/\1/')
     1.7 -	n=$((10+$svr)); dpy=localhost:$n
     1.8 -	dbclient -f -R $((6000+$n)):localhost:$((6000+$svr)) "$@" \
     1.9 -	    "xauth add $dpy $type $data; export DISPLAY=$dpy; $TERM || xterm" \
    1.10 +	n=$((10+($RANDOM % 90))); dpy=localhost:$n
    1.11 +	remote=""
    1.12 +	while true; do
    1.13 +		arg="$1"; shift
    1.14 +		remote="$remote $arg"
    1.15 +		case "$arg" in
    1.16 +		-[piIlLRWKBJ])	remote="$remote $1"; shift ;;
    1.17 +		-*)		;;
    1.18 +		*)		break ;;
    1.19 +		esac
    1.20 +	done
    1.21 +	[ -n "$1" ] || set -- "$TERM || xterm"
    1.22 +	exec dbclient -f -R $((6000+$n)):localhost:$((6000+$svr)) $remote \
    1.23 +	    "xauth add $dpy $type $data; export DISPLAY=$dpy; $@" \
    1.24  	    < /dev/null > /dev/null 2>&1
    1.25  }
    1.26  
    1.27  case "$DISPLAY" in
    1.28 -'')	dbclient "$@" ;;
    1.29 +'')	exec dbclient "$@" ;;
    1.30  *)	xauth list $DISPLAY | xdbclient "$@" ;;
    1.31  esac