summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbluhm <bluhm@openbsd.org>2015-07-09 21:12:44 +0000
committerbluhm <bluhm@openbsd.org>2015-07-09 21:12:44 +0000
commit5c5eea2a5b07aea8dccdbe6b4d2fecef583fa744 (patch)
tree2ac8099124ce70d83767d33e2b5caf7a1f9b35b5
parentDuring fd passing, receive_fd() tries to read the result value and (diff)
downloadwireguard-openbsd-5c5eea2a5b07aea8dccdbe6b4d2fecef583fa744.tar.xz
wireguard-openbsd-5c5eea2a5b07aea8dccdbe6b4d2fecef583fa744.zip
Test syslogd with reduced file descriptor limit. It has too many
log files in syslog.conf and must close and reopen them at SIGHUP.
-rw-r--r--regress/usr.sbin/syslogd/Makefile4
-rw-r--r--regress/usr.sbin/syslogd/Proc.pm15
-rw-r--r--regress/usr.sbin/syslogd/args-fdexhaustion-config.pl35
-rw-r--r--regress/usr.sbin/syslogd/args-fdexhaustion-sighup.pl60
4 files changed, 112 insertions, 2 deletions
diff --git a/regress/usr.sbin/syslogd/Makefile b/regress/usr.sbin/syslogd/Makefile
index d0f8d56bb0e..1866f51b0aa 100644
--- a/regress/usr.sbin/syslogd/Makefile
+++ b/regress/usr.sbin/syslogd/Makefile
@@ -1,9 +1,10 @@
-# $OpenBSD: Makefile,v 1.9 2015/06/15 21:44:57 bluhm Exp $
+# $OpenBSD: Makefile,v 1.10 2015/07/09 21:12:44 bluhm Exp $
# The following ports must be installed for the regression tests:
# p5-IO-Socket-INET6 object interface for AF_INET and AF_INET6 domain sockets
# p5-Socket6 Perl defines relating to AF_INET6 sockets
# p5-IO-Socket-SSL perl interface to SSL sockets
+# p5-BSD-Resource BSD process resource limit and priority functions
#
# This package enables additional interoperability tests
# rsyslog syslog daemon supporting databases, TCP, SSL, RELP
@@ -15,6 +16,7 @@ PERL_REQUIRE != perl -Mstrict -Mwarnings -e ' \
eval { require IO::Socket::INET6 } or print $@; \
eval { require Socket6 } or print $@; \
eval { require IO::Socket::SSL } or print $@; \
+ eval { require BSD::Resource } or print $@; \
'
.if ! empty (PERL_REQUIRE)
regress:
diff --git a/regress/usr.sbin/syslogd/Proc.pm b/regress/usr.sbin/syslogd/Proc.pm
index 9b328a93e60..1a8d47bc2b3 100644
--- a/regress/usr.sbin/syslogd/Proc.pm
+++ b/regress/usr.sbin/syslogd/Proc.pm
@@ -1,4 +1,4 @@
-# $OpenBSD: Proc.pm,v 1.6 2015/02/13 21:40:50 bluhm Exp $
+# $OpenBSD: Proc.pm,v 1.7 2015/07/09 21:12:44 bluhm Exp $
# Copyright (c) 2010-2015 Alexander Bluhm <bluhm@openbsd.org>
# Copyright (c) 2014 Florian Riehm <mail@friehm.de>
@@ -19,6 +19,7 @@ use strict;
use warnings;
package Proc;
+use BSD::Resource qw(getrlimit setrlimit get_rlimits);
use Carp;
use Errno;
use IO::File;
@@ -107,6 +108,18 @@ sub run {
or die ref($self), " dup STDIN failed: $!";
close($reader);
+ if ($self->{rlimit}) {
+ my $rlimits = get_rlimits()
+ or die ref($self), " get_rlimits failed: $!";
+ while (my($name, $newsoft) = each %{$self->{rlimit}}) {
+ defined(my $resource = $rlimits->{$name})
+ or die ref($self), " rlimit $name does not exists";
+ my ($soft, $hard) = getrlimit($resource)
+ or die ref($self), " getrlimit $name failed: $!";
+ setrlimit($resource, $newsoft, $hard) or die ref($self),
+ " setrlimit $name to $newsoft failed: $!";
+ }
+ }
if ($self->{ktrace}) {
my @cmd = ("ktrace", "-f", $self->{ktracefile}, "-p", $$);
system(@cmd)
diff --git a/regress/usr.sbin/syslogd/args-fdexhaustion-config.pl b/regress/usr.sbin/syslogd/args-fdexhaustion-config.pl
new file mode 100644
index 00000000000..c5bdfc971dd
--- /dev/null
+++ b/regress/usr.sbin/syslogd/args-fdexhaustion-config.pl
@@ -0,0 +1,35 @@
+# The syslogd is started with reduced file descriptor limits.
+# The syslogd config contains more log files than possible.
+# 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 the loghost.
+# The server receives the message on its UDP socket.
+# Find the message in client, file, pipe, syslogd, server log.
+# Check the error messages and multiple log file content.
+
+use strict;
+use warnings;
+use Cwd;
+
+my $objdir = getcwd();
+
+our %args = (
+ syslogd => {
+ conf => join("", map { "*.*\t$objdir/file-$_.log\n" } 0..19),
+ rlimit => {
+ RLIMIT_NOFILE => 30,
+ },
+ loggrep => {
+ qr/syslogd: receive_fd: recvmsg: Message too long/ => 4,
+ # One file is opened by test default config, 20 by multifile.
+ qr/X FILE:/ => 1+16,
+ qr/X UNUSED:/ => 4,
+ },
+ },
+ multifile => [
+ (map { { loggrep => get_testlog() } } 0..15),
+ (map { { loggrep => { qr/./s => 0 } } } 16..19),
+ ],
+);
+
+1;
diff --git a/regress/usr.sbin/syslogd/args-fdexhaustion-sighup.pl b/regress/usr.sbin/syslogd/args-fdexhaustion-sighup.pl
new file mode 100644
index 00000000000..239954c42a1
--- /dev/null
+++ b/regress/usr.sbin/syslogd/args-fdexhaustion-sighup.pl
@@ -0,0 +1,60 @@
+# The syslogd is started with reduced file descriptor limits.
+# The syslogd config is reread after SIGHUP.
+# 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 the loghost.
+# The server receives the message on its UDP socket.
+# Find the message in client, file, pipe, syslogd, server log.
+# Check the error messages and multiple log file content.
+
+use strict;
+use warnings;
+use Cwd;
+
+my $objdir = getcwd();
+
+our %args = (
+ client => {
+ func => sub { write_between2logs(shift, sub {
+ my $self = shift;
+ ${$self->{server}}->loggrep("Signal", 8)
+ or die ref($self), " no 'Signal' between logs";
+ })},
+ loggrep => { get_between2loggrep() },
+ },
+ syslogd => {
+ conf => join("", map { "*.*\t$objdir/file-$_.log\n" } 0..19),
+ rlimit => {
+ RLIMIT_NOFILE => 30,
+ },
+ loggrep => {
+ # If not in startup, each failed PRIV_OPEN_LOG is logged
+ # to tty, so PRIV_OPEN_TTY fails again.
+ qr/syslogd: receive_fd: recvmsg: Message too long/ => 4+2*3,
+ # During first initialization the lockpipe is open. When
+ # SIGHUP happens it is closed and one more file can be opened.
+ qr/X FILE:/ => 1+16+1+17,
+ qr/X UNUSED:/ => 4+3,
+ },
+ },
+ server => {
+ func => sub { read_between2logs(shift, sub {
+ my $self = shift;
+ ${$self->{syslogd}}->kill_syslogd('HUP');
+ ${$self->{syslogd}}->loggrep("syslogd: restarted", 5)
+ or die ref($self), " no 'syslogd: restarted' between logs";
+ print STDERR "Signal\n";
+ })},
+ loggrep => {
+ get_between2loggrep(),
+ qr/Signal/ => 1,
+ qr/Accepted/ => 1,
+ },
+ },
+ multifile => [
+ (map { { loggrep => get_testlog() } } 0..16),
+ (map { { loggrep => { qr/./s => 0 } } } 17..19),
+ ],
+);
+
+1;