1a588825eSbluhm# The TLS server aborts the connection to syslogd.
2a588825eSbluhm# The client writes a message to Sys::Syslog native method.
3a588825eSbluhm# The syslogd writes it into a file and through a pipe.
4a588825eSbluhm# The syslogd passes it via IPv4 TLS to an explicit loghost.
5a588825eSbluhm# The server receives the message on its TLS socket.
6a588825eSbluhm# Find the message in client, pipe, syslogd log.
7a588825eSbluhm# Check that syslogd writes a log message about the server error.
8a588825eSbluhm
9a588825eSbluhmuse strict;
10a588825eSbluhmuse warnings;
11a588825eSbluhmuse Socket;
12b44307d8Sbluhmuse Errno ':POSIX';
13b44307d8Sbluhm
14*9fe0079aSbluhmmy @errors = (ECONNRESET, EPIPE);
15b44307d8Sbluhmmy $errors = "(". join("|", map { $! = $_ } @errors). ")";
16a588825eSbluhm
17a588825eSbluhmour %args = (
18a588825eSbluhm    client => {
19a588825eSbluhm	func => sub {
20a588825eSbluhm	    my $self = shift;
21a588825eSbluhm	    ${$self->{syslogd}}->loggrep("loghost .* connection error", 5)
224dc3bc25Sbluhm		or die ref($self), " no connection error in syslogd.log";
238cd3cffcSbluhm	    write_log($self);
24a588825eSbluhm	},
25a588825eSbluhm    },
26a588825eSbluhm    syslogd => {
27a588825eSbluhm	loghost => '@tls://127.0.0.1:$connectport',
28a588825eSbluhm	loggrep => {
29a588825eSbluhm	    qr/Logging to FORWTLS \@tls:\/\/127.0.0.1:\d+/ => '>=4',
30bb7ea376Sbluhm	    get_testgrep() => 1,
318579df47Sbluhm	    qr/syslogd\[\d+\]: loghost .* connection error/ => 1,
32a588825eSbluhm	},
33a588825eSbluhm    },
34a588825eSbluhm    server => {
35a588825eSbluhm	listen => { domain => AF_INET, proto => "tls", addr => "127.0.0.1" },
36a588825eSbluhm	func => sub {
37a588825eSbluhm	    my $self = shift;
38a588825eSbluhm	    setsockopt(STDOUT, SOL_SOCKET, SO_LINGER, pack('ii', 1, 0))
394dc3bc25Sbluhm		or die ref($self), " set socket linger failed: $!";
40a588825eSbluhm	},
41a588825eSbluhm	loggrep => {},
42a588825eSbluhm    },
43a588825eSbluhm    file => {
44a588825eSbluhm	loggrep => {
458579df47Sbluhm	    qr/syslogd\[\d+\]: loghost .* connection error: /.
46*9fe0079aSbluhm		qr/(?:read|write) failed: .*$errors/ => 1,
47a588825eSbluhm	},
48a588825eSbluhm    },
49a588825eSbluhm);
50a588825eSbluhm
51a588825eSbluhm1;
52