summaryrefslogtreecommitdiff
path: root/regress/usr.sbin
diff options
context:
space:
mode:
Diffstat (limited to 'regress/usr.sbin')
-rw-r--r--regress/usr.sbin/syslogd/Syslogd.pm33
-rw-r--r--regress/usr.sbin/syslogd/args-privsep-daemon.pl7
-rw-r--r--regress/usr.sbin/syslogd/args-privsep-foreground.pl7
-rw-r--r--regress/usr.sbin/syslogd/args-privsep.pl11
4 files changed, 46 insertions, 12 deletions
diff --git a/regress/usr.sbin/syslogd/Syslogd.pm b/regress/usr.sbin/syslogd/Syslogd.pm
index 8e1a42607b9..a493ea2720b 100644
--- a/regress/usr.sbin/syslogd/Syslogd.pm
+++ b/regress/usr.sbin/syslogd/Syslogd.pm
@@ -1,4 +1,4 @@
-# $OpenBSD: Syslogd.pm,v 1.19 2016/07/12 15:44:58 bluhm Exp $
+# $OpenBSD: Syslogd.pm,v 1.20 2016/10/12 23:02:25 bluhm Exp $
# Copyright (c) 2010-2015 Alexander Bluhm <bluhm@openbsd.org>
# Copyright (c) 2014 Florian Riehm <mail@friehm.de>
@@ -68,9 +68,9 @@ sub new {
open(my $fh, '>', $self->{conffile})
or die ref($self), " create conf file $self->{conffile} failed: $!";
print $fh "*.*\t$self->{outfile}\n";
- print $fh "*.*\t|dd of=$self->{outpipe}\n";
- print $fh "*.*\t/dev/console\n";
- print $fh "*.*\tsyslogd-regress\n";
+ print $fh "*.*\t|dd of=$self->{outpipe}\n" unless $self->{nopipe};
+ print $fh "*.*\t/dev/console\n" unless $self->{noconsole};
+ print $fh "*.*\tsyslogd-regress\n" unless $self->{nouser};
my $memory = $self->{memory};
print $fh "*.*\t:$memory->{size}:$memory->{name}\n" if $memory;
my $loghost = $self->{loghost};
@@ -189,7 +189,7 @@ sub up {
# check fstat kqueue entry to detect statup
open(my $fh, '<', $self->{fstatfile}) or die ref($self),
" open $self->{fstatfile} for reading failed: $!";
- last if grep { /kqueue/ } <$fh>;
+ last if grep { /kqueue .* state: W/ } <$fh>;
time() < $end
or croak ref($self), " no 'kqueue' in $self->{fstatfile} ".
"after $timeout seconds";
@@ -212,6 +212,29 @@ sub up {
return $self;
}
+sub down {
+ my $self = Proc::up(shift, @_);
+ return $self unless $self->{daemon};
+
+ my $timeout = shift || 10;
+ my $end = time() + $timeout;
+
+ my @sudo = $ENV{SUDO} ? $ENV{SUDO} : "env";
+ my @pkill = (@sudo, "pkill", "-TERM", "-x", "syslogd");
+ my @pgrep = ("pgrep", "-x", "syslogd");
+ system(@pkill) && $? != 256
+ and die ref($self), " system '@pkill' failed: $?";
+ do {
+ sleep .1;
+ system(@pgrep) && $? != 256
+ and die ref($self), " system '@pgrep' failed: $?";
+ return $self if $? == 256;
+ print STDERR "syslogd still running\n";
+ } while (time() < $end);
+
+ return;
+}
+
sub fstat {
my $self = shift;
diff --git a/regress/usr.sbin/syslogd/args-privsep-daemon.pl b/regress/usr.sbin/syslogd/args-privsep-daemon.pl
index 771713b3b86..092bb5d1852 100644
--- a/regress/usr.sbin/syslogd/args-privsep-daemon.pl
+++ b/regress/usr.sbin/syslogd/args-privsep-daemon.pl
@@ -14,6 +14,9 @@ use warnings;
our %args = (
syslogd => {
daemon => 1,
+ nopipe => 1,
+ noconsole => 1,
+ nouser => 1,
loggrep => {
qr/ -F / => 0,
qr/ -d / => 0,
@@ -31,8 +34,8 @@ our %args = (
qr/^_syslogd .* internet/ => 2,
},
ktrace => {
- qr/CALL setresuid(.*"_syslogd".*){3}/ => 2,
- qr/CALL setresgid(.*"_syslogd".*){3}/ => 2,
+ qr/CALL setresuid(.*"_syslogd".*){3}/ => 1,
+ qr/CALL setresgid(.*"_syslogd".*){3}/ => 1,
qr/CALL setsid/ => 1,
qr/RET setsid.* errno / => 0,
},
diff --git a/regress/usr.sbin/syslogd/args-privsep-foreground.pl b/regress/usr.sbin/syslogd/args-privsep-foreground.pl
index dfffd197a63..f7dbfa9e595 100644
--- a/regress/usr.sbin/syslogd/args-privsep-foreground.pl
+++ b/regress/usr.sbin/syslogd/args-privsep-foreground.pl
@@ -14,6 +14,9 @@ use warnings;
our %args = (
syslogd => {
foreground => 1,
+ nopipe => 1,
+ noconsole => 1,
+ nouser => 1,
loggrep => {
qr/ -F / => 1,
qr/ -d / => 0,
@@ -31,8 +34,8 @@ our %args = (
qr/^_syslogd .* internet/ => 2,
},
ktrace => {
- qr/CALL setresuid(.*"_syslogd".*){3}/ => 2,
- qr/CALL setresgid(.*"_syslogd".*){3}/ => 2,
+ qr/CALL setresuid(.*"_syslogd".*){3}/ => 1,
+ qr/CALL setresgid(.*"_syslogd".*){3}/ => 1,
qr/CALL setsid/ => 0,
},
},
diff --git a/regress/usr.sbin/syslogd/args-privsep.pl b/regress/usr.sbin/syslogd/args-privsep.pl
index 66ade910f65..ac300164b94 100644
--- a/regress/usr.sbin/syslogd/args-privsep.pl
+++ b/regress/usr.sbin/syslogd/args-privsep.pl
@@ -2,7 +2,7 @@
# 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.
+# Find the message in client, file, syslogd, server log.
# Check fstat for the parent and child process.
# Check ktrace for setting the correct uid and gid and exec priv.
@@ -12,6 +12,9 @@ use warnings;
our %args = (
syslogd => {
up => qr/fork\+exec done/,
+ nopipe => 1,
+ noconsole => 1,
+ nouser => 1,
loggrep => {
qr/ -F / => 0,
qr/ -d / => 1,
@@ -30,13 +33,15 @@ our %args = (
qr/^_syslogd .* internet/ => 2,
},
ktrace => {
- qr/syslogd CALL setresuid(.*"_syslogd".*){3}/ => 2,
- qr/syslogd CALL setresgid(.*"_syslogd".*){3}/ => 2,
+ qr/syslogd CALL setresuid(.*"_syslogd".*){3}/ => 1,
+ qr/syslogd CALL setresgid(.*"_syslogd".*){3}/ => 1,
qr/syslogd CALL setsid/ => 0,
qr/syslogd RET execve 0/ => 2,
qr/\[\d\] = "-P"/ => 1,
},
},
+ pipe => { nocheck => 1 },
+ tty => { nocheck => 1 },
);
1;