1 # $OpenBSD: scp.sh,v 1.3 2004/07/08 12:59:35 dtucker Exp $
2 # Placed in the Public Domain.
8 # Figure out if diff understands "-N"
9 if diff -N ${SRC}/scp.sh ${SRC}/scp.sh 2>/dev/null; then
21 SRC=`dirname ${SCRIPT}`
22 cp ${SRC}/scp-ssh-wrapper.sh ${OBJ}/scp-ssh-wrapper.scp
23 chmod 755 ${OBJ}/scp-ssh-wrapper.scp
24 scpopts="-q -S ${OBJ}/scp-ssh-wrapper.scp"
27 rm -rf ${COPY} ${COPY2} ${DIR} ${DIR2}
31 verbose "$tid: simple copy local file to remote file"
33 $SCP $scpopts ${DATA} somehost:${COPY} || fail "copy failed"
34 cmp ${DATA} ${COPY} || fail "corrupted copy"
36 verbose "$tid: simple copy remote file to local file"
38 $SCP $scpopts somehost:${DATA} ${COPY} || fail "copy failed"
39 cmp ${DATA} ${COPY} || fail "corrupted copy"
41 verbose "$tid: simple copy local file to remote dir"
44 $SCP $scpopts ${COPY} somehost:${DIR} || fail "copy failed"
45 cmp ${COPY} ${DIR}/copy || fail "corrupted copy"
47 verbose "$tid: simple copy remote file to local dir"
50 $SCP $scpopts somehost:${COPY} ${DIR} || fail "copy failed"
51 cmp ${COPY} ${DIR}/copy || fail "corrupted copy"
53 verbose "$tid: recursive local dir to remote dir"
56 cp ${DATA} ${DIR}/copy
57 $SCP $scpopts -r ${DIR} somehost:${DIR2} || fail "copy failed"
58 diff ${DIFFOPT} ${DIR} ${DIR2} || fail "corrupted copy"
60 verbose "$tid: recursive remote dir to local dir"
63 cp ${DATA} ${DIR}/copy
64 $SCP $scpopts -r somehost:${DIR} ${DIR2} || fail "copy failed"
65 diff ${DIFFOPT} ${DIR} ${DIR2} || fail "corrupted copy"
67 if [ ! -z "$SUDO" ]; then
68 verbose "$tid: skipped file after scp -p with failed chown+utimes"
70 cp -p ${DATA} ${DIR}/copy
71 cp -p ${DATA} ${DIR}/copy2
72 cp ${DATA} ${DIR2}/copy
73 chmod 660 ${DIR2}/copy
74 $SUDO chown root ${DIR2}/copy
75 $SCP -p $scpopts somehost:${DIR}/\* ${DIR2} >/dev/null 2>&1
76 diff ${DIFFOPT} ${DIR} ${DIR2} || fail "corrupted copy"
80 for i in 0 1 2 3 4; do
81 verbose "$tid: disallow bad server #$i"
82 SCPTESTMODE=badserver_$i
83 export DIR SCPTESTMODE
85 $SCP $scpopts somehost:${DATA} ${DIR} >/dev/null 2>/dev/null
86 [ -d {$DIR}/rootpathdir ] && fail "allows dir relative to root dir"
87 [ -d ${DIR}/dotpathdir ] && fail "allows dir creation in non-recursive mode"
90 $SCP -r $scpopts somehost:${DATA} ${DIR2} >/dev/null 2>/dev/null
91 [ -d ${DIR}/dotpathdir ] && fail "allows dir creation outside of subdir"
95 rm -f ${OBJ}/scp-ssh-wrapper.scp