1# The TLS server closes the connection to syslogd. 2# The client writes a message to Sys::Syslog native method. 3# The syslogd writes it into a file and through a pipe. 4# The syslogd does a TLS reconnect and passes it to loghost. 5# The server receives the message on its new accepted TLS socket. 6# Find the message in client, pipe, syslogd, server log. 7# Check that syslogd and server close and reopen the connection. 8 9use strict; 10use warnings; 11use Socket; 12use Errno ':POSIX'; 13 14my @errors = (ECONNREFUSED, EPIPE); 15my $errors = "(". join("|", map { $! = $_ } @errors). ")"; 16 17our %args = ( 18 client => { 19 func => sub { write_between2logs(shift, sub { 20 my $self = shift; 21 ${$self->{syslogd}}->loggrep($errors, 5) 22 or die "no $errors in syslogd.log"; 23 })}, 24 }, 25 syslogd => { 26 loghost => '@tls://127.0.0.1:$connectport', 27 loggrep => { 28 qr/Logging to FORWTLS \@tls:\/\/127.0.0.1:\d+/ => '>=6', 29 qr/syslogd\[\d+\]: /. 30 qr/(connect .*|.* connection error: handshake failed): /. 31 $errors => 1, 32 get_between2loggrep(), 33 }, 34 }, 35 server => { 36 listen => { domain => AF_INET, proto => "tls", addr => "127.0.0.1" }, 37 redo => 0, 38 func => sub { read_between2logs(shift, sub { 39 my $self = shift; 40 if ($self->{redo}) { 41 $self->{redo}--; 42 return; 43 } 44 $self->close(); 45 shutdown(\*STDOUT, 1) 46 or die "shutdown write failed: $!"; 47 ${$self->{syslogd}}->loggrep($errors, 5) 48 or die "no $errors in syslogd.log"; 49 $self->listen(); 50 $self->{redo}++; 51 })}, 52 loggrep => { 53 qr/Accepted/ => 2, 54 qr/syslogd\[\d+\]: loghost .* connection close/ => 1, 55 qr/syslogd\[\d+\]: /. 56 qr/(connect .*|.* connection error: handshake failed): /. 57 $errors => 1, 58 get_between2loggrep(), 59 }, 60 }, 61 file => { 62 loggrep => { 63 qr/syslogd\[\d+\]: /. 64 qr/(connect .*|.* connection error: handshake failed): /. 65 $errors => 1, 66 get_between2loggrep(), 67 }, 68 }, 69); 70 711; 72