Skip to content

Commit

Permalink
Test localhost in config file.
Browse files Browse the repository at this point in the history
Write localhost into pfresolved config.
Wait until pfresolved creates table regress-pfresolved.
Read IP addresses from pf table with pfctl.
Check that pfresolved added 127.0.0.1 and ::1.
Check that table contains 127.0.0.1 and ::1.
  • Loading branch information
bluhm authored and CaBeckmann committed Nov 7, 2023
1 parent bd432b8 commit fffb702
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
12 changes: 8 additions & 4 deletions regress/Pfctl.pm
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ sub new {

sub child {
my $self = shift;
my $timeout = $self->{timeout} || 5;
my $updates = $self->{updates};
my $pfresolved = $self->{pfresolved};

my $table = "updating addresses for pf table";
$pfresolved->loggrep($table, 5)
or die ref($self), " no '$table' in $pfresolved->{logfile} ".
"after 5 seconds";
my $table = "updated addresses for pf table";
my $tomsg = $timeout ? " after $timeout seconds" : "";
my $upmsg = $updates ? " for $updates times" : "";
$pfresolved->loggrep($table, $timeout, $updates)
or die ref($self), " no '$table' in $pfresolved->{logfile}",
$tomsg, $upmsg;

open(STDOUT, '>&', \*STDERR)
or die ref($self), " dup STDOUT failed: $!";
Expand Down
2 changes: 1 addition & 1 deletion regress/Pfresolved.pm
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ sub child {
my @ktrace;
@ktrace = ($self->{ktraceexec}, "-i", "-f", $self->{ktracefile})
if $self->{ktraceexec};
my @cmd = (@sudo, @ktrace, $self->{execfile}, "-dvv",
my @cmd = (@sudo, @ktrace, $self->{execfile}, "-dvvv",
"-f", $self->{conffile});
print STDERR "execute: @cmd\n";
exec @cmd;
Expand Down
27 changes: 27 additions & 0 deletions regress/args-localhost.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Write localhost into pfresolved config.
# Wait until pfresolved creates table regress-pfresolved.
# Read IP addresses from pf table with pfctl.
# Check that pfresolved added 127.0.0.1 and ::1.
# Check that table contains 127.0.0.1 and ::1.

use strict;
use warnings;

our %args = (
pfresolved => {
address_list => [qw(localhost.)], # must resolve A and AAAA
loggrep => {
qr{added: 127.0.0.1/32,} => 1,
qr{added: ::1/128,} => 1,
},
},
pfctl => {
updates => 3,
loggrep => {
qr/^ 127.0.0.1$/ => 1,
qr/^ ::1$/ => 1,
},
},
);

1;

0 comments on commit fffb702

Please sign in to comment.