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 UDP to the loghost.
4# The server receives the message on its UDP socket.
5# Find the message in client, file, pipe, syslogd, server log.
6# Check that a SIGHUP is propagated from privsep parent to syslog child.
7
8use strict;
9use warnings;
10
11our %args = (
12    client => {
13	func => sub { write_between2logs(shift, sub {
14	    my $self = shift;
15	    ${$self->{server}}->loggrep("Signal", 8)
16		or die ref($self), " no 'Signal' between logs";
17	})},
18	loggrep => { get_between2loggrep() },
19    },
20    syslogd => {
21	ktrace => {
22	    qr/syslogd  PSIG  SIGHUP caught handler/ => 2,
23	    qr/syslogd  RET   execve JUSTRETURN/ => 2,
24	},
25	loggrep => {
26	    qr/syslogd: restarted/ => 1,
27	    get_between2loggrep(),
28	},
29    },
30    server => {
31	func => sub { read_between2logs(shift, sub {
32	    my $self = shift;
33	    ${$self->{syslogd}}->rotate();
34	    ${$self->{syslogd}}->rotate();
35	    ${$self->{syslogd}}->kill_privsep('HUP');
36	    ${$self->{syslogd}}->loggrep("syslogd: restarted", 5)
37		or die ref($self), " no 'syslogd: restarted' between logs";
38	    print STDERR "Signal\n";
39	})},
40	loggrep => { get_between2loggrep() },
41    },
42    check => sub {
43	my $self = shift;
44	my $r = $self->{syslogd};
45	$r->loggrep("bytes transferred", 1, 2) or sleep 1;
46	foreach my $name (qw(file pipe)) {
47		my $file = $r->{"out$name"}.".1";
48		my $pattern = (get_between2loggrep())[0];
49		check_pattern($name, $file, $pattern, \&filegrep);
50	}
51    },
52);
53
541;
55