1 # $OpenBSD: sftp-badcmds.sh,v 1.2 2003/05/15 04:07:12 mouring Exp $
2 # Placed in the Public Domain.
4 tid
="sftp invalid commands"
10 GLOBFILES
=`(cd /bin;echo l*)`
12 rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.
dd
15 verbose
"$tid: get nonexistent"
16 echo "get $NONEXIST $COPY" |
${SFTP} -P ${SFTPSERVER} >/dev
/null
2>&1 \
17 || fail
"get nonexistent failed"
18 test -f ${COPY} && fail
"existing copy after get nonexistent"
21 verbose
"$tid: glob get to nonexistent directory"
22 echo "get /bin/l* $NONEXIST" |
${SFTP} -P ${SFTPSERVER} >/dev
/null
2>&1 \
23 || fail
"get nonexistent failed"
24 for x
in $GLOBFILES; do
25 test -f ${COPY}.dd
/$x && fail
"existing copy after get nonexistent"
29 verbose
"$tid: put nonexistent"
30 echo "put $NONEXIST $COPY" |
${SFTP} -P ${SFTPSERVER} >/dev
/null
2>&1 \
31 || fail
"put nonexistent failed"
32 test -f ${COPY} && fail
"existing copy after put nonexistent"
35 verbose
"$tid: glob put to nonexistent directory"
36 echo "put /bin/l* ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \
37 || fail "put nonexistent failed
"
38 for x in $GLOBFILES; do
39 test -f ${COPY}.dd/$x && fail "existing copy after nonexistent
"
43 verbose "$tid: rename nonexistent
"
44 echo "rename
$NONEXIST ${COPY}.1" | ${SFTP} -P ${SFTPSERVER} >/dev
/null
2>&1 \
45 || fail
"rename nonexist failed"
46 test -f ${COPY}.1 && fail
"file exists after rename nonexistent"
48 rm -f ${COPY} ${COPY}.1
51 verbose
"$tid: rename target exists"
52 echo "rename $COPY ${COPY}.1" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \
53 || fail "rename target exists failed
"
54 test -f ${COPY} || fail "oldname missing after rename target exists
"
55 test -f ${COPY}.1 || fail "newname missing after rename target exists
"
56 cmp $DATA ${COPY} >/dev/null 2>&1 || fail "corrupted oldname after rename target exists
"
57 cmp $DATA2 ${COPY}.1 >/dev/null 2>&1 || fail "corrupted newname after rename target exists
"
59 rm -rf ${COPY} ${COPY}.dd
62 verbose "$tid: rename target exists
(directory
)"
63 echo "rename
$COPY ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev
/null
2>&1 \
64 || fail
"rename target exists (directory) failed"
65 test -f ${COPY} || fail
"oldname missing after rename target exists (directory)"
66 test -d ${COPY}.
dd || fail
"newname missing after rename target exists (directory)"
67 cmp $DATA ${COPY} >/dev
/null
2>&1 || fail
"corrupted oldname after rename target exists (directory)"
72 verbose
"$tid: glob put files to local file"
73 echo "put /bin/l* $COPY" |
${SFTP} -P ${SFTPSERVER} >/dev
/null
2>&1
74 cmp ${DATA2} ${COPY} || fail
"put successed when it should have failed"
76 rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.
dd