1# $OpenBSD: sftp-chroot.sh,v 1.4 2014/01/20 00:00:30 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" ]; then 11 echo "skipped: need SUDO to create file in /var/run, test won't work without" 12 exit 0 13fi 14 15if ! $OBJ/check-perm -m chroot "$CHROOT" ; then 16 echo "skipped: $CHROOT is unsuitable as ChrootDirectory" 17 exit 0 18fi 19 20$SUDO sh -c "echo mekmitastdigoat > $PRIVDATA" || \ 21 fatal "create $PRIVDATA failed" 22 23start_sshd -oChrootDirectory=$CHROOT -oForceCommand="internal-sftp -d /" 24 25verbose "test $tid: get" 26${SFTP} -S "$SSH" -F $OBJ/ssh_config host:/${FILENAME} $COPY \ 27 >>$TEST_REGRESS_LOGFILE 2>&1 || \ 28 fatal "Fetch ${FILENAME} failed" 29cmp $PRIVDATA $COPY || fail "$PRIVDATA $COPY differ" 30 31$SUDO rm $PRIVDATA 32