robsd-exec: timeout 3600s + . /usr/local/libexec/robsd/util-regress.sh + config_load + << "EOF" + _err=0 + _env=REGRESS_FAIL_EARLY=no + config_value regress-usr.bin/nc-env + 2> /dev/null + _env=REGRESS_FAIL_EARLY=no GOCACHE=/tmp + _make=make -C /home/src/regress/usr.bin/nc REGRESS_FAIL_EARLY=no GOCACHE=/tmp + config_value regress-usr.bin/nc-targets + regress_root usr.bin/nc + export SUDO + unpriv -c staff build exec make -C /home/src/regress/usr.bin/nc REGRESS_FAIL_EARLY=no GOCACHE=/tmp regress ==== run-tcp ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f server.err; echo greeting | ./netcat-regress -n -v -l 127.0.0.1 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Listening on 127.0.0.1 15722 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port rm -f client.err; echo command | ./netcat-regress -n -v 127.0.0.1 `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'Connection to .* succeeded' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection to 127.0.0.1 15722 port [tcp/*] succeeded! Connection received on 127.0.0.1 27830 let timeout=`date +%s`+5; until grep -q 'greeting' client.out && grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep '^greeting$' client.out greeting grep '^command$' server.out command grep 'Listening on 127.0.0.1 ' server.err Listening on 127.0.0.1 15722 grep 'Connection received on 127.0.0.1 ' server.err Connection received on 127.0.0.1 27830 grep 'Connection to 127.0.0.1 .* succeeded!' client.err Connection to 127.0.0.1 15722 port [tcp/*] succeeded! ==== run-tcp6 ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f server.err; echo greeting | ./netcat-regress -n -v -l ::1 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Listening on ::1 43171 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port rm -f client.err; echo command | ./netcat-regress -n -v ::1 `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'Connection to .* succeeded' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection received on ::1 2199 Connection to ::1 43171 port [tcp/*] succeeded! let timeout=`date +%s`+5; until grep -q 'greeting' client.out && grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep '^greeting$' client.out greeting grep '^command$' server.out command grep 'Listening on ::1 ' server.err Listening on ::1 43171 grep 'Connection received on ::1 ' server.err Connection received on ::1 2199 grep 'Connection to ::1 .* succeeded!' client.err Connection to ::1 43171 port [tcp/*] succeeded! ==== run-tcp-localhost-server ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f server.err; echo greeting | ./netcat-regress -4 -v -l localhost 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Listening on localhost 45377 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port rm -f client.err; echo command | ./netcat-regress -n -v 127.0.0.1 `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'Connection to .* succeeded' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection to 127.0.0.1 45377 port [tcp/*] succeeded! Connection received on localhost 39759 let timeout=`date +%s`+5; until grep -q 'greeting' client.out && grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep '^greeting$' client.out greeting grep '^command$' server.out command grep 'Listening on localhost ' server.err Listening on localhost 45377 grep 'Connection received on localhost ' server.err Connection received on localhost 39759 grep 'Connection to 127.0.0.1 .* succeeded!' client.err Connection to 127.0.0.1 45377 port [tcp/*] succeeded! ==== run-tcp6-localhost-server ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f server.err; echo greeting | ./netcat-regress -6 -v -l localhost 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Listening on localhost 20254 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port rm -f client.err; echo command | ./netcat-regress -n -v ::1 `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'Connection to .* succeeded' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection received on localhost 29664 Connection to ::1 20254 port [tcp/*] succeeded! let timeout=`date +%s`+5; until grep -q 'greeting' client.out && grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep '^greeting$' client.out greeting grep '^command$' server.out command grep 'Listening on localhost ' server.err Listening on localhost 20254 grep 'Connection received on localhost ' server.err Connection received on localhost 29664 grep 'Connection to ::1 .* succeeded!' client.err Connection to ::1 20254 port [tcp/*] succeeded! ==== run-tcp-localhost-client ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f server.err; echo greeting | ./netcat-regress -n -v -l 127.0.0.1 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Listening on 127.0.0.1 22732 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port rm -f client.err; echo command | ./netcat-regress -4 -v localhost `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'Connection to .* succeeded' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection received on 127.0.0.1 9470 Connection to localhost (127.0.0.1) 22732 port [tcp/*] succeeded! let timeout=`date +%s`+5; until grep -q 'greeting' client.out && grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep '^greeting$' client.out greeting grep '^command$' server.out command grep 'Listening on 127.0.0.1 ' server.err Listening on 127.0.0.1 22732 grep 'Connection received on 127.0.0.1 ' server.err Connection received on 127.0.0.1 9470 grep 'Connection to localhost .* succeeded!' client.err Connection to localhost (127.0.0.1) 22732 port [tcp/*] succeeded! ==== run-tcp6-localhost-client ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f server.err; echo greeting | ./netcat-regress -n -v -l ::1 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Listening on ::1 26703 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port rm -f client.err; echo command | ./netcat-regress -6 -v localhost `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'Connection to .* succeeded' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection received on ::1 22922 Connection to localhost (::1) 26703 port [tcp/*] succeeded! let timeout=`date +%s`+5; until grep -q 'greeting' client.out && grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep '^greeting$' client.out greeting grep '^command$' server.out command grep 'Listening on ::1 ' server.err Listening on ::1 26703 grep 'Connection received on ::1 ' server.err Connection received on ::1 22922 grep 'Connection to localhost .* succeeded!' client.err Connection to localhost (::1) 26703 port [tcp/*] succeeded! ==== run-tcp-bad-localhost-server ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress ! ./netcat-regress -4 -v -l ::1 0 >server.out 2>server.err grep 'non-recoverable failure in name resolution' server.err netcat-regress: getaddrinfo: non-recoverable failure in name resolution ==== run-tcp6-bad-localhost-server ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress ! ./netcat-regress -6 -v -l 127.0.0.0 0 >server.out 2>server.err grep 'no address associated with name' server.err netcat-regress: getaddrinfo: no address associated with name ==== run-tcp-bad-localhost-client ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f server.err; echo greeting | ./netcat-regress -n -v -l 127.0.0.1 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep: server.err: No such file or directory grep: server.err: No such file or directory Listening on 127.0.0.1 8109 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port ! ./netcat-regress -4 -v ::1 `cat server.port` >client.out 2>client.err grep 'non-recoverable failure in name resolution' client.err netcat-regress: getaddrinfo for host "::1" port 8109: non-recoverable failure in name resolution ==== run-tcp6-bad-localhost-client ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f server.err; echo greeting | ./netcat-regress -n -v -l 127.0.0.1 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Listening on 127.0.0.1 37249 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port ! ./netcat-regress -6 -v 127.0.0.1 `cat server.port` >client.out 2>client.err grep 'no address associated with name' client.err netcat-regress: getaddrinfo for host "127.0.0.1" port 37249: no address associated with name ==== run-tcp-sleep ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f server.err; echo greeting | ./netcat-regress -n -v -l 127.0.0.1 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Listening on 127.0.0.1 47100 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port rm -f client.err; echo command | ./netcat-regress -n -v 127.0.0.1 `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'Connection to .* succeeded' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection received on 127.0.0.1 14491 Connection to 127.0.0.1 47100 port [tcp/*] succeeded! let timeout=`date +%s`+5; until grep -q 'greeting' client.out && grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep '^greeting$' client.out greeting grep '^command$' server.out command grep 'Listening on 127.0.0.1 ' server.err Listening on 127.0.0.1 47100 grep 'Connection received on 127.0.0.1 ' server.err Connection received on 127.0.0.1 14491 grep 'Connection to 127.0.0.1 .* succeeded!' client.err Connection to 127.0.0.1 47100 port [tcp/*] succeeded! # netcat waits for the other side to terminate, check it is sleeping let timeout=`date +%s`+5; while ps -xww -o comm,stat | grep -q 'netcat-regress .*R'; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done ps -xww -o comm,stat,args | grep '^netcat-regress .*S.* -v -l 127' netcat-regress Sp ./netcat-regress -n -v -l 127.0.0.1 0 ps -xww -o comm,stat,args | grep '^netcat-regress .*S.* -v 127' netcat-regress Sp ./netcat-regress -n -v 127.0.0.1 47100 ==== run-tcp-keep ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f server.err; echo greeting | ./netcat-regress -k -n -v -l 127.0.0.1 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Listening on 127.0.0.1 46612 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port rm -f client.err; echo command | ./netcat-regress -n -v 127.0.0.1 `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'Connection to .* succeeded' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection received on 127.0.0.1 5024 Connection to 127.0.0.1 46612 port [tcp/*] succeeded! let timeout=`date +%s`+5; until grep -q 'greeting' client.out && grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep '^greeting$' client.out greeting grep '^command$' server.out command grep 'Listening on 127.0.0.1 ' server.err Listening on 127.0.0.1 46612 grep 'Connection received on 127.0.0.1 ' server.err Connection received on 127.0.0.1 5024 grep 'Connection to 127.0.0.1 .* succeeded!' client.err Connection to 127.0.0.1 46612 port [tcp/*] succeeded! # kill client and reconnect with a new one :> server.err pkill -l -f "^./netcat-regress .* 127.0.0.1 `cat server.port`$" 88959 netcat-regress Listening on 127.0.0.1 44974 rm -f client.{out,err} :> server.out # server closes the listen socket and binds a new one with new port let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port rm -f client.err; echo command | ./netcat-regress -n -v 127.0.0.1 `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'Connection to .* succeeded' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection received on 127.0.0.1 41986 Connection to 127.0.0.1 44974 port [tcp/*] succeeded! # server sends only one greeting, do not wait for a second one let timeout=`date +%s`+5; until grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done ! grep 'greeting' client.out # truncation of log results in NUL bytes, do not match ^ grep 'command$' server.out Binary file server.out matches grep 'Listening on 127.0.0.1 ' server.err Binary file server.err matches grep 'Connection received on 127.0.0.1 ' server.err Binary file server.err matches grep 'Connection to 127.0.0.1 .* succeeded!' client.err Connection to 127.0.0.1 44974 port [tcp/*] succeeded! ==== run-tls ==== openssl req -batch -new -subj /L=OpenBSD/O=netcat-regress/OU=server/CN=127.0.0.1/ -nodes -newkey rsa -keyout 127.0.0.1.key -x509 -out 127.0.0.1.crt Generating a 2048 bit RSA private key ...................................................... .................... writing new private key to '127.0.0.1.key' ----- pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f server.err; echo greeting | ./netcat-regress -c -C 127.0.0.1.crt -K 127.0.0.1.key -n -v -l 127.0.0.1 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Listening on 127.0.0.1 26830 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port rm -f client.err; echo command | ./netcat-regress -c -R 127.0.0.1.crt -n -v 127.0.0.1 `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'Connection to .* succeeded' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection received on 127.0.0.1 33228 Connection to 127.0.0.1 26830 port [tcp/*] succeeded! let timeout=`date +%s`+5; until grep -q 'Cert Hash:' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done TLS handshake negotiated TLSv1.3/TLS_AES_256_GCM_SHA384 with host 127.0.0.1 Peer name: 127.0.0.1 Subject: /L=OpenBSD/O=netcat-regress/OU=server/CN=127.0.0.1 Issuer: /L=OpenBSD/O=netcat-regress/OU=server/CN=127.0.0.1 Valid From: Wed Nov 13 11:51:54 2024 Valid Until: Fri Dec 13 11:51:54 2024 Cert Hash: SHA256:13d791c829d56072d9e7bc78e39e318416f82e2b3efbd1a81d6f9ff2a473ddf5 let timeout=`date +%s`+5; until grep -q 'greeting' client.out && grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep '^greeting$' client.out greeting grep '^command$' server.out command grep 'Listening on 127.0.0.1 ' server.err Listening on 127.0.0.1 26830 grep 'Connection received on 127.0.0.1 ' server.err Connection received on 127.0.0.1 33228 # XXX success message should be issued after TLS handshake grep 'Connection to 127.0.0.1 .* succeeded!' client.err Connection to 127.0.0.1 26830 port [tcp/*] succeeded! grep 'Subject: .*/OU=server/CN=127.0.0.1' client.err Subject: /L=OpenBSD/O=netcat-regress/OU=server/CN=127.0.0.1 grep 'Issuer: .*/OU=server/CN=127.0.0.1' client.err Issuer: /L=OpenBSD/O=netcat-regress/OU=server/CN=127.0.0.1 ==== run-tls6 ==== openssl req -batch -new -subj /L=OpenBSD/O=netcat-regress/OU=server/CN=::1/ -nodes -newkey rsa -keyout 1.key -x509 -out 1.crt Generating a 2048 bit RSA private key .............. .............................. writing new private key to '1.key' ----- pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f server.err; echo greeting | ./netcat-regress -c -C 1.crt -K 1.key -n -v -l ::1 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Listening on ::1 11121 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port rm -f client.err; echo command | ./netcat-regress -c -R 1.crt -n -v ::1 `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'Connection to .* succeeded' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection to ::1 11121 port [tcp/*] succeeded! Connection received on ::1 21878 let timeout=`date +%s`+5; until grep -q 'Cert Hash:' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done TLS handshake negotiated TLSv1.3/TLS_AES_256_GCM_SHA384 with host ::1 Peer name: ::1 Subject: /L=OpenBSD/O=netcat-regress/OU=server/CN=::1 Issuer: /L=OpenBSD/O=netcat-regress/OU=server/CN=::1 Valid From: Wed Nov 13 11:51:55 2024 Valid Until: Fri Dec 13 11:51:55 2024 Cert Hash: SHA256:b4aa4c1e178485b7081d98b8d75c1074da059bc54883d02b093359b7933e9e59 let timeout=`date +%s`+5; until grep -q 'greeting' client.out && grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep '^greeting$' client.out greeting grep '^command$' server.out command grep 'Listening on ::1 ' server.err Listening on ::1 11121 grep 'Connection received on ::1 ' server.err Connection received on ::1 21878 grep 'Connection to ::1 .* succeeded!' client.err Connection to ::1 11121 port [tcp/*] succeeded! grep 'Subject: .*/OU=server/CN=::1' client.err Subject: /L=OpenBSD/O=netcat-regress/OU=server/CN=::1 grep 'Issuer: .*/OU=server/CN=::1' client.err Issuer: /L=OpenBSD/O=netcat-regress/OU=server/CN=::1 ==== run-tls-localhost ==== openssl req -batch -new -subj /L=OpenBSD/O=netcat-regress/OU=ca/CN=root/ -nodes -newkey rsa -keyout ca.key -x509 -out ca.crt Generating a 2048 bit RSA private key ....................................................... ................................ writing new private key to 'ca.key' ----- openssl req -batch -new -subj /L=OpenBSD/O=netcat-regress/OU=server/CN=localhost/ -nodes -newkey rsa -keyout server.key -out server.req Generating a 2048 bit RSA private key .............................................................................................................................................................................................................................................. ............................................... writing new private key to 'server.key' ----- openssl x509 -CAcreateserial -CAkey ca.key -CA ca.crt -req -in server.req -out server.crt Signature ok subject=/L=OpenBSD/O=netcat-regress/OU=server/CN=localhost pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f server.err; echo greeting | ./netcat-regress -c -C server.crt -K server.key -v -l localhost 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Listening on localhost 21439 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port rm -f client.err; echo command | ./netcat-regress -c -R ca.crt -v localhost `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'Connection to .* succeeded' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection received on localhost 20484 Connection to localhost (127.0.0.1) 21439 port [tcp/*] succeeded! let timeout=`date +%s`+5; until grep -q 'Cert Hash:' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done TLS handshake negotiated TLSv1.3/TLS_AES_256_GCM_SHA384 with host localhost Peer name: localhost Subject: /L=OpenBSD/O=netcat-regress/OU=server/CN=localhost Issuer: /L=OpenBSD/O=netcat-regress/OU=ca/CN=root Valid From: Wed Nov 13 11:51:59 2024 Valid Until: Fri Dec 13 11:51:59 2024 Cert Hash: SHA256:c4dc5ed8a8f37195271148930e98599d99dfa871fe7e6c67581e0873f4bd4a4f let timeout=`date +%s`+5; until grep -q 'greeting' client.out && grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep '^greeting$' client.out greeting grep '^command$' server.out command grep 'Listening on localhost ' server.err Listening on localhost 21439 grep 'Connection received on localhost ' server.err Connection received on localhost 20484 grep 'Connection to localhost .* succeeded!' client.err Connection to localhost (127.0.0.1) 21439 port [tcp/*] succeeded! grep 'Subject: .*/OU=server/CN=localhost' client.err Subject: /L=OpenBSD/O=netcat-regress/OU=server/CN=localhost grep 'Issuer: .*/OU=ca/CN=root' client.err Issuer: /L=OpenBSD/O=netcat-regress/OU=ca/CN=root ==== run-tls-bad-ca ==== openssl req -batch -new -subj /L=OpenBSD/O=netcat-regress/OU=ca/CN=root/ -nodes -newkey rsa -keyout fake-ca.key -x509 -out fake-ca.crt Generating a 2048 bit RSA private key .. ....... writing new private key to 'fake-ca.key' ----- pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f server.err; echo greeting | ./netcat-regress -c -C server.crt -K server.key -v -l localhost 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Listening on localhost 42061 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port # the client uses the wrong root ca to verify the server cert ! ./netcat-regress -c -R fake-ca.crt -v localhost `cat server.port` >client.out 2>client.err Connection received on localhost 32895 let timeout=`date +%s`+5; until grep -q 'Connection to .* succeeded' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done netcat-regress: tls handshake failed (handshake failed: error:02FFF020:system library:func(4095):Broken pipe) grep 'Listening on localhost ' server.err Listening on localhost 42061 grep 'Connection received on localhost ' server.err Connection received on localhost 32895 grep 'certificate verification failed' client.err netcat-regress: tls handshake failed (certificate verification failed: certificate signature failure) ! grep 'greeting' client.out ! grep 'command' server.out ==== run-tls-name ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f server.err; echo greeting | ./netcat-regress -c -C server.crt -K server.key -n -v -l 127.0.0.1 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Listening on 127.0.0.1 16947 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port rm -f client.err; echo command | ./netcat-regress -c -e localhost -R ca.crt -n -v 127.0.0.1 `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'Connection to .* succeeded' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection to 127.0.0.1 16947 port [tcp/*] succeeded! Connection received on 127.0.0.1 15581 let timeout=`date +%s`+5; until grep -q 'Cert Hash:' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done TLS handshake negotiated TLSv1.3/TLS_AES_256_GCM_SHA384 with host 127.0.0.1 Peer name: localhost Subject: /L=OpenBSD/O=netcat-regress/OU=server/CN=localhost Issuer: /L=OpenBSD/O=netcat-regress/OU=ca/CN=root Valid From: Wed Nov 13 11:51:59 2024 Valid Until: Fri Dec 13 11:51:59 2024 Cert Hash: SHA256:c4dc5ed8a8f37195271148930e98599d99dfa871fe7e6c67581e0873f4bd4a4f let timeout=`date +%s`+5; until grep -q 'greeting' client.out && grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep '^greeting$' client.out greeting grep '^command$' server.out command grep 'Listening on 127.0.0.1 ' server.err Listening on 127.0.0.1 16947 grep 'Connection received on 127.0.0.1 ' server.err Connection received on 127.0.0.1 15581 grep 'Connection to 127.0.0.1 .* succeeded!' client.err Connection to 127.0.0.1 16947 port [tcp/*] succeeded! grep 'Subject: .*/OU=server/CN=localhost' client.err Subject: /L=OpenBSD/O=netcat-regress/OU=server/CN=localhost grep 'Issuer: .*/OU=ca/CN=root' client.err Issuer: /L=OpenBSD/O=netcat-regress/OU=ca/CN=root ==== run-tls-bad-name ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f server.err; echo greeting | ./netcat-regress -c -C server.crt -K server.key -n -v -l 127.0.0.1 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Listening on 127.0.0.1 14548 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port # the common name in server.crt is localhost, not 127.0.0.1 ! ./netcat-regress -c -e 127.0.0.1 -R ca.crt -n -v 127.0.0.1 `cat server.port` >client.out 2>client.err Connection received on 127.0.0.1 41837 let timeout=`date +%s`+5; until grep -q 'Connection to .* succeeded' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep 'Listening on 127.0.0.1 ' server.err Listening on 127.0.0.1 14548 grep 'Connection received on 127.0.0.1 ' server.err Connection received on 127.0.0.1 41837 grep 'Connection to 127.0.0.1 .* succeeded!' client.err Connection to 127.0.0.1 14548 port [tcp/*] succeeded! grep "name \`127.0.0.1\' not present in server certificate" client.err netcat-regress: tls handshake failed (name `127.0.0.1' not present in server certificate) ! grep 'greeting' client.out ! grep 'command' server.out ==== run-tls-hash ==== openssl x509 -in server.crt -outform der | sha256 | sed s/^/SHA256:/ >server.hash pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f server.err; echo greeting | ./netcat-regress -c -C server.crt -K server.key -v -l localhost 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Listening on localhost 24947 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port # check that the server presents certificate with correct hash rm -f client.err; echo command | ./netcat-regress -c -H `cat server.hash` -R ca.crt -v localhost `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'Connection to .* succeeded' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection to localhost (127.0.0.1) 24947 port [tcp/*] succeeded! Connection received on localhost 16299 let timeout=`date +%s`+5; until grep -q 'Cert Hash:' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done TLS handshake negotiated TLSv1.3/TLS_AES_256_GCM_SHA384 with host localhost Peer name: localhost Subject: /L=OpenBSD/O=netcat-regress/OU=server/CN=localhost Issuer: /L=OpenBSD/O=netcat-regress/OU=ca/CN=root Valid From: Wed Nov 13 11:51:59 2024 Valid Until: Fri Dec 13 11:51:59 2024 Cert Hash: SHA256:c4dc5ed8a8f37195271148930e98599d99dfa871fe7e6c67581e0873f4bd4a4f let timeout=`date +%s`+5; until grep -q 'greeting' client.out && grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep '^greeting$' client.out greeting grep '^command$' server.out command grep 'Listening on localhost ' server.err Listening on localhost 24947 grep 'Connection received on localhost ' server.err Connection received on localhost 16299 grep 'Connection to localhost .* succeeded!' client.err Connection to localhost (127.0.0.1) 24947 port [tcp/*] succeeded! grep 'Subject: .*/OU=server/CN=localhost' client.err Subject: /L=OpenBSD/O=netcat-regress/OU=server/CN=localhost grep 'Issuer: .*/OU=ca/CN=root' client.err Issuer: /L=OpenBSD/O=netcat-regress/OU=ca/CN=root grep 'Cert Hash: SHA256:' client.err Cert Hash: SHA256:c4dc5ed8a8f37195271148930e98599d99dfa871fe7e6c67581e0873f4bd4a4f ==== run-tls-bad-hash ==== openssl x509 -in ca.crt -outform der | sha256 | sed s/^/SHA256:/ >ca.hash pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f server.err; echo greeting | ./netcat-regress -c -C server.crt -K server.key -v -l localhost 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Listening on localhost 19592 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port # server presents certificate with server.hash, ca.hash is wrong ! ./netcat-regress -c -H `cat ca.hash` -R ca.crt -v localhost `cat server.port` >client.out 2>client.err Connection received on localhost 26879 netcat-regress: let timeout=`date +%s`+5; until grep -q 'Connection to .* succeeded' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done tls read failed (read failed: error:02FFF036:system library:func(4095):Connection reset by peer) let timeout=`date +%s`+5; until grep -q 'Cert Hash:' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep 'Listening on localhost ' server.err Listening on localhost 19592 grep 'Connection received on localhost ' server.err Connection received on localhost 26879 grep 'Connection to localhost .* succeeded!' client.err Connection to localhost (127.0.0.1) 19592 port [tcp/*] succeeded! grep 'peer certificate is not SHA256:' client.err netcat-regress: peer certificate is not SHA256:92700e354927629092370c2992c0ff5070ab51dd2504a321c0077d02d5f6475d ! grep 'greeting' client.out ! grep 'command' server.out ==== run-tls-client ==== openssl req -batch -new -subj /L=OpenBSD/O=netcat-regress/OU=client/CN=localhost/ -nodes -newkey rsa -keyout client.key -out client.req Generating a 2048 bit RSA private key ..................................................................................................................................................................... .......................................... writing new private key to 'client.key' ----- openssl x509 -CAcreateserial -CAkey ca.key -CA ca.crt -req -in client.req -out client.crt Signature ok subject=/L=OpenBSD/O=netcat-regress/OU=client/CN=localhost pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress # use client certificate and validate at server rm -f server.err; echo greeting | ./netcat-regress -c -R ca.crt -C server.crt -K server.key -v -l localhost 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Listening on localhost 5848 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port rm -f client.err; echo command | ./netcat-regress -c -R ca.crt -C client.crt -K client.key -v localhost `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'Connection to .* succeeded' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection to localhostConnection received on localhost 38121 (127.0.0.1) 5848 port [tcp/*] succeeded! let timeout=`date +%s`+5; until grep -q 'Cert Hash:' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done TLS handshake negotiated TLSv1.3/TLS_AES_256_GCM_SHA384 with host localhost Peer name: localhost Subject: /L=OpenBSD/O=netcat-regress/OU=client/CN=localhost Issuer: /L=OpenBSD/O=netcat-regress/OU=ca/CN=root Valid From: Wed Nov 13 11:52:08 2024 Valid Until: Fri Dec 13 11:52:08 2024 TLS handshake negotiated TLSv1.3/TLS_AES_256_GCM_SHA384 with host localhost Peer name: localhost Subject: /L=OpenBSD/O=netcat-regress/OU=server/CN=localhost Issuer: /L=OpenBSD/O=netcat-regress/OU=ca/CN=root Valid From: Wed Nov 13 11:51:59 2024 Valid Until: Fri Dec 13 11:51:59 2024 Cert Hash: SHA256:c4dc5ed8a8f37195271148930e98599d99dfa871fe7e6c67581e0873f4bd4a4f Cert Hash: SHA256:7e68be87b292f37e87f4433d8e8d24c3792a8721def34c5f22be33184f5526c1 let timeout=`date +%s`+5; until grep -q 'greeting' client.out && grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep '^greeting$' client.out greeting grep '^command$' server.out command grep 'Listening on localhost ' server.err Listening on localhost 5848 grep 'Connection received on localhost ' server.err Connection received on localhost 38121 grep 'Connection to localhost .* succeeded!' client.err Connection to localhost (127.0.0.1) 5848 port [tcp/*] succeeded! grep 'Subject: .*/OU=server/CN=localhost' client.err Subject: /L=OpenBSD/O=netcat-regress/OU=server/CN=localhost grep 'Issuer: .*/OU=ca/CN=root' client.err Issuer: /L=OpenBSD/O=netcat-regress/OU=ca/CN=root grep 'Subject: .*/OU=client/CN=localhost' server.err Subject: /L=OpenBSD/O=netcat-regress/OU=client/CN=localhost grep 'Issuer: .*/OU=ca/CN=root' server.err Issuer: /L=OpenBSD/O=netcat-regress/OU=ca/CN=root ==== run-tls-bad-client ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress # require client certificate at server rm -f server.err; echo greeting | ./netcat-regress -c -T clientcert -R ca.crt -C server.crt -K server.key -v -l localhost 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Listening on localhost 43252 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port # client does not provide certificate rm -f client.err; echo command | ./netcat-regress -c -R ca.crt -v localhost `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'Connection to .* succeeded' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection received on localhost 35787 Connection to localhost (127.0.0.1) 43252 port [tcp/*] succeeded! let timeout=`date +%s`+5; until grep -q 'Cert Hash:' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done TLS handshake negotiated TLSv1.3/TLS_AES_256_GCM_SHA384 with host localhost Peer name: localhost Subject: /L=OpenBSD/O=netcat-regress/OU=server/CN=localhost Issuer: /L=OpenBSD/O=netcat-regress/OU=ca/CN=root Valid From: Wed Nov 13 11:51:59 2024 Valid Until: Fri Dec 13 11:51:59 2024 Cert Hash: SHA256:c4dc5ed8a8f37195271148930e98599d99dfa871fe7e6c67581e0873f4bd4a4f netcat-regress: No client certificate provided grep 'Listening on localhost ' server.err Listening on localhost 43252 grep 'Connection received on localhost ' server.err Connection received on localhost 35787 grep 'Connection to localhost .* succeeded!' client.err Connection to localhost (127.0.0.1) 43252 port [tcp/*] succeeded! grep 'Subject: .*/OU=server/CN=localhost' client.err Subject: /L=OpenBSD/O=netcat-regress/OU=server/CN=localhost grep 'Issuer: .*/OU=ca/CN=root' client.err Issuer: /L=OpenBSD/O=netcat-regress/OU=ca/CN=root grep 'No client certificate provided' server.err netcat-regress: No client certificate provided ! grep 'greeting' client.out ! grep 'command' server.out ==== run-tls-client-bad-ca ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress # the server uses the wrong root ca to verify the client cert rm -f server.err; echo greeting | ./netcat-regress -c -R fake-ca.crt -C server.crt -K server.key -v -l localhost 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Listening on localhost 41079 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port ! ./netcat-regress -c -R ca.crt -C client.crt -K client.key -v localhost `cat server.port` >client.out 2>client.err Connection received on localhost 21627 netcat-regress: tls handshake failed (handshake failed: error:04FFF06A:rsa routines:CRYPTO_internal:block type is not 01) let timeout=`date +%s`+5; until grep -q 'Connection to .* succeeded' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done nc localhost `cat server.port` 2>/dev/null || : grep 'Listening on localhost ' server.err Listening on localhost 41079 grep 'Connection received on localhost ' server.err Connection received on localhost 21627 grep 'Connection to localhost .* succeeded!' client.err Connection to localhost (127.0.0.1) 41079 port [tcp/*] succeeded! # XXX no specific error message for bogus ca egrep 'CRYPTO_internal:(block type is not 01|data too large for modulus)' server.err netcat-regress: tls handshake failed (handshake failed: error:04FFF06A:rsa routines:CRYPTO_internal:block type is not 01) ! grep 'greeting' client.out ! grep 'command' server.out ==== run-tls-client-name ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress # check client certificate name at server rm -f server.err; echo greeting | ./netcat-regress -c -e localhost -R ca.crt -C server.crt -K server.key -n -v -l 127.0.0.1 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Listening on 127.0.0.1 27961 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port rm -f client.err; echo command | ./netcat-regress -4 -c -R ca.crt -C client.crt -K client.key -v localhost `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'Connection to .* succeeded' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection received on 127.0.0.1 7455 Connection to localhost (127.0.0.1) 27961 port [tcp/*] succeeded! let timeout=`date +%s`+5; until grep -q 'Cert Hash:' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done TLS handshake negotiated TLSv1.3/TLS_AES_256_GCM_SHA384 with host localhost Peer name: localhost Subject: /L=OpenBSD/O=netcat-regress/OU=server/CN=localhost Issuer: /L=OpenBSD/O=netcat-regress/OU=ca/CN=root Valid From: Wed Nov 13 11:51:59 2024 Valid Until: Fri Dec 13 11:51:59 2024 Cert Hash: SHA256:c4dc5ed8a8f37195271148930e98599d99dfa871fe7e6c67581e0873f4bd4a4f TLS handshake negotiated TLSv1.3/TLS_AES_256_GCM_SHA384 with host 127.0.0.1 Peer name: localhost Subject: /L=OpenBSD/O=netcat-regress/OU=client/CN=localhost let timeout=`date +%s`+5; until grep -q 'greeting' client.out && grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Issuer: /L=OpenBSD/O=netcat-regress/OU=ca/CN=root Valid From: Wed Nov 13 11:52:08 2024 Valid Until: Fri Dec 13 11:52:08 2024 Cert Hash: SHA256:7e68be87b292f37e87f4433d8e8d24c3792a8721def34c5f22be33184f5526c1 grep '^greeting$' client.out greeting grep '^command$' server.out command grep 'Listening on 127.0.0.1 ' server.err Listening on 127.0.0.1 27961 grep 'Connection received on 127.0.0.1 ' server.err Connection received on 127.0.0.1 7455 grep 'Connection to localhost .* succeeded!' client.err Connection to localhost (127.0.0.1) 27961 port [tcp/*] succeeded! grep 'Subject: .*/OU=server/CN=localhost' client.err Subject: /L=OpenBSD/O=netcat-regress/OU=server/CN=localhost grep 'Issuer: .*/OU=ca/CN=root' client.err Issuer: /L=OpenBSD/O=netcat-regress/OU=ca/CN=root grep 'Subject: .*/OU=client/CN=localhost' server.err Subject: /L=OpenBSD/O=netcat-regress/OU=client/CN=localhost grep 'Issuer: .*/OU=ca/CN=root' server.err Issuer: /L=OpenBSD/O=netcat-regress/OU=ca/CN=root ==== run-tls-client-bad-name ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress # client certificate is for localhost, check with 127.0.0.1 should fail rm -f server.err; echo greeting | ./netcat-regress -c -e 127.0.0.1 -R ca.crt -C server.crt -K server.key -n -v -l 127.0.0.1 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Listening on 127.0.0.1 11683 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port # client does not see any problem, TLS handshake works, wait for exit rm -f client.err; echo command | ./netcat-regress -4 -c -R ca.crt -C client.crt -K client.key -v localhost `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'Connection to .* succeeded' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection to localhost (127.0.0.1) 11683 port [tcp/*] succeeded! Connection received on 127.0.0.1 10091 let timeout=`date +%s`+5; until grep -q 'Cert Hash:' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done TLS handshake negotiated TLSv1.3/TLS_AES_256_GCM_SHA384 with host localhost Peer name: localhost TLS handshake negotiated TLSv1.3/TLS_AES_256_GCM_SHA384 with host 127.0.0.1 Peer name: 127.0.0.1 Subject: /L=OpenBSD/O=netcat-regress/OU=client/CN=localhost Issuer: /L=OpenBSD/O=netcat-regress/OU=ca/CN=root Valid From: Wed Nov 13 11:52:08 2024 Valid Until: Fri Dec 13 11:52:08 2024 Cert Hash: SHA256:7e68be87b292f37e87f4433d8e8d24c3792a8721def34c5f22be33184f5526c1 Subject: /L=OpenBSD/O=netcat-regress/OU=server/CN=localhost netcat-regress: name (127.0.0.1) not found in client certIssuer: /L=OpenBSD/O=netcat-regress/OU=ca/CN=root Valid From: Wed Nov 13 11:51:59 2024 Valid Until: Fri Dec 13 11:51:59 2024 Cert Hash: SHA256:c4dc5ed8a8f37195271148930e98599d99dfa871fe7e6c67581e0873f4bd4a4f grep 'Listening on 127.0.0.1 ' server.err Listening on 127.0.0.1 11683 grep 'Connection received on 127.0.0.1 ' server.err Connection received on 127.0.0.1 10091 grep 'Connection to localhost .* succeeded!' client.err Connection to localhost (127.0.0.1) 11683 port [tcp/*] succeeded! grep 'Subject: .*/OU=server/CN=localhost' client.err Subject: /L=OpenBSD/O=netcat-regress/OU=server/CN=localhost grep 'Issuer: .*/OU=ca/CN=root' client.err Issuer: /L=OpenBSD/O=netcat-regress/OU=ca/CN=root grep 'Subject: .*/OU=client/CN=localhost' server.err Subject: /L=OpenBSD/O=netcat-regress/OU=client/CN=localhost grep 'Issuer: .*/OU=ca/CN=root' server.err Issuer: /L=OpenBSD/O=netcat-regress/OU=ca/CN=root grep 'name (127.0.0.1) not found in client cert' server.err netcat-regress: name (127.0.0.1) not found in client cert ! grep 'greeting' client.out ! grep 'command' server.out ==== run-tls-client-hash ==== openssl x509 -in client.crt -outform der | sha256 | sed s/^/SHA256:/ >client.hash pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress # check client certificate hash at server rm -f server.err; echo greeting | ./netcat-regress -c -H `cat client.hash` -R ca.crt -C server.crt -K server.key -v -l localhost 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Listening on localhost 25825 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port rm -f client.err; echo command | ./netcat-regress -c -R ca.crt -C client.crt -K client.key -v localhost `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'Connection to .* succeeded' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection received on localhost 28474 Connection to localhost (127.0.0.1) 25825 port [tcp/*] succeeded! let timeout=`date +%s`+5; until grep -q 'Cert Hash:' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done TLS handshake negotiated TLSv1.3/TLS_AES_256_GCM_SHA384 with host localhost Peer name: localhost Subject: /L=OpenBSD/O=netcat-regress/OU=server/CN=localhost Issuer: /L=OpenBSD/O=netcat-regress/OU=ca/CN=root Valid From: Wed Nov 13 11:51:59 2024 Valid Until: Fri Dec 13 11:51:59 2024 Cert Hash: SHA256:c4dc5ed8a8f37195271148930e98599d99dfa871fe7e6c67581e0873f4bd4a4f TLS handshake negotiated TLSv1.3/TLS_AES_256_GCM_SHA384 with host localhost Peer name: localhost Subject: /L=OpenBSD/O=netcat-regress/OU=client/CN=localhost Issuer: /L=OpenBSD/O=netcat-regress/OU=ca/CN=root Valid From: Wed Nov 13 11:52:08 2024 Valid Until: Fri Dec 13 11:52:08 2024 Cert Hash: SHA256:7e68be87b292f37e87f4433d8e8d24c3792a8721def34c5f22be33184f5526c1 let timeout=`date +%s`+5; until grep -q 'greeting' client.out && grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep '^greeting$' client.out greeting grep '^command$' server.out command grep 'Listening on localhost ' server.err Listening on localhost 25825 grep 'Connection received on localhost ' server.err Connection received on localhost 28474 grep 'Connection to localhost .* succeeded!' client.err Connection to localhost (127.0.0.1) 25825 port [tcp/*] succeeded! grep 'Subject: .*/OU=server/CN=localhost' client.err Subject: /L=OpenBSD/O=netcat-regress/OU=server/CN=localhost grep 'Issuer: .*/OU=ca/CN=root' client.err Issuer: /L=OpenBSD/O=netcat-regress/OU=ca/CN=root grep 'Subject: .*/OU=client/CN=localhost' server.err Subject: /L=OpenBSD/O=netcat-regress/OU=client/CN=localhost grep 'Issuer: .*/OU=ca/CN=root' server.err Issuer: /L=OpenBSD/O=netcat-regress/OU=ca/CN=root ==== run-tls-client-bad-hash ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress # client presents certificate with client.hash, ca.hash is wrong rm -f server.err; echo greeting | ./netcat-regress -c -H `cat ca.hash` -R ca.crt -C server.crt -K server.key -v -l localhost 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Listening on localhost 15024 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port # client does not see any problem, TLS handshake works, wait for exit rm -f client.err; echo command | ./netcat-regress -c -R ca.crt -C client.crt -K client.key -v localhost `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'Connection to .* succeeded' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection received on localhost 22873 Connection to localhost (127.0.0.1) 15024 port [tcp/*] succeeded! let timeout=`date +%s`+5; until grep -q 'Cert Hash:' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done TLS handshake negotiated TLSv1.3/TLS_AES_256_GCM_SHA384 with host localhost Peer name: localhost Subject: /L=OpenBSD/O=netcat-regress/OU=server/CN=localhost Issuer: /L=OpenBSD/O=netcat-regress/OU=ca/CN=root Valid From: Wed Nov 13 11:51:59 2024 Valid Until: Fri Dec 13 11:51:59 2024 Cert Hash: SHA256:c4dc5ed8a8f37195271148930e98599d99dfa871fe7e6c67581e0873f4bd4a4f nc localhost `cat server.port` 2>/dev/null || : TLS handshake negotiated TLSv1.3/TLS_AES_256_GCM_SHA384 with host localhost Peer name: localhost Subject: /L=OpenBSD/O=netcat-regress/OU=client/CN=localhost Issuer: /L=OpenBSD/O=netcat-regress/OU=ca/CN=root Valid From: Wed Nov 13 11:52:08 2024 Valid Until: Fri Dec 13 11:52:08 2024 Cert Hash: SHA256:7e68be87b292f37e87f4433d8e8d24c3792a8721def34c5f22be33184f5526c1 netcat-regress: peer certificate is not SHA256:92700e354927629092370c2992c0ff5070ab51dd2504a321c0077d02d5f6475d grep 'Listening on localhost ' server.err Listening on localhost 15024 grep 'Connection received on localhost ' server.err Connection received on localhost 22873 grep 'Connection to localhost .* succeeded!' client.err Connection to localhost (127.0.0.1) 15024 port [tcp/*] succeeded! grep 'Subject: .*/OU=server/CN=localhost' client.err Subject: /L=OpenBSD/O=netcat-regress/OU=server/CN=localhost grep 'Issuer: .*/OU=ca/CN=root' client.err Issuer: /L=OpenBSD/O=netcat-regress/OU=ca/CN=root grep 'Subject: .*/OU=client/CN=localhost' server.err Subject: /L=OpenBSD/O=netcat-regress/OU=client/CN=localhost grep 'Issuer: .*/OU=ca/CN=root' server.err Issuer: /L=OpenBSD/O=netcat-regress/OU=ca/CN=root grep 'peer certificate is not SHA256:' server.err netcat-regress: peer certificate is not SHA256:92700e354927629092370c2992c0ff5070ab51dd2504a321c0077d02d5f6475d ! grep 'greeting' client.out ! grep 'command' server.out ==== run-tls-client-no-hash ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress # check client certificate hash at server if available rm -f server.err; echo greeting | ./netcat-regress -c -H `cat client.hash` -R ca.crt -C server.crt -K server.key -v -l localhost 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Listening on localhost 8567 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port # client provides no certificate rm -f client.err; echo command | ./netcat-regress -c -R ca.crt -v localhost `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'Connection to .* succeeded' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection to localhost (127.0.0.1) 8567 port [tcp/*] succeeded! Connection received on localhost 3337 let timeout=`date +%s`+5; until grep -q 'Cert Hash:' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done TLS handshake negotiated TLSv1.3/TLS_AES_256_GCM_SHA384 with host localhost Peer name: localhost Subject: /L=OpenBSD/O=netcat-regress/OU=server/CN=localhost Issuer: /L=OpenBSD/O=netcat-regress/OU=ca/CN=root Valid From: Wed Nov 13 11:51:59 2024 Valid Until: Fri Dec 13 11:51:59 2024 Cert Hash: SHA256:c4dc5ed8a8f37195271148930e98599d99dfa871fe7e6c67581e0873f4bd4a4f let timeout=`date +%s`+5; until grep -q 'greeting' client.out && grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done # client certificate and hash is optional, transfer is successful grep '^greeting$' client.out greeting grep '^command$' server.out command grep 'Listening on localhost ' server.err Listening on localhost 8567 grep 'Connection received on localhost ' server.err Connection received on localhost 3337 grep 'Connection to localhost .* succeeded!' client.err Connection to localhost (127.0.0.1) 8567 port [tcp/*] succeeded! grep 'Subject: .*/OU=server/CN=localhost' client.err Subject: /L=OpenBSD/O=netcat-regress/OU=server/CN=localhost grep 'Issuer: .*/OU=ca/CN=root' client.err Issuer: /L=OpenBSD/O=netcat-regress/OU=ca/CN=root # non existing hash is not checked ! grep 'Cert Hash: SHA256:' server.err ==== run-tls-sleep ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f server.err; echo greeting | ./netcat-regress -c -C 127.0.0.1.crt -K 127.0.0.1.key -n -v -l 127.0.0.1 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Listening on 127.0.0.1 13916 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port rm -f client.err; echo command | ./netcat-regress -c -R 127.0.0.1.crt -n -v 127.0.0.1 `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'Connection to .* succeeded' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep: client.err: No such file or directory Connection received on 127.0.0.1 12502 Connection to 127.0.0.1 13916 port [tcp/*] succeeded! let timeout=`date +%s`+5; until grep -q 'Cert Hash:' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done TLS handshake negotiated TLSv1.3/TLS_AES_256_GCM_SHA384 with host 127.0.0.1 Peer name: 127.0.0.1 Subject: /L=OpenBSD/O=netcat-regress/OU=server/CN=127.0.0.1 Issuer: /L=OpenBSD/O=netcat-regress/OU=server/CN=127.0.0.1 Valid From: Wed Nov 13 11:51:54 2024 Valid Until: Fri Dec 13 11:51:54 2024 Cert Hash: SHA256:13d791c829d56072d9e7bc78e39e318416f82e2b3efbd1a81d6f9ff2a473ddf5 let timeout=`date +%s`+5; until grep -q 'greeting' client.out && grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep '^greeting$' client.out greeting grep '^command$' server.out command grep 'Listening on 127.0.0.1 ' server.err Listening on 127.0.0.1 13916 grep 'Connection received on 127.0.0.1 ' server.err Connection received on 127.0.0.1 12502 # XXX success message should be issued after TLS handshake grep 'Connection to 127.0.0.1 .* succeeded!' client.err Connection to 127.0.0.1 13916 port [tcp/*] succeeded! grep 'Subject: .*/OU=server/CN=127.0.0.1' client.err Subject: /L=OpenBSD/O=netcat-regress/OU=server/CN=127.0.0.1 grep 'Issuer: .*/OU=server/CN=127.0.0.1' client.err Issuer: /L=OpenBSD/O=netcat-regress/OU=server/CN=127.0.0.1 # netcat waits for the other side to terminate, check it is sleeping let timeout=`date +%s`+5; while ps -xww -o comm,stat | grep -q 'netcat-regress .*R'; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done ps -xww -o comm,stat,args | grep '^netcat-regress .*S.* -v -l 127' netcat-regress Sp ./netcat-regress -c -C 127.0.0.1.crt -K 127.0.0.1.key -n -v -l 127.0.0.1 0 ps -xww -o comm,stat,args | grep '^netcat-regress .*S.* -v 127' netcat-regress Sp ./netcat-regress -c -R 127.0.0.1.crt -n -v 127.0.0.1 13916 ==== run-tls-keep ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f server.err; echo greeting | ./netcat-regress -k -c -C 127.0.0.1.crt -K 127.0.0.1.key -n -v -l 127.0.0.1 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Listening on 127.0.0.1 48756 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port rm -f client.err; echo command | ./netcat-regress -c -R 127.0.0.1.crt -n -v 127.0.0.1 `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'Connection to .* succeeded' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection to 127.0.0.1 48756 port [tcp/*] succeeded! Connection received on 127.0.0.1 46550 let timeout=`date +%s`+5; until grep -q 'Cert Hash:' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done TLS handshake negotiated TLSv1.3/TLS_AES_256_GCM_SHA384 with host 127.0.0.1 Peer name: 127.0.0.1 Subject: /L=OpenBSD/O=netcat-regress/OU=server/CN=127.0.0.1 Issuer: /L=OpenBSD/O=netcat-regress/OU=server/CN=127.0.0.1 Valid From: Wed Nov 13 11:51:54 2024 Valid Until: Fri Dec 13 11:51:54 2024 Cert Hash: SHA256:13d791c829d56072d9e7bc78e39e318416f82e2b3efbd1a81d6f9ff2a473ddf5 let timeout=`date +%s`+5; until grep -q 'greeting' client.out && grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep '^greeting$' client.out greeting grep '^command$' server.out command grep 'Listening on 127.0.0.1 ' server.err Listening on 127.0.0.1 48756 grep 'Connection received on 127.0.0.1 ' server.err Connection received on 127.0.0.1 46550 grep 'Connection to 127.0.0.1 .* succeeded!' client.err Connection to 127.0.0.1 48756 port [tcp/*] succeeded! grep 'Subject: .*/OU=server/CN=127.0.0.1' client.err Subject: /L=OpenBSD/O=netcat-regress/OU=server/CN=127.0.0.1 grep 'Issuer: .*/OU=server/CN=127.0.0.1' client.err Issuer: /L=OpenBSD/O=netcat-regress/OU=server/CN=127.0.0.1 # kill client and reconnect with a new one :> server.err pkill -l -f "^./netcat-regress .* 127.0.0.1 `cat server.port`$" 65462 netcat-regress Listening on 127.0.0.1 46832 rm -f client.{out,err} :> server.out # server closes the listen socket and binds a new one with new port let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port rm -f client.err; echo command | ./netcat-regress -c -R 127.0.0.1.crt -n -v 127.0.0.1 `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'Connection to .* succeeded' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection received on 127.0.0.1 10370 Connection to 127.0.0.1 46832 port [tcp/*] succeeded! let timeout=`date +%s`+5; until grep -q 'Cert Hash:' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done TLS handshake negotiated TLSv1.3/TLS_AES_256_GCM_SHA384 with host 127.0.0.1 Peer name: 127.0.0.1 Subject: /L=OpenBSD/O=netcat-regress/OU=server/CN=127.0.0.1 Issuer: /L=OpenBSD/O=netcat-regress/OU=server/CN=127.0.0.1 Valid From: Wed Nov 13 11:51:54 2024 Valid Until: Fri Dec 13 11:51:54 2024 Cert Hash: SHA256:13d791c829d56072d9e7bc78e39e318416f82e2b3efbd1a81d6f9ff2a473ddf5 # server sends only one greeting, do not wait for a second one let timeout=`date +%s`+5; until grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done ! grep 'greeting' client.out # truncation of log results in NUL bytes, do not match ^ grep 'command$' server.out Binary file server.out matches grep 'Listening on 127.0.0.1 ' server.err Binary file server.err matches grep 'Connection received on 127.0.0.1 ' server.err Binary file server.err matches grep 'Connection to 127.0.0.1 .* succeeded!' client.err Connection to 127.0.0.1 46832 port [tcp/*] succeeded! grep 'Subject: .*/OU=server/CN=127.0.0.1' client.err Subject: /L=OpenBSD/O=netcat-regress/OU=server/CN=127.0.0.1 grep 'Issuer: .*/OU=server/CN=127.0.0.1' client.err Issuer: /L=OpenBSD/O=netcat-regress/OU=server/CN=127.0.0.1 ==== run-udp ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f server.err; echo greeting | ./netcat-regress -u -n -v -l 127.0.0.1 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Bound on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Bound on 127.0.0.1 32501 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port # the -v option would cause udptest() to write additional X rm -f client.err; echo command | ./netcat-regress -u -n 127.0.0.1 `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'greeting' client.out && grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection received on 127.0.0.1 6616 grep '^greeting$' client.out greeting grep '^command$' server.out command grep 'Bound on 127.0.0.1 ' server.err Bound on 127.0.0.1 32501 grep 'Connection received on 127.0.0.1 ' server.err Connection received on 127.0.0.1 6616 ==== run-udp6 ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f server.err; echo greeting | ./netcat-regress -u -n -v -l ::1 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Bound on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Bound on ::1 41688 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port # the -v option would cause udptest() to write additional X rm -f client.err; echo command | ./netcat-regress -u -n ::1 `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'greeting' client.out && grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection received on ::1 42951 grep '^greeting$' client.out greeting grep '^command$' server.out command grep 'Bound on ::1 ' server.err Bound on ::1 41688 grep 'Connection received on ::1 ' server.err Connection received on ::1 42951 ==== run-udp-probe ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f server.err; echo greeting | ./netcat-regress -u -n -v -l 127.0.0.1 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Bound on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Bound on 127.0.0.1 18924 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port rm -f client.err; echo command | ./netcat-regress -u -v -n 127.0.0.1 `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'greeting' client.out && grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection received on 127.0.0.1 46980 grep '^greeting$' client.out greeting grep '^command$' server.out command grep 'Bound on 127.0.0.1 ' server.err Bound on 127.0.0.1 18924 grep 'Connection received on 127.0.0.1 ' server.err Connection received on 127.0.0.1 46980 ==== run-udp-localhost ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f server.err; echo greeting | ./netcat-regress -u -4 -v -l localhost 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Bound on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Bound on localhost 35663 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port # the -v option would cause udptest() to write additional X rm -f client.err; echo command | ./netcat-regress -u -4 localhost `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'greeting' client.out && grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection received on localhost 48419 grep '^greeting$' client.out greeting grep '^command$' server.out command grep 'Bound on localhost ' server.err Bound on localhost 35663 grep 'Connection received on localhost ' server.err Connection received on localhost 48419 ==== run-udp6-localhost ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f server.err; echo greeting | ./netcat-regress -u -6 -v -l localhost 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Bound on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Bound on localhost 40736 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port # the -v option would cause udptest() to write additional X rm -f client.err; echo command | ./netcat-regress -u -6 localhost `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'greeting' client.out && grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection received on localhost 45952 grep '^greeting$' client.out greeting grep '^command$' server.out command grep 'Bound on localhost ' server.err Bound on localhost 40736 grep 'Connection received on localhost ' server.err Connection received on localhost 45952 ==== run-udp-keep ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f server.err; echo greeting | ./netcat-regress -k -u -n -v -l 127.0.0.1 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Bound on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Bound on 127.0.0.1 5459 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port # the -v option causes udptest() to write additional X rm -f client.err; echo command | ./netcat-regress -u -n -v 127.0.0.1 `cat server.port` 2>&1 >client.out | tee client.err & # server does not connect, nothing reaches the client let timeout=`date +%s`+5; until grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done ! grep 'greeting' client.out grep '^command$' server.out command grep 'Bound on 127.0.0.1 ' server.err Bound on 127.0.0.1 5459 # client does not connect ! grep 'Connection received on ' server.err # kill client and reconnect with a new one :> server.err pkill -l -f "^./netcat-regress .* 127.0.0.1 `cat server.port`$" 87877 netcat-regress rm -f client.{out,err} :> server.out rm -f client.err; echo command | ./netcat-regress -u -n -v 127.0.0.1 `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done ! grep 'greeting' client.out # truncation of log results in NUL bytes, do not match ^ grep 'command$' server.out Binary file server.out matches # server keeps socket and does not bind again ! grep 'Bound on ' server.err # client does not connect ! grep 'Connection received on ' server.err ==== run-udp-sleep ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f server.err; echo greeting | ./netcat-regress -u -n -v -l 127.0.0.1 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Bound on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Bound on 127.0.0.1 21721 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port # the -v option would cause udptest() to write additional X rm -f client.err; echo command | ./netcat-regress -u -n 127.0.0.1 `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'greeting' client.out && grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection received on 127.0.0.1 4697 grep '^greeting$' client.out greeting grep '^command$' server.out command grep 'Bound on 127.0.0.1 ' server.err Bound on 127.0.0.1 21721 grep 'Connection received on 127.0.0.1 ' server.err Connection received on 127.0.0.1 4697 # netcat waits for the other side to terminate, check it is sleeping let timeout=`date +%s`+5; while ps -xww -o comm,stat | grep -q 'netcat-regress .*R'; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done ps -xww -o comm,stat,args | grep '^netcat-regress .*S.* -v -l 127' netcat-regress Sp ./netcat-regress -u -n -v -l 127.0.0.1 0 ps -xww -o comm,stat,args | grep '^netcat-regress .*S.* -n 127' netcat-regress Sp ./netcat-regress -u -n 127.0.0.1 21721 ==== run-unix ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f server.sock rm -f server.err; echo greeting | ./netcat-regress -U -n -v -l server.sock 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Bound on server.sock Listening on server.sock rm -f client.err; echo command | ./netcat-regress -U -n -v server.sock 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'greeting' client.out && grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection received on server.sock grep '^greeting$' client.out greeting grep '^command$' server.out command # XXX message Bound and Listening is redundant grep 'Bound on server.sock$' server.err Bound on server.sock grep 'Listening on server.sock$' server.err Listening on server.sock grep 'Connection received on server.sock$' server.err Connection received on server.sock # XXX message succeeded is missing ! grep 'Connection to server.sock .* succeeded!' client.err ==== run-unix-namelookup ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f server.sock rm -f server.err; echo greeting | ./netcat-regress -U -v -l server.sock 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Bound on server.sock Listening on server.sock rm -f client.err; echo command | ./netcat-regress -U -v server.sock 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'greeting' client.out && grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection received on server.sock grep '^greeting$' client.out greeting grep '^command$' server.out command # XXX message Bound and Listening is redundant grep 'Bound on server.sock$' server.err Bound on server.sock grep 'Listening on server.sock$' server.err Listening on server.sock grep 'Connection received on server.sock$' server.err Connection received on server.sock # XXX message succeeded is missing ! grep 'Connection to server.sock .* succeeded!' client.err ==== run-unix-probe ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f server.sock rm -f server.err; echo greeting | ./netcat-regress -U -n -v -l server.sock 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Bound on server.sock Listening on server.sock # connect and close immediately, check if socket is listening ./netcat-regress -N -U -v server.sock client.out 2>client.err Connection received on server.sock # XXX message Bound and Listening is redundant grep 'Bound on server.sock$' server.err Bound on server.sock grep 'Listening on server.sock$' server.err Listening on server.sock grep 'Connection received on server.sock$' server.err Connection received on server.sock # XXX message succeeded is missing ! grep 'Connection to server.sock .* succeeded!' client.err # server accepts one connection, second connection should be refused ! ./netcat-regress -N -U -v server.sock client.out 2>client.err grep 'server.sock: Connection refused' client.err netcat-regress: server.sock: Connection refused # connection to non existing socket file should fail rm server.sock ! ./netcat-regress -N -U -v server.sock client.out 2>client.err grep 'server.sock: No such file or directory' client.err netcat-regress: server.sock: No such file or directory ==== run-unix-keep ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f server.sock rm -f server.err; echo greeting | ./netcat-regress -k -U -n -v -l server.sock 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Bound on server.sock Listening on server.sock rm -f client.err; echo command | ./netcat-regress -U -n -v server.sock 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'greeting' client.out && grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection received on server.sock grep '^greeting$' client.out greeting grep '^command$' server.out command # XXX message Bound and Listening is redundant grep 'Bound on server.sock$' server.err Bound on server.sock grep 'Listening on server.sock$' server.err Listening on server.sock grep 'Connection received on server.sock$' server.err Connection received on server.sock # XXX message succeeded is missing ! grep 'Connection to server.sock .* succeeded!' client.err # kill client and reconnect with a new one :> server.err pkill -l -f "^./netcat-regress .* -v server.sock$" 59119 netcat-regress rm -f client.{out,err} :> server.out rm -f client.err; echo command | ./netcat-regress -U -n -v server.sock 2>&1 >client.out | tee client.err & # server sends only one greeting, do not wait for a second one let timeout=`date +%s`+5; until grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection received on server.sock ! grep 'greeting' client.out # truncation of log results in NUL bytes, do not match ^ grep 'command$' server.out Binary file server.out matches grep 'Connection received on server.sock$' server.err Binary file server.err matches # XXX message succeeded is missing ! grep 'Connection to server.sock .* succeeded!' client.err ==== run-unix-dgram ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f {client,server}.sock rm -f server.err; echo greeting | ./netcat-regress -U -u -n -v -l server.sock 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Bound on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Bound on server.sock rm -f client.err; echo command | ./netcat-regress -U -u -n -v server.sock 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'greeting' client.out && grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Bound on /tmp/nc.WBBXMWMkNf Connection received on server.sock let timeout=`date +%s`+5; until grep -q 'Bound on ' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep '^greeting$' client.out greeting grep '^command$' server.out command grep 'Bound on server.sock$' server.err Bound on server.sock grep 'Connection received on server.sock$' server.err Connection received on server.sock # XXX message succeeded is missing ! grep 'Connection to server.sock .* succeeded!' client.err ==== run-unix-dgram-namelookup ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f {client,server}.sock rm -f server.err; echo greeting | ./netcat-regress -U -u -v -l server.sock 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Bound on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Bound on server.sock rm -f client.err; echo command | ./netcat-regress -U -u -v server.sock 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'greeting' client.out && grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Bound on /tmp/nc.ucgTqQRyYS Connection received on server.sock let timeout=`date +%s`+5; until grep -q 'Bound on ' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep '^greeting$' client.out greeting grep '^command$' server.out command grep 'Bound on server.sock$' server.err Bound on server.sock grep 'Connection received on server.sock$' server.err Connection received on server.sock # XXX message succeeded is missing ! grep 'Connection to server.sock .* succeeded!' client.err ==== run-unix-dgram-clientsock ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f {client,server}.sock rm -f server.err; echo greeting | ./netcat-regress -U -u -n -v -l server.sock 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Bound on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Bound on server.sock rm -f client.err; echo command | ./netcat-regress -U -u -n -v -s client.sock server.sock 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'greeting' client.out && grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Bound on client.sock Connection received on server.sock grep '^greeting$' client.out greeting grep '^command$' server.out command grep 'Bound on server.sock$' server.err Bound on server.sock grep 'Connection received on server.sock$' server.err Connection received on server.sock # XXX message succeeded is missing ! grep 'Connection to server.sock .* succeeded!' client.err ==== run-unix-dgram-keep ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f {client,server}.sock rm -f server.err; echo greeting | ./netcat-regress -k -U -u -n -v -l server.sock 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Bound on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Bound on server.sock rm -f client.err; echo command | ./netcat-regress -U -u -n -v server.sock 2>&1 >client.out | tee client.err & # server does not connect, nothing reaches the client let timeout=`date +%s`+5; until grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Bound on /tmp/nc.VDwcS45gB8 let timeout=`date +%s`+5; until grep -q 'Bound on ' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done ! grep 'greeting' client.out grep '^command$' server.out command grep 'Bound on server.sock$' server.err Bound on server.sock # client does not connect ! grep 'Connection received on ' server.err # XXX message succeeded is missing ! grep 'Connection to server.sock .* succeeded!' client.err # kill client and reconnect with a new one :> server.err pkill -l -f "^./netcat-regress .* -v server.sock$" 25056 netcat-regress rm -f client.{out,err} :> server.out rm -f client.err; echo command | ./netcat-regress -U -u -n -v server.sock 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Bound on /tmp/nc.y9xzD8JdBP let timeout=`date +%s`+5; until grep -q 'Bound on ' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done ! grep 'greeting' client.out # truncation of log results in NUL bytes, do not match ^ grep 'command$' server.out Binary file server.out matches # server keeps socket and does not bind again ! grep 'Bound on ' server.err # client does not connect ! grep 'Connection received on ' server.err # XXX message succeeded is missing ! grep 'Connection to 127.0.0.1 .* succeeded!' client.err ==== run-tcp-test ==== cc -O2 -pipe -Wall -Wpointer-arith -Wuninitialized -Wstrict-prototypes -Wmissing-prototypes -Wunused -Wsign-compare -Wshadow -MD -MP -c /home/src/regress/usr.bin/nc/server-tcp.c cc -O2 -pipe -Wall -Wpointer-arith -Wuninitialized -Wstrict-prototypes -Wmissing-prototypes -Wunused -Wsign-compare -Wshadow -MD -MP -c /home/src/regress/usr.bin/nc/util.c cc -o server-tcp server-tcp.o util.o cc -O2 -pipe -Wall -Wpointer-arith -Wuninitialized -Wstrict-prototypes -Wmissing-prototypes -Wunused -Wsign-compare -Wshadow -MD -MP -c /home/src/regress/usr.bin/nc/client-tcp.c cc -o client-tcp client-tcp.o util.o pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress # test the test tools ./server-tcp -s greeting -r command 127.0.0.1 0 >server.port sock: 127.0.0.1 12631 ./client-tcp -r greeting -s command 127.0.0.1 `cat server.port` >client.port sock: 127.0.0.1 3888 peer: 127.0.0.1 12631 peer: 127.0.0.1 3888 >>> greeting <<< greeting >>> command <<< command ==== run-tcp-test-shutdown ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress # test the test tools ./server-tcp -s greeting -N -r command -E 127.0.0.1 0 >server.port sock: 127.0.0.1 11386 ./client-tcp -r greeting -E -s command -N 127.0.0.1 `cat server.port` >client.port peer: 127.0.0.1 38487 sock: 127.0.0.1 38487 >>> greeting peer: 127.0.0.1 11386 <<< greeting <<< EOF >>> command <<< command <<< EOF ==== run-tcp-server ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f server.err; echo greeting | ./netcat-regress -n -v -l 127.0.0.1 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Listening on 127.0.0.1 35466 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port # test client read from netcat, then send line and exit ./client-tcp -r greeting -s command 127.0.0.1 `cat server.port` >client.port Connection received on 127.0.0.1 22999 sock: 127.0.0.1 22999 peer: 127.0.0.1 35466 <<< greeting >>> command let timeout=`date +%s`+5; until grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep '^command$' server.out command grep 'Listening on 127.0.0.1 ' server.err Listening on 127.0.0.1 35466 grep 'Connection received on 127.0.0.1 ' server.err Connection received on 127.0.0.1 22999 ==== run-tcp-server-eof ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f server.err; echo greeting | ./netcat-regress -n -v -l 127.0.0.1 0 2>&1 >server.out | tee server.err & Listening on 127.0.0.1 5136 let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port # test client read from netcat, then send line, shutdown, wait for eof ./client-tcp -r greeting -s command -N -E 127.0.0.1 `cat server.port` >client.port Connection received on 127.0.0.1 19905 sock: 127.0.0.1 19905 peer: 127.0.0.1 5136 <<< greeting >>> command <<< EOF let timeout=`date +%s`+5; until grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep '^command$' server.out command grep 'Listening on 127.0.0.1 ' server.err Listening on 127.0.0.1 5136 grep 'Connection received on 127.0.0.1 ' server.err Connection received on 127.0.0.1 19905 ==== run-tcp-server-reverse-eof ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress rm -f server.err; echo greeting | ./netcat-regress -n -v -l 127.0.0.1 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Listening on 127.0.0.1 46715 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port # test client send to netcat, shutdown, then read line, wait for eof ./client-tcp -s command -N -r greeting -E 127.0.0.1 `cat server.port` >client.port Connection received on 127.0.0.1 17557 sock: 127.0.0.1 17557 peer: 127.0.0.1 46715 >>> command <<< greeting <<< EOF let timeout=`date +%s`+5; until grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep '^command$' server.out command grep 'Listening on 127.0.0.1 ' server.err Listening on 127.0.0.1 46715 grep 'Connection received on 127.0.0.1 ' server.err Connection received on 127.0.0.1 17557 ==== run-tcp-server-shutdown-eof ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress # netcat calls shutdown on output after EOF on input rm -f server.err; echo greeting | ./netcat-regress -N -n -v -l 127.0.0.1 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep: server.err: No such file or directory Listening on 127.0.0.1 15755 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port # test client read from netcat, then send line, wait for eof, shutdown ./client-tcp -r greeting -s command -E -N 127.0.0.1 `cat server.port` >client.port Connection received on 127.0.0.1 30872 sock: 127.0.0.1 30872 peer: 127.0.0.1 15755 <<< greeting >>> command <<< EOF let timeout=`date +%s`+5; until grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep '^command$' server.out command grep 'Listening on 127.0.0.1 ' server.err Listening on 127.0.0.1 15755 grep 'Connection received on 127.0.0.1 ' server.err Connection received on 127.0.0.1 30872 ==== run-tcp-server-shutdown-reverse-eof ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress # netcat calls shutdown on output after EOF on input rm -f server.err; echo greeting | ./netcat-regress -N -n -v -l 127.0.0.1 0 2>&1 >server.out | tee server.err & let timeout=`date +%s`+5; until grep -q 'Listening on ' server.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Listening on 127.0.0.1 21086 sed -E -n 's/(Listening|Bound) on .* //p' server.err >server.port # test client send to netcat, shutdown, then read line, wait for eof ./client-tcp -s command -N -r greeting -E 127.0.0.1 `cat server.port` >client.port sock: 127.0.0.1 14613 peer: 127.0.0.1 21086 >>> command Connection received on 127.0.0.1 14613 <<< greeting <<< EOF let timeout=`date +%s`+5; until grep -q 'command' server.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep '^command$' server.out command grep 'Listening on 127.0.0.1 ' server.err Listening on 127.0.0.1 21086 grep 'Connection received on 127.0.0.1 ' server.err Connection received on 127.0.0.1 14613 ==== run-tcp-client ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress # test server send to netcat, then read line and exit ./server-tcp -s greeting -r command 127.0.0.1 0 >server.port sock: 127.0.0.1 11061 rm -f client.err; echo command | ./netcat-regress -n -v 127.0.0.1 `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'Connection to .* succeeded' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done peer: 127.0.0.1 8041 >>> greeting Connection to 127.0.0.1 11061 port [tcp/*] succeeded! <<< command let timeout=`date +%s`+5; until grep -q 'greeting' client.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep '^greeting$' client.out greeting grep 'Connection to 127.0.0.1 .* succeeded!' client.err Connection to 127.0.0.1 11061 port [tcp/*] succeeded! ==== run-tcp-client-eof ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress # test server send to netcat, shutdown, then read line, wait for eof ./server-tcp -s greeting -N -r command -E 127.0.0.1 0 >server.port sock: 127.0.0.1 26504 rm -f client.err; echo command | ./netcat-regress -n -v 127.0.0.1 `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'Connection to .* succeeded' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection to 127.0.0.1 26504 port [tcp/*] succeeded! peer: 127.0.0.1 18518 >>> greeting <<< command <<< EOF let timeout=`date +%s`+5; until grep -q 'greeting' client.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep '^greeting$' client.out greeting grep 'Connection to 127.0.0.1 .* succeeded!' client.err Connection to 127.0.0.1 26504 port [tcp/*] succeeded! ==== run-tcp-client-reverse-eof ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress # test server read from netcat, then read line, wait for eof, shutdown ./server-tcp -r command -s greeting -E -N 127.0.0.1 0 >server.port sock: 127.0.0.1 43490 rm -f client.err; echo command | ./netcat-regress -n -v 127.0.0.1 `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'Connection to .* succeeded' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep: client.err: No such file or directory peer: 127.0.0.1 21003 <<< command >>> greeting grep: client.err: No such file or directory grep: client.err: No such file or directory Connection to 127.0.0.1 43490 port [tcp/*] succeeded! let timeout=`date +%s`+5; until grep -q 'greeting' client.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep '^greeting$' client.out greeting grep 'Connection to 127.0.0.1 .* succeeded!' client.err Connection to 127.0.0.1 43490 port [tcp/*] succeeded! ==== run-tcp-client-shutdown-eof ==== pkill netcat-regress || true <<< EOF rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress # test server send to netcat, shutdown, then read line, wait for eof ./server-tcp -s greeting -N -r command -E 127.0.0.1 0 >server.port sock: 127.0.0.1 5577 # netcat calls shutdown on output after EOF on input rm -f client.err; echo command | ./netcat-regress -N -n -v 127.0.0.1 `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'Connection to .* succeeded' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection to 127.0.0.1peer: 127.0.0.1 41088 5577 port [tcp/*] succeeded! >>> greeting <<< command <<< EOF let timeout=`date +%s`+5; until grep -q 'greeting' client.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep '^greeting$' client.out greeting grep 'Connection to 127.0.0.1 .* succeeded!' client.err Connection to 127.0.0.1 5577 port [tcp/*] succeeded! ==== run-tcp-client-shutdown-reverse-eof ==== pkill netcat-regress || true rm -f netcat-regress # copying global netcat to local name allows to pkill it during cleanup cp /usr/bin/nc netcat-regress chmod 755 netcat-regress # test server read from netcat, wait for eof, then read line, shutdown ./server-tcp -r command -E -s greeting -N 127.0.0.1 0 >server.port sock: 127.0.0.1 11019 # netcat calls shutdown on output after EOF on input rm -f client.err; echo command | ./netcat-regress -N -n -v 127.0.0.1 `cat server.port` 2>&1 >client.out | tee client.err & let timeout=`date +%s`+5; until grep -q 'Connection to .* succeeded' client.err; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done Connection to 127.0.0.1 11019 port [tcp/*] succeeded! peer: 127.0.0.1 28638 <<< command <<< EOF >>> greeting let timeout=`date +%s`+5; until grep -q 'greeting' client.out; do [[ `date +%s` -lt $timeout ]] || { echo timeout; exit 1; }; done grep '^greeting$' client.out greeting grep 'Connection to 127.0.0.1 .* succeeded!' client.err Connection to 127.0.0.1 11019 port [tcp/*] succeeded! ==== cleanup ==== pkill netcat-regress || true