Skip to content

Commit

Permalink
Test TTL with more aggressive sighup.
Browse files Browse the repository at this point in the history
If test runs with SUDO=doas sending SUGHUP to nsd may fail.  In
this case execute /bin/kill as root to send signal to nsd.
  • Loading branch information
bluhm authored and CaBeckmann committed Nov 24, 2023
1 parent f2a2203 commit 0dbe7b5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
20 changes: 16 additions & 4 deletions regress/Nsd.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use warnings;
package Nsd;
use parent 'Proc';
use Carp;
use Errno;
use File::Basename;
use Socket;
use Sys::Hostname;
Expand Down Expand Up @@ -164,11 +165,22 @@ sub zone {
system(@cmd) and die ref($self),
"sign regress zone command '@cmd' failed: $?";
}
}

if ($args{sighup}) {
kill('HUP', $self->{pid}) or die
ref($self), " kill HUP child '$self->{pid}' failed: $!";
}
sub sighup {
my $self = shift;

kill(HUP => $self->{pid})
and return;

my @sudo = split(' ', $ENV{SUDO});
@sudo && $!{EPERM}
or die ref($self), " kill HUP child '$self->{pid}' failed: $!";

# sudo is enabled and kill failed with operation not permitted
my @cmd = (@sudo, '/bin/kill', '-HUP', $self->{pid});
system(@cmd)
and die ref($self), " command '@cmd' failed: $?";
}

sub child {
Expand Down
2 changes: 1 addition & 1 deletion regress/args-ttl.pl
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
"foobar A 192.0.2.20",
"foobar AAAA 2001:DB8::20",
],
sighup => 1,
);
$nsd->sighup();

# wait until TTL 2 has expired, pfresolvd delays another second,
# waiting another 2 seconds is against a race in the test
Expand Down

0 comments on commit 0dbe7b5

Please sign in to comment.