1# The syslogd listens on 127.0.0.1 TCP socket.
2# The client writes non transparent framing message that is too long.
3# The syslogd writes it into a file and through a pipe.
4# The syslogd passes it via UDP to the loghost.
5# The server receives the message on its UDP socket.
6# Find the message in client, file, syslogd, server log.
7# Check that the file log contains the truncated message.
8
9use strict;
10use warnings;
11use Socket;
12use constant MAXLINE => 8192;
13use constant MAX_UDPMSG => 1180;
14
15our %args = (
16    client => {
17	connect => { domain => AF_INET, proto => "tcp", addr => "127.0.0.1",
18	    port => 514 },
19	func => sub {
20	    my $self = shift;
21	    local $| = 1;
22	    my $msg = generate_chars(MAXLINE+1);
23	    print "$msg\n";
24	    print STDERR "<<< $msg\n";
25	    ${$self->{syslogd}}->loggrep(qr/tcp logger .* use \d+ bytes/, 5)
26		or die ref($self), " syslogd did not use bytes";
27	    $msg = generate_chars(MAXLINE);
28	    print $msg;
29	    print STDERR "<<< $msg\n";
30	    ${$self->{syslogd}}->loggrep("tcp logger .* incomplete", 5, 2)
31		or die ref($self), " syslogd did not receive 2 incomplete";
32	    print "\n";
33	    print STDERR "<<< \n";
34	    write_shutdown($self);
35	},
36	loggrep => {
37	    qr/<<< 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ/ => 2,
38	},
39    },
40    syslogd => {
41	options => ["-T", "127.0.0.1:514"],
42	loggrep => {
43	    qr/non transparent framing, incomplete frame, /.
44		qr/buffer \d+ bytes/ => 2,
45	    qr/non transparent framing, use /.(MAXLINE+2).qr/ bytes/ => 1,
46	    qr/non transparent framing, use /.(MAXLINE+1).qr/ bytes/ => 1,
47	},
48    },
49    server => {
50	# >>> <13>Jul  6 22:33:32 0123456789ABC...fgh
51	loggrep => {
52	    qr/>>> .{19} /.generate_chars(MAX_UDPMSG-20).qr/$/ => 2,
53	},
54    },
55    file => {
56	loggrep => {
57	    generate_chars(MAXLINE).qr/$/ => 2,
58	},
59    },
60    pipe => { nocheck => 1 },  # XXX syslogd ignore short writes to pipe
61    tty => { nocheck => 1 },
62);
63
641;
65