- (djm) [openbsd-compat/port-linux.c] Check whether SELinux is enabled
[openssh-git.git] / regress / sftp-glob.sh
blob8d4df2c98b5f2b6fe8dad8924ffa6bf825a46cfa
1 # $OpenBSD: sftp-glob.sh,v 1.4 2009/08/13 01:11:55 djm Exp $
2 # Placed in the Public Domain.
4 tid="sftp glob"
6 config_defined FILESYSTEM_NO_BACKSLASH && nobs="not supported on this platform"
8 sftp_ls() {
9 target=$1
10 errtag=$2
11 expected=$3
12 unexpected=$4
13 skip=$5
14 if test "x$skip" != "x" ; then
15 verbose "$tid: $errtag (skipped: $skip)"
16 return
18 verbose "$tid: $errtag"
19 printf "ls -l %s" "${target}" | \
20 ${SFTP} -b - -D ${SFTPSERVER} 2>/dev/null | \
21 grep -v "^sftp>" > ${RESULTS}
22 if [ $? -ne 0 ]; then
23 fail "$errtag failed"
25 if test "x$expected" != "x" ; then
26 if fgrep "$expected" ${RESULTS} >/dev/null 2>&1 ; then
28 else
29 fail "$expected missing from $errtag results"
32 if test "x$unexpected" != "x" && \
33 fgrep "$unexpected" ${RESULTS} >/dev/null 2>&1 ; then
34 fail "$unexpected present in $errtag results"
36 rm -f ${RESULTS}
39 BASE=${OBJ}/glob
40 RESULTS=${OBJ}/results
41 DIR=${BASE}/dir
42 DATA=${DIR}/file
44 GLOB1="${DIR}/g-wild*"
45 GLOB2="${DIR}/g-wildx"
46 QUOTE="${DIR}/g-quote\""
47 SLASH="${DIR}/g-sl\\ash"
48 ESLASH="${DIR}/g-slash\\"
49 QSLASH="${DIR}/g-qs\\\""
50 SPACE="${DIR}/g-q space"
52 rm -rf ${BASE}
53 mkdir -p ${DIR}
54 touch "${DATA}" "${GLOB1}" "${GLOB2}" "${QUOTE}" "${SPACE}"
55 test "x$nobs" = "x" && touch "${QSLASH}" "${ESLASH}" "${SLASH}"
57 # target message expected unexpected
58 sftp_ls "${DIR}/fil*" "file glob" "${DATA}" ""
59 sftp_ls "${BASE}/d*" "dir glob" "`basename ${DATA}`" ""
60 sftp_ls "${DIR}/g-wild\"*\"" "quoted glob" "g-wild*" "g-wildx"
61 sftp_ls "${DIR}/g-wild\*" "escaped glob" "g-wild*" "g-wildx"
62 sftp_ls "${DIR}/g-quote\\\"" "escaped quote" "g-quote\"" ""
63 sftp_ls "\"${DIR}/g-quote\\\"\"" "quoted quote" "g-quote\"" ""
64 sftp_ls "'${DIR}/g-quote\"'" "single-quoted quote" "g-quote\"" ""
65 sftp_ls "${DIR}/g-q\\ space" "escaped space" "g-q space" ""
66 sftp_ls "'${DIR}/g-q space'" "quoted space" "g-q space" ""
67 sftp_ls "${DIR}/g-sl\\\\ash" "escaped slash" "g-sl\\ash" "" "$nobs"
68 sftp_ls "'${DIR}/g-sl\\\\ash'" "quoted slash" "g-sl\\ash" "" "$nobs"
69 sftp_ls "${DIR}/g-slash\\\\" "escaped slash at EOL" "g-slash\\" "" "$nobs"
70 sftp_ls "'${DIR}/g-slash\\\\'" "quoted slash at EOL" "g-slash\\" "" "$nobs"
71 sftp_ls "${DIR}/g-qs\\\\\\\"" "escaped slash+quote" "g-qs\\\"" "" "$nobs"
72 sftp_ls "'${DIR}/g-qs\\\\\"'" "quoted slash+quote" "g-qs\\\"" "" "$nobs"
74 rm -rf ${BASE}