sub read_config ($) {
my ($if) = @_;
- my ($fh,$z,@self,$before, $mod,$dir,$prefix,$suffix,$lprefix,$lsuffix);
+ my ($fh,$z,@self,$before,
+ $mod,$dir,$prefix,$suffix,$subfile,$lprefix,$lsuffix,$zf);
local ($_);
$fh= new IO::File $if,'r' or cfg_fail("open $if:\n $!");
@self_soa= @self if $1 ne '-ns';
} elsif (m/^self\-addr\s+([0-9. \t]+)/) {
@self_addr= split /\s+/, $1;
- } elsif (m/^primary\-dir([*?]?)\s+(\S+)((?:\s+(\S+))?:\s+(\S+))?$/) {
- ($mod, $dir, $prefix, $suffix) = ($1,qualify($2),$3,$4);
- $suffix= '_db' if !defined $suffix;
- $prefix= '' if !defined $prefix;
+ } elsif (m,^
+ primary\-dir ([*?]?)
+ \s+ (\S+)/([^/ \t]*)
+ (?: \s+ ([^/ \t]*) (?: (/.+) )?
+ )?
+ $,x) {
+ ($mod, $dir, $prefix, $suffix, $subfile) =
+ ($1,qualify($2),$3,$4,$5);
+ $suffix= '' if !defined $suffix;
+ $subfile= '' if !defined $subfile;
+ $suffix= '_db' if !length $suffix && !length $subfile;
+ if (-d "$dir$prefix") { $dir.=$prefix; $prefix=''; }
opendir D, $dir or cfg_fail("open primary-dir $dir:\n $!");
$lprefix= length $prefix; $lsuffix= length $suffix;
while (defined($_= readdir D)) {
next unless substr($_,0,$lprefix) eq $prefix;
next unless substr($_,length($_)-$lsuffix) eq $suffix;
$z= substr($_,$lprefix,length($_)-($lprefix+$lsuffix));
- zone_conf($z,'primary','p',$mod,"$dir/$_");
+ $zf= $dir.'/'.$prefix.$z.$suffix.$subfile;
+ if (!stat $zf) {
+ next if length $subfile && $! == &ENOENT;
+ cfg_fail("cannot stat zonefile $zf:\n $!");
+ }
+ -f _ or cfg_fail("zonefile $zf is not a plain file");
+ zone_conf($z,'primary','p',$mod,$zf);
}
closedir D or cfg_fail("close primary-dir $dir:\n $!");
} elsif (m/^primary([*?]?)\s+(\S+)\s+(\S+)$/) {
zone_conf($2,'published','s',$1,'',$3);
} elsif (m/^stealth([*?]?)\s+(\S+)\s+([0-9. \t]+)$/) {
zone_conf($2,'stealth','u',$1,'',split /\s+/, $3);
- } elsif (m/^slave\-dir\s+(\S+)((?:\s+(\S+))?:\s+(\S+))?$/) {
+ } elsif (m/^slave\-dir\s+(\S+)(?:(?:\s+(\S+))\s+(\S+))?$/) {
($slave_dir, $slave_prefix, $slave_suffix) = (qualify($1),$2,$3);
} elsif (m/^output\s+bind8\+(\S+)$/) {
cfg_fail("default output may not apply to only some zones")
and that the zone data is to be found in
.IR filename .
.TP
-.BR primary\-dir [ * | ? "] \fIdirectory\fP [[\fIprefix\fP] \fIsuffix\fP]"
+.BR primary\-dir [ * | ? "] \fIdirectory\fP[" / "\fIprefix\fP] [\fIsuffix\fP[" / \fIsubfile\fP]]
Search
.I directory
-for files whose names match the glob pattern
-.IR suffix * prefix .
-Each such file is taken to represent a zone file for which this server
-is supposed to be the primary. * is the name of the zone. The
-default for
-.I suffix
-is
-.BR _db ;
-the default for
+for files whose names start with
.I prefix
-is empty.
+and end with
+.IR suffix .
+Each such file is taken to represent a zone file for which this server
+is supposed to be the primary; the part of the filename between
+.IR prefix " and " suffix
+is the name of the zone.
+
+If
+.BI / subfile
+is specified, then instead of looking for files, we search for
+directories containing
+.IR subfile ;
+directories which do not contain the subfile are simply skipped.
+
+If
+.IR directory [\fB/\fP prefix ]
+exists as specified and is a directory then it is interpreted as
+.I directory
+with an empty prefix; otherwise the final path component is assumed to
+be the prefix. If no
+.IB suffix / subfile
+is specified then the default is
+.BR _db .
.TP
.BR published [ * | ? "] \fIzone origin\-addr\fP"
Specifies that this server is supposed to be a published slave