1 # $OpenBSD: scp.sh,v 1.5 2006/01/27 06:49:21 djm 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 local file"
33 $SCP $scpopts ${DATA} ${COPY} || fail "copy failed"
34 cmp ${DATA} ${COPY} || fail "corrupted copy"
36 verbose "$tid: simple copy local file to remote file"
38 $SCP $scpopts ${DATA} somehost:${COPY} || fail "copy failed"
39 cmp ${DATA} ${COPY} || fail "corrupted copy"
41 verbose "$tid: simple copy remote file to local file"
43 $SCP $scpopts somehost:${DATA} ${COPY} || fail "copy failed"
44 cmp ${DATA} ${COPY} || fail "corrupted copy"
46 verbose "$tid: simple copy local file to remote dir"
49 $SCP $scpopts ${COPY} somehost:${DIR} || fail "copy failed"
50 cmp ${COPY} ${DIR}/copy || fail "corrupted copy"
52 verbose "$tid: simple copy local file to local dir"
55 $SCP $scpopts ${COPY} ${DIR} || fail "copy failed"
56 cmp ${COPY} ${DIR}/copy || fail "corrupted copy"
58 verbose "$tid: simple copy remote file to local dir"
61 $SCP $scpopts somehost:${COPY} ${DIR} || fail "copy failed"
62 cmp ${COPY} ${DIR}/copy || fail "corrupted copy"
64 verbose "$tid: recursive local dir to remote dir"
67 cp ${DATA} ${DIR}/copy
68 $SCP $scpopts -r ${DIR} somehost:${DIR2} || fail "copy failed"
69 diff ${DIFFOPT} ${DIR} ${DIR2} || fail "corrupted copy"
71 verbose "$tid: recursive local dir to local dir"
74 cp ${DATA} ${DIR}/copy
75 $SCP $scpopts -r ${DIR} ${DIR2} || fail "copy failed"
76 diff ${DIFFOPT} ${DIR} ${DIR2} || fail "corrupted copy"
78 verbose "$tid: recursive remote dir to local dir"
81 cp ${DATA} ${DIR}/copy
82 $SCP $scpopts -r somehost:${DIR} ${DIR2} || fail "copy failed"
83 diff ${DIFFOPT} ${DIR} ${DIR2} || fail "corrupted copy"
85 if [ ! -z "$SUDO" ]; then
86 verbose "$tid: skipped file after scp -p with failed chown+utimes"
88 cp -p ${DATA} ${DIR}/copy
89 cp -p ${DATA} ${DIR}/copy2
90 cp ${DATA} ${DIR2}/copy
91 chmod 660 ${DIR2}/copy
92 $SUDO chown root ${DIR2}/copy
93 $SCP -p $scpopts somehost:${DIR}/\* ${DIR2} >/dev/null 2>&1
94 $SUDO diff ${DIFFOPT} ${DIR} ${DIR2} || fail "corrupted copy"
98 for i in 0 1 2 3 4; do
99 verbose "$tid: disallow bad server #$i"
100 SCPTESTMODE=badserver_$i
101 export DIR SCPTESTMODE
103 $SCP $scpopts somehost:${DATA} ${DIR} >/dev/null 2>/dev/null
104 [ -d {$DIR}/rootpathdir ] && fail "allows dir relative to root dir"
105 [ -d ${DIR}/dotpathdir ] && fail "allows dir creation in non-recursive mode"
108 $SCP -r $scpopts somehost:${DATA} ${DIR2} >/dev/null 2>/dev/null
109 [ -d ${DIR}/dotpathdir ] && fail "allows dir creation outside of subdir"
113 rm -f ${OBJ}/scp-ssh-wrapper.scp