args-secure-udp.pl revision 1.2
1# The client writes messages to localhost IPv4 and IPv6 UDP socket.
2# The syslogd does not receive them as it is started without -u.
3# Keep the sockets open by pretending to write to them.
4# Check that client does send the message, but it is not in the file.
5# Check with fstat that both *:514 sockets are bound.
6# Check that there is no recvfrom localhost in syslogd ktrace.
7
8use strict;
9use warnings;
10use Socket;
11
12our %args = (
13    client => {
14	connectaddr => "none",
15	redo => [
16	    {
17		domain => AF_INET,
18		addr   => "127.0.0.1",
19	    },
20	    {
21		domain => AF_INET,
22		addr   => "127.0.0.1",
23	    },
24	    {
25		domain => AF_INET6,
26		addr   => "::1",
27	    },
28	],
29	func => sub {
30	    my $self = shift;
31	    write_message($self, "client addr: ". $self->{connectaddr});
32	    if ($self->{cs}) {
33		# wait for possible icmp errors, port is open
34		sleep .1;
35		close($self->{cs})
36		    or die ref($self), " close failed: $!";
37	    };
38	    if (my $connect = shift @{$self->{redo}}) {
39		$self->{connectdomain} = $connect->{domain};
40		$self->{connectaddr}   = $connect->{addr};
41		$self->{connectproto}  = "udp";
42		$self->{connectport}   = "514";
43	    } else {
44		delete $self->{connectdomain};
45		$self->{logsock} = { type => "native" };
46		setlogsock($self->{logsock})
47		    or die ref($self), " setlogsock failed: $!";
48		sleep .1;
49		write_log($self);
50		undef $self->{redo};
51	    }
52	},
53	loggrep => {
54	    qr/client addr:/ => 4,
55	    get_testgrep() => 1,
56	}
57    },
58    syslogd => {
59	options => [],
60	loghost => "/dev/null",
61	conf =>
62	    "*.*\t\@udp4://0.0.0.0:0\n".
63	    "*.*\t\@udp6://[::]:0\n",
64	fstat => {
65	    qr/^_syslogd syslogd .* internet6? dgram udp \*:514$/ => 2,
66	},
67	ktrace => {
68	    qr/127\.0\.0\.1/ => 0,
69	    qr/\[::1\]/ => 0,
70	},
71    },
72    server => {
73	noserver => 1,
74    },
75    file => {
76	loggrep => {
77	    qr/client addr: none/ => 1,
78	    qr/client addr:/ => 1,
79	    get_testgrep() => 1,
80	}
81    },
82);
83
841;
85