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
14our %args = (
15    client => {
16	func => sub { write_between2logs(shift, sub {
17	    my $self = shift;
18	    ${$self->{syslogd}}->loggrep(
19		qr/SSL_internal:unknown failure occurred/, 5)
20		or die ref($self), " no SSL_internal error in syslogd.log";
21	})},
22    },
23    syslogd => {
24	loghost => '@tls://127.0.0.1:$connectport',
25	loggrep => {
26	    qr/Logging to FORWTLS \@tls:\/\/127.0.0.1:\d+/ => '>=6',
27	    qr/syslogd\[\d+\]: /.
28		qr/(connect .*|.* connection error: handshake failed): /.
29		qr/.*SSL_internal:unknown failure occurred/ => 1,
30	    get_between2loggrep(),
31	},
32    },
33    server => {
34	listen => { domain => AF_INET, proto => "tls", addr => "127.0.0.1" },
35	func => sub { accept_between2logs(shift, sub {
36	    my $self = shift;
37	    $self->close();
38	    shutdown(\*STDOUT, 1)
39		or die ref($self), " shutdown write failed: $!";
40	    ${$self->{syslogd}}->loggrep(
41		qr/SSL_internal:unknown failure occurred/, 5)
42		or die ref($self), " no SSL_internal error in syslogd.log";
43	    $self->listen();
44	})},
45	loggrep => {
46	    qr/Accepted/ => 2,
47	    qr/syslogd\[\d+\]: loghost .* connection close/ => 1,
48	    qr/syslogd\[\d+\]: /.
49		qr/(connect .*|.* connection error: handshake failed): /.
50		qr/.*SSL_internal:unknown failure occurred/ => 1,
51	    get_between2loggrep(),
52	},
53    },
54    file => {
55	loggrep => {
56	    qr/syslogd\[\d+\]: /.
57		qr/(connect .*|.* connection error: handshake failed): /.
58		qr/.*SSL_internal:unknown failure occurred/ => 1,
59	    get_between2loggrep(),
60	},
61    },
62);
63
641;
65