summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbluhm <bluhm@openbsd.org>2017-04-28 15:04:49 +0000
committerbluhm <bluhm@openbsd.org>2017-04-28 15:04:49 +0000
commit1c9afadeb178022c0da9820a851975efe9e6dea4 (patch)
treeee920bc2ce153e72eabe688e241c1a0ad1ad0c84
parentWhen syslogd(8) failed to open a logfile, the error message could (diff)
downloadwireguard-openbsd-1c9afadeb178022c0da9820a851975efe9e6dea4.tar.xz
wireguard-openbsd-1c9afadeb178022c0da9820a851975efe9e6dea4.zip
Check that non existing log files in syslog.conf are reported to
/dev/console during startup and restart. Startup warnings contain the pid now. Console logging creates additional errors if the file descriptor limit is exhausted.
-rw-r--r--regress/usr.sbin/syslogd/args-fdexhaustion-config.pl2
-rw-r--r--regress/usr.sbin/syslogd/args-fdexhaustion-tcp.pl2
-rw-r--r--regress/usr.sbin/syslogd/args-maxhostlen.pl2
-rw-r--r--regress/usr.sbin/syslogd/args-maxloghostlen.pl2
-rw-r--r--regress/usr.sbin/syslogd/args-maxportlen.pl2
-rw-r--r--regress/usr.sbin/syslogd/args-nofile-sighup.pl53
-rw-r--r--regress/usr.sbin/syslogd/args-nofile.pl34
-rw-r--r--regress/usr.sbin/syslogd/args-proto-invalid.pl2
-rw-r--r--regress/usr.sbin/syslogd/args-proto-udp4-host6.pl2
-rw-r--r--regress/usr.sbin/syslogd/args-proto-udp4-only6.pl2
-rw-r--r--regress/usr.sbin/syslogd/args-proto-udp6-host4.pl2
-rw-r--r--regress/usr.sbin/syslogd/args-proto-udp6-only4.pl2
-rw-r--r--regress/usr.sbin/syslogd/args-tls-cafile-noexist.pl2
13 files changed, 98 insertions, 11 deletions
diff --git a/regress/usr.sbin/syslogd/args-fdexhaustion-config.pl b/regress/usr.sbin/syslogd/args-fdexhaustion-config.pl
index dfeb97ea310..b30d7ebfc2f 100644
--- a/regress/usr.sbin/syslogd/args-fdexhaustion-config.pl
+++ b/regress/usr.sbin/syslogd/args-fdexhaustion-config.pl
@@ -17,7 +17,7 @@ our %args = (
RLIMIT_NOFILE => 30,
},
loggrep => {
- qr/syslogd: receive_fd: recvmsg: Message too long/ => 5,
+ qr/syslogd: receive_fd: recvmsg: Message too long/ => 5*2,
# One file is opened by test default config, 20 by multifile.
qr/X FILE:/ => 1+15,
qr/X UNUSED:/ => 5,
diff --git a/regress/usr.sbin/syslogd/args-fdexhaustion-tcp.pl b/regress/usr.sbin/syslogd/args-fdexhaustion-tcp.pl
index d4bae232733..4cb0e8c364a 100644
--- a/regress/usr.sbin/syslogd/args-fdexhaustion-tcp.pl
+++ b/regress/usr.sbin/syslogd/args-fdexhaustion-tcp.pl
@@ -25,7 +25,7 @@ our %args = (
RLIMIT_NOFILE => 30,
},
loggrep => {
- qr/syslogd: receive_fd: recvmsg: Message too long/ => 6,
+ qr/syslogd: receive_fd: recvmsg: Message too long/ => 6*2,
# One file is opened by test default config, 20 by multifile.
qr/X FILE:/ => 1+14,
qr/X UNUSED:/ => 6,
diff --git a/regress/usr.sbin/syslogd/args-maxhostlen.pl b/regress/usr.sbin/syslogd/args-maxhostlen.pl
index 8122f756241..803d227cc65 100644
--- a/regress/usr.sbin/syslogd/args-maxhostlen.pl
+++ b/regress/usr.sbin/syslogd/args-maxhostlen.pl
@@ -11,7 +11,7 @@ our %args = (
syslogd => {
loghost => '@'.('X'x256).':514',
loggrep => {
- qr/syslogd: host too long "\@X+/ => 1,
+ qr/syslogd\[\d+\]: host too long "\@X+/ => 1,
get_testgrep() => 1,
},
},
diff --git a/regress/usr.sbin/syslogd/args-maxloghostlen.pl b/regress/usr.sbin/syslogd/args-maxloghostlen.pl
index 009d7098f17..1bb3f70d7f8 100644
--- a/regress/usr.sbin/syslogd/args-maxloghostlen.pl
+++ b/regress/usr.sbin/syslogd/args-maxloghostlen.pl
@@ -11,7 +11,7 @@ our %args = (
syslogd => {
loghost => '@'.('X'x300),
loggrep => {
- qr/syslogd: loghost too long "\@X+/ => 1,
+ qr/syslogd\[\d+\]: loghost too long "\@X+/ => 1,
get_testgrep() => 1,
},
},
diff --git a/regress/usr.sbin/syslogd/args-maxportlen.pl b/regress/usr.sbin/syslogd/args-maxportlen.pl
index 6ac63f451fb..170c78da1bd 100644
--- a/regress/usr.sbin/syslogd/args-maxportlen.pl
+++ b/regress/usr.sbin/syslogd/args-maxportlen.pl
@@ -12,7 +12,7 @@ our %args = (
syslogd => {
loghost => '@127.0.0.1:'.('X'x32),
loggrep => {
- qr/syslogd: port too long "\@127.0.0.1:X+/ => 1,
+ qr/syslogd\[\d+\]: port too long "\@127.0.0.1:X+/ => 1,
get_testgrep() => 1,
},
},
diff --git a/regress/usr.sbin/syslogd/args-nofile-sighup.pl b/regress/usr.sbin/syslogd/args-nofile-sighup.pl
new file mode 100644
index 00000000000..bde2e8f9271
--- /dev/null
+++ b/regress/usr.sbin/syslogd/args-nofile-sighup.pl
@@ -0,0 +1,53 @@
+# The syslogd has a non existing log file in its config.
+# The client waits for syslogd startup and sends sighup.
+# The client writes a message to Sys::Syslog native method.
+# The syslogd writes it into a file and through a pipe and to tty.
+# 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, console, user, syslogd, server log.
+# Check that only the error message is twice in the console log.
+
+use strict;
+use warnings;
+
+our %args = (
+ client => {
+ func => sub {
+ my $self = shift;
+ ${$self->{syslogd}}->loggrep("syslogd: started", 5)
+ or die ref($self), " no 'syslogd: started' in log";
+ ${$self->{syslogd}}->kill_syslogd('HUP');
+ ${$self->{syslogd}}->loggrep("syslogd: restarted", 5)
+ or die ref($self), " no 'syslogd: restarted' in log";
+ write_log($self);
+ },
+ },
+ syslogd => {
+ conf => "*.*\t\$objdir/file-noexist.log\n",
+ loggrep => {
+ qr{syslogd\[\d+\]: priv_open_log ".*/file-noexist.log": }.
+ qr{No such file or directory} => 2,
+ qr/syslogd: started/ => 1,
+ qr/syslogd: restarted/ => 1,
+ },
+ noconsole => 1, # do not write /dev/console in config file
+ },
+ console => {
+ loggrep => {
+ qr{".*/file-noexist.log": No such file or directory} => 2,
+ qr/syslogd\[\d+\]: start/ => 0,
+ qr/syslogd\[\d+\]: restart/ => 0,
+ get_testgrep() => 0,
+ },
+ },
+ file => {
+ loggrep => {
+ qr{".*/file-noexist.log": No such file or directory} => 0,
+ qr/syslogd\[\d+\]: start/ => 1,
+ qr/syslogd\[\d+\]: restart/ => 1,
+ get_testgrep() => 1,
+ },
+ },
+);
+
+1;
diff --git a/regress/usr.sbin/syslogd/args-nofile.pl b/regress/usr.sbin/syslogd/args-nofile.pl
new file mode 100644
index 00000000000..0e5ffad2980
--- /dev/null
+++ b/regress/usr.sbin/syslogd/args-nofile.pl
@@ -0,0 +1,34 @@
+# The syslogd has a non existing log file in its config.
+# The client writes a message to Sys::Syslog native method.
+# The syslogd writes it into a file and through a pipe and to tty.
+# 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, console, user, syslogd, server log.
+# Check that the error message during config read is in the console log.
+
+use strict;
+use warnings;
+
+our %args = (
+ syslogd => {
+ conf => "*.*\t\$objdir/file-noexist.log\n",
+ loggrep => {
+ qr{syslogd\[\d+\]: priv_open_log ".*/file-noexist.log": }.
+ qr{No such file or directory} => 1,
+ },
+ },
+ console => {
+ loggrep => {
+ qr{".*/file-noexist.log": No such file or directory} => 1,
+ get_testgrep() => 1,
+ },
+ },
+ file => {
+ loggrep => {
+ qr{".*/file-noexist.log": No such file or directory} => 0,
+ get_testgrep() => 1,
+ },
+ },
+);
+
+1;
diff --git a/regress/usr.sbin/syslogd/args-proto-invalid.pl b/regress/usr.sbin/syslogd/args-proto-invalid.pl
index f998ef536d0..553cb82f46e 100644
--- a/regress/usr.sbin/syslogd/args-proto-invalid.pl
+++ b/regress/usr.sbin/syslogd/args-proto-invalid.pl
@@ -11,7 +11,7 @@ our %args = (
syslogd => {
loghost => '@invalid://127.0.0.1',
loggrep => {
- qr/syslogd: bad protocol "\@invalid:\/\/127.0.0.1"/ => 1,
+ qr/syslogd\[\d+\]: bad protocol "\@invalid:\/\/127.0.0.1"/ => 1,
get_testgrep() => 1,
},
},
diff --git a/regress/usr.sbin/syslogd/args-proto-udp4-host6.pl b/regress/usr.sbin/syslogd/args-proto-udp4-host6.pl
index d70228887c0..37f6a072b6d 100644
--- a/regress/usr.sbin/syslogd/args-proto-udp4-host6.pl
+++ b/regress/usr.sbin/syslogd/args-proto-udp4-host6.pl
@@ -11,7 +11,7 @@ our %args = (
syslogd => {
loghost => '@udp4://[::1]',
loggrep => {
- qr/syslogd: bad hostname "\@udp4:\/\/\[::1\]"/ => 1,
+ qr/syslogd\[\d+\]: bad hostname "\@udp4:\/\/\[::1\]"/ => 1,
get_testgrep() => 1,
},
},
diff --git a/regress/usr.sbin/syslogd/args-proto-udp4-only6.pl b/regress/usr.sbin/syslogd/args-proto-udp4-only6.pl
index f28e26dedce..ba8ddf8f3cc 100644
--- a/regress/usr.sbin/syslogd/args-proto-udp4-only6.pl
+++ b/regress/usr.sbin/syslogd/args-proto-udp4-only6.pl
@@ -11,7 +11,7 @@ our %args = (
syslogd => {
loghost => '@udp4://127.0.0.1',
loggrep => {
- qr/syslogd: no udp4 "\@udp4:\/\/127.0.0.1/ => 1,
+ qr/syslogd\[\d+\]: no udp4 "\@udp4:\/\/127.0.0.1/ => 1,
get_testgrep() => 1,
},
options => ["-6"],
diff --git a/regress/usr.sbin/syslogd/args-proto-udp6-host4.pl b/regress/usr.sbin/syslogd/args-proto-udp6-host4.pl
index bc0f3aa8cc4..aff56c9f9f6 100644
--- a/regress/usr.sbin/syslogd/args-proto-udp6-host4.pl
+++ b/regress/usr.sbin/syslogd/args-proto-udp6-host4.pl
@@ -11,7 +11,7 @@ our %args = (
syslogd => {
loghost => '@udp6://127.0.0.1',
loggrep => {
- qr/syslogd: bad hostname "\@udp6:\/\/127.0.0.1"/ => 1,
+ qr/syslogd\[\d+\]: bad hostname "\@udp6:\/\/127.0.0.1"/ => 1,
get_testgrep() => 1,
},
},
diff --git a/regress/usr.sbin/syslogd/args-proto-udp6-only4.pl b/regress/usr.sbin/syslogd/args-proto-udp6-only4.pl
index a863c3471d0..0aca8099b20 100644
--- a/regress/usr.sbin/syslogd/args-proto-udp6-only4.pl
+++ b/regress/usr.sbin/syslogd/args-proto-udp6-only4.pl
@@ -11,7 +11,7 @@ our %args = (
syslogd => {
loghost => '@udp6://[::1]',
loggrep => {
- qr/syslogd: no udp6 "\@udp6:\/\/\[::1\]/ => 1,
+ qr/syslogd\[\d+\]: no udp6 "\@udp6:\/\/\[::1\]/ => 1,
get_testgrep() => 1,
},
options => ["-4"],
diff --git a/regress/usr.sbin/syslogd/args-tls-cafile-noexist.pl b/regress/usr.sbin/syslogd/args-tls-cafile-noexist.pl
index 8105a94ccf0..83c05c7cea7 100644
--- a/regress/usr.sbin/syslogd/args-tls-cafile-noexist.pl
+++ b/regress/usr.sbin/syslogd/args-tls-cafile-noexist.pl
@@ -13,7 +13,7 @@ our %args = (
syslogd => {
loghost => '@tls://localhost:$connectport',
loggrep => {
- qr/syslogd: load client TLS CA: failed to open CA file/ => 1,
+ qr/syslogd\[\d+\]: load client TLS CA: failed to open CA file/ => 1,
qr/Logging to FORWTLS \@tls:\/\/localhost:\d+/ => '>=4',
qr/syslogd\[\d+\]: tls_connect_socket .*: /.
qr/ssl verify memory setup failure/ => 1,