Deleted Added
full compact
sftp-chroot.sh (255774) sftp-chroot.sh (263712)
1# $OpenBSD: sftp-chroot.sh,v 1.2 2013/05/17 04:29:14 dtucker Exp $
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"
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} -qS "$SSH" -F $OBJ/ssh_config host:/${FILENAME} $COPY || \
21${SFTP} -S "$SSH" -F $OBJ/ssh_config host:/${FILENAME} $COPY \
22 >>$TEST_REGRESS_LOGFILE 2>&1 || \
22 fatal "Fetch ${FILENAME} failed"
23cmp $PRIVDATA $COPY || fail "$PRIVDATA $COPY differ"
24
25$SUDO rm $PRIVDATA
23 fatal "Fetch ${FILENAME} failed"
24cmp $PRIVDATA $COPY || fail "$PRIVDATA $COPY differ"
25
26$SUDO rm $PRIVDATA