summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2015-05-20 05:04:56 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2015-05-20 05:08:37 (GMT)
commit1866566b9abb7ee4d3cd4f04fe9a88959db8fc4e (patch) (side-by-side diff)
tree7761d3029ccfbda3dad6824820e176642bafbfd6
parent20fed8167852cf54fc89322bb5f5cb1e16653b3d (diff)
downloaddnstools-1866566b9abb7ee4d3cd4f04fe9a88959db8fc4e.tar.gz
dnstools-1866566b9abb7ee4d3cd4f04fe9a88959db8fc4e.tar.bz2
Fix reconfiguration on SIGNUP
* dgd/dgd (defconfig): New variable. (readconfig): Remove calls to check_mandatory (temporarly) (scan_links): Filter off incomplete link definitions. Don't panic if core.active points to an undefined link. (main): Initialize %config. (SIGHUP): Initialize %t.
Diffstat (more/less context) (ignore whitespace changes)
-rwxr-xr-xdgd/dgd36
1 files changed, 20 insertions, 16 deletions
diff --git a/dgd/dgd b/dgd/dgd
index 4aa7f02..1aeac04 100755
--- a/dgd/dgd
+++ b/dgd/dgd
@@ -36,7 +36,7 @@ my $use_syslog;
my @links;
my $active_link;
-my %config = (
+my %defconfig = (
core => {
interval => 60,
timeout => 3,
@@ -44,6 +44,7 @@ my %config = (
tolerance => 2
}
);
+my %config;
my $rxip = '\d{1,3}\.\d{1,3}.\d{1,3}.\d{1,3}';
@@ -235,9 +236,6 @@ sub readconfig {
next if ($_ eq "");
if (/^\[(.+?)\]$/) {
- $err += check_mandatory($section, $kw, "$file:$line")
- if defined $kw;
-
$include = 0;
my $arg = $1;
$arg =~ s/^\s+//;
@@ -320,9 +318,9 @@ sub readconfig {
}
}
close $fd;
- if (defined($param{kw}) and !$param{include}) {
- $err += check_mandatory($conf, $param{kw}, "$file:$line", 1);
- }
+ # if (defined($param{kw}) and !$param{include}) {
+ # $err += check_mandatory($conf, $param{kw}, "$file:$line", 1);
+ # }
return $err;
}
@@ -342,9 +340,13 @@ sub get_default_gw {
sub scan_links {
@links = sort { $a->{priority} <=> $b->{priority} }
- map { $_->{priority} = 100 unless exists $_->{priority};
- debug(1, "registered link $_->{name} via $_->{if}");
- $_
+ map { if (defined($_->{name})) {
+ $_->{priority} = 100 unless exists $_->{priority};
+ debug(1, "registered link $_->{name} via $_->{if}");
+ $_
+ } else {
+ ()
+ }
} values %{$config{link}};
abend(EX_CONFIG, "no links configured")
@@ -354,11 +356,12 @@ sub scan_links {
for ($active_link = 0; $active_link <= $#links; ++$active_link) {
last if $links[$active_link]->{name} eq $config{core}{active};
}
+ error("no link corresponding to the active one");
+ $active_link = undef;
+ delete $config{core}{active};
+ }
- abend(EX_CONFIG,
- "no link corresponding to the active one")
- if ($active_link > $#links);
- } else {
+ unless (defined($active_link)) {
my $gw = get_default_gw();
if (defined($gw)) {
debug(1, "default gw $gw");
@@ -481,6 +484,7 @@ GetOptions("h" => sub {
"foreground|f" => \$foreground,
"config|c=s" => \$conffile) or exit(1);
+%config = %defconfig;
if (readconfig($conffile, \%config, kw => \%kw)) {
exit(EX_CONFIG);
}
@@ -524,9 +528,9 @@ unless ($foreground) {
}
$SIG{HUP} = sub {
- my %t;
+ my %t = %defconfig;
diag('info', "re-reading configuration file");
- if (readconfig($conffile, \%t)) {
+ if (readconfig($conffile, \%t) == 0) {
%config = %t;
@links = ();
scan_links;

Return to:

Send suggestions and report system problems to the System administrator.