args-sighup-tls.pl revision 1.5
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; 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 0/ => 1, 29 }, 30 loghost => '@tls://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 => "tls", addr => "127.0.0.1" }, 40 redo => 0, 41 func => sub { read_between2logs(shift, sub { 42 my $self = shift; 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 # regenerate fstat file 53 ${$self->{syslogd}}->fstat(); 54 $self->{redo}++; 55 })}, 56 loggrep => { 57 get_between2loggrep(), 58 qr/Signal/ => 1, 59 qr/Accepted/ => 2, 60 }, 61 }, 62); 63 641; 65