1 #!/bin/sh 2 # $OpenBSD: scp-ssh-wrapper.sh,v 1.3 2014/01/26 10:49:17 djm Exp $ 3 # Placed in the Public Domain. 4 5 printname () { 6 NAME=$1 7 save_IFS=$IFS 8 IFS=/ 9 set -- `echo "$NAME"` 10 IFS="$save_IFS" 11 while [ $# -ge 1 ] ; do 12 if [ "x$1" != "x" ]; then 13 echo "D0755 0 $1" 14 fi 15 shift; 16 done 17 } 18 19 # Discard all but last argument. We use arg later. 20 while test "x$1" != "x"; do 21 arg="$1" 22 shift 23 done 24 25 BAD="../../../../../../../../../../../../../${DIR}/dotpathdir" 26 27 case "$SCPTESTMODE" in 28 badserver_0) 29 echo "D0755 0 /${DIR}/rootpathdir" 30 echo "C755 2 rootpathfile" 31 echo "X" 32 ;; 33 badserver_1) 34 echo "D0755 0 $BAD" 35 echo "C755 2 file" 36 echo "X" 37 ;; 38 badserver_2) 39 echo "D0755 0 $BAD" 40 echo "C755 2 file" 41 echo "X" 42 ;; 43 badserver_3) 44 printname $BAD 45 echo "C755 2 file" 46 echo "X" 47 ;; 48 badserver_4) 49 printname $BAD 50 echo "D0755 0 .." 51 echo "C755 2 file" 52 echo "X" 53 ;; 54 *) 55 set -- $arg 56 shift 57 exec $SCP "$@" 58 ;; 59 esac 60