args-sighup-tls.pl revision 1.1
1# The client writes a message to Sys::Syslog native method.
2# The syslogd writes it into a file and through a pipe.
3# The syslogd passes it via TLS to the loghost.
4# The server receives the message on its TLS socket.
5# Find the message in client, file, pipe, syslogd, server log.
6# Check that a SIGHUP reconnects the TLS stream and closes the socket.
7
8use strict;
9use warnings;
10
11our %args = (
12    client => {
13	func => sub {
14	    my $self = shift;
15	    write_between2logs($self, sub {
16		${$self->{server}}->loggrep("Signal", 8)
17		    or die ref($self), " no 'Signal' between logs";
18	    });
19	},
20	loggrep => { get_between2loggrep() },
21    },
22    syslogd => {
23	ktrace => 1,
24	fstat => 1,
25	kdump => {
26	    qr/syslogd  PSIG  SIGHUP caught handler/ => 1,
27	    qr/syslogd  RET   execve 0/ => 1,
28	},
29	loghost => '@tls://127.0.0.1:$connectport',
30	loggrep => {
31	    qr/config file changed: dying/ => 0,
32	    qr/config file modified: restarting/ => 0,
33	    qr/syslogd: restarted/ => 1,
34	    get_between2loggrep(),
35	},
36    },
37    server => {
38	listen => { domain => AF_INET, addr => "127.0.0.1", proto => "tls" },
39	redo => 0,
40	func => sub {
41	    my $self = shift;
42	    read_between2logs($self, sub {
43		if ($self->{redo}) {
44			$self->{redo}--;
45			return;
46		}
47		${$self->{syslogd}}->rotate();
48		${$self->{syslogd}}->kill_syslogd('HUP');
49		${$self->{syslogd}}->loggrep("syslogd: restarted", 5)
50		    or die ref($self), " no 'syslogd: restarted' between logs";
51		print STDERR "Signal\n";
52		# regeneate fstat file
53		${$self->{syslogd}}->fstat();
54		$self->{redo}++;
55	    });
56	},
57	loggrep => {
58	    get_between2loggrep(),
59	    qr/Signal/ => 1,
60	    qr/Accepted/ => 2,
61	},
62    },
63    fstat => {
64	loggrep => {
65	    # sighup must not leak a TCP socket
66	    qr/internet stream tcp/ => 1,
67	},
68    },
69);
70
711;
72