]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - crypto/openssh/regress/sftp-uri.sh
Upgrade to OpenSSH 7.7p1.
[FreeBSD/FreeBSD.git] / crypto / openssh / regress / sftp-uri.sh
1 #       $OpenBSD: sftp-uri.sh,v 1.1 2017/10/24 19:33:32 millert Exp $
2 #       Placed in the Public Domain.
3
4 tid="sftp-uri"
5
6 #set -x
7
8 COPY2=${OBJ}/copy2
9 DIR=${COPY}.dd
10 DIR2=${COPY}.dd2
11 SRC=`dirname ${SCRIPT}`
12
13 sftpclean() {
14         rm -rf ${COPY} ${COPY2} ${DIR} ${DIR2}
15         mkdir ${DIR} ${DIR2}
16 }
17
18 start_sshd -oForceCommand="internal-sftp -d /"
19
20 # Remove Port and User from ssh_config, we want to rely on the URI
21 cp $OBJ/ssh_config $OBJ/ssh_config.orig
22 egrep -v '^     +(Port|User)    +.*$' $OBJ/ssh_config.orig > $OBJ/ssh_config
23
24 verbose "$tid: non-interactive fetch to local file"
25 sftpclean
26 ${SFTP} -q -S "$SSH" -F $OBJ/ssh_config "sftp://${USER}@somehost:${PORT}/${DATA}" ${COPY} || fail "copy failed"
27 cmp ${DATA} ${COPY} || fail "corrupted copy"
28
29 verbose "$tid: non-interactive fetch to local dir"
30 sftpclean
31 cp ${DATA} ${COPY}
32 ${SFTP} -q -S "$SSH" -F $OBJ/ssh_config "sftp://${USER}@somehost:${PORT}/${COPY}" ${DIR} || fail "copy failed"
33 cmp ${COPY} ${DIR}/copy || fail "corrupted copy"
34
35 verbose "$tid: put to remote directory (trailing slash)"
36 sftpclean
37 ${SFTP} -q -S "$SSH" -F $OBJ/ssh_config -b - \
38     "sftp://${USER}@somehost:${PORT}/${DIR}/" > /dev/null 2>&1 << EOF
39         version
40         put ${DATA} copy
41 EOF
42 r=$?
43 if [ $r -ne 0 ]; then
44         fail "sftp failed with $r"
45 else
46         cmp ${DATA} ${DIR}/copy || fail "corrupted copy"
47 fi
48
49 verbose "$tid: put to remote directory (no slash)"
50 sftpclean
51 ${SFTP} -q -S "$SSH" -F $OBJ/ssh_config -b - \
52     "sftp://${USER}@somehost:${PORT}/${DIR}" > /dev/null 2>&1 << EOF
53         version
54         put ${DATA} copy
55 EOF
56 r=$?
57 if [ $r -ne 0 ]; then
58         fail "sftp failed with $r"
59 else
60         cmp ${DATA} ${DIR}/copy || fail "corrupted copy"
61 fi
62
63 sftpclean