summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--regress/sftp-cmds.sh47
-rw-r--r--regress/sftp-glob.sh69
-rw-r--r--regress/test-exec.sh17
4 files changed, 105 insertions, 34 deletions
diff --git a/ChangeLog b/ChangeLog
index 83ee8b648..c20d611b5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -69,6 +69,10 @@
69 [regress/cipher-speed.sh regress/try-ciphers.sh] 69 [regress/cipher-speed.sh regress/try-ciphers.sh]
70 test umac-64@openssh.com 70 test umac-64@openssh.com
71 ok djm@ 71 ok djm@
72 - djm@cvs.openbsd.org 2007/10/24 03:32:35
73 [regress/sftp-cmds.sh regress/sftp-glob.sh regress/test-exec.sh]
74 comprehensive tests for sftp escaping its interaction with globbing;
75 ok dtucker@
72 76
7320070927 7720070927
74 - (dtucker) [configure.ac atomicio.c] Fall back to including <sys/poll.h> if 78 - (dtucker) [configure.ac atomicio.c] Fall back to including <sys/poll.h> if
@@ -3340,4 +3344,4 @@
3340 OpenServer 6 and add osr5bigcrypt support so when someone migrates 3344 OpenServer 6 and add osr5bigcrypt support so when someone migrates
3341 passwords between UnixWare and OpenServer they will still work. OK dtucker@ 3345 passwords between UnixWare and OpenServer they will still work. OK dtucker@
3342 3346
3343$Id: ChangeLog,v 1.4775 2007/10/26 04:45:57 djm Exp $ 3347$Id: ChangeLog,v 1.4776 2007/10/26 04:54:12 djm Exp $
diff --git a/regress/sftp-cmds.sh b/regress/sftp-cmds.sh
index 78416735d..5625c5b26 100644
--- a/regress/sftp-cmds.sh
+++ b/regress/sftp-cmds.sh
@@ -1,4 +1,4 @@
1# $OpenBSD: sftp-cmds.sh,v 1.7 2006/08/29 09:44:00 djm Exp $ 1# $OpenBSD: sftp-cmds.sh,v 1.8 2007/10/24 03:32:35 djm Exp $
2# Placed in the Public Domain. 2# Placed in the Public Domain.
3 3
4# XXX - TODO: 4# XXX - TODO:
@@ -34,6 +34,11 @@ fi
34# Path with embedded quote 34# Path with embedded quote
35QUOTECOPY=${COPY}".\"blah\"" 35QUOTECOPY=${COPY}".\"blah\""
36QUOTECOPY_ARG=${COPY}'.\"blah\"' 36QUOTECOPY_ARG=${COPY}'.\"blah\"'
37# File with spaces
38SPACECOPY="${COPY} this has spaces.txt"
39SPACECOPY_ARG="${COPY}\ this\ has\ spaces.txt"
40# File with glob metacharacters
41GLOBMETACOPY="${COPY} [metachar].txt"
37 42
38rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.dd ${COPY}.dd2 43rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.dd ${COPY}.dd2
39mkdir ${COPY}.dd 44mkdir ${COPY}.dd
@@ -89,12 +94,27 @@ if [ "$os" != "cygwin" ]; then
89rm -f ${QUOTECOPY} 94rm -f ${QUOTECOPY}
90cp $DATA ${QUOTECOPY} 95cp $DATA ${QUOTECOPY}
91verbose "$tid: get filename with quotes" 96verbose "$tid: get filename with quotes"
92echo "get \"$QUOTECOPY_ARG\" ${COPY}" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ 97echo "get \"$QUOTECOPY_ARG\" ${COPY}" | \
93 || fail "put failed" 98 ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ || fail "get failed"
94cmp ${COPY} ${QUOTECOPY} || fail "corrupted copy after get with quotes" 99cmp ${COPY} ${QUOTECOPY} || fail "corrupted copy after get with quotes"
95rm -f ${QUOTECOPY} ${COPY} 100rm -f ${QUOTECOPY} ${COPY}
96fi 101fi
97 102
103rm -f "$SPACECOPY" ${COPY}
104cp $DATA "$SPACECOPY"
105verbose "$tid: get filename with spaces"
106echo "get ${SPACECOPY_ARG} ${COPY}" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \
107 || fail "get failed"
108cmp ${COPY} "$SPACECOPY" || fail "corrupted copy after get with spaces"
109
110rm -f "$GLOBMETACOPY" ${COPY}
111cp $DATA "$GLOBMETACOPY"
112verbose "$tid: get filename with glob metacharacters"
113echo "get \"${GLOBMETACOPY}\" ${COPY}" | \
114 ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 || fail "get failed"
115cmp ${COPY} "$GLOBMETACOPY" || \
116 fail "corrupted copy after get with glob metacharacters"
117
98rm -f ${COPY}.dd/* 118rm -f ${COPY}.dd/*
99verbose "$tid: get to directory" 119verbose "$tid: get to directory"
100echo "get $DATA ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ 120echo "get $DATA ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \
@@ -125,18 +145,24 @@ done
125 145
126rm -f ${COPY} 146rm -f ${COPY}
127verbose "$tid: put" 147verbose "$tid: put"
128echo "put $DATA $COPY" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ 148echo "put $DATA $COPY" | \
129 || fail "put failed" 149 ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 || fail "put failed"
130cmp $DATA ${COPY} || fail "corrupted copy after put" 150cmp $DATA ${COPY} || fail "corrupted copy after put"
131 151
132if [ "$os" != "cygwin" ]; then 152if [ "$os" != "cygwin" ]; then
133rm -f ${QUOTECOPY} 153rm -f ${QUOTECOPY}
134verbose "$tid: put filename with quotes" 154verbose "$tid: put filename with quotes"
135echo "put $DATA \"$QUOTECOPY_ARG\"" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ 155echo "put $DATA \"$QUOTECOPY_ARG\"" | \
136 || fail "put failed" 156 ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 || fail "put failed"
137cmp $DATA ${QUOTECOPY} || fail "corrupted copy after put with quotes" 157cmp $DATA ${QUOTECOPY} || fail "corrupted copy after put with quotes"
138fi 158fi
139 159
160rm -f "$SPACECOPY"
161verbose "$tid: put filename with spaces"
162echo "put $DATA ${SPACECOPY_ARG}" | \
163 ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 || fail "put failed"
164cmp $DATA "$SPACECOPY" || fail "corrupted copy after put with spaces"
165
140rm -f ${COPY}.dd/* 166rm -f ${COPY}.dd/*
141verbose "$tid: put to directory" 167verbose "$tid: put to directory"
142echo "put $DATA ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ 168echo "put $DATA ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \
@@ -172,8 +198,9 @@ test -f ${COPY}.1 || fail "missing file after rename"
172cmp $DATA ${COPY}.1 >/dev/null 2>&1 || fail "corrupted copy after rename" 198cmp $DATA ${COPY}.1 >/dev/null 2>&1 || fail "corrupted copy after rename"
173 199
174verbose "$tid: rename directory" 200verbose "$tid: rename directory"
175echo "rename ${COPY}.dd ${COPY}.dd2" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ 201echo "rename ${COPY}.dd ${COPY}.dd2" | \
176 || fail "rename directory failed" 202 ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 || \
203 fail "rename directory failed"
177test -d ${COPY}.dd && fail "oldname exists after rename directory" 204test -d ${COPY}.dd && fail "oldname exists after rename directory"
178test -d ${COPY}.dd2 || fail "missing newname after rename directory" 205test -d ${COPY}.dd2 || fail "missing newname after rename directory"
179 206
@@ -207,5 +234,5 @@ echo "lchdir ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \
207 || fail "lchdir failed" 234 || fail "lchdir failed"
208 235
209rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.dd ${COPY}.dd2 236rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.dd ${COPY}.dd2
210rm -rf ${QUOTECOPY} 237rm -rf ${QUOTECOPY} "$SPACECOPY" "$GLOBMETACOPY"
211 238
diff --git a/regress/sftp-glob.sh b/regress/sftp-glob.sh
index e238356a2..d5ebf9fd6 100644
--- a/regress/sftp-glob.sh
+++ b/regress/sftp-glob.sh
@@ -1,28 +1,65 @@
1# $OpenBSD: sftp-glob.sh,v 1.1 2004/12/10 01:31:30 fgsch Exp $ 1# $OpenBSD: sftp-glob.sh,v 1.2 2007/10/24 03:32:35 djm Exp $
2# Placed in the Public Domain. 2# Placed in the Public Domain.
3 3
4tid="sftp glob" 4tid="sftp glob"
5 5
6sftp_ls() {
7 target=$1
8 errtag=$2
9 expected=$3
10 unexpected=$4
11 verbose "$tid: $errtag"
12 $ECHOE "ls -l ${target}" | \
13 ${SFTP} -b - -P ${SFTPSERVER} 2>/dev/null | \
14 grep -v "^sftp>" > ${RESULTS}
15 if [ $? -ne 0 ]; then
16 fail "$errtag failed"
17 fi
18 if test "x$expected" != "x" && \
19 ! fgrep "$expected" ${RESULTS} >/dev/null 2>&1 ; then
20 fail "$expected missing from $errtag results"
21 fi
22 if test "x$unexpected" != "x" && \
23 fgrep "$unexpected" ${RESULTS} >/dev/null 2>&1 ; then
24 fail "$unexpected present in $errtag results"
25 fi
26 rm -f ${RESULTS}
27}
28
6BASE=${OBJ}/glob 29BASE=${OBJ}/glob
30RESULTS=${OBJ}/results
7DIR=${BASE}/dir 31DIR=${BASE}/dir
8DATA=${DIR}/file 32DATA=${DIR}/file
9 33
34GLOB1="${DIR}/g-wild*"
35GLOB2="${DIR}/g-wildx"
36QUOTE="${DIR}/g-quote\""
37SLASH="${DIR}/g-sl\\ash"
38ESLASH="${DIR}/g-slash\\"
39QSLASH="${DIR}/g-qs\\\""
40SPACE="${DIR}/g-q space"
41
10rm -rf ${BASE} 42rm -rf ${BASE}
11mkdir -p ${DIR} 43mkdir -p ${DIR}
12touch ${DATA} 44touch "${DATA}" "${GLOB1}" "${GLOB2}" "${QUOTE}"
13 45touch "${QSLASH}" "${ESLASH}" "${SLASH}" "${SPACE}"
14verbose "$tid: ls file" 46
15echo "ls -l ${DIR}/fil*" | ${SFTP} -P ${SFTPSERVER} 2>/dev/null | \ 47# target message expected unexpected
16 grep ${DATA} >/dev/null 2>&1 48sftp_ls "${DIR}/fil*" "file glob" "${DATA}" ""
17if [ $? -ne 0 ]; then 49sftp_ls "${BASE}/d*" "dir glob" "`basename ${DATA}`" ""
18 fail "globbed ls file failed" 50sftp_ls "${DIR}/g-wild\"*\"" "quoted glob" "g-wild*" "g-wildx"
19fi 51sftp_ls "${DIR}/g-wild\*" "escaped glob" "g-wild*" "g-wildx"
20 52sftp_ls "${DIR}/g-quote\\\"" "escaped quote" "g-quote\"" ""
21verbose "$tid: ls dir" 53sftp_ls "\"${DIR}/g-quote\\\"\"" "quoted quote" "g-quote\"" ""
22echo "ls -l ${BASE}/d*" | ${SFTP} -P ${SFTPSERVER} 2>/dev/null | \ 54sftp_ls "'${DIR}/g-quote\"'" "single-quoted quote" "g-quote\"" ""
23 grep file >/dev/null 2>&1 55sftp_ls "${DIR}/g-sl\\\\ash" "escaped slash" "g-sl\\ash" ""
24if [ $? -ne 0 ]; then 56sftp_ls "'${DIR}/g-sl\\\\ash'" "quoted slash" "g-sl\\ash" ""
25 fail "globbed ls dir failed" 57sftp_ls "${DIR}/g-slash\\\\" "escaped slash at EOL" "g-slash\\" ""
26fi 58sftp_ls "'${DIR}/g-slash\\\\'" "quoted slash at EOL" "g-slash\\" ""
59sftp_ls "${DIR}/g-qs\\\\\\\"" "escaped slash+quote" "g-qs\\\"" ""
60sftp_ls "'${DIR}/g-qs\\\\\"'" "quoted slash+quote" "g-qs\\\"" ""
61sftp_ls "${DIR}/g-q\\ space" "escaped space" "g-q space" ""
62sftp_ls "'${DIR}/g-q space'" "quoted space" "g-q space" ""
27 63
28rm -rf ${BASE} 64rm -rf ${BASE}
65
diff --git a/regress/test-exec.sh b/regress/test-exec.sh
index 59ae33c08..650be419e 100644
--- a/regress/test-exec.sh
+++ b/regress/test-exec.sh
@@ -30,6 +30,9 @@ else
30 USER=`id -un` 30 USER=`id -un`
31fi 31fi
32 32
33# XXX platforms that don't support -E may need a replacement
34ECHOE="echo -E"
35
33OBJ=$1 36OBJ=$1
34if [ "x$OBJ" = "x" ]; then 37if [ "x$OBJ" = "x" ]; then
35 echo '$OBJ not defined' 38 echo '$OBJ not defined'
@@ -156,31 +159,31 @@ cleanup ()
156 159
157trace () 160trace ()
158{ 161{
159 echo "trace: $@" >>$TEST_SSH_LOGFILE 162 $ECHOE "trace: $@" >>$TEST_SSH_LOGFILE
160 if [ "X$TEST_SSH_TRACE" = "Xyes" ]; then 163 if [ "X$TEST_SSH_TRACE" = "Xyes" ]; then
161 echo "$@" 164 $ECHOE "$@"
162 fi 165 fi
163} 166}
164 167
165verbose () 168verbose ()
166{ 169{
167 echo "verbose: $@" >>$TEST_SSH_LOGFILE 170 $ECHOE "verbose: $@" >>$TEST_SSH_LOGFILE
168 if [ "X$TEST_SSH_QUIET" != "Xyes" ]; then 171 if [ "X$TEST_SSH_QUIET" != "Xyes" ]; then
169 echo "$@" 172 $ECHOE "$@"
170 fi 173 fi
171} 174}
172 175
173 176
174fail () 177fail ()
175{ 178{
176 echo "FAIL: $@" >>$TEST_SSH_LOGFILE 179 $ECHOE "FAIL: $@" >>$TEST_SSH_LOGFILE
177 RESULT=1 180 RESULT=1
178 echo "$@" 181 $ECHOE "$@"
179} 182}
180 183
181fatal () 184fatal ()
182{ 185{
183 echo "FATAL: $@" >>$TEST_SSH_LOGFILE 186 $ECHOE "FATAL: $@" >>$TEST_SSH_LOGFILE
184 echon "FATAL: " 187 echon "FATAL: "
185 fail "$@" 188 fail "$@"
186 cleanup 189 cleanup