summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2020-07-24 22:12:01 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2020-07-24 22:12:01 +0000
commita946a529f7f6cc5d364981ee5ae2fa25ff31c06c (patch)
treedddfcc8d48f1dda868d3a72c342c9421caca4a4d
parent1d3c19decce83c5a4690da9991825b654a1cc92f (diff)
If KTRACE environment is set, generate ktrace output also for client
and server. Together with the syslogd ktrace this helps debugging.
-rw-r--r--regress/usr.sbin/syslogd/Client.pm6
-rw-r--r--regress/usr.sbin/syslogd/Proc.pm13
-rw-r--r--regress/usr.sbin/syslogd/Server.pm6
-rw-r--r--regress/usr.sbin/syslogd/Syslogd.pm12
4 files changed, 23 insertions, 14 deletions
diff --git a/regress/usr.sbin/syslogd/Client.pm b/regress/usr.sbin/syslogd/Client.pm
index b2f2b9514ea..b7215b880e3 100644
--- a/regress/usr.sbin/syslogd/Client.pm
+++ b/regress/usr.sbin/syslogd/Client.pm
@@ -1,6 +1,6 @@
-# $OpenBSD: Client.pm,v 1.11 2017/09/13 00:35:53 bluhm Exp $
+# $OpenBSD: Client.pm,v 1.12 2020/07/24 22:12:00 bluhm Exp $
-# Copyright (c) 2010-2014 Alexander Bluhm <bluhm@openbsd.org>
+# Copyright (c) 2010-2020 Alexander Bluhm <bluhm@openbsd.org>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
@@ -30,6 +30,8 @@ use Sys::Syslog qw(:standard :extended :macros);
sub new {
my $class = shift;
my %args = @_;
+ $args{ktracepid} = "ktrace" if $args{ktrace};
+ $args{ktracepid} = $ENV{KTRACE} if $ENV{KTRACE};
$args{ktracefile} ||= "client.ktrace";
$args{logfile} ||= "client.log";
$args{up} ||= "Openlog";
diff --git a/regress/usr.sbin/syslogd/Proc.pm b/regress/usr.sbin/syslogd/Proc.pm
index f2dde53614c..0769c8a91a3 100644
--- a/regress/usr.sbin/syslogd/Proc.pm
+++ b/regress/usr.sbin/syslogd/Proc.pm
@@ -1,6 +1,6 @@
-# $OpenBSD: Proc.pm,v 1.8 2016/05/03 19:13:04 bluhm Exp $
+# $OpenBSD: Proc.pm,v 1.9 2020/07/24 22:12:00 bluhm Exp $
-# Copyright (c) 2010-2015 Alexander Bluhm <bluhm@openbsd.org>
+# Copyright (c) 2010-2020 Alexander Bluhm <bluhm@openbsd.org>
# Copyright (c) 2014 Florian Riehm <mail@friehm.de>
#
# Permission to use, copy, modify, and distribute this software for any
@@ -65,7 +65,9 @@ sub new {
$self->{down} ||= "Shutdown";
$self->{func} && ref($self->{func}) eq 'CODE'
or croak "$class func not given";
- !$self->{ktrace} || $self->{ktracefile}
+ $self->{ktracepid} && $self->{ktraceexec}
+ and croak "$class ktrace both pid and exec given";
+ !($self->{ktracepid} || $self->{ktraceexec}) || $self->{ktracefile}
or croak "$class ktrace file not given";
$self->{logfile}
or croak "$class log file not given";
@@ -120,8 +122,9 @@ sub run {
" setrlimit $name to $newsoft failed: $!";
}
}
- if ($self->{ktrace}) {
- my @cmd = ("ktrace", "-f", $self->{ktracefile}, "-p", $$);
+ if ($self->{ktracepid}) {
+ my @cmd = ($self->{ktracepid}, "-i", "-f", $self->{ktracefile},
+ "-p", $$);
system(@cmd)
and die ref($self), " system '@cmd' failed: $?";
}
diff --git a/regress/usr.sbin/syslogd/Server.pm b/regress/usr.sbin/syslogd/Server.pm
index 78f4e45e738..c9414325dd6 100644
--- a/regress/usr.sbin/syslogd/Server.pm
+++ b/regress/usr.sbin/syslogd/Server.pm
@@ -1,6 +1,6 @@
-# $OpenBSD: Server.pm,v 1.11 2017/01/31 18:02:54 bluhm Exp $
+# $OpenBSD: Server.pm,v 1.12 2020/07/24 22:12:00 bluhm Exp $
-# Copyright (c) 2010-2015 Alexander Bluhm <bluhm@openbsd.org>
+# Copyright (c) 2010-2020 Alexander Bluhm <bluhm@openbsd.org>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
@@ -29,6 +29,8 @@ use IO::Socket::SSL;
sub new {
my $class = shift;
my %args = @_;
+ $args{ktracepid} = "ktrace" if $args{ktrace};
+ $args{ktracepid} = $ENV{KTRACE} if $ENV{KTRACE};
$args{ktracefile} ||= "server.ktrace";
$args{logfile} ||= "server.log";
$args{up} ||= "Accepted";
diff --git a/regress/usr.sbin/syslogd/Syslogd.pm b/regress/usr.sbin/syslogd/Syslogd.pm
index 9bdde06a95a..101f5e5a2bb 100644
--- a/regress/usr.sbin/syslogd/Syslogd.pm
+++ b/regress/usr.sbin/syslogd/Syslogd.pm
@@ -1,6 +1,6 @@
-# $OpenBSD: Syslogd.pm,v 1.24 2019/09/10 19:58:13 bluhm Exp $
+# $OpenBSD: Syslogd.pm,v 1.25 2020/07/24 22:12:00 bluhm Exp $
-# Copyright (c) 2010-2019 Alexander Bluhm <bluhm@openbsd.org>
+# Copyright (c) 2010-2020 Alexander Bluhm <bluhm@openbsd.org>
# Copyright (c) 2014 Florian Riehm <mail@friehm.de>
#
# Permission to use, copy, modify, and distribute this software for any
@@ -31,6 +31,8 @@ use Time::HiRes qw(time alarm sleep);
sub new {
my $class = shift;
my %args = @_;
+ $args{ktraceexec} = "ktrace" if $args{ktrace};
+ $args{ktraceexec} = $ENV{KTRACE} if $ENV{KTRACE};
$args{ktracefile} ||= "syslogd.ktrace";
$args{fstatfile} ||= "syslogd.fstat";
$args{logfile} ||= "syslogd.log";
@@ -191,9 +193,9 @@ sub child {
push @libevent, "$_=1" if delete $ENV{$_};
}
push @libevent, "EVENT_SHOW_METHOD=1" if @libevent;
- my @ktrace = $ENV{KTRACE} || ();
- @ktrace = "ktrace" if $self->{ktrace} && !@ktrace;
- push @ktrace, "-i", "-f", $self->{ktracefile} if @ktrace;
+ my @ktrace;
+ @ktrace = ($self->{ktraceexec}, "-i", "-f", $self->{ktracefile})
+ if $self->{ktraceexec};
my @cmd = (@sudo, @libevent, @ktrace, $self->{execfile},
"-f", $self->{conffile});
push @cmd, "-d" if !$self->{foreground} && !$self->{daemon};