[openssh-commits] [openssh] 08/11: upstream commit

git+noreply at mindrot.org git+noreply at mindrot.org
Tue Oct 31 10:04:38 AEDT 2017


This is an automated email from the git hooks/post-receive script.

djm pushed a commit to branch master
in repository openssh.

commit 116b1b439413a724ebb3320633a64dd0f3ee1fe7
Author: millert at openbsd.org@openbsd.org <millert at openbsd.org@openbsd.org>
Date:   Tue Oct 24 19:33:32 2017 +0000

    upstream commit
    
    Add tests for URI parsing.  OK markus@
    
    OpenBSD-Regress-ID: 5d1df19874f3b916d1a2256a905526e17a98bd3b
---
 regress/Makefile       |  5 +++-
 regress/connect-uri.sh | 29 ++++++++++++++++++++++
 regress/scp-uri.sh     | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++
 regress/sftp-uri.sh    | 63 +++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 162 insertions(+), 1 deletion(-)

diff --git a/regress/Makefile b/regress/Makefile
index 7d50f9cf..d15898ad 100644
--- a/regress/Makefile
+++ b/regress/Makefile
@@ -1,4 +1,4 @@
-#	$OpenBSD: Makefile,v 1.95 2017/06/24 06:35:24 djm Exp $
+#	$OpenBSD: Makefile,v 1.96 2017/10/24 19:33:32 millert Exp $
 
 REGRESS_TARGETS=	unit t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t-exec
 tests:		prep $(REGRESS_TARGETS)
@@ -19,6 +19,7 @@ distclean:	clean
 LTESTS= 	connect \
 		proxy-connect \
 		connect-privsep \
+		connect-uri \
 		proto-version \
 		proto-mismatch \
 		exit-status \
@@ -42,6 +43,7 @@ LTESTS= 	connect \
 		keygen-moduli \
 		key-options \
 		scp \
+		scp-uri \
 		sftp \
 		sftp-chroot \
 		sftp-cmds \
@@ -49,6 +51,7 @@ LTESTS= 	connect \
 		sftp-batch \
 		sftp-glob \
 		sftp-perm \
+		sftp-uri \
 		reconfigure \
 		dynamic-forward \
 		forwarding \
