]> andersk Git - openssh.git/blame - regress/scp.sh
- djm@cvs.openbsd.org 2006/01/27 06:49:21
[openssh.git] / regress / scp.sh
CommitLineData
452613c1 1# $OpenBSD: scp.sh,v 1.5 2006/01/27 06:49:21 djm 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
452613c1 31verbose "$tid: simple copy local file to local file"
32scpclean
33$SCP $scpopts ${DATA} ${COPY} || fail "copy failed"
34cmp ${DATA} ${COPY} || fail "corrupted copy"
35
53e2a65c 36verbose "$tid: simple copy local file to remote file"
37scpclean
38$SCP $scpopts ${DATA} somehost:${COPY} || fail "copy failed"
39cmp ${DATA} ${COPY} || fail "corrupted copy"
40
41verbose "$tid: simple copy remote file to local file"
42scpclean
43$SCP $scpopts somehost:${DATA} ${COPY} || fail "copy failed"
44cmp ${DATA} ${COPY} || fail "corrupted copy"
45
46verbose "$tid: simple copy local file to remote dir"
47scpclean
48cp ${DATA} ${COPY}
49$SCP $scpopts ${COPY} somehost:${DIR} || fail "copy failed"
50cmp ${COPY} ${DIR}/copy || fail "corrupted copy"
51
452613c1 52verbose "$tid: simple copy local file to local dir"
53scpclean
54cp ${DATA} ${COPY}
55$SCP $scpopts ${COPY} ${DIR} || fail "copy failed"
56cmp ${COPY} ${DIR}/copy || fail "corrupted copy"
57
53e2a65c 58verbose "$tid: simple copy remote file to local dir"
59scpclean
60cp ${DATA} ${COPY}
61$SCP $scpopts somehost:${COPY} ${DIR} || fail "copy failed"
62cmp ${COPY} ${DIR}/copy || fail "corrupted copy"
63
64verbose "$tid: recursive local dir to remote dir"
65scpclean
6d89f486 66rm -rf ${DIR2}
53e2a65c 67cp ${DATA} ${DIR}/copy
68$SCP $scpopts -r ${DIR} somehost:${DIR2} || fail "copy failed"
502f32cd 69diff ${DIFFOPT} ${DIR} ${DIR2} || fail "corrupted copy"
53e2a65c 70
452613c1 71verbose "$tid: recursive local dir to local dir"
72scpclean
73rm -rf ${DIR2}
74cp ${DATA} ${DIR}/copy
75$SCP $scpopts -r ${DIR} ${DIR2} || fail "copy failed"
76diff ${DIFFOPT} ${DIR} ${DIR2} || fail "corrupted copy"
77
53e2a65c 78verbose "$tid: recursive remote dir to local dir"
79scpclean
6d89f486 80rm -rf ${DIR2}
53e2a65c 81cp ${DATA} ${DIR}/copy
82$SCP $scpopts -r somehost:${DIR} ${DIR2} || fail "copy failed"
502f32cd 83diff ${DIFFOPT} ${DIR} ${DIR2} || fail "corrupted copy"
53e2a65c 84
642c4a6f 85if [ ! -z "$SUDO" ]; then
86 verbose "$tid: skipped file after scp -p with failed chown+utimes"
87 scpclean
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
89deb4c2 94 $SUDO diff ${DIFFOPT} ${DIR} ${DIR2} || fail "corrupted copy"
642c4a6f 95 $SUDO rm ${DIR2}/copy
96fi
97
53e2a65c 98for i in 0 1 2 3 4; do
99 verbose "$tid: disallow bad server #$i"
100 SCPTESTMODE=badserver_$i
101 export DIR SCPTESTMODE
102 scpclean
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"
106
107 scpclean
108 $SCP -r $scpopts somehost:${DATA} ${DIR2} >/dev/null 2>/dev/null
109 [ -d ${DIR}/dotpathdir ] && fail "allows dir creation outside of subdir"
110done
111
112scpclean
1f29cb36 113rm -f ${OBJ}/scp-ssh-wrapper.scp
This page took 0.097456 seconds and 5 git commands to generate.