]> andersk Git - openssh.git/blame - regress/scp.sh
- (dtucker) [regress/scp.sh] Use portable-friendly $DIFFOPTs in new test.
[openssh.git] / regress / scp.sh
CommitLineData
642c4a6f 1# $OpenBSD: scp.sh,v 1.3 2004/07/08 12:59:35 dtucker Exp $
53e2a65c 2# Placed in the Public Domain.
3
4tid="scp"
5
6#set -x
7
502f32cd 8# Figure out if diff understands "-N"
9if diff -N ${SRC}/scp.sh ${SRC}/scp.sh 2>/dev/null; then
10 DIFFOPT="-rN"
11else
12 DIFFOPT="-r"
13fi
14
1f29cb36 15DATA=/bin/ls${EXEEXT}
53e2a65c 16COPY=${OBJ}/copy
17COPY2=${OBJ}/copy2
18DIR=${COPY}.dd
19DIR2=${COPY}.dd2
20
21SRC=`dirname ${SCRIPT}`
1f29cb36 22cp ${SRC}/scp-ssh-wrapper.sh ${OBJ}/scp-ssh-wrapper.scp
23chmod 755 ${OBJ}/scp-ssh-wrapper.scp
24scpopts="-q -S ${OBJ}/scp-ssh-wrapper.scp"
53e2a65c 25
26scpclean() {
27 rm -rf ${COPY} ${COPY2} ${DIR} ${DIR2}
28 mkdir ${DIR} ${DIR2}
29}
30
31verbose "$tid: simple copy local file to remote file"
32scpclean
33$SCP $scpopts ${DATA} somehost:${COPY} || fail "copy failed"
34cmp ${DATA} ${COPY} || fail "corrupted copy"
35
36verbose "$tid: simple copy remote file to local file"
37scpclean
38$SCP $scpopts somehost:${DATA} ${COPY} || fail "copy failed"
39cmp ${DATA} ${COPY} || fail "corrupted copy"
40
41verbose "$tid: simple copy local file to remote dir"
42scpclean
43cp ${DATA} ${COPY}
44$SCP $scpopts ${COPY} somehost:${DIR} || fail "copy failed"
45cmp ${COPY} ${DIR}/copy || fail "corrupted copy"
46
47verbose "$tid: simple copy remote file to local dir"
48scpclean
49cp ${DATA} ${COPY}
50$SCP $scpopts somehost:${COPY} ${DIR} || fail "copy failed"
51cmp ${COPY} ${DIR}/copy || fail "corrupted copy"
52
53verbose "$tid: recursive local dir to remote dir"
54scpclean
6d89f486 55rm -rf ${DIR2}
53e2a65c 56cp ${DATA} ${DIR}/copy
57$SCP $scpopts -r ${DIR} somehost:${DIR2} || fail "copy failed"
502f32cd 58diff ${DIFFOPT} ${DIR} ${DIR2} || fail "corrupted copy"
53e2a65c 59
60verbose "$tid: recursive remote dir to local dir"
61scpclean
6d89f486 62rm -rf ${DIR2}
53e2a65c 63cp ${DATA} ${DIR}/copy
64$SCP $scpopts -r somehost:${DIR} ${DIR2} || fail "copy failed"
502f32cd 65diff ${DIFFOPT} ${DIR} ${DIR2} || fail "corrupted copy"
53e2a65c 66
642c4a6f 67if [ ! -z "$SUDO" ]; then
68 verbose "$tid: skipped file after scp -p with failed chown+utimes"
69 scpclean
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
03543667 76 diff ${DIFFOPT} ${DIR} ${DIR2} || fail "corrupted copy"
642c4a6f 77 $SUDO rm ${DIR2}/copy
78fi
79
53e2a65c 80for i in 0 1 2 3 4; do
81 verbose "$tid: disallow bad server #$i"
82 SCPTESTMODE=badserver_$i
83 export DIR SCPTESTMODE
84 scpclean
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"
88
89 scpclean
90 $SCP -r $scpopts somehost:${DATA} ${DIR2} >/dev/null 2>/dev/null
91 [ -d ${DIR}/dotpathdir ] && fail "allows dir creation outside of subdir"
92done
93
94scpclean
1f29cb36 95rm -f ${OBJ}/scp-ssh-wrapper.scp
This page took 0.184844 seconds and 5 git commands to generate.