diff --git a/regress/connect-uri.sh b/regress/connect-uri.sh
new file mode 100644
index 00000000..f13f15e6
--- /dev/null
+++ b/regress/connect-uri.sh
@@ -0,0 +1,29 @@
+#	$OpenBSD: connect-uri.sh,v 1.1 2017/10/24 19:33:32 millert Exp $
+#	Placed in the Public Domain.
+
+tid="uri connect"
+
+# Remove Port and User from ssh_config, we want to rely on the URI
+cp $OBJ/ssh_config $OBJ/ssh_config.orig
+egrep -v '^	+(Port|User)	+.*$' $OBJ/ssh_config.orig > $OBJ/ssh_config
+
+start_sshd
+
+verbose "$tid: no trailing slash"
+${SSH} -F $OBJ/ssh_config "ssh://${USER}@somehost:${PORT}" true
+if [ $? -ne 0 ]; then
+	fail "ssh connection failed"
+fi
+
+verbose "$tid: trailing slash"
+${SSH} -F $OBJ/ssh_config "ssh://${USER}@somehost:${PORT}/" true
+if [ $? -ne 0 ]; then
+	fail "ssh connection failed"
+fi
+
+verbose "$tid: with path name"
+${SSH} -F $OBJ/ssh_config "ssh://${USER}@somehost:${PORT}/${DATA}" true \
+    > /dev/null 2>&1
+if [ $? -eq 0 ]; then
+	fail "ssh connection succeeded, expected failure"
+fi
diff --git a/regress/scp-uri.sh b/regress/scp-uri.sh
new file mode 100644
index 00000000..bf21bf32
--- /dev/null
+++ b/regress/scp-uri.sh
@@ -0,0 +1,66 @@
+#	$OpenBSD: scp-uri.sh,v 1.1 2017/10/24 19:33:32 millert Exp $
+#	Placed in the Public Domain.
+
+tid="scp-uri"
+
+#set -x
+
+COPY2=${OBJ}/copy2
+DIR=${COPY}.dd
+DIR2=${COPY}.dd2
+
+SRC=`dirname ${SCRIPT}`
+cp ${SRC}/scp-ssh-wrapper.sh ${OBJ}/scp-ssh-wrapper.scp
+chmod 755 ${OBJ}/scp-ssh-wrapper.scp
+scpopts="-q -S ${OBJ}/scp-ssh-wrapper.scp"
+export SCP # used in scp-ssh-wrapper.scp
+
+scpclean() {
+	rm -rf ${COPY} ${COPY2} ${DIR} ${DIR2}
+	mkdir ${DIR} ${DIR2}
+}
+
+# Remove Port and User from ssh_config, we want to rely on the URI
+cp $OBJ/ssh_config $OBJ/ssh_config.orig
+egrep -v '^	+(Port|User)	+.*$' $OBJ/ssh_config.orig > $OBJ/ssh_config
+
+verbose "$tid: simple copy local file to remote file"
+scpclean
+$SCP $scpopts ${DATA} "scp://${USER}@somehost:${PORT}/${COPY}" || fail "copy failed"
+cmp ${DATA} ${COPY} || fail "corrupted copy"
+
+verbose "$tid: simple copy remote file to local file"
+scpclean
+$SCP $scpopts "scp://${USER}@somehost:${PORT}/${DATA}" ${COPY} || fail "copy failed"
+cmp ${DATA} ${COPY} || fail "corrupted copy"
+
+verbose "$tid: simple copy local file to remote dir"
+scpclean
+cp ${DATA} ${COPY}
+$SCP $scpopts ${COPY} "scp://${USER}@somehost:${PORT}/${DIR}" || fail "copy failed"
+cmp ${COPY} ${DIR}/copy || fail "corrupted copy"
+
+verbose "$tid: simple copy remote file to local dir"
+scpclean
+cp ${DATA} ${COPY}
+$SCP $scpopts "scp://${USER}@somehost:${PORT}/${COPY}" ${DIR} || fail "copy failed"
+cmp ${COPY} ${DIR}/copy || fail "corrupted copy"
+
+verbose "$tid: recursive local dir to remote dir"
+scpclean
+rm -rf ${DIR2}
+cp ${DATA} ${DIR}/copy
+$SCP $scpopts -r ${DIR} "scp://${USER}@somehost:${PORT}/${DIR2}" || fail "copy failed"
+diff -rN ${DIR} ${DIR2} || fail "corrupted copy"
+
+verbose "$tid: recursive remote dir to local dir"
+scpclean
+rm -rf ${DIR2}
+cp ${DATA} ${DIR}/copy
+$SCP $scpopts -r "scp://${USER}@somehost:${PORT}/${DIR}" ${DIR2} || fail "copy failed"
+diff -rN ${DIR} ${DIR2} || fail "corrupted copy"
+
+# TODO: scp -3
+
+scpclean
+rm -f ${OBJ}/scp-ssh-wrapper.exe
diff --git a/regress/sftp-uri.sh b/regress/sftp-uri.sh
new file mode 100644
index 00000000..4d19dd71
--- /dev/null
+++ b/regress/sftp-uri.sh
@@ -0,0 +1,63 @@
+#	$OpenBSD: sftp-uri.sh,v 1.1 2017/10/24 19:33:32 millert Exp $
+#	Placed in the Public Domain.
+
+tid="sftp-uri"
+
+#set -x
+
+COPY2=${OBJ}/copy2
+DIR=${COPY}.dd
+DIR2=${COPY}.dd2
+SRC=`dirname ${SCRIPT}`
+
+sftpclean() {
+	rm -rf ${COPY} ${COPY2} ${DIR} ${DIR2}
+	mkdir ${DIR} ${DIR2}
+}
+
+start_sshd -oForceCommand="internal-sftp -d /"
+
+# Remove Port and User from ssh_config, we want to rely on the URI
+cp $OBJ/ssh_config $OBJ/ssh_config.orig
+egrep -v '^	+(Port|User)	+.*$' $OBJ/ssh_config.orig > $OBJ/ssh_config
+
+verbose "$tid: non-interactive fetch to local file"
+sftpclean
+${SFTP} -q -S "$SSH" -F $OBJ/ssh_config "sftp://${USER}@somehost:${PORT}/${DATA}" ${COPY} || fail "copy failed"
+cmp ${DATA} ${COPY} || fail "corrupted copy"
+
+verbose "$tid: non-interactive fetch to local dir"
+sftpclean
+cp ${DATA} ${COPY}
+${SFTP} -q -S "$SSH" -F $OBJ/ssh_config "sftp://${USER}@somehost:${PORT}/${COPY}" ${DIR} || fail "copy failed"
+cmp ${COPY} ${DIR}/copy || fail "corrupted copy"
+
+verbose "$tid: put to remote directory (trailing slash)"
+sftpclean
+${SFTP} -q -S "$SSH" -F $OBJ/ssh_config -b /dev/stdin \
+    "sftp://${USER}@somehost:${PORT}/${DIR}/" > /dev/null 2>&1 << EOF
+	version
+	put ${DATA} copy
+EOF
+r=$?
+if [ $r -ne 0 ]; then
+	fail "sftp failed with $r"
+else
+	cmp ${DATA} ${DIR}/copy || fail "corrupted copy"
+fi
+
+verbose "$tid: put to remote directory (no slash)"
+sftpclean
+${SFTP} -q -S "$SSH" -F $OBJ/ssh_config -b /dev/stdin \
+    "sftp://${USER}@somehost:${PORT}/${DIR}" > /dev/null 2>&1 << EOF
+	version
+	put ${DATA} copy
+EOF
+r=$?
+if [ $r -ne 0 ]; then
+	fail "sftp failed with $r"
+else
+	cmp ${DATA} ${DIR}/copy || fail "corrupted copy"
+fi
+
+sftpclean

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list