sftp-chroot.sh revision 264377
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
15$SUDO sh -c "echo mekmitastdigoat > $PRIVDATA" || \
16	fatal "create $PRIVDATA failed"
17
18start_sshd -oChrootDirectory=$CHROOT -oForceCommand="internal-sftp -d /"
19
20verbose "test $tid: get"
21${SFTP} -S "$SSH" -F $OBJ/ssh_config host:/${FILENAME} $COPY \
22    >>$TEST_REGRESS_LOGFILE 2>&1 || \
23	fatal "Fetch ${FILENAME} failed"
24cmp $PRIVDATA $COPY || fail "$PRIVDATA $COPY differ"
25
26$SUDO rm $PRIVDATA
27