diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2020-11-06 03:26:19 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2020-11-06 03:26:19 +0000 |
commit | 0e0ad22b8c64938b4d54f5d30b370d495c1cdb84 (patch) | |
tree | b0b88c5978088027b6069d023d45e2adbfae66b6 /regress/usr.sbin | |
parent | d98d86e5e48e010519784b08beded7de97c288f8 (diff) |
Fix some races in syslogd tests. Fewer handshakes in TLS 1.3 make
the error messages and behavior less deterministic.
Diffstat (limited to 'regress/usr.sbin')
-rw-r--r-- | regress/usr.sbin/syslogd/Client.pm | 5 | ||||
-rw-r--r-- | regress/usr.sbin/syslogd/args-client-tls-fake.pl | 12 | ||||
-rw-r--r-- | regress/usr.sbin/syslogd/args-server-tls-client-fake.pl | 5 | ||||
-rw-r--r-- | regress/usr.sbin/syslogd/funcs.pl | 12 |
4 files changed, 25 insertions, 9 deletions
diff --git a/regress/usr.sbin/syslogd/Client.pm b/regress/usr.sbin/syslogd/Client.pm index 12764f6c503..74fb839de73 100644 --- a/regress/usr.sbin/syslogd/Client.pm +++ b/regress/usr.sbin/syslogd/Client.pm @@ -1,4 +1,4 @@ -# $OpenBSD: Client.pm,v 1.13 2020/10/16 22:46:45 bluhm Exp $ +# $OpenBSD: Client.pm,v 1.14 2020/11/06 03:26:18 bluhm Exp $ # Copyright (c) 2010-2020 Alexander Bluhm <bluhm@openbsd.org> # @@ -47,7 +47,8 @@ sub child { # TLS 1.3 writes multiple messages without acknowledgement. # If the other side closes early, we want broken pipe error. - $SIG{PIPE} = 'IGNORE' if $self->{connectproto} eq "tls"; + $SIG{PIPE} = 'IGNORE' if defined($self->{connectdomain}) && + $self->{connectproto} eq "tls"; if (defined($self->{connectdomain}) && $self->{connectdomain} ne "sendsyslog") { diff --git a/regress/usr.sbin/syslogd/args-client-tls-fake.pl b/regress/usr.sbin/syslogd/args-client-tls-fake.pl index 92e25c535b8..b3ba24f1f71 100644 --- a/regress/usr.sbin/syslogd/args-client-tls-fake.pl +++ b/regress/usr.sbin/syslogd/args-client-tls-fake.pl @@ -11,9 +11,14 @@ use warnings; use Errno ':POSIX'; use Socket; -my @errors = (EPIPE); +my @errors = (EPIPE, ECONNRESET); my $errors = "(". join("|", map { $! = $_ } @errors). ")"; +my $connecterror = qr/Client IO::Socket::SSL socket connect failed: /. + qr/.*,SSL connect attempt failed error:.*$errors/; +my $shutdownerror = qr/Client error after shutdown: /. + qr/.*:tlsv1 alert decrypt error/; + our %args = ( client => { connect => { domain => AF_UNSPEC, proto => "tls", addr => "localhost", @@ -21,11 +26,10 @@ our %args = ( sslcert => "client.crt", sslkey => "client.key", up => qr/IO::Socket::SSL socket connect failed/, - down => qr/SSL connect attempt failed/, + down => qr/SSL connect attempt failed|error after shutdown/, exit => 255, loggrep => { - qr/Client IO::Socket::SSL socket connect failed: /. - qr/.*,SSL connect attempt failed error:.*$errors/ => 1, + qr/$connecterror|$shutdownerror/ => 1, }, }, syslogd => { diff --git a/regress/usr.sbin/syslogd/args-server-tls-client-fake.pl b/regress/usr.sbin/syslogd/args-server-tls-client-fake.pl index 048f211a451..c35e03c441d 100644 --- a/regress/usr.sbin/syslogd/args-server-tls-client-fake.pl +++ b/regress/usr.sbin/syslogd/args-server-tls-client-fake.pl @@ -10,8 +10,9 @@ use warnings; use Errno ':POSIX'; use Socket; -my @errors = (EPIPE); -my $errors = "(". join("|", map { $! = $_ } @errors). ")"; +my @errors = (EPIPE, ECONNRESET); +my $errors = "(". join("|", map { $! = $_ } @errors). + "|tlsv1 alert decrypt error)"; our %args = ( syslogd => { diff --git a/regress/usr.sbin/syslogd/funcs.pl b/regress/usr.sbin/syslogd/funcs.pl index bdabfc934a3..fe3d4397c8e 100644 --- a/regress/usr.sbin/syslogd/funcs.pl +++ b/regress/usr.sbin/syslogd/funcs.pl @@ -1,4 +1,4 @@ -# $OpenBSD: funcs.pl,v 1.37 2019/09/17 22:24:08 bluhm Exp $ +# $OpenBSD: funcs.pl,v 1.38 2020/11/06 03:26:18 bluhm Exp $ # Copyright (c) 2010-2015 Alexander Bluhm <bluhm@openbsd.org> # @@ -26,6 +26,7 @@ use Sys::Syslog qw(:standard :extended :macros); use Time::HiRes 'sleep'; use IO::Socket; use IO::Socket::INET6; +use IO::Socket::SSL; my $firstlog = "syslogd regress test first message"; my $secondlog = "syslogd regress test second message"; @@ -118,6 +119,15 @@ sub write_shutdown { setlogsock("native") or die ref($self), " setlogsock native failed: $!"; syslog(LOG_NOTICE, $downlog); + + if (defined($self->{connectdomain}) && + $self->{connectproto} eq "tls" && + $self->{exit}) { + # Due to missing handshakes TLS 1.3 cannot detect all + # connection errors while writing. Try to read. + defined(read(STDIN, my $buf, 1)) + or die ref($self), " error after shutdown: $!,$SSL_ERROR"; + } } sub write_lines { |