diff options
-rwxr-xr-x | dgd/dgd | 31 | ||||
-rwxr-xr-x | dgd/rc.uplink | 2 |
2 files changed, 25 insertions, 8 deletions
@@ -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 |