~ubuntu-branches/ubuntu/lucid/openssh/lucid

« back to all changes in this revision

Viewing changes to regress/sftp-glob.sh

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2008-09-30 23:09:58 UTC
  • mfrom: (1.13.3 upstream) (29 hardy)
  • mto: This revision was merged to the branch mainline in revision 43.
  • Revision ID: james.westby@ubuntu.com-20080930230958-o6vsgn8c4mm959s0
Tags: 1:5.1p1-3
* Remove unnecessary ssh-vulnkey output in non-verbose mode when no
  compromised or unknown keys were found (closes: #496495).
* Configure with --disable-strip; dh_strip will deal with stripping
  binaries and will honour DEB_BUILD_OPTIONS (thanks, Bernhard R. Link;
  closes: #498681).
* Fix handling of zero-length server banners (thanks, Tomas Mraz; closes:
  #497026).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#       $OpenBSD: sftp-glob.sh,v 1.1 2004/12/10 01:31:30 fgsch Exp $
 
1
#       $OpenBSD: sftp-glob.sh,v 1.3 2007/10/26 05:30:01 djm Exp $
2
2
#       Placed in the Public Domain.
3
3
 
4
4
tid="sftp glob"
5
5
 
 
6
sftp_ls() {
 
7
        target=$1
 
8
        errtag=$2
 
9
        expected=$3
 
10
        unexpected=$4
 
11
        verbose "$tid: $errtag"
 
12
        printf "ls -l %s" "${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" ; then
 
19
            if fgrep "$expected" ${RESULTS} >/dev/null 2>&1 ; then
 
20
                :
 
21
            else
 
22
                fail "$expected missing from $errtag results"
 
23
            fi
 
24
        fi
 
25
        if test "x$unexpected" != "x" && \
 
26
           fgrep "$unexpected" ${RESULTS} >/dev/null 2>&1 ; then
 
27
                fail "$unexpected present in $errtag results"
 
28
        fi
 
29
        rm -f ${RESULTS}
 
30
}
 
31
 
6
32
BASE=${OBJ}/glob
 
33
RESULTS=${OBJ}/results
7
34
DIR=${BASE}/dir
8
35
DATA=${DIR}/file
9
36
 
 
37
GLOB1="${DIR}/g-wild*"
 
38
GLOB2="${DIR}/g-wildx"
 
39
QUOTE="${DIR}/g-quote\""
 
40
SLASH="${DIR}/g-sl\\ash"
 
41
ESLASH="${DIR}/g-slash\\"
 
42
QSLASH="${DIR}/g-qs\\\""
 
43
SPACE="${DIR}/g-q space"
 
44
 
10
45
rm -rf ${BASE}
11
46
mkdir -p ${DIR}
12
 
touch ${DATA}
13
 
 
14
 
verbose "$tid: ls file"
15
 
echo "ls -l ${DIR}/fil*" | ${SFTP} -P ${SFTPSERVER} 2>/dev/null | \
16
 
        grep ${DATA} >/dev/null 2>&1
17
 
if [ $? -ne 0 ]; then
18
 
        fail "globbed ls file failed"
19
 
fi
20
 
 
21
 
verbose "$tid: ls dir"
22
 
echo "ls -l ${BASE}/d*" | ${SFTP} -P ${SFTPSERVER} 2>/dev/null | \
23
 
        grep file >/dev/null 2>&1
24
 
if [ $? -ne 0 ]; then
25
 
        fail "globbed ls dir failed"
26
 
fi
 
47
touch "${DATA}" "${GLOB1}" "${GLOB2}" "${QUOTE}"
 
48
touch "${QSLASH}" "${ESLASH}" "${SLASH}" "${SPACE}"
 
49
 
 
50
#       target                   message                expected     unexpected
 
51
sftp_ls "${DIR}/fil*"            "file glob"            "${DATA}"    ""
 
52
sftp_ls "${BASE}/d*"             "dir glob"             "`basename ${DATA}`" ""
 
53
sftp_ls "${DIR}/g-wild\"*\""     "quoted glob"          "g-wild*"    "g-wildx"
 
54
sftp_ls "${DIR}/g-wild\*"        "escaped glob"         "g-wild*"    "g-wildx"
 
55
sftp_ls "${DIR}/g-quote\\\""     "escaped quote"        "g-quote\""  ""
 
56
sftp_ls "\"${DIR}/g-quote\\\"\"" "quoted quote"         "g-quote\""  ""
 
57
sftp_ls "'${DIR}/g-quote\"'"     "single-quoted quote"  "g-quote\""  ""
 
58
sftp_ls "${DIR}/g-sl\\\\ash"     "escaped slash"        "g-sl\\ash"  ""
 
59
sftp_ls "'${DIR}/g-sl\\\\ash'"   "quoted slash"         "g-sl\\ash"  ""
 
60
sftp_ls "${DIR}/g-slash\\\\"     "escaped slash at EOL" "g-slash\\"  ""
 
61
sftp_ls "'${DIR}/g-slash\\\\'"   "quoted slash at EOL"  "g-slash\\"  ""
 
62
sftp_ls "${DIR}/g-qs\\\\\\\""    "escaped slash+quote"  "g-qs\\\""   ""
 
63
sftp_ls "'${DIR}/g-qs\\\\\"'"    "quoted slash+quote"   "g-qs\\\""   ""
 
64
sftp_ls "${DIR}/g-q\\ space"     "escaped space"        "g-q space"  ""
 
65
sftp_ls "'${DIR}/g-q space'"     "quoted space"         "g-q space"  ""
27
66
 
28
67
rm -rf ${BASE}
 
68