wok-current rev 14027

dropbear: add pppssh
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Feb 18 09:47:47 2013 +0100 (2013-02-18)
parents fdee667feb2c
children 4371e2f99088
files dropbear/receipt dropbear/stuff/sshx
line diff
     1.1 --- a/dropbear/receipt	Sun Feb 17 20:13:48 2013 +0100
     1.2 +++ b/dropbear/receipt	Mon Feb 18 09:47:47 2013 +0100
     1.3 @@ -72,6 +72,7 @@
     1.4  	cp -a $stuff/dropbear $fs/etc
     1.5  	cp -a $stuff/init.d $fs/etc
     1.6  	cp -a $stuff/sshx $fs/usr/bin
     1.7 +	ln -s sshx $fs/usr/bin/pppssh
     1.8  	touch $fs/etc/dropbear/dropbear_dss_host_key \
     1.9  		$fs/etc/dropbear/dropbear_rsa_host_key
    1.10  
     2.1 --- a/dropbear/stuff/sshx	Sun Feb 17 20:13:48 2013 +0100
     2.2 +++ b/dropbear/stuff/sshx	Mon Feb 18 09:47:47 2013 +0100
     2.3 @@ -2,27 +2,43 @@
     2.4  
     2.5  xdbclient()
     2.6  {
     2.7 -	read host type data
     2.8 -	svr=$(echo $DISPLAY | sed 's/.*:\([0-9]*\).*/\1/')
     2.9 -	scr=${DISPLAY/*./.}; [ "$scr" == "$DISPLAY" ] && scr=""
    2.10 +	read host data
    2.11 +	svr=${DISPLAY#*:}
    2.12  	n=$((10+($RANDOM % 90))); dpy=localhost:$n
    2.13 -	remote=""
    2.14 +	scr=${DISPLAY/${DISPLAY%.*}/$dpy}
    2.15 +	r=""
    2.16  	while true; do
    2.17 -		arg="$1"; shift
    2.18 -		remote="$remote $arg"
    2.19 -		case "$arg" in
    2.20 -		-[piIlLRWKBJ])	remote="$remote $1"; shift ;;
    2.21 +		a="$1"
    2.22 +		r="$r $1"; shift
    2.23 +		case "$a" in
    2.24 +		-[piIlLRWKBJ])	r="$r $1"; shift;;
    2.25  		-*)		;;
    2.26  		*)		break ;;
    2.27  		esac
    2.28  	done
    2.29 -	[ -n "$1" ] || set -- "$TERM || xterm"
    2.30 -	exec dbclient -f -R $((6000+$n)):localhost:$((6000+$svr)) $remote \
    2.31 -	    "xauth add $dpy $type $data; export DISPLAY=$dpy$scr; $@ ; xauth remove $dpy" \
    2.32 -	    < /dev/null > /dev/null
    2.33 +	[ -n "$1" ] || set -- "${TERM:-false} || xterm -ls"
    2.34 +	exec dbclient -f -R $((6000+$n)):localhost:$((6000+${svr%.*})) $r \
    2.35 +	   "xauth add $dpy $data; export DISPLAY=$scr; $@ ; xauth remove $dpy" \
    2.36 +	   </dev/null >/dev/null
    2.37  }
    2.38  
    2.39 -case "$DISPLAY" in
    2.40 -'')	exec dbclient "$@" ;;
    2.41 -*)	xauth list $DISPLAY | xdbclient "$@" ;;
    2.42 +pppssh()
    2.43 +{
    2.44 +	[ -z "$DROPBEAR_PASSWORD" ] && echo -n "ssh password: " &&
    2.45 +	read -s -t 30 DROPBEAR_PASSWORD && export DROPBEAR_PASSWORD
    2.46 +	dbclient -y $1 true || exit 1
    2.47 +	ff=/tmp/pppssh$$
    2.48 +	n=10.$(($$%256)).$(($$/256))
    2.49 +	ppp="/usr/sbin/pppd local lock notty"
    2.50 +	mkfifo $ff
    2.51 +	dbclient -y $1 "$ppp ${3:-proxyarp}" <$ff | $ppp ${2:-$n.1:$n.2} >$ff
    2.52 +	rm -f $ff
    2.53 +}
    2.54 +
    2.55 +case "$(basename $0)" in
    2.56 +ppp*)	[ -z "$1" ] &&
    2.57 +	echo "Usage: $0 '[sshargs] user@remote' '[localip:remoteip] [localpppargs]' 'remotepppargs'" ||
    2.58 +	pppssh "$@" ;;
    2.59 +*)	[ -z "$DISPLAY" ] && exec dbclient "$@"
    2.60 +	xauth list $DISPLAY | xdbclient "$@"
    2.61  esac