summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbluhm <bluhm@openbsd.org>2015-12-04 13:49:42 +0000
committerbluhm <bluhm@openbsd.org>2015-12-04 13:49:42 +0000
commitef01d180277bb9d2ab1000a61103676542d37a9c (patch)
tree0d419a82bf2f72117c70e7ec981e88f3d1510354
parentAdd etherip.4 to MAN (diff)
downloadwireguard-openbsd-ef01d180277bb9d2ab1000a61103676542d37a9c.tar.xz
wireguard-openbsd-ef01d180277bb9d2ab1000a61103676542d37a9c.zip
Add tests that call the syscalls sendsyslog(2) and sendsyslog2(2)
directly.
-rw-r--r--regress/usr.sbin/syslogd/Server.pm6
-rw-r--r--regress/usr.sbin/syslogd/args-sendsyslog-native.pl4
-rw-r--r--regress/usr.sbin/syslogd/args-sendsyslog-syscall.pl25
-rw-r--r--regress/usr.sbin/syslogd/args-sendsyslog-syscall2.pl23
-rw-r--r--regress/usr.sbin/syslogd/args-ttymsg-delay.pl2
-rw-r--r--regress/usr.sbin/syslogd/funcs.pl19
-rw-r--r--regress/usr.sbin/syslogd/ttylog.c2
7 files changed, 72 insertions, 9 deletions
diff --git a/regress/usr.sbin/syslogd/Server.pm b/regress/usr.sbin/syslogd/Server.pm
index 25b73055e3e..d81ecf83b69 100644
--- a/regress/usr.sbin/syslogd/Server.pm
+++ b/regress/usr.sbin/syslogd/Server.pm
@@ -1,4 +1,4 @@
-# $OpenBSD: Server.pm,v 1.6 2015/01/28 22:58:38 bluhm Exp $
+# $OpenBSD: Server.pm,v 1.7 2015/12/04 13:49:42 bluhm Exp $
# Copyright (c) 2010-2015 Alexander Bluhm <bluhm@openbsd.org>
#
@@ -57,10 +57,10 @@ sub listen {
SSL_verify_mode => SSL_VERIFY_NONE,
$self->{sslversion} ? (SSL_version => $self->{sslversion}) : (),
$self->{sslciphers} ? (SSL_cipher_list => $self->{sslciphers}) : (),
- ) or die ref($self), " $iosocket socket listen failed: $!,$SSL_ERROR";
+ ) or die ref($self), " $iosocket socket failed: $!,$SSL_ERROR";
if ($self->{listenproto} ne "udp") {
listen($ls, 1)
- or die ref($self), " socket failed: $!";
+ or die ref($self), " socket listen failed: $!";
}
my $log = $self->{log};
print $log "listen sock: ",$ls->sockhost()," ",$ls->sockport(),"\n";
diff --git a/regress/usr.sbin/syslogd/args-sendsyslog-native.pl b/regress/usr.sbin/syslogd/args-sendsyslog-native.pl
index 18f716301ee..0c00ea9c76b 100644
--- a/regress/usr.sbin/syslogd/args-sendsyslog-native.pl
+++ b/regress/usr.sbin/syslogd/args-sendsyslog-native.pl
@@ -12,9 +12,9 @@ use warnings;
our %args = (
client => {
ktrace => {
- qr/CALL sendsyslog/ => 2,
+ qr/CALL sendsyslog2/ => 2,
qr/GIO fd -1 wrote \d+ bytes/ => 2,
- qr/RET sendsyslog 0/ => 2,
+ qr/RET sendsyslog2 0/ => 2,
},
},
);
diff --git a/regress/usr.sbin/syslogd/args-sendsyslog-syscall.pl b/regress/usr.sbin/syslogd/args-sendsyslog-syscall.pl
new file mode 100644
index 00000000000..336a2a8e3a4
--- /dev/null
+++ b/regress/usr.sbin/syslogd/args-sendsyslog-syscall.pl
@@ -0,0 +1,25 @@
+# The client writes a message with sendsyslog syscall.
+# 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.
+# Create a ktrace dump of the client and check that sendsyslog(2)
+# has been used.
+
+use strict;
+use warnings;
+
+our %args = (
+ client => {
+ connect => { domain => "sendsyslog", version => 0 },
+ ktrace => {
+ qr/CALL sendsyslog\(/ => 1,
+ qr/CALL sendsyslog2\(/ => 1,
+ qr/GIO fd -1 wrote \d+ bytes/ => 2,
+ qr/RET sendsyslog 0/ => 1,
+ qr/RET sendsyslog2 0/ => 1,
+ },
+ },
+);
+
+1;
diff --git a/regress/usr.sbin/syslogd/args-sendsyslog-syscall2.pl b/regress/usr.sbin/syslogd/args-sendsyslog-syscall2.pl
new file mode 100644
index 00000000000..1f2a8122561
--- /dev/null
+++ b/regress/usr.sbin/syslogd/args-sendsyslog-syscall2.pl
@@ -0,0 +1,23 @@
+# The client writes a message with sendsyslog2 syscall.
+# 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.
+# Create a ktrace dump of the client and check that sendsyslog2(2)
+# has been used.
+
+use strict;
+use warnings;
+
+our %args = (
+ client => {
+ connect => { domain => "sendsyslog", version => 2, flags => 0 },
+ ktrace => {
+ qr/CALL sendsyslog2\(/ => 2,
+ qr/GIO fd -1 wrote \d+ bytes/ => 2,
+ qr/RET sendsyslog2 0/ => 2,
+ },
+ },
+);
+
+1;
diff --git a/regress/usr.sbin/syslogd/args-ttymsg-delay.pl b/regress/usr.sbin/syslogd/args-ttymsg-delay.pl
index 383247cf91c..f06134747b9 100644
--- a/regress/usr.sbin/syslogd/args-ttymsg-delay.pl
+++ b/regress/usr.sbin/syslogd/args-ttymsg-delay.pl
@@ -13,7 +13,7 @@ our %args = (
client => {
func => sub {
my $self = shift;
- write_lines($self, 2, 900);
+ write_lines($self, 5, 900);
write_log($self);
},
},
diff --git a/regress/usr.sbin/syslogd/funcs.pl b/regress/usr.sbin/syslogd/funcs.pl
index 881169eef44..4cf196db13e 100644
--- a/regress/usr.sbin/syslogd/funcs.pl
+++ b/regress/usr.sbin/syslogd/funcs.pl
@@ -1,4 +1,4 @@
-# $OpenBSD: funcs.pl,v 1.27 2015/10/23 14:06:55 bluhm Exp $
+# $OpenBSD: funcs.pl,v 1.28 2015/12/04 13:49:42 bluhm Exp $
# Copyright (c) 2010-2015 Alexander Bluhm <bluhm@openbsd.org>
#
@@ -86,8 +86,14 @@ sub write_message {
if (defined($self->{connectdomain})) {
my $msg = join("", @_);
if ($self->{connectdomain} eq "sendsyslog") {
- sendsyslog($msg)
- or die ref($self), " sendsyslog failed: $!";
+ if (($self->{connect}{version} || 0) == 2) {
+ my $flags = $self->{connect}{flags} || 0;
+ sendsyslog2($msg, $flags) or die ref($self),
+ " sendsyslog2 failed: $!";
+ } else {
+ sendsyslog($msg) or die ref($self),
+ " sendsyslog failed: $!";
+ }
} elsif ($self->{connectproto} eq "udp") {
# writing UDP packets works only with syswrite()
defined(my $n = syswrite(STDOUT, $msg))
@@ -110,6 +116,13 @@ sub sendsyslog {
return syscall(&SYS_sendsyslog, $msg, length($msg)) != -1;
}
+sub sendsyslog2 {
+ my $msg = shift;
+ my $flags = shift;
+ require 'sys/syscall.ph';
+ return syscall(&SYS_sendsyslog2, $msg, length($msg), $flags) != -1;
+}
+
sub write_shutdown {
my $self = shift;
diff --git a/regress/usr.sbin/syslogd/ttylog.c b/regress/usr.sbin/syslogd/ttylog.c
index 72c410b1bb8..733464893de 100644
--- a/regress/usr.sbin/syslogd/ttylog.c
+++ b/regress/usr.sbin/syslogd/ttylog.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: ttylog.c,v 1.4 2015/12/04 13:49:42 bluhm Exp $ */
+
/*
* Copyright (c) 2015 Alexander Bluhm <bluhm@openbsd.org>
*