BIND8 and writing zones from HTML forms

Kevin Darcy kcd at daimlerchrysler.com
Wed Dec 6 03:10:16 UTC 2000


This is probably just some sort of buffering problem. Does php's
fwrite() call flush I/O buffers and close the file when it completes? If
not, then perhaps you have an empty zonefile in the filesystem when you're
invoking "ndc", thus explaining the "no SOA RR found" error. After the php
program exits, the flush and close is done, so a subsequent "ndc" sees
valid file contents.

Just out of curiosity, if you're writing a tool from scratch, why would you
muck around with rewriting zone files and calling "ndc reload"? That's so
old-fashioned. :-) You could just submit the changes via Dynamic
Update. Such an approach is not only more elegant, but also allows you to
separate the web server from the nameserver if you ever feel like it. Or to
even have a web utility that can manage *multiple* master nameservers (this
is _my_ big challenge right now).


- Kevin

dex wrote:

> I have a quite strange problem... I have written a rudimentary tool in
> php to administer bind8 (did not like webmin).
> The zonefile is loaded into a TEXTAREA form for editing.
> Once edited, a POST is performed with the data to be written back into
> the zonefile and the zone reloaded.
>
> here is the relevant codeblock
> <?
> $zoneinfo = ereg_replace("\r", "", $zoneinfo);
> $backup = sprintf("/var/named/backup/master/%s_%s\n", $zone,
> $timestamp);
> copy("/var/named/master/$zonefile", $backup);
> $fp = fopen("/var/named/master/$zonefile", "w+");
> fwrite($fp, $zoneinfo, strlen($zoneinfo));
> system("/usr/sbin/ndc reload $zone");
> ?>
>
> Now it appear to work... I get output on the webpage "Zone is now
> scheduled for reloading", however I get errors in syslog..
> named[941]: Zone "zone.wa.gov.au" (file master/zone.wa.gov.au.hosts): no
> SOA RR found
> named[941]: master zone "zone.wa.gov.au" (IN) rejected due to errors
> (serial 8)
>
> Ok... so maybe the file is not being written in a format bind likes...
> but  here is the strange thing..
> If I do an 'ndc reload zone.wa.gov.au' from the command line, after the
> zonefile has been edited from the webpage, and without doing anything to
> the zonefile, it works!
>
> named[941]: master zone "zone.wa.gov.au" (IN) loaded (serial 9)
>
> Anyone have any ideas what's going on ?






More information about the bind-users mailing list