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