summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2015-05-19 04:10:34 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2015-05-19 04:10:34 (GMT)
commit20fed8167852cf54fc89322bb5f5cb1e16653b3d (patch) (side-by-side diff)
tree3bd8aae2655a7ad471f8de3e9f922dc347c3ff92
parenteb851ae32ee068dd368a8cb6db9b04e526316643 (diff)
downloaddnstools-20fed8167852cf54fc89322bb5f5cb1e16653b3d.tar.gz
dnstools-20fed8167852cf54fc89322bb5f5cb1e16653b3d.tar.bz2
Bugfixes
* dgd/dgd: Support for core.pidfile (readconfig): New keyword include.pathopt Use bsd_globr; don't complain if pattern does not match any file. (scan_links): Don't treat undefined core.active as error. * dgd/rc.uplink (linkup): Print semicolon after each IP.
Diffstat (more/less context) (ignore whitespace changes)
-rwxr-xr-xdgd/dgd31
-rwxr-xr-xdgd/rc.uplink2
2 files changed, 25 insertions, 8 deletions
diff --git a/dgd/dgd b/dgd/dgd
index 0afae81..4aa7f02 100755
--- a/dgd/dgd
+++ b/dgd/dgd
@@ -17,6 +17,7 @@
use strict;
use Getopt::Long qw(:config gnu_getopt no_ignore_case);
use File::Basename;
+use File::Glob ':bsd_glob';
use Net::Ping;
use Pod::Usage;
use Pod::Man;
@@ -70,7 +71,8 @@ my %kw = (
active => 1,
up => { check => \&check_prog },
down => { check => \&check_prog },
- logpriority => { re => '^0|1$' }
+ logpriority => { re => '^0|1$' },
+ pidfile => 1
}
},
syslog => {
@@ -203,10 +205,12 @@ sub readconfig {
my $conf = shift;
my %param = @_;
+ debug(1, "reading $file");
open(my $fd, "<", $file)
or do {
+ error("can't open configuration file $file: $!");
return 1 if $param{include};
- abend(EX_NOINPUT, "can't open configuration file $file: $!");
+ exit(EX_NOINPUT);
};
my $line;
@@ -263,9 +267,12 @@ sub readconfig {
if ($include) {
if ($k eq 'path') {
$err += readconfig($v, $conf, include => 1, @_);
+ } elsif ($k eq 'pathopt') {
+ $err += readconfig($v, $conf, include => 1, @_)
+ if -f $v;
} elsif ($k eq 'glob') {
- foreach my $file (glob $v) {
- $err += readconfig($file, $conf, @_);
+ foreach my $file (bsd_glob($v, 0)) {
+ $err += readconfig($file, $conf, include => 1, @_);
}
} else {
error("$file:$line: unknown keyword");
@@ -314,7 +321,7 @@ sub readconfig {
}
close $fd;
if (defined($param{kw}) and !$param{include}) {
- $err += check_mandatory($conf, $param{kw}, "$file:$line", 1)
+ $err += check_mandatory($conf, $param{kw}, "$file:$line", 1);
}
return $err;
}
@@ -353,8 +360,9 @@ sub scan_links {
if ($active_link > $#links);
} else {
my $gw = get_default_gw();
- debug(1, "default gw $gw");
if (defined($gw)) {
+ debug(1, "default gw $gw");
+
for ($active_link = 0; $active_link <= $#links; ++$active_link) {
last if $links[$active_link]->{gw} eq $gw;
}
@@ -364,7 +372,8 @@ sub scan_links {
debug(1, "active link $links[$active_link]->{name}");
} else {
- abend(EX_CONFIG, "no active link configured")
+ debug(1, "no active link configured");
+ $active_link = undef;
}
}
@@ -624,6 +633,10 @@ another file. It can contain following variables:
Include contents of F<FILE>. The file must exist.
+=item B<pathopt => F<FILE>
+
+Same as B<path>, except that F<FILE> is not required to exist.
+
=item B<glob => I<PATTERN>
Include all files matching B<glob>(7) I<PATTERN>. It is OK if no
@@ -673,6 +686,10 @@ the link in question is passed as argument to I<COMMAND>.
Name of the external command to run when a link goes up. Name of
the link in question is passed as argument to I<COMMAND>.
+=item B<pidfile => I<FILE>
+
+Write PID of the B<dgd> daemon process to I<FILE>.
+
=back
=head2 Section B<[syslog]>
diff --git a/dgd/rc.uplink b/dgd/rc.uplink
index ac0488a..f116293 100755
--- a/dgd/rc.uplink
+++ b/dgd/rc.uplink
@@ -74,7 +74,7 @@ linkup() {
EOT
echo "$link_ns" | awk '
BEGIN { print "forwarders {" }
-{ for (i = 1; i <= NF; i++) print " " $(i); }
+{ for (i = 1; i <= NF; i++) print " " $(i) ";"; }
END { print "};" }' > $forwarders
rndc reload
else

Return to:

Send suggestions and report system problems to the System administrator.