scp.sh revision 1.2
1# $OpenBSD: scp.sh,v 1.2 2004/06/16 13:15:09 dtucker Exp $ 2# Placed in the Public Domain. 3 4tid="scp" 5 6#set -x 7 8DATA=/bin/ls 9COPY=${OBJ}/copy 10COPY2=${OBJ}/copy2 11DIR=${COPY}.dd 12DIR2=${COPY}.dd2 13 14SRC=`dirname ${SCRIPT}` 15cp ${SRC}/scp-ssh-wrapper.sh ${OBJ}/scp-ssh-wrapper.exe 16chmod 755 ${OBJ}/scp-ssh-wrapper.exe 17scpopts="-q -S ${OBJ}/scp-ssh-wrapper.exe" 18 19scpclean() { 20 rm -rf ${COPY} ${COPY2} ${DIR} ${DIR2} 21 mkdir ${DIR} ${DIR2} 22} 23 24verbose "$tid: simple copy local file to remote file" 25scpclean 26$SCP $scpopts ${DATA} somehost:${COPY} || fail "copy failed" 27cmp ${DATA} ${COPY} || fail "corrupted copy" 28 29verbose "$tid: simple copy remote file to local file" 30scpclean 31$SCP $scpopts somehost:${DATA} ${COPY} || fail "copy failed" 32cmp ${DATA} ${COPY} || fail "corrupted copy" 33 34verbose "$tid: simple copy local file to remote dir" 35scpclean 36cp ${DATA} ${COPY} 37$SCP $scpopts ${COPY} somehost:${DIR} || fail "copy failed" 38cmp ${COPY} ${DIR}/copy || fail "corrupted copy" 39 40verbose "$tid: simple copy remote file to local dir" 41scpclean 42cp ${DATA} ${COPY} 43$SCP $scpopts somehost:${COPY} ${DIR} || fail "copy failed" 44cmp ${COPY} ${DIR}/copy || fail "corrupted copy" 45 46verbose "$tid: recursive local dir to remote dir" 47scpclean 48rm -rf ${DIR2} 49cp ${DATA} ${DIR}/copy 50$SCP $scpopts -r ${DIR} somehost:${DIR2} || fail "copy failed" 51diff -rN ${DIR} ${DIR2} || fail "corrupted copy" 52 53verbose "$tid: recursive remote dir to local dir" 54scpclean 55rm -rf ${DIR2} 56cp ${DATA} ${DIR}/copy 57$SCP $scpopts -r somehost:${DIR} ${DIR2} || fail "copy failed" 58diff -rN ${DIR} ${DIR2} || fail "corrupted copy" 59 60for i in 0 1 2 3 4; do 61 verbose "$tid: disallow bad server #$i" 62 SCPTESTMODE=badserver_$i 63 export DIR SCPTESTMODE 64 scpclean 65 $SCP $scpopts somehost:${DATA} ${DIR} >/dev/null 2>/dev/null 66 [ -d {$DIR}/rootpathdir ] && fail "allows dir relative to root dir" 67 [ -d ${DIR}/dotpathdir ] && fail "allows dir creation in non-recursive mode" 68 69 scpclean 70 $SCP -r $scpopts somehost:${DATA} ${DIR2} >/dev/null 2>/dev/null 71 [ -d ${DIR}/dotpathdir ] && fail "allows dir creation outside of subdir" 72done 73 74scpclean 75rm -f ${OBJ}/scp-ssh-wrapper.exe 76