1# The TLS server aborts 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 passes it via IPv4 TLS to an explicit loghost.
5# The server receives the message on its TLS socket.
6# Find the message in client, pipe, syslogd log.
7# Check that syslogd writes a log message about the server error.
8
9use strict;
10use warnings;
11use Socket;
12use Errno ':POSIX';
13
14my @errors = (ECONNRESET, EPIPE);
15my $errors = "(". join("|", map { $! = $_ } @errors). ")";
16
17our %args = (
18    client => {
19	func => sub {
20	    my $self = shift;
21	    ${$self->{syslogd}}->loggrep("loghost .* connection error", 5)
22		or die ref($self), " no connection error in syslogd.log";
23	    write_log($self);
24	},
25    },
26    syslogd => {
27	loghost => '@tls://127.0.0.1:$connectport',
28	loggrep => {
29	    qr/Logging to FORWTLS \@tls:\/\/127.0.0.1:\d+/ => '>=4',
30	    get_testgrep() => 1,
31	    qr/syslogd\[\d+\]: loghost .* connection error/ => 1,
32	},
33    },
34    server => {
35	listen => { domain => AF_INET, proto => "tls", addr => "127.0.0.1" },
36	func => sub {
37	    my $self = shift;
38	    setsockopt(STDOUT, SOL_SOCKET, SO_LINGER, pack('ii', 1, 0))
39		or die ref($self), " set socket linger failed: $!";
40	},
41	loggrep => {},
42    },
43    file => {
44	loggrep => {
45	    qr/syslogd\[\d+\]: loghost .* connection error: /.
46		qr/(?:read|write) failed: .*$errors/ => 1,
47	},
48    },
49);
50
511;
52