include and use OpenBSD netcat in regress/

This commit is contained in:
Damien Miller 2014-12-22 16:30:42 +11:00
parent 8f6784f0cb
commit 293cac52dc
4 changed files with 1649 additions and 19 deletions

View File

@ -436,6 +436,10 @@ regress/setuid-allowed$(EXEEXT): $(srcdir)/regress/setuid-allowed.c
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $? \
$(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
regress/netcat$(EXEEXT): $(srcdir)/regress/netcat.c
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $? \
$(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
UNITTESTS_TEST_HELPER_OBJS=\
regress/unittests/test_helper/test_helper.o \
regress/unittests/test_helper/fuzz.o
@ -476,6 +480,7 @@ regress/unittests/sshkey/test_sshkey$(EXEEXT): ${UNITTESTS_TEST_SSHKEY_OBJS} \
REGRESS_BINARIES=\
regress/modpipe$(EXEEXT) \
regress/setuid-allowed$(EXEEXT) \
regress/netcat$(EXEEXT) \
regress/unittests/sshbuf/test_sshbuf$(EXEEXT) \
regress/unittests/sshkey/test_sshkey$(EXEEXT)

View File

@ -92,7 +92,7 @@ CLEANFILES= t2.out t3.out t6.out1 t6.out2 t7.out t7.out.pub copy.1 copy.2 \
regress.log failed-regress.log ssh-log-wrapper.sh \
sftp-server.sh sftp-server.log sftp.log setuid-allowed \
data ed25519-agent ed25519-agent.pub key.ed25519-512 \
key.ed25519-512.pub
key.ed25519-512.pub netcat
SUDO_CLEAN+= /var/run/testdata_${USER} /var/run/keycommand_${USER}

View File

@ -5,20 +5,7 @@ CTL=/tmp/openssh.regress.ctl-sock.$$
tid="connection multiplexing"
if have_prog nc ; then
if nc -h 2>&1 | grep -- -N >/dev/null; then
NC="nc -N";
elif nc -h 2>&1 | grep -- "-U.*Use UNIX" >/dev/null ; then
NC="nc"
else
echo "nc is incompatible"
fi
fi
if test -z "$NC" ; then
echo "skipped (no compatible nc found)"
exit 0
fi
NC=$OBJ/netcat
trace "will use ProxyCommand $proxycmd"
if config_defined DISABLE_FD_PASSING ; then
@ -90,20 +77,20 @@ cmp ${DATA} ${COPY} || fail "scp: corrupted copy of ${DATA}"
rm -f ${COPY}
verbose "test $tid: forward"
trace "forward over TCP/IP and check result"
$NC -l 127.0.0.1 $((${PORT} + 1)) < ${DATA} > /dev/null &
$NC -N -l 127.0.0.1 $((${PORT} + 1)) < ${DATA} > /dev/null &
netcat_pid=$!
${SSH} -F $OBJ/ssh_config -S $CTL -Oforward -L127.0.0.1:$((${PORT} + 2)):127.0.0.1:$((${PORT} + 1)) otherhost >>$TEST_SSH_LOGFILE 2>&1
$NC -d 127.0.0.1 $((${PORT} + 2)) > ${COPY} < /dev/null
$NC 127.0.0.1 $((${PORT} + 2)) < /dev/null > ${COPY}
cmp ${DATA} ${COPY} || fail "ssh: corrupted copy of ${DATA}"
kill $netcat_pid 2>/dev/null
rm -f ${COPY} $OBJ/unix-[123].fwd
trace "forward over UNIX and check result"
$NC -Ul $OBJ/unix-1.fwd < ${DATA} > /dev/null &
$NC -N -Ul $OBJ/unix-1.fwd < ${DATA} > /dev/null &
netcat_pid=$!
${SSH} -F $OBJ/ssh_config -S $CTL -Oforward -L$OBJ/unix-2.fwd:$OBJ/unix-1.fwd otherhost >>$TEST_SSH_LOGFILE 2>&1
${SSH} -F $OBJ/ssh_config -S $CTL -Oforward -R$OBJ/unix-3.fwd:$OBJ/unix-2.fwd otherhost >>$TEST_SSH_LOGFILE 2>&1
$NC -d -U $OBJ/unix-3.fwd > ${COPY} < /dev/null
$NC -U $OBJ/unix-3.fwd < /dev/null > ${COPY}
cmp ${DATA} ${COPY} || fail "ssh: corrupted copy of ${DATA}"
kill $netcat_pid 2>/dev/null
rm -f ${COPY} $OBJ/unix-[123].fwd

1638
regress/netcat.c Normal file

File diff suppressed because it is too large Load Diff