1323134Sdes# $OpenBSD: sftp-chroot.sh,v 1.5 2016/09/26 21:34:38 bluhm Exp $ 2255670Sdes# Placed in the Public Domain. 3255670Sdes 4255670Sdestid="sftp in chroot" 5255670Sdes 6255670SdesCHROOT=/var/run 7255670SdesFILENAME=testdata_${USER} 8255670SdesPRIVDATA=${CHROOT}/${FILENAME} 9255670Sdes 10323134Sdesif [ -z "$SUDO" -a ! -w /var/run ]; then 11255670Sdes echo "skipped: need SUDO to create file in /var/run, test won't work without" 12255670Sdes exit 0 13255670Sdesfi 14255670Sdes 15296633Sdesif ! $OBJ/check-perm -m chroot "$CHROOT" ; then 16296633Sdes echo "skipped: $CHROOT is unsuitable as ChrootDirectory" 17296633Sdes exit 0 18296633Sdesfi 19296633Sdes 20255670Sdes$SUDO sh -c "echo mekmitastdigoat > $PRIVDATA" || \ 21255670Sdes fatal "create $PRIVDATA failed" 22255670Sdes 23255670Sdesstart_sshd -oChrootDirectory=$CHROOT -oForceCommand="internal-sftp -d /" 24255670Sdes 25255670Sdesverbose "test $tid: get" 26263712Sdes${SFTP} -S "$SSH" -F $OBJ/ssh_config host:/${FILENAME} $COPY \ 27263712Sdes >>$TEST_REGRESS_LOGFILE 2>&1 || \ 28255670Sdes fatal "Fetch ${FILENAME} failed" 29255670Sdescmp $PRIVDATA $COPY || fail "$PRIVDATA $COPY differ" 30255670Sdes 31255670Sdes$SUDO rm $PRIVDATA 32