]>
Commit | Line | Data |
---|---|---|
6c8ebe98 | 1 | # $OpenBSD: sftp-badcmds.sh,v 1.4 2009/08/13 01:11:55 djm Exp $ |
1d6c0b69 | 2 | # Placed in the Public Domain. |
3 | ||
4 | tid="sftp invalid commands" | |
5 | ||
83d96134 | 6 | DATA=/bin/ls${EXEEXT} |
006cb311 | 7 | DATA2=/bin/sh${EXEEXT} |
1d6c0b69 | 8 | NONEXIST=/NONEXIST.$$ |
9 | COPY=${OBJ}/copy | |
10 | GLOBFILES=`(cd /bin;echo l*)` | |
11 | ||
2b1bb684 | 12 | rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.dd |
1d6c0b69 | 13 | |
14 | rm -f ${COPY} | |
15 | verbose "$tid: get nonexistent" | |
6c8ebe98 | 16 | echo "get $NONEXIST $COPY" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
1d6c0b69 | 17 | || fail "get nonexistent failed" |
18 | test -f ${COPY} && fail "existing copy after get nonexistent" | |
19 | ||
20 | rm -f ${COPY}.dd/* | |
21 | verbose "$tid: glob get to nonexistent directory" | |
6c8ebe98 | 22 | echo "get /bin/l* $NONEXIST" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
1d6c0b69 | 23 | || fail "get nonexistent failed" |
24 | for x in $GLOBFILES; do | |
25 | test -f ${COPY}.dd/$x && fail "existing copy after get nonexistent" | |
26 | done | |
27 | ||
28 | rm -f ${COPY} | |
29 | verbose "$tid: put nonexistent" | |
6c8ebe98 | 30 | echo "put $NONEXIST $COPY" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
1d6c0b69 | 31 | || fail "put nonexistent failed" |
32 | test -f ${COPY} && fail "existing copy after put nonexistent" | |
33 | ||
34 | rm -f ${COPY}.dd/* | |
35 | verbose "$tid: glob put to nonexistent directory" | |
6c8ebe98 | 36 | echo "put /bin/l* ${COPY}.dd" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
1d6c0b69 | 37 | || fail "put nonexistent failed" |
38 | for x in $GLOBFILES; do | |
39 | test -f ${COPY}.dd/$x && fail "existing copy after nonexistent" | |
40 | done | |
41 | ||
42 | rm -f ${COPY} | |
43 | verbose "$tid: rename nonexistent" | |
6c8ebe98 | 44 | echo "rename $NONEXIST ${COPY}.1" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
1d6c0b69 | 45 | || fail "rename nonexist failed" |
46 | test -f ${COPY}.1 && fail "file exists after rename nonexistent" | |
47 | ||
1d6c0b69 | 48 | rm -rf ${COPY} ${COPY}.dd |
49 | cp $DATA $COPY | |
50 | mkdir ${COPY}.dd | |
51 | verbose "$tid: rename target exists (directory)" | |
6c8ebe98 | 52 | echo "rename $COPY ${COPY}.dd" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
1d6c0b69 | 53 | || fail "rename target exists (directory) failed" |
54 | test -f ${COPY} || fail "oldname missing after rename target exists (directory)" | |
55 | test -d ${COPY}.dd || fail "newname missing after rename target exists (directory)" | |
56 | cmp $DATA ${COPY} >/dev/null 2>&1 || fail "corrupted oldname after rename target exists (directory)" | |
57 | ||
58 | rm -f ${COPY}.dd/* | |
59 | rm -rf ${COPY} | |
60 | cp ${DATA2} ${COPY} | |
61 | verbose "$tid: glob put files to local file" | |
6c8ebe98 | 62 | echo "put /bin/l* $COPY" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 |
1d6c0b69 | 63 | cmp ${DATA2} ${COPY} || fail "put successed when it should have failed" |
64 | ||
2b1bb684 | 65 | rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.dd |
1d6c0b69 | 66 | |
67 |