Darren Tucker | f3568fc | 2013-05-17 09:35:26 +1000 | [diff] [blame^] | 1 | # $OpenBSD: sftp-chroot.sh,v 1.1 2013/04/18 02:46:12 djm Exp $ |
| 2 | # Placed in the Public Domain. |
| 3 | |
| 4 | tid="sftp in chroot" |
| 5 | |
| 6 | COPY=${OBJ}/copy |
| 7 | CHROOT=/var/run |
| 8 | FILENAME=testdata_${USER} |
| 9 | PRIVDATA=${CHROOT}/${FILENAME} |
| 10 | |
| 11 | if [ -z "$SUDO" ]; then |
| 12 | fatal "need SUDO to create file in /var/run, test won't work without" |
| 13 | fi |
| 14 | |
| 15 | $SUDO sh -c "echo mekmitastdigoat > $PRIVDATA" || \ |
| 16 | fatal "create $PRIVDATA failed" |
| 17 | |
| 18 | start_sshd -oChrootDirectory=$CHROOT -oForceCommand="internal-sftp -d /" |
| 19 | |
| 20 | verbose "test $tid: get" |
| 21 | rm -f ${COPY} |
| 22 | ${SFTP} -qS "$SSH" -F $OBJ/ssh_config host:/${FILENAME} $COPY || \ |
| 23 | fatal "Fetch ${FILENAME} failed" |
| 24 | cmp $PRIVDATA $COPY || fail "$PRIVDATA $COPY differ" |
| 25 | |
| 26 | $SUDO rm $PRIVDATA |