From 68a0568a845088b62a2e0aae71d4bb8eefecd363 Mon Sep 17 00:00:00 2001 From: ianmdlvl Date: Wed, 2 Jan 2002 20:20:12 +0000 Subject: [PATCH] new subfile stuff --- scripts/named-conf | 29 ++++++++++++++++++++++------- scripts/named-conf.8 | 36 +++++++++++++++++++++++++----------- 2 files changed, 47 insertions(+), 18 deletions(-) diff --git a/scripts/named-conf b/scripts/named-conf index 0cad802..4426116 100755 --- a/scripts/named-conf +++ b/scripts/named-conf @@ -114,7 +114,8 @@ sub cfg_fail ($) { die "$quis: $where:\n $_[0]\n"; } 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 $!"); @@ -139,10 +140,18 @@ sub read_config ($) { @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)) { @@ -151,7 +160,13 @@ sub read_config ($) { 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+)$/) { @@ -160,7 +175,7 @@ sub read_config ($) { 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") diff --git a/scripts/named-conf.8 b/scripts/named-conf.8 index 6e80aec..7756e64 100644 --- a/scripts/named-conf.8 +++ b/scripts/named-conf.8 @@ -190,20 +190,34 @@ for 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 -- 2.30.2