summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2016-11-28 20:57:42 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2016-11-28 20:57:42 +0000
commit322137e42fa1ddcbb3c68cb5e964d80af995116a (patch)
treedabacf90b1683edd57678506e3905b809d6848da
parentfd62949ac731b6e14e4290a1eb6b61fd73fc3caa (diff)
To test the pipe feature, a dd is started and writing into a log
file as user _syslogd. Since /usr/obj is 0770 now, user _syslogd cannot access this file there anymore. Create pipe.log in temporary directory in /tmp instead.
-rw-r--r--regress/usr.sbin/syslogd/Syslogd.pm26
1 files changed, 22 insertions, 4 deletions
diff --git a/regress/usr.sbin/syslogd/Syslogd.pm b/regress/usr.sbin/syslogd/Syslogd.pm
index a493ea2720b..2a60e609e32 100644
--- a/regress/usr.sbin/syslogd/Syslogd.pm
+++ b/regress/usr.sbin/syslogd/Syslogd.pm
@@ -1,4 +1,4 @@
-# $OpenBSD: Syslogd.pm,v 1.20 2016/10/12 23:02:25 bluhm Exp $
+# $OpenBSD: Syslogd.pm,v 1.21 2016/11/28 20:57:41 bluhm Exp $
# Copyright (c) 2010-2015 Alexander Bluhm <bluhm@openbsd.org>
# Copyright (c) 2014 Florian Riehm <mail@friehm.de>
@@ -23,6 +23,8 @@ use parent 'Proc';
use Carp;
use Cwd;
use File::Basename;
+use File::Copy;
+use File::Temp qw(tempfile tempdir);
use Sys::Hostname;
use Time::HiRes qw(time alarm sleep);
@@ -41,7 +43,14 @@ sub new {
$args{func} = sub { Carp::confess "$class func may not be called" };
$args{conffile} ||= "syslogd.conf";
$args{outfile} ||= "file.log";
- $args{outpipe} ||= "pipe.log";
+ unless ($args{outpipe}) {
+ my $dir = tempdir("syslogd-regress-XXXXXXXXXX",
+ CLEANUP => 1, TMPDIR => 1);
+ chmod(0755, $dir)
+ or die "$class chmod directory $dir failed: $!";
+ $args{tempdir} = $dir;
+ $args{outpipe} = "$dir/pipe.log";
+ }
$args{outconsole} ||= "console.log";
$args{outuser} ||= "user.log";
if ($args{memory}) {
@@ -97,9 +106,12 @@ sub create_out {
open($fh, '>', $self->{outpipe})
or die ref($self), " create pipe file $self->{outpipe} failed: $!";
- close $fh;
- chmod(0666, $self->{outpipe})
+ chmod(0644, $self->{outpipe})
or die ref($self), " chmod pipe file $self->{outpipe} failed: $!";
+ my @cmd = (@sudo, "chown", "_syslogd", $self->{outpipe});
+ system(@cmd)
+ and die ref($self), " chown pipe file $self->{outpipe} failed: $!";
+ close $fh;
foreach my $dev (qw(console user)) {
my $file = $self->{"out$dev"};
@@ -214,6 +226,12 @@ sub up {
sub down {
my $self = Proc::up(shift, @_);
+
+ if (my $dir = $self->{tempdir}) {
+ # keep all logs in single directory for easy debugging
+ copy($_, ".") foreach glob("$dir/*");
+ }
+
return $self unless $self->{daemon};
my $timeout = shift || 10;