1# The TCP server writes cleartext into the TLS 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 accepts an TCP socket.
6# Find the message in client, pipe, syslogd log.
7# Check that syslogd writes a log message about the SSL connect error.
8
9use strict;
10use warnings;
11use Socket;
12
13our %args = (
14    client => {
15	func => sub {
16	    my $self = shift;
17	    ${$self->{syslogd}}->loggrep("loghost .* connection error", 5)
18		or die ref($self), " no connection error in syslogd.log";
19	    write_log($self);
20	},
21    },
22    syslogd => {
23	loghost => '@tls://127.0.0.1:$connectport',
24	loggrep => {
25	    qr/Logging to FORWTLS \@tls:\/\/127.0.0.1:\d+/ => '>=4',
26	    get_testgrep() => 1,
27	    qr/syslogd\[\d+\]: loghost .* connection error/ => 1,
28	},
29    },
30    server => {
31	listen => { domain => AF_INET, proto => "tcp", addr => "127.0.0.1" },
32	func => sub {
33	    my $self = shift;
34	    print "Writing cleartext into a TLS connection is a bad idea\n";
35	    ${$self->{syslogd}}->loggrep("loghost .* connection error", 5)
36		or die ref($self), " no connection error in syslogd.log";
37	},
38	loggrep => {},
39    },
40    file => {
41	loggrep => {
42	    qr/syslogd\[\d+\]: loghost .* connection error: /.
43		qr/handshake failed: error:.*:SSL routines:/.
44		qr/CONNECT_CR_SRVR_HELLO:tlsv1 alert protocol version/ => 1,
45	},
46    },
47);
48
491;
50