1# $OpenBSD: sftp-chroot.sh,v 1.6 2018/02/09 03:42:57 dtucker Exp $ 2# Placed in the Public Domain. 3 4tid="sftp in chroot" 5 6CHROOT=/var/run 7FILENAME=testdata_${USER} 8PRIVDATA=${CHROOT}/${FILENAME} 9 10if [ -z "$SUDO" -a ! -w /var/run ]; then 11 echo "need SUDO to create file in /var/run, test won't work without" 12 echo SKIPPED 13 exit 0 14fi 15 16if ! $OBJ/check-perm -m chroot "$CHROOT" ; then 17 echo "skipped: $CHROOT is unsuitable as ChrootDirectory" 18 exit 0 19fi 20 21$SUDO sh -c "echo mekmitastdigoat > $PRIVDATA" || \ 22 fatal "create $PRIVDATA failed" 23 24start_sshd -oChrootDirectory=$CHROOT -oForceCommand="internal-sftp -d /" 25 26verbose "test $tid: get" 27${SFTP} -S "$SSH" -F $OBJ/ssh_config host:/${FILENAME} $COPY \ 28 >>$TEST_REGRESS_LOGFILE 2>&1 || \ 29 fatal "Fetch ${FILENAME} failed" 30cmp $PRIVDATA $COPY || fail "$PRIVDATA $COPY differ" 31 32$SUDO rm $PRIVDATA 33