chiark / gitweb /
new subfile stuff
authorianmdlvl <ianmdlvl>
Wed, 2 Jan 2002 20:20:12 +0000 (20:20 +0000)
committerianmdlvl <ianmdlvl>
Wed, 2 Jan 2002 20:20:12 +0000 (20:20 +0000)
scripts/named-conf
scripts/named-conf.8

index 0cad8021db6dba31e66c89ca3bede0c8777177ca..44261169a5b2978fc2ba376d2b759b669051c05d 100755 (executable)
@@ -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")
index 6e80aec7f0772750daaef79f5e83f9067e4989b2..7756e642f9f327ecc18311f93c2ba42009bb8e0a 100644 (file)
@@ -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