#!/usr/bin/perl require './dns-lib.pl'; &header("BIND 4 DNS Server", "", undef, 1, 1); print &ui_hr(); %access = &get_module_acl(); # Check if named exists if (!-x $config{'named_pathname'}) { print "

The BIND 4 DNS server $config{'named_pathname'}\n"; print "could not be found on your system. Maybe it is not installed,\n"; print "or your BIND 4 module\n"; print "configuration is incorrect.

\n"; print &ui_hr(); &footer("/", "index"); exit; } # Check for future versions of BIND with the -v option $out = `$config{'named_pathname'} -v 2>&1`; if (0 && ($out =~ /bind\s+(\d+)\./i || $out =~ /named\s+(\d+)\./) && $1 >= 8) { print "

The server $config{'named_pathname'} appears to\n"; print "be BIND 8. Maybe your should use the\n"; print "BIND 8 server module instead.

\n"; print &ui_hr(); &footer("/", "index"); exit; } # Check if BIND is the right version.. Only BIND 8 offers the -f option # Is there a better way to do this? $out = `$config{'named_pathname'} -help 2>&1`; if (0 && $out =~ /\[-f\]/) { print "

The server $config{'named_pathname'} appears to\n"; print "be BIND 8. Maybe your should use the\n"; print "BIND 8 server module instead.

\n"; print &ui_hr(); &footer("/", "index"); exit; } # If the named.boot file is empty or does not exist, offer to create it if (!-r $config{named_boot_file}) { $need_create++; } else { $conf = &get_config(); if (!@$conf) { $need_create++; } } if ($need_create) { # There is no nameserver boot file.. offer to create print "

The primary configuration file\n"; print "$config{named_boot_file} does not exist,\n"; print "or is empty. Create it?

\n"; print "

\n"; print " Setup nameserver for ", "internal non-internet use only

\n"; print " Setup as an ", "internet name server, and download root server information

\n"; print " Setup as an internet name ", "server, but use Webmin's older root server information

\n"; print "

\n"; print "
\n"; print &ui_hr(); &footer("/", "index"); exit; } @zlist = (&find_config("primary", $conf), &find_config("secondary", $conf)); if (!@zlist) { # Nothing in named file.. print "There are no DNS zones defined for this name server

\n"; } else { print &ui_subheading("Existing DNS Zones"); foreach $z (@zlist) { next if (!&can_edit_zone(\%access, $z->{'values'}->[0])); if ($z->{'name'} eq "primary") { push(@zlinks, "edit_master.cgi?index=$z->{'index'}"); push(@ztitles, &arpa_to_ip($z->{'values'}->[0])); push(@zicons, "../bind8/images/master.gif"); push(@ztypes, "Master"); } else { push(@zlinks, "edit_slave.cgi?index=$z->{'index'}"); push(@ztitles, &arpa_to_ip($z->{'values'}->[0])); push(@zicons, "../bind8/images/slave.gif"); push(@ztypes, "Slave"); } $len++; } # sort list of zones @zorder = sort { $ztitles[$a] cmp $ztitles[$b] } (0 .. $len-1); @zlinks = map { $zlinks[$_] } @zorder; @ztitles = map { $ztitles[$_] } @zorder; @zicons = map { $zicons[$_] } @zorder; @ztypes = map { $ztypes[$_] } @zorder; if ($config{'show_list'}) { # display as list $mid = int((@zlinks+1)/2); print "
\n"; &zones_table([ @zlinks[0 .. $mid-1] ], [ @ztitles[0 .. $mid-1] ], [ @ztypes[0 .. $mid-1] ]); print "\n"; if ($mid < @zlinks) { &zones_table([ @zlinks[$mid .. $#zlinks] ], [ @ztitles[$mid .. $#ztitles] ], [ @ztypes[$mid .. $#ztypes] ]); } print "
\n"; } else { # display as icons &icons_table(\@zlinks, \@ztitles, \@zicons); } } if ($access{'master'}) { print "Create a new ", "master zone  \n"; } if ($access{'slave'}) { print "Create a new ", "slave zone  \n"; } print "

\n"; if ($access{'defaults'}) { # Display form to set the defaults for new zones &get_zone_defaults(\%zd); print &ui_hr(); print &ui_subheading("New Master Zone Defaults"); print "

\n"; print "\n"; print "\n"; print "
Defaults for new master zones
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
Refresh time secondsTransfer retry time seconds
Expiry time secondsDefault time-to-live seconds

\n"; print "
\n"; } # Display a form to start or restart named print &ui_hr(); if ($config{'named_pid_file'}) { if (open(PID, $config{'named_pid_file'})) { =~ /(\d+)/; $pid = $1; close(PID); } } else { &foreign_require("proc", "proc-lib.pl"); foreach $p (&proc::list_processes()) { if ($p->{'args'} =~ /^\Q$config{'named_pathname'}\E/) { $pid = $p->{'pid'}; last; } } } if ($pid && kill(0, $pid)) { # named is running print "
\n"; print "\n"; print "\n"; print "
\n"; print "Click this button to restart the running BIND 4 server.\n"; print "This will cause the current configuration to become\n"; print "active
\n"; print "
\n"; } else { # named is not running print "
\n"; print "\n"; print "
\n"; print "Click this button to start the BIND 4 server, and load\n"; print "the current configuration
\n"; print "
\n"; } print &ui_hr(); &footer("/", "index"); sub zones_table { local($i); print "\n"; print "\n"; for($i=0; $i<@{$_[0]}; $i++) { print "\n"; print "\n"; print "\n"; print "\n"; } print "
Zone Type
[$i]\">$_[1]->[$i]$_[2]->[$i]
\n"; }