diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2015-05-20 08:04:56 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2015-05-20 08:08:37 +0300 |
commit | 1866566b9abb7ee4d3cd4f04fe9a88959db8fc4e (patch) | |
tree | 7761d3029ccfbda3dad6824820e176642bafbfd6 | |
parent | 20fed8167852cf54fc89322bb5f5cb1e16653b3d (diff) | |
download | dnstools-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.
-rwxr-xr-x | dgd/dgd | 36 |
1 files changed, 20 insertions, 16 deletions
@@ -38,3 +38,3 @@ my $active_link; -my %config = ( +my %defconfig = ( core => { @@ -46,2 +46,3 @@ my %config = ( ); +my %config; @@ -237,5 +238,2 @@ sub readconfig { if (/^\[(.+?)\]$/) { - $err += check_mandatory($section, $kw, "$file:$line") - if defined $kw; - $include = 0; @@ -322,5 +320,5 @@ 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; @@ -344,5 +342,9 @@ 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}}; @@ -356,7 +358,8 @@ sub scan_links { } + 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(); @@ -483,2 +486,3 @@ GetOptions("h" => sub { +%config = %defconfig; if (readconfig($conffile, \%config, kw => \%kw)) { @@ -526,5 +530,5 @@ 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; |