diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2014-08-25 17:55:28 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2014-08-25 17:55:28 +0000 |
commit | 9d94cb5ca414325af784c1326cae87b56b737275 (patch) | |
tree | 63caffd5307632f3f59b847ac45b6c21834dab32 /regress/usr.sbin | |
parent | 3d43008fc1af31f5d3343eb8c58818bfeef0ed5f (diff) |
Add tests for syslogd sending and receiving over IPv6 sockets.
Diffstat (limited to 'regress/usr.sbin')
-rw-r--r-- | regress/usr.sbin/syslogd/Client.pm | 4 | ||||
-rw-r--r-- | regress/usr.sbin/syslogd/Server.pm | 4 | ||||
-rw-r--r-- | regress/usr.sbin/syslogd/args-client-udp6-nodns.pl | 23 | ||||
-rw-r--r-- | regress/usr.sbin/syslogd/args-client-udp6.pl | 23 | ||||
-rw-r--r-- | regress/usr.sbin/syslogd/args-localhost.pl | 34 | ||||
-rw-r--r-- | regress/usr.sbin/syslogd/args-maxhostlen.pl | 23 | ||||
-rw-r--r-- | regress/usr.sbin/syslogd/args-maxloghostlen.pl | 23 | ||||
-rw-r--r-- | regress/usr.sbin/syslogd/args-maxportlen.pl | 23 | ||||
-rw-r--r-- | regress/usr.sbin/syslogd/args-server-udp4.pl | 28 | ||||
-rw-r--r-- | regress/usr.sbin/syslogd/args-server-udp6.pl | 28 | ||||
-rw-r--r-- | regress/usr.sbin/syslogd/args-socket.pl | 1 | ||||
-rw-r--r-- | regress/usr.sbin/syslogd/funcs.pl | 4 |
12 files changed, 212 insertions, 6 deletions
diff --git a/regress/usr.sbin/syslogd/Client.pm b/regress/usr.sbin/syslogd/Client.pm index 202540d18d0..7605360c963 100644 --- a/regress/usr.sbin/syslogd/Client.pm +++ b/regress/usr.sbin/syslogd/Client.pm @@ -1,4 +1,4 @@ -# $OpenBSD: Client.pm,v 1.1 2014/08/20 20:52:14 bluhm Exp $ +# $OpenBSD: Client.pm,v 1.2 2014/08/25 17:55:27 bluhm Exp $ # Copyright (c) 2010-2014 Alexander Bluhm <bluhm@openbsd.org> # @@ -36,7 +36,7 @@ sub new { sub child { my $self = shift; - if ($self->{connectdomain}) { + if (defined($self->{connectdomain})) { my $cs = IO::Socket::INET6->new( Proto => "udp", Domain => $self->{connectdomain}, diff --git a/regress/usr.sbin/syslogd/Server.pm b/regress/usr.sbin/syslogd/Server.pm index 5b5397937fb..8bcdf73d630 100644 --- a/regress/usr.sbin/syslogd/Server.pm +++ b/regress/usr.sbin/syslogd/Server.pm @@ -1,4 +1,4 @@ -# $OpenBSD: Server.pm,v 1.1 2014/08/20 20:52:14 bluhm Exp $ +# $OpenBSD: Server.pm,v 1.2 2014/08/25 17:55:27 bluhm Exp $ # Copyright (c) 2010-2014 Alexander Bluhm <bluhm@openbsd.org> # @@ -34,7 +34,7 @@ sub new { $args{up} ||= "Accepted"; my $self = Proc::new($class, %args); $self->{listenprotocol} ||= "udp"; - $self->{listendomain} + defined($self->{listendomain}) or croak "$class listen domain not given"; $SSL_ERROR = ""; my $iosocket = $self->{listenprotocol} eq "tls" ? diff --git a/regress/usr.sbin/syslogd/args-client-udp6-nodns.pl b/regress/usr.sbin/syslogd/args-client-udp6-nodns.pl new file mode 100644 index 00000000000..c608fff2539 --- /dev/null +++ b/regress/usr.sbin/syslogd/args-client-udp6-nodns.pl @@ -0,0 +1,23 @@ +# The client writes a message to a localhost IPv6 UDP socket. +# The syslogd writes it into a file and through a pipe without dns. +# The syslogd passes it via UDP to the loghost. +# The server receives the message on its UDP socket. +# Find the message in client, file, pipe, syslogd, server log. +# Check that the file log contains the ::1 address. + +use strict; +use warnings; + +our %args = ( + client => { + connect => { domain => AF_INET6, addr => "::1", port => 514 }, + }, + syslogd => { + options => ["-un"], + }, + file => { + loggrep => qr/ ::1 /. get_log(), + }, +); + +1; diff --git a/regress/usr.sbin/syslogd/args-client-udp6.pl b/regress/usr.sbin/syslogd/args-client-udp6.pl new file mode 100644 index 00000000000..dda6b91b61a --- /dev/null +++ b/regress/usr.sbin/syslogd/args-client-udp6.pl @@ -0,0 +1,23 @@ +# The client writes a message to a localhost IPv6 UDP socket. +# The syslogd writes it into a file and through a pipe. +# The syslogd passes it via UDP to the loghost. +# The server receives the message on its UDP socket. +# Find the message in client, file, pipe, syslogd, server log. +# Check that the file log contains the localhost name. + +use strict; +use warnings; + +our %args = ( + client => { + connect => { domain => AF_INET6, addr => "::1", port => 514 }, + }, + syslogd => { + options => ["-u"], + }, + file => { + loggrep => qr/ localhost /. get_log(), + }, +); + +1; diff --git a/regress/usr.sbin/syslogd/args-localhost.pl b/regress/usr.sbin/syslogd/args-localhost.pl new file mode 100644 index 00000000000..adb1dbdb078 --- /dev/null +++ b/regress/usr.sbin/syslogd/args-localhost.pl @@ -0,0 +1,34 @@ +# The client writes a message to Sys::Syslog native method. +# The syslogd writes it into a file and through a pipe. +# The syslogd passes it via UDP to localhost. +# The server receives the message on its UDP socket. +# Check that localhost gets resolved to local IPv4 or IPv6 address. + +use strict; +use warnings; + +our %args = ( + client => { + connect => { domain => AF_UNSPEC, addr => "localhost.", port => 514 }, + loggrep => { + qr/connect sock: (127.0.0.1|::1) \d+/ => 1, + get_log() => 1, + }, + }, + syslogd => { + loghost => '@localhost.:$connectport', + options => ["-u"], + loggrep => { + qr/ from localhost, msg /.get_log() => 1, + }, + }, + server => { + listen => { domain => AF_UNSPEC, addr => "localhost." }, + loggrep => { + qr/listen sock: (127.0.0.1|::1) \d+/ => 1, + get_log() => 1, + }, + }, +); + +1; diff --git a/regress/usr.sbin/syslogd/args-maxhostlen.pl b/regress/usr.sbin/syslogd/args-maxhostlen.pl new file mode 100644 index 00000000000..3603e7800c6 --- /dev/null +++ b/regress/usr.sbin/syslogd/args-maxhostlen.pl @@ -0,0 +1,23 @@ +# The client writes a message to Sys::Syslog native method. +# The syslogd writes it into a file and through a pipe. +# The syslogd does not pass it via a too long host name. +# Find the message in client, file, pipe, syslogd log. +# Check that the syslogd logs the error. + +use strict; +use warnings; + +our %args = ( + syslogd => { + loghost => '@'.('X'x256).':514', + loggrep => { + qr/syslogd: host too long "\@X+/ => 2, # XXX 2? + get_log() => 1, + }, + }, + server => { + noserver => 1, + }, +); + +1; diff --git a/regress/usr.sbin/syslogd/args-maxloghostlen.pl b/regress/usr.sbin/syslogd/args-maxloghostlen.pl new file mode 100644 index 00000000000..b628967fcef --- /dev/null +++ b/regress/usr.sbin/syslogd/args-maxloghostlen.pl @@ -0,0 +1,23 @@ +# The client writes a message to Sys::Syslog native method. +# The syslogd writes it into a file and through a pipe. +# The syslogd does not pass it via a too long loghost name. +# Find the message in client, file, pipe, syslogd log. +# Check that the syslogd logs the error. + +use strict; +use warnings; + +our %args = ( + syslogd => { + loghost => '@'.('X'x300), + loggrep => { + qr/syslogd: loghost too long "\@X+/ => 2, # XXX 2? + get_log() => 1, + }, + }, + server => { + noserver => 1, + }, +); + +1; diff --git a/regress/usr.sbin/syslogd/args-maxportlen.pl b/regress/usr.sbin/syslogd/args-maxportlen.pl new file mode 100644 index 00000000000..9d0cce60695 --- /dev/null +++ b/regress/usr.sbin/syslogd/args-maxportlen.pl @@ -0,0 +1,23 @@ +# The client writes a message to Sys::Syslog native method. +# The syslogd writes it into a file and through a pipe. +# The syslogd does not pass it via a too long port name. +# Find the message in client, file, pipe, syslogd log. +# Check that the syslogd logs the error. + +use strict; +use warnings; + +our %args = ( + syslogd => { + loghost => '@127.0.0.1:'.('X'x32), + loggrep => { + qr/syslogd: port too long "\@127.0.0.1:X+/ => 2, # XXX 2? + get_log() => 1, + }, + }, + server => { + noserver => 1, + }, +); + +1; diff --git a/regress/usr.sbin/syslogd/args-server-udp4.pl b/regress/usr.sbin/syslogd/args-server-udp4.pl new file mode 100644 index 00000000000..d43b2cd1cba --- /dev/null +++ b/regress/usr.sbin/syslogd/args-server-udp4.pl @@ -0,0 +1,28 @@ +# The client writes a message to Sys::Syslog native method. +# The syslogd writes it into a file and through a pipe. +# The syslogd passes it via IPv4 UDP to an explicit loghost. +# The server receives the message on its UDP socket. +# Find the message in client, file, pipe, syslogd, server log. +# Check that syslogd and server log contain 127.0.0.1 address. + +use strict; +use warnings; + +our %args = ( + syslogd => { + loghost => '@127.0.0.1:$connectport', + loggrep => { + qr/Logging to FORW \@127.0.0.1:\d+/ => 5, + get_log() => 1, + }, + }, + server => { + listen => { domain => AF_INET, addr => "127.0.0.1" }, + loggrep => { + qr/listen sock: 127.0.0.1 \d+/ => 1, + get_log() => 1, + }, + }, +); + +1; diff --git a/regress/usr.sbin/syslogd/args-server-udp6.pl b/regress/usr.sbin/syslogd/args-server-udp6.pl new file mode 100644 index 00000000000..db393091b41 --- /dev/null +++ b/regress/usr.sbin/syslogd/args-server-udp6.pl @@ -0,0 +1,28 @@ +# The client writes a message to Sys::Syslog native method. +# The syslogd writes it into a file and through a pipe. +# The syslogd passes it via IPv6 UDP to an explicit loghost. +# The server receives the message on its UDP socket. +# Find the message in client, file, pipe, syslogd, server log. +# Check that syslogd and server log contain ::1 address. + +use strict; +use warnings; + +our %args = ( + syslogd => { + loghost => '@[::1]:$connectport', + loggrep => { + qr/Logging to FORW \@\[::1\]:\d+/ => 5, + get_log() => 1, + }, + }, + server => { + listen => { domain => AF_INET6, addr => "::1" }, + loggrep => { + qr/listen sock: ::1 \d+/ => 1, + get_log() => 1, + }, + }, +); + +1; diff --git a/regress/usr.sbin/syslogd/args-socket.pl b/regress/usr.sbin/syslogd/args-socket.pl index 9173a42069e..17c6ed415be 100644 --- a/regress/usr.sbin/syslogd/args-socket.pl +++ b/regress/usr.sbin/syslogd/args-socket.pl @@ -20,6 +20,7 @@ our %args = ( fstat => { loggrep => { qr/ internet dgram udp \*:514$/ => 1, + qr/ internet6 dgram udp \*:514$/ => 1, }, }, ); diff --git a/regress/usr.sbin/syslogd/funcs.pl b/regress/usr.sbin/syslogd/funcs.pl index 181911758c8..c7030d12d1c 100644 --- a/regress/usr.sbin/syslogd/funcs.pl +++ b/regress/usr.sbin/syslogd/funcs.pl @@ -1,4 +1,4 @@ -# $OpenBSD: funcs.pl,v 1.1 2014/08/20 20:52:14 bluhm Exp $ +# $OpenBSD: funcs.pl,v 1.2 2014/08/25 17:55:27 bluhm Exp $ # Copyright (c) 2010-2014 Alexander Bluhm <bluhm@openbsd.org> # @@ -34,7 +34,7 @@ my $downlog = "syslogd regress client shutdown"; sub write_log { my $self = shift; - if ($self->{connectdomain}) { + if (defined($self->{connectdomain})) { print $testlog; print STDERR $testlog, "\n"; } else { |