1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# The client writes 300 messages to Sys::Syslog native method.
# The syslogd writes it into a file and through a pipe.
# The syslogd passes it via TLS to the loghost.
# The server blocks the message on its TLS socket.
# The server waits until the client as written all messages.
# The server sends a SIGHUP to syslogd and reads messages from kernel.
# The client waits until the server has read the first message.
# Find the message in client, file, pipe, syslogd, server log.
# Check that the 300 messages are in syslogd and file log.
# Check that the dropped message is in server and file log.
use strict;
use warnings;
use Socket;
our %args = (
client => {
func => sub { write_between2logs(shift, sub {
my $self = shift;
write_message($self, get_secondlog());
write_lines($self, 300, 1024);
write_message($self, get_thirdlog());
${$self->{server}}->loggrep(get_secondlog(), 8)
or die ref($self), " server did not receive second log";
})},
},
syslogd => {
loghost => '@tls://localhost:$connectport',
loggrep => {
get_between2loggrep(),
get_charlog() => 300,
qr/SSL3_WRITE_PENDING/ => 0,
},
},
server => {
listen => { domain => AF_UNSPEC, proto => "tls", addr => "localhost" },
rcvbuf => 2**12,
func => sub { accept_between2logs(shift, sub {
my $self = shift;
${$self->{syslogd}}->loggrep(get_thirdlog(), 20)
or die ref($self), " syslogd did not receive third log";
${$self->{syslogd}}->kill_syslogd('HUP');
${$self->{syslogd}}->loggrep("syslogd: restarted", 5)
or die ref($self), " no 'syslogd: restarted' between logs";
# syslogd has shut down, read from kernel socket buffer
read_log($self);
})},
loggrep => {
get_between2loggrep(),
get_secondlog() => 1,
get_thirdlog() => 0,
qr/syslogd\[\d+\]: start/ => 1,
qr/syslogd\[\d+\]: restart/ => 1,
get_charlog() => '~91',
qr/syslogd\[\d+\]: dropped 2[0-2][0-9] messages to remote loghost/
=> 1,
},
},
file => {
loggrep => {
get_between2loggrep(),
get_secondlog() => 1,
get_thirdlog() => 1,
qr/syslogd\[\d+\]: start/ => 1,
qr/syslogd\[\d+\]: restart/ => 1,
get_charlog() => 300,
qr/syslogd\[\d+\]: dropped 2[0-2][0-9] messages to remote loghost/
=> 1,
},
},
);
1;
|