summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordjm <djm@openbsd.org>2013-04-18 02:46:12 +0000
committerdjm <djm@openbsd.org>2013-04-18 02:46:12 +0000
commitc763b0e2c93d8c2a234c457420643a5a3321c5d4 (patch)
treeaa47af566f6fd3591127475369e3efb07134148c
parentstruct timezone is so 1980 (diff)
downloadwireguard-openbsd-c763b0e2c93d8c2a234c457420643a5a3321c5d4.tar.xz
wireguard-openbsd-c763b0e2c93d8c2a234c457420643a5a3321c5d4.zip
test sshd ChrootDirectory+internal-sftp; feedback & ok dtucker@
-rw-r--r--regress/usr.bin/ssh/Makefile6
-rw-r--r--regress/usr.bin/ssh/sftp-chroot.sh26
2 files changed, 31 insertions, 1 deletions
diff --git a/regress/usr.bin/ssh/Makefile b/regress/usr.bin/ssh/Makefile
index b0b8dd90062..7d84e6c4a71 100644
--- a/regress/usr.bin/ssh/Makefile
+++ b/regress/usr.bin/ssh/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.64 2013/04/07 02:16:03 dtucker Exp $
+# $OpenBSD: Makefile,v 1.65 2013/04/18 02:46:12 djm Exp $
REGRESS_TARGETS= t1 t2 t3 t4 t5 t6 t7 t8 t9
@@ -31,6 +31,7 @@ LTESTS= connect \
key-options \
scp \
sftp \
+ sftp-chroot \
sftp-cmds \
sftp-badcmds \
sftp-batch \
@@ -75,6 +76,8 @@ CLEANFILES+= authorized_keys_${USER} known_hosts pidfile \
ssh.log failed-ssh.log sshd.log failed-sshd.log \
regress.log failed-regress.log ssh-log-wrapper.sh
+SUDO_CLEAN+= /var/run/testdata_${USER} /var/run/keycommand_${USER}
+
# Enable all malloc(3) randomisations and checks
TEST_ENV= "MALLOC_OPTIONS=AFGJPRX"
@@ -153,6 +156,7 @@ interop: ${INTEROP_TARGETS}
clean:
rm -f ${CLEANFILES}
+ test -z "${SUDO}" || ${SUDO} rm -f ${SUDO_CLEAN}
rm -rf .putty
.include <bsd.regress.mk>
diff --git a/regress/usr.bin/ssh/sftp-chroot.sh b/regress/usr.bin/ssh/sftp-chroot.sh
new file mode 100644
index 00000000000..8c07979b4a0
--- /dev/null
+++ b/regress/usr.bin/ssh/sftp-chroot.sh
@@ -0,0 +1,26 @@
+# $OpenBSD: sftp-chroot.sh,v 1.1 2013/04/18 02:46:12 djm Exp $
+# Placed in the Public Domain.
+
+tid="sftp in chroot"
+
+COPY=${OBJ}/copy
+CHROOT=/var/run
+FILENAME=testdata_${USER}
+PRIVDATA=${CHROOT}/${FILENAME}
+
+if [ -z "$SUDO" ]; then
+ fatal "need SUDO to create file in /var/run, test won't work without"
+fi
+
+$SUDO sh -c "echo mekmitastdigoat > $PRIVDATA" || \
+ fatal "create $PRIVDATA failed"
+
+start_sshd -oChrootDirectory=$CHROOT -oForceCommand="internal-sftp -d /"
+
+verbose "test $tid: get"
+rm -f ${COPY}
+${SFTP} -qS "$SSH" -F $OBJ/ssh_config host:/${FILENAME} $COPY || \
+ fatal "Fetch ${FILENAME} failed"
+cmp $PRIVDATA $COPY || fail "$PRIVDATA $COPY differ"
+
+$SUDO rm $PRIVDATA