#!/usr/bin/perl # # A Simple WWW interface for Sleuth domain checker # (c) 1999--2001 Martin Mares # # Load configuration file and all modules we need BEGIN { require "check.conf"; } use CGI; use IO::Handle; $query = new CGI; print $query->header; $domain = $query->param('domain'); $server = $query->param('server'); $serverip = $query->param('serverip'); $verbose = $query->param('verbose'); $secondary = $query->param('secondary'); $submitter = $query->param('submitter'); $submit = "Submit"; $stylesheet = <start_html( -title=>"DNS Sleuth", -author=>"$admin_email", -dtd=>'-//W3C//DTD HTML 4.01//EN', -style=>{-code=>$stylesheet} ); print <

The DNS Sleuth

An online tool for checking of DNS zones

Sleuth version $version ($rev_date)

Written by $author_ref <$author_email>

EOF ; if ($secondary_ns eq "") { $secondary = ''; } $msg = "New query"; if ($domain eq "") { print <This is an online version of Sleuth -- a detector of common errors in DNS zones.

To check a zone, just enter its name in the form below. You can explictly specify a name server to be asked for zone data and if its name isn't available from the public DNS, then also its IP address. If you select the verbose mode, you will also get a full dump of the zone at no extra cost. EOF ; if ($secondary_ns ne "") { print <If you want to submit a request for secondary DNS service, fill in all form fields and check the "request secondary" box. The secondary server will run on $secondary_ns, so don't forget to list it as an authoritative server in your zone file. EOF ; } print <If you want to run Sleuth on your own machine, just download the latest version from our FTP server. Sleuth is free software, you can freely use and distribute it according to the GNU General Public License.

If this page looks a bit fruitless, but otherwise displayed correctly, it's probably because your browser doesn't support the Cascading Style Sheets which are The Right Way to define presentation of HTML documents. In case this page looks a bit weird, your browser probably tries to support the style sheets, but does it wrongly (hello, Netscape 4). EOF ; } elsif ($secondary ne "" && $server eq "") { $msg = "Missing server name"; } elsif ($secondary ne "" && $serverip eq "") { $msg = "Missing server IP"; } elsif ($secondary ne "" && $submitter eq "" && $need_submitter) { $msg = "Please fill in who is submitting the zone"; } elsif ($server !~ /^[0-9A-Za-z.-]*$/ || $serverip !~ /^(\d+\.\d+\.\d+\.\d+)?$/ || $domain !~ /^[0-9A-Za-z.-]*$/ || $submitter !~ /^[0-9A-Za-z.\240-\376 -]*$/) { $msg = "Incorrect parameter syntax"; } elsif ($secondary ne "" && defined $sec_ns_addr_space && unpack("H8",pack("c4",split(/\./,$serverip))) !~ $sec_ns_addr_space) { $msg = "Name server address out of permitted range"; } else { print "

Check results for $domain

\n"; @c = "./sleuth"; if ($verbose ne "") { push @c, "-v"; } push @c, "-h", $domain, $server; if ($serverip ne "") { push @c, $serverip; } if ($secondary ne "") { push @c, $secondary_ns, $secondary_ns_ip; } STDOUT->flush(); $rc = system @c; if ($secondary ne "") { if ($rc / 256) { print "

Request for secondary DNS service rejected because of errors in the zone.\n"; print "

If you have any questions, please ask $admin_ref.\n"; } else { print "

Forwarding your secondary DNS service request to $admin_ref\n"; print "who will notify you by e-mail sent to the hostmaster address given in the\n"; print "SOA record when the secondary server will be configured.\n"; shift @c; while ($c[0] =~ /^-[vh]$/) { shift @c; } $ru = $query->remote_user; ($rh = $query->remote_host) =~ s/[^A-Za-z0-9. \240-\376-]/?/g; # "@c" might look insecure, but we know all the names have been correctly # validated by the first sleuth run. &{sub { local *HMSLEUTH; open(HMSLEUTH,"./sleuth -m @c|") or return; my $hostmaster = ""; # default /^\. Hostmaster e-mail address is (.*)$/m and $hostmaster=$1 while ; close HMSLEUTH; local *MAILCMD; open(MAILCMD,"|(cat;./sleuth @c)|/usr/sbin/sendmail -oi -oee -t") or return; print MAILCMD (!$hostmaster ? "" : "Reply-To: \"Hostmaster for $domain\" <$hostmaster>\n"), <<"EOF"; Subject: New zone To: $secondaries_to Domain: $domain Server: $server [$serverip] Hostmaster: $hostmaster User: $ru From: $submitter ($rh) EOF close MAILCMD; 1; }} or print "

Forwarding failed (rc=$?)\n"; } } print "


\n"; } print $query->startform(-method=>'GET'); print "\

\n\ \n"; print "\n"; print "\n"; print "\n"; print "\n"; if ($secondary_ns ne "") { print "\n"; print "\n"; } print "\n"; print "
$msg
Domain:", $query->textfield('domain'), "Verbose output:", $query->checkbox(-name=>'verbose',value=>'ON',-label=>''), "
Server name:", $query->textfield('server'), "Server IP:", $query->textfield('serverip'), "
Request secondary:", $query->checkbox(-name=>'secondary',value=>'ON',-label=>''), "Your name:", $query->textfield('submitter'), "
", $query->submit('action', 'Submit'), "
\n"; print $query->endform; print "

Please send your bug reports and suggestions to $author_ref.

\n"; print $query->end_html; print "\n";