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 TCP to the loghost. 4# The server receives the message on its TCP socket. 5# Find the message in client, file, pipe, syslogd, server log. 6# Check that a SIGHUP reconnects the TCP stream and closes the socket. 7 8use strict; 9use warnings; 10use Socket; 11 12our %args = ( 13 client => { 14 func => sub { write_between2logs(shift, sub { 15 my $self = shift; 16 ${$self->{server}}->loggrep("Signal", 8) 17 or die ref($self), " no 'Signal' between logs"; 18 })}, 19 loggrep => { get_between2loggrep() }, 20 }, 21 syslogd => { 22 fstat => { 23 # sighup must not leak a TCP socket 24 qr/internet stream tcp/ => 1, 25 }, 26 ktrace => { 27 qr/syslogd PSIG SIGHUP caught handler/ => 1, 28 qr/syslogd RET execve \d+/ => 2, 29 }, 30 loghost => '@tcp://127.0.0.1:$connectport', 31 loggrep => { 32 qr/config file changed: dying/ => 0, 33 qr/config file modified: restarting/ => 0, 34 qr/syslogd: restarted/ => 1, 35 get_between2loggrep(), 36 }, 37 }, 38 server => { 39 listen => { domain => AF_INET, proto => "tcp", addr => "127.0.0.1" }, 40 func => sub { accept_between2logs(shift, sub { 41 my $self = shift; 42 ${$self->{syslogd}}->rotate(); 43 ${$self->{syslogd}}->kill_syslogd('HUP'); 44 ${$self->{syslogd}}->loggrep("syslogd: restarted", 5) 45 or die ref($self), " no 'syslogd: restarted' between logs"; 46 print STDERR "Signal\n"; 47 # regenerate fstat file 48 ${$self->{syslogd}}->fstat(); 49 })}, 50 loggrep => { 51 get_between2loggrep(), 52 qr/Signal/ => 1, 53 qr/Accepted/ => 2, 54 }, 55 }, 56); 57 581; 59