source: trunk/DNSDB.pm@ 82

Last change on this file since 82 was 78, checked in by Kris Deugau, 14 years ago

/trunk

Tweak and fix permission update sub; it should now properly add
the permission entry if the permissions being edited were inherited

  • Property svn:keywords set to Date Rev Author Id
File size: 38.6 KB
Line 
1# dns/trunk/DNSDB.pm
2# Abstraction functions for DNS administration
3###
4# SVN revision info
5# $Date: 2011-02-23 19:53:57 +0000 (Wed, 23 Feb 2011) $
6# SVN revision $Rev: 78 $
7# Last update by $Author: kdeugau $
8###
9# Copyright (C) 2008 - Kris Deugau <kdeugau@deepnet.cx>
10
11package DNSDB;
12
13use strict;
14use warnings;
15use Exporter;
16use DBI;
17use Net::DNS;
18use Crypt::PasswdMD5;
19#use Net::SMTP;
20#use NetAddr::IP qw( Compact );
21#use POSIX;
22use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
23
24$VERSION = 0.1;
25@ISA = qw(Exporter);
26@EXPORT_OK = qw(
27 &initGlobals
28 &initPermissions &getPermissions &changePermissions &comparePermissions
29 &connectDB &finish
30 &addDomain &delDomain &domainName
31 &addGroup &delGroup &getChildren &groupName
32 &addUser &delUser &userFullName &userStatus
33 &getSOA &getRecLine &getDomRecs
34 &addRec &updateRec &delRec
35 &domStatus &importAXFR
36 %typemap %reverse_typemap
37 %permissions @permtypes $permlist
38 );
39
40@EXPORT = (); # Export nothing by default.
41%EXPORT_TAGS = ( ALL => [qw(
42 &initGlobals
43 &initPermissions &getPermissions &changePermissions &comparePermissions
44 &connectDB &finish
45 &addDomain &delDomain &domainName
46 &addGroup &delGroup &getChildren &groupName
47 &addUser &delUser &userFullName &userStatus
48 &getSOA &getRecLine &getDomRecs
49 &addRec &updateRec &delRec
50 &domStatus &importAXFR
51 %typemap %reverse_typemap
52 %permissions @permtypes $permlist
53 )]
54 );
55
56our $group = 1;
57our $errstr = '';
58
59# Halfway sane defaults for SOA, TTL, etc.
60our %def = qw (
61 contact hostmaster.DOMAIN
62 prins ns1.myserver.com
63 soattl 86400
64 refresh 10800
65 retry 3600
66 expire 604800
67 minttl 10800
68 ttl 10800
69);
70
71# Arguably defined wholly in the db, but little reason to change without supporting code changes
72our @permtypes = qw (
73 group_edit group_create group_delete
74 user_edit user_create user_delete
75 domain_edit domain_create domain_delete
76 record_edit record_create record_delete
77 self_edit admin
78);
79our $permlist = join(',',@permtypes);
80
81# DNS record type map and reverse map.
82# loaded from the database, from http://www.iana.org/assignments/dns-parameters
83our %typemap;
84our %reverse_typemap;
85
86our %permissions;
87
88##
89## Initialization and cleanup subs
90##
91
92
93## DNSDB::connectDB()
94# Creates connection to DNS database.
95# Requires the database name, username, and password.
96# Returns a handle to the db.
97# Set up for a PostgreSQL db; could be any transactional DBMS with the
98# right changes.
99sub connectDB {
100 $errstr = '';
101 my $dbname = shift;
102 my $user = shift;
103 my $pass = shift;
104 my $dbh;
105 my $DSN = "DBI:Pg:dbname=$dbname";
106
107 my $host = shift;
108 $DSN .= ";host=$host" if $host;
109
110# Note that we want to autocommit by default, and we will turn it off locally as necessary.
111# We may not want to print gobbledygook errors; YMMV. Have to ponder that further.
112 $dbh = DBI->connect($DSN, $user, $pass, {
113 AutoCommit => 1,
114 PrintError => 0
115 })
116 or return (undef, $DBI::errstr) if(!$dbh);
117
118# Return here if we can't select. Note that this indicates a
119# problem executing the select.
120 my $sth = $dbh->prepare("select group_id from groups limit 1");
121 $sth->execute();
122 return (undef,$DBI::errstr) if ($sth->err);
123
124# See if the select returned anything (or null data). This should
125# succeed if the select executed, but...
126 $sth->fetchrow();
127 return (undef,$DBI::errstr) if ($sth->err);
128
129 $sth->finish;
130
131# If we get here, we should be OK.
132 return ($dbh,"DB connection OK");
133} # end connectDB
134
135
136## DNSDB::finish()
137# Cleans up after database handles and so on.
138# Requires a database handle
139sub finish {
140 my $dbh = $_[0];
141 $dbh->disconnect;
142} # end finish
143
144
145## DNSDB::initGlobals()
146# Initialize global variables
147# NB: this does NOT include web-specific session variables!
148# Requires a database handle
149sub initGlobals {
150 my $dbh = shift;
151
152# load system-wide site defaults and things from config file
153 if (open SYSDEFAULTS, "</etc/dnsdb.conf") {
154##fixme - error check!
155 while (<SYSDEFAULTS>) {
156 next if /^\s*#/;
157 $def{contact} = $1 if /contact ?= ?([a-z0-9_.-]+)/i;
158 $def{prins} = $1 if /prins ?= ?([a-z0-9_.-]+)/i;
159 $def{soattl} = $1 if /soattl ?= ?([a-z0-9_.-]+)/i;
160 $def{refresh} = $1 if /refresh ?= ?([a-z0-9_.-]+)/i;
161 $def{retry} = $1 if /retry ?= ?([a-z0-9_.-]+)/i;
162 $def{expire} = $1 if /expire ?= ?([a-z0-9_.-]+)/i;
163 $def{minttl} = $1 if /minttl ?= ?([a-z0-9_.-]+)/i;
164 $def{ttl} = $1 if /ttl ?= ?([a-z0-9_.-]+)/i;
165##fixme? load DB user/pass from config file?
166 }
167 }
168# load from database
169 my $sth = $dbh->prepare("select val,name from rectypes");
170 $sth->execute;
171 while (my ($recval,$recname) = $sth->fetchrow_array()) {
172 $typemap{$recval} = $recname;
173 $reverse_typemap{$recname} = $recval;
174 }
175} # end initGlobals
176
177
178## DNSDB::initPermissions()
179# Set up permissions global
180# Takes database handle and UID
181sub initPermissions {
182 my $dbh = shift;
183 my $uid = shift;
184
185# %permissions = $(getPermissions($dbh,'user',$uid));
186 getPermissions($dbh, 'user', $uid, \%permissions);
187
188} # end initPermissions()
189
190
191## DNSDB::getPermissions()
192# Get permissions from DB
193# Requires DB handle, group or user flag, ID, and hashref.
194sub getPermissions {
195 my $dbh = shift;
196 my $type = shift;
197 my $id = shift;
198 my $hash = shift;
199
200 my $sql = qq(
201 SELECT
202 p.admin,p.self_edit,
203 p.group_create,p.group_edit,p.group_delete,
204 p.user_create,p.user_edit,p.user_delete,
205 p.domain_create,p.domain_edit,p.domain_delete,
206 p.record_create,p.record_edit,p.record_delete
207 FROM permissions p
208 );
209 if ($type eq 'group') {
210 $sql .= qq(
211 JOIN groups g ON g.permission_id=p.permission_id
212 WHERE g.group_id=?
213 );
214 } else {
215 $sql .= qq(
216 JOIN users u ON u.permission_id=p.permission_id
217 WHERE u.user_id=?
218 );
219 }
220
221 my $sth = $dbh->prepare($sql);
222
223 $sth->execute($id) or die "argh: ".$sth->errstr;
224
225# my $permref = $sth->fetchrow_hashref;
226# return $permref;
227# $hash = $permref;
228# Eww. Need to learn how to forcibly drop a hashref onto an existing hash.
229 ($hash->{admin},$hash->{self_edit},
230 $hash->{group_create},$hash->{group_edit},$hash->{group_delete},
231 $hash->{user_create},$hash->{user_edit},$hash->{user_delete},
232 $hash->{domain_create},$hash->{domain_edit},$hash->{domain_delete},
233 $hash->{record_create},$hash->{record_edit},$hash->{record_delete})
234 = $sth->fetchrow_array;
235
236} # end getPermissions()
237
238
239## DNSDB::changePermissions()
240# Update an ACL entry
241# Takes a db handle, type, owner-id, and hashref for the changed permissions.
242##fixme: Must handle case of changing object's permissions from inherited to custom
243sub changePermissions {
244 my $dbh = shift;
245 my $type = shift;
246 my $id = shift;
247 my $newperms = shift;
248
249 my $failmsg = '';
250
251 # see if we're switching from inherited to custom
252 my $sth = $dbh->prepare("SELECT (u.permission_id=g.permission_id) AS was_inherited,u.permission_id".
253 " FROM ".($type eq 'user' ? 'users' : 'groups')." u ".
254 " JOIN groups g ON u.".($type eq 'user' ? '' : 'parent_')."group_id=g.group_id ".
255 " WHERE u.".($type eq 'user' ? 'user' : 'group')."_id=?");
256 $sth->execute($id);
257
258 my ($wasinherited,$permid) = $sth->fetchrow_array;
259
260# hack phtoui
261# group id 1 is "special" in that it's it's own parent (err... possibly.)
262# may make its parent id 0 which doesn't exist, and as a bonus is Perl-false.
263 $wasinherited = 0 if ($type eq 'group' && $id == 1);
264
265 local $dbh->{AutoCommit} = 0;
266 local $dbh->{RaiseError} = 1;
267
268 # Wrap all the SQL in a transaction
269 eval {
270 if ($wasinherited) {
271##fixme: need to add semirecursive bit to properly munge inherited permission ID on subgroups and users
272 $dbh->do("INSERT INTO permissions ($permlist) ".
273 "SELECT $permlist FROM permissions WHERE permission_id=?", undef, ($permid) );
274 #$sth = $dbh->prepare($sql);
275 #$sth->execute($permid);
276 $sth = $dbh->prepare("SELECT permission_id FROM ".($type eq 'user' ? 'users' : 'groups').
277 " WHERE ".($type eq 'user' ? 'user' : 'group')."_id=?");
278 $sth->execute($id);
279 ($permid) = $sth->fetchrow_array;
280 $dbh->do("UPDATE permissions SET ".($type eq 'user' ? 'user' : 'group')."_id=? ".
281 "WHERE permission_id=?", undef, ($id,$permid) );
282 $dbh->do("UPDATE ".($type eq 'user' ? 'users' : 'groups')." SET permission_id=? ".
283 "WHERE ".($type eq 'user' ? 'user' : 'group')."_id=?", undef, ($permid,$id) );
284 }
285 foreach (@permtypes) {
286 if (defined ($newperms->{$_})) {
287 $dbh->do("UPDATE permissions SET $_=? WHERE permission_id=?", undef, ($newperms->{$_},$permid) );
288 #$sth->execute($newperms->{$_},$permid);
289 }
290 }
291
292 $dbh->commit;
293 }; # end eval
294 if ($@) {
295 my $msg = $@;
296 eval { $dbh->rollback; };
297 return ('FAIL',"$failmsg: $msg");
298 } else {
299 return ('OK',$permid);
300 }
301
302} # end changePermissions()
303
304
305## DNSDB::comparePermissions()
306# Compare two permission hashes
307# Returns '>', '<', '=', '!'
308sub comparePermissions {
309 my $p1 = shift;
310 my $p2 = shift;
311
312 my $retval = '='; # assume equality until proven otherwise
313
314 no warnings "uninitialized";
315
316 foreach (@permtypes) {
317 next if $p1->{$_} == $p2->{$_}; # equal is good
318 if ($p1->{$_} && !$p2->{$_}) {
319 if ($retval eq '<') { # if we've already found an unequal pair where
320 $retval = '!'; # $p2 has more access, and we now find a pair
321 last; # where $p1 has more access, the overall access
322 } # is neither greater or lesser, it's unequal.
323 $retval = '>';
324 }
325 if (!$p1->{$_} && $p2->{$_}) {
326 if ($retval eq '>') { # if we've already found an unequal pair where
327 $retval = '!'; # $p1 has more access, and we now find a pair
328 last; # where $p2 has more access, the overall access
329 } # is neither greater or lesser, it's unequal.
330 $retval = '<';
331 }
332 }
333 return $retval;
334} # end comparePermissions()
335
336
337## DNSDB::_log()
338# Log an action
339# Internal sub
340# Takes a database handle, <foo>, <bar>
341sub _log {
342} # end _log
343
344
345##
346## Processing subs
347##
348
349## DNSDB::addDomain()
350# Add a domain
351# Takes a database handle, domain name, numeric group, and boolean(ish) state (active/inactive)
352# Returns a status code and message
353sub addDomain {
354 $errstr = '';
355 my $dbh = shift;
356 return ('FAIL',"Need database handle") if !$dbh;
357 my $domain = shift;
358 return ('FAIL',"Need domain") if !defined($domain);
359 my $group = shift;
360 return ('FAIL',"Need group") if !defined($group);
361 my $state = shift;
362 return ('FAIL',"Need domain status") if !defined($state);
363
364 my $sth = $dbh->prepare("SELECT domain_id FROM domains WHERE domain=?");
365 my $dom_id;
366
367# quick check to start to see if we've already got one
368 $sth->execute($domain);
369 ($dom_id) = $sth->fetchrow_array;
370
371 return ('FAIL', "Domain already exists") if $dom_id;
372
373 # Allow transactions, and raise an exception on errors so we can catch it later.
374 # Use local to make sure these get "reset" properly on exiting this block
375 local $dbh->{AutoCommit} = 0;
376 local $dbh->{RaiseError} = 1;
377
378 # Wrap all the SQL in a transaction
379 eval {
380 # insert the domain...
381 my $sth = $dbh->prepare("insert into domains (domain,group_id,status) values (?,?,?)");
382 $sth->execute($domain,$group,$state);
383
384 # get the ID...
385 $sth = $dbh->prepare("select domain_id from domains where domain='$domain'");
386 $sth->execute;
387 ($dom_id) = $sth->fetchrow_array();
388
389 # ... and now we construct the standard records from the default set. NB: group should be variable.
390 $sth = $dbh->prepare("select host,type,val,distance,weight,port,ttl from default_records where group_id=$group");
391 my $sth_in = $dbh->prepare("insert into records (domain_id,host,type,val,distance,weight,port,ttl)".
392 " values ($dom_id,?,?,?,?,?,?,?)");
393 $sth->execute;
394 while (my ($host,$type,$val,$dist,$weight,$port,$ttl) = $sth->fetchrow_array()) {
395 $host =~ s/DOMAIN/$domain/g;
396 $val =~ s/DOMAIN/$domain/g;
397 $sth_in->execute($host,$type,$val,$dist,$weight,$port,$ttl);
398 }
399
400 # once we get here, we should have suceeded.
401 $dbh->commit;
402 }; # end eval
403
404 if ($@) {
405 my $msg = $@;
406 eval { $dbh->rollback; };
407 return ('FAIL',$msg);
408 } else {
409 return ('OK',$dom_id);
410 }
411} # end addDomain
412
413
414## DNSDB::delDomain()
415# Delete a domain.
416# for now, just delete the records, then the domain.
417# later we may want to archive it in some way instead (status code 2, for example?)
418sub delDomain {
419 my $dbh = shift;
420 my $domid = shift;
421
422 # Allow transactions, and raise an exception on errors so we can catch it later.
423 # Use local to make sure these get "reset" properly on exiting this block
424 local $dbh->{AutoCommit} = 0;
425 local $dbh->{RaiseError} = 1;
426
427 my $failmsg = '';
428
429 # Wrap all the SQL in a transaction
430 eval {
431 my $sth = $dbh->prepare("delete from records where domain_id=?");
432 $failmsg = "Failure removing domain records";
433 $sth->execute($domid);
434 $sth = $dbh->prepare("delete from domains where domain_id=?");
435 $failmsg = "Failure removing domain";
436 $sth->execute($domid);
437
438 # once we get here, we should have suceeded.
439 $dbh->commit;
440 }; # end eval
441
442 if ($@) {
443 my $msg = $@;
444 eval { $dbh->rollback; };
445 return ('FAIL',"$failmsg: $msg");
446 } else {
447 return ('OK','OK');
448 }
449
450} # end delDomain()
451
452
453## DNSDB::domainName()
454# Return the domain name based on a domain ID
455# Takes a database handle and the domain ID
456# Returns the domain name or undef on failure
457sub domainName {
458 $errstr = '';
459 my $dbh = shift;
460 my $domid = shift;
461 my $sth = $dbh->prepare("select domain from domains where domain_id=?");
462 $sth->execute($domid);
463 my ($domname) = $sth->fetchrow_array();
464 $errstr = $DBI::errstr if !$domname;
465 return $domname if $domname;
466} # end domainName
467
468
469## DNSDB::addGroup()
470# Add a group
471# Takes a database handle, group name, parent group, hashref for permissions,
472# and optional template-vs-cloneme flag
473# Returns a status code and message
474sub addGroup {
475 $errstr = '';
476 my $dbh = shift;
477 my $groupname = shift;
478 my $pargroup = shift;
479 my $permissions = shift;
480
481 # 0 indicates "custom", hardcoded.
482 # Any other value clones that group's default records, if it exists.
483 my $inherit = shift || 0;
484##fixme: need a flag to indicate clone records or <?> ?
485
486 # Allow transactions, and raise an exception on errors so we can catch it later.
487 # Use local to make sure these get "reset" properly on exiting this block
488 local $dbh->{AutoCommit} = 0;
489 local $dbh->{RaiseError} = 1;
490
491 my $sth = $dbh->prepare("SELECT group_id FROM groups WHERE group_name=?");
492 my $group_id;
493
494# quick check to start to see if we've already got one
495 $sth->execute($groupname);
496 ($group_id) = $sth->fetchrow_array;
497
498 return ('FAIL', "Group already exists") if $group_id;
499
500 # Wrap all the SQL in a transaction
501 eval {
502 $sth = $dbh->prepare("INSERT INTO groups (parent_group_id,group_name) VALUES (?,?)");
503 $sth->execute($pargroup,$groupname);
504
505 $sth = $dbh->prepare("SELECT group_id FROM groups WHERE group_name=?");
506 $sth->execute($groupname);
507 my ($groupid) = $sth->fetchrow_array();
508
509# Permissions
510 if ($inherit) {
511 } else {
512 my @permvals;
513 foreach (@permtypes) {
514 if (!defined ($permissions->{$_})) {
515 push @permvals, 0;
516 } else {
517 push @permvals, $permissions->{$_};
518 }
519 }
520
521 $sth = $dbh->prepare("INSERT INTO permissions (group_id,$permlist) values (?".',?'x($#permtypes+1).")");
522 $sth->execute($groupid,@permvals);
523
524 $sth = $dbh->prepare("SELECT permission_id FROM permissions WHERE group_id=?");
525 $sth->execute($groupid);
526 my ($permid) = $sth->fetchrow_array();
527
528 $dbh->do("UPDATE groups SET permission_id=$permid WHERE group_id=$groupid");
529 } # done permission fiddling
530
531# Default records
532 $sth = $dbh->prepare("INSERT INTO default_records (group_id,host,type,val,distance,weight,port,ttl) ".
533 "VALUES ($groupid,?,?,?,?,?,?,?)");
534 if ($inherit) {
535##fixme: fixme!
536 my $sth2 = $dbh->prepare("SELECT host,type,val,distance,weight,port,ttl FROM default_records WHERE group_id=?");
537 while (my @clonedata = $sth2->fetchrow_array) {
538 $sth->execute(@clonedata);
539 }
540 } else {
541##fixme: Hardcoding is Bad, mmmmkaaaay?
542 # reasonable basic defaults for SOA, MX, NS, and minimal hosting
543 # could load from a config file, but somewhere along the line we need hardcoded bits.
544 $sth->execute('ns1.example.com:hostmaster.example.com', 6, '10800:3600:604800:10800', 0, 0, 0, 86400);
545 $sth->execute('DOMAIN', 1, '192.168.4.2', 0, 0, 0, 7200);
546 $sth->execute('DOMAIN', 15, 'mx.example.com', 10, 0, 0, 7200);
547 $sth->execute('DOMAIN', 2, 'ns1.example.com', 0, 0, 0, 7200);
548 $sth->execute('DOMAIN', 2, 'ns2.example.com', 0, 0, 0, 7200);
549 $sth->execute('www.DOMAIN', 5, 'DOMAIN', 0, 0, 0, 7200);
550 }
551
552 # once we get here, we should have suceeded.
553 $dbh->commit;
554 }; # end eval
555
556 if ($@) {
557 my $msg = $@;
558 eval { $dbh->rollback; };
559 return ('FAIL',$msg);
560 } else {
561 return ('OK','OK');
562 }
563
564} # end addGroup()
565
566
567## DNSDB::delGroup()
568# Delete a group.
569# Takes a group ID
570# Returns a status code and message
571sub delGroup {
572 my $dbh = shift;
573 my $groupid = shift;
574
575 # Allow transactions, and raise an exception on errors so we can catch it later.
576 # Use local to make sure these get "reset" properly on exiting this block
577 local $dbh->{AutoCommit} = 0;
578 local $dbh->{RaiseError} = 1;
579
580##fixme: locate "knowable" error conditions and deal with them before the eval
581# ... or inside, whatever.
582# -> domains still exist in group
583# -> ...
584 my $failmsg = '';
585
586 # Wrap all the SQL in a transaction
587 eval {
588 my $sth = $dbh->prepare("SELECT count(*) FROM domains WHERE group_id=?");
589 $sth->execute($groupid);
590 my ($domcnt) = $sth->fetchrow_array;
591 $failmsg = "Can't remove group ".groupName($dbh,$groupid);
592 die "$domcnt domains still in group\n" if $domcnt;
593
594 $sth = $dbh->prepare("delete from default_records where group_id=?");
595 $failmsg = "Failed to delete default records for ".groupName($dbh,$groupid);
596 $sth->execute($groupid);
597 $sth = $dbh->prepare("delete from groups where group_id=?");
598 $failmsg = "Failed to remove group ".groupName($dbh,$groupid);
599 $sth->execute($groupid);
600
601 # once we get here, we should have suceeded.
602 $dbh->commit;
603 }; # end eval
604
605 if ($@) {
606 my $msg = $@;
607 eval { $dbh->rollback; };
608 return ('FAIL',"$failmsg: $msg");
609 } else {
610 return ('OK','OK');
611 }
612} # end delGroup()
613
614
615## DNSDB::getChildren()
616# Get a list of all groups whose parent^n is group <n>
617# Takes a database handle, group ID, reference to an array to put the group IDs in,
618# and an optional flag to return only immediate children or all children-of-children
619# default to returning all children
620# Calls itself
621sub getChildren {
622 $errstr = '';
623 my $dbh = shift;
624 my $rootgroup = shift;
625 my $groupdest = shift;
626 my $immed = shift || 'all';
627
628 # special break for default group; otherwise we get stuck.
629 if ($rootgroup == 1) {
630 # by definition, group 1 is the Root Of All Groups
631 my $sth = $dbh->prepare("SELECT group_id FROM groups WHERE NOT (group_id=1)".
632 ($immed ne 'all' ? " AND parent_group_id=1" : ''));
633 $sth->execute;
634 while (my @this = $sth->fetchrow_array) {
635 push @$groupdest, @this;
636 }
637 } else {
638 my $sth = $dbh->prepare("SELECT group_id FROM groups WHERE parent_group_id=?");
639 $sth->execute($rootgroup);
640 return if $sth->rows == 0;
641 my @grouplist;
642 while (my ($group) = $sth->fetchrow_array) {
643 push @$groupdest, $group;
644 getChildren($dbh,$group,$groupdest) if $immed eq 'all';
645 }
646 }
647} # end getChildren()
648
649
650## DNSDB::groupName()
651# Return the group name based on a group ID
652# Takes a database handle and the group ID
653# Returns the group name or undef on failure
654sub groupName {
655 $errstr = '';
656 my $dbh = shift;
657 my $groupid = shift;
658 my $sth = $dbh->prepare("SELECT group_name FROM groups WHERE group_id=?");
659 $sth->execute($groupid);
660 my ($groupname) = $sth->fetchrow_array();
661 $errstr = $DBI::errstr if !$groupname;
662 return $groupname if $groupname;
663} # end groupName
664
665
666## DNSDB::addUser()
667#
668sub addUser {
669 $errstr = '';
670 my $dbh = shift;
671 return ('FAIL',"Need database handle") if !$dbh;
672 my $username = shift;
673 return ('FAIL',"Missing username") if !defined($username);
674 my $group = shift;
675 return ('FAIL',"Missing group") if !defined($group);
676 my $pass = shift;
677 return ('FAIL',"Missing password") if !defined($pass);
678 my $state = shift;
679 return ('FAIL',"Need account status") if !defined($state);
680
681 my $type = shift || 'u'; # create limited users by default - fwiw, not sure yet how this will interact with ACLs
682
683 my $permstring = shift || 'i'; # default is to inhert permissions from group
684
685 my $fname = shift || $username;
686 my $lname = shift || '';
687 my $phone = shift || ''; # not going format-check
688
689 my $sth = $dbh->prepare("SELECT user_id FROM users WHERE username=?");
690 my $user_id;
691
692# quick check to start to see if we've already got one
693 $sth->execute($username);
694 ($user_id) = $sth->fetchrow_array;
695
696 return ('FAIL', "User already exists") if $user_id;
697
698 # Allow transactions, and raise an exception on errors so we can catch it later.
699 # Use local to make sure these get "reset" properly on exiting this block
700 local $dbh->{AutoCommit} = 0;
701 local $dbh->{RaiseError} = 1;
702
703 # Wrap all the SQL in a transaction
704 eval {
705 # insert the user...
706 my $sth = $dbh->prepare("INSERT INTO users (group_id,username,password,firstname,lastname,phone,type,status) ".
707 "VALUES (?,?,?,?,?,?,?,?)");
708 $sth->execute($group,$username,unix_md5_crypt($pass),$fname,$lname,$phone,$type,$state);
709
710 # get the ID...
711 $sth = $dbh->prepare("select user_id from users where username=?");
712 $sth->execute($username);
713 ($user_id) = $sth->fetchrow_array();
714
715##fixme: add another table to hold name/email for log table?
716die "dying horribly\n";
717
718 # once we get here, we should have suceeded.
719 $dbh->commit;
720 }; # end eval
721
722 if ($@) {
723 my $msg = $@;
724 eval { $dbh->rollback; };
725 return ('FAIL',$msg);
726 } else {
727 return ('OK',$user_id);
728 }
729} # end addUser
730
731
732## DNSDB::checkUser()
733# Check user/pass combo on login
734sub checkUser {
735 my $dbh = shift;
736 my $user = shift;
737 my $inpass = shift;
738
739 my $sth = $dbh->prepare("SELECT user_id,group_id,password,firstname,lastname FROM users WHERE username=?");
740 $sth->execute($user);
741 my ($uid,$gid,$pass,$fname,$lname) = $sth->fetchrow_array;
742 my $loginfailed = 1 if !defined($uid);
743
744 if ($pass =~ m|^\$1\$([A-Za-z0-9/.]+)\$|) {
745 $loginfailed = 1 if $pass ne unix_md5_crypt($inpass,$1);
746 } else {
747 $loginfailed = 1 if $pass ne $inpass;
748 }
749
750 # nnnngggg
751 return ($uid, $gid);
752} # end checkUser
753
754
755## DNSDB::delUser()
756#
757sub delUser {
758 my $dbh = shift;
759 return ('FAIL',"Need database handle") if !$dbh;
760 my $userid = shift;
761 return ('FAIL',"Missing userid") if !defined($userid);
762
763 my $sth = $dbh->prepare("delete from users where user_id=?");
764 $sth->execute($userid);
765
766 return ('FAIL',"Couldn't remove user: ".$sth->errstr) if $sth->err;
767
768 return ('OK','OK');
769
770} # end delUser
771
772
773## DNSDB::userFullName()
774# Return a pretty string!
775# Takes a user_id and optional printf-ish string to indicate which pieces where:
776# %u for the username
777# %f for the first name
778# %l for the last name
779# All other text in the passed string will be left as-is.
780##fixme: need a "smart" option too, so that missing/null/blank first/last names don't give funky output
781sub userFullName {
782 $errstr = '';
783 my $dbh = shift;
784 my $userid = shift;
785 my $fullformat = shift || '%f %l (%u)';
786 my $sth = $dbh->prepare("select username,firstname,lastname from users where user_id=?");
787 $sth->execute($userid);
788 my ($uname,$fname,$lname) = $sth->fetchrow_array();
789 $errstr = $DBI::errstr if !$uname;
790
791 $fullformat =~ s/\%u/$uname/g;
792 $fullformat =~ s/\%f/$fname/g;
793 $fullformat =~ s/\%l/$lname/g;
794
795 return $fullformat;
796} # end userFullName
797
798
799## DNSDB::userStatus()
800# Sets and/or returns a user's status
801# Takes a database handle, user ID and optionally a status argument
802# Returns undef on errors.
803sub userStatus {
804 my $dbh = shift;
805 my $id = shift;
806 my $newstatus = shift;
807
808 return undef if $id !~ /^\d+$/;
809
810 my $sth;
811
812# ooo, fun! let's see what we were passed for status
813 if ($newstatus) {
814 $sth = $dbh->prepare("update users set status=? where user_id=?");
815 # ass-u-me caller knows what's going on in full
816 if ($newstatus =~ /^[01]$/) { # only two valid for now.
817 $sth->execute($newstatus,$id);
818 } elsif ($newstatus =~ /^usero(?:n|ff)$/) {
819 $sth->execute(($newstatus eq 'useron' ? 1 : 0),$id);
820 }
821 }
822
823 $sth = $dbh->prepare("select status from users where user_id=?");
824 $sth->execute($id);
825 my ($status) = $sth->fetchrow_array;
826 return $status;
827} # end userStatus()
828
829
830## DNSDB::editRecord()
831# Change an existing record
832# Takes a database handle, default/live flag, record ID, and new data and updates the data fields for it
833sub editRecord {
834 $errstr = '';
835 my $dbh = shift;
836 my $defflag = shift;
837 my $recid = shift;
838 my $host = shift;
839 my $address = shift;
840 my $distance = shift;
841 my $weight = shift;
842 my $port = shift;
843 my $ttl = shift;
844}
845
846
847## DNSDB::getSOA()
848# Return all suitable fields from an SOA record in separate elements of a hash
849# Takes a database handle, default/live flag, and group (default) or domain (live) ID
850sub getSOA {
851 $errstr = '';
852 my $dbh = shift;
853 my $def = shift;
854 my $id = shift;
855 my %ret;
856
857 my $sql = "select record_id,host,val,ttl from";
858 if ($def eq 'def' or $def eq 'y') {
859 $sql .= " default_records where group_id=$id and type=$reverse_typemap{SOA}";
860 } else {
861 # we're editing a live SOA record; find based on domain
862 $sql .= " records where domain_id=$id and type=$reverse_typemap{SOA}";
863 }
864 my $sth = $dbh->prepare($sql);
865 $sth->execute;
866
867 my ($recid,$host,$val,$ttl) = $sth->fetchrow_array();
868 my ($prins,$contact) = split /:/, $host;
869 my ($refresh,$retry,$expire,$minttl) = split /:/, $val;
870
871 $ret{recid} = $recid;
872 $ret{ttl} = $ttl;
873 $ret{prins} = $prins;
874 $ret{contact} = $contact;
875 $ret{refresh} = $refresh;
876 $ret{retry} = $retry;
877 $ret{expire} = $expire;
878 $ret{minttl} = $minttl;
879
880 return %ret;
881} # end getSOA()
882
883
884## DNSDB::getRecLine()
885# Return all data fields for a zone record in separate elements of a hash
886# Takes a database handle, default/live flag, and record ID
887sub getRecLine {
888 $errstr = '';
889 my $dbh = shift;
890 my $def = shift;
891 my $id = shift;
892
893 my $sql = "SELECT record_id,host,type,val,distance,weight,port,ttl".
894 (($def eq 'def' or $def eq 'y') ? ',group_id FROM default_' : ',domain_id FROM ').
895 "records WHERE record_id=?";
896 my $sth = $dbh->prepare($sql);
897 $sth->execute($id);
898
899 my ($recid,$host,$rtype,$val,$distance,$weight,$port,$ttl,$parid) = $sth->fetchrow_array();
900
901 if ($sth->err) {
902 $errstr = $DBI::errstr;
903 return undef;
904 }
905 my %ret;
906 $ret{recid} = $recid;
907 $ret{host} = $host;
908 $ret{type} = $rtype;
909 $ret{val} = $val;
910 $ret{distance}= $distance;
911 $ret{weight} = $weight;
912 $ret{port} = $port;
913 $ret{ttl} = $ttl;
914 $ret{parid} = $parid;
915
916 return %ret;
917}
918
919
920##fixme: should use above (getRecLine()) to get lines for below?
921## DNSDB::getDomRecs()
922# Return records for a domain
923# Takes a database handle, default/live flag, group/domain ID, start,
924# number of records, sort field, and sort order
925# Returns a reference to an array of hashes
926sub getDomRecs {
927 $errstr = '';
928 my $dbh = shift;
929 my $type = shift;
930 my $id = shift;
931 my $nrecs = shift || 'all';
932 my $nstart = shift || 0;
933
934## for order, need to map input to column names
935 my $order = shift || 'host';
936 my $direction = shift || 'ASC';
937
938 my $sql = "SELECT record_id,host,type,val,distance,weight,port,ttl FROM ";
939 if ($type eq 'def' or $type eq 'y') {
940 $sql .= " default_records where group_id=$id";
941 } else {
942 $sql .= " records where domain_id=$id";
943 }
944 $sql .= " and not type=$reverse_typemap{SOA} order by $order $direction";
945##fixme: need to set nstart properly (offset is not internally multiplied with limit)
946 $sql .= " limit $nrecs offset ".($nstart*$nrecs) if $nstart ne 'all';
947
948 my $sth = $dbh->prepare($sql);
949 $sth->execute;
950
951 my @retbase;
952 while (my $ref = $sth->fetchrow_hashref()) {
953 push @retbase, $ref;
954 }
955
956 my $ret = \@retbase;
957 return $ret;
958} # end getDomRecs()
959
960
961## DNSDB::addRec()
962# Add a new record to a domain or a group's default records
963# Takes a database handle, default/live flag, group/domain ID,
964# host, type, value, and TTL
965# Some types require additional detail: "distance" for MX and SRV,
966# and weight/port for SRV
967# Returns a status code and detail message in case of error
968sub addRec {
969 $errstr = '';
970 my $dbh = shift;
971 my $defrec = shift;
972 my $id = shift;
973
974 my $host = shift;
975 my $rectype = shift;
976 my $val = shift;
977 my $ttl = shift;
978
979 my $fields = ($defrec eq 'y' ? 'group_id' : 'domain_id').",host,type,val,ttl";
980 my $vallen = "?,?,?,?,?";
981 my @vallist = ($id,$host,$rectype,$val,$ttl);
982
983 my $dist;
984 if ($rectype == $reverse_typemap{MX} or $rectype == $reverse_typemap{SRV}) {
985 $dist = shift;
986 return ('FAIL',"Need distance for $typemap{$rectype} record") if !defined($dist);
987 $fields .= ",distance";
988 $vallen .= ",?";
989 push @vallist, $dist;
990 }
991 my $weight;
992 my $port;
993 if ($rectype == $reverse_typemap{SRV}) {
994 # check for _service._protocol. NB: RFC2782 does not say "MUST"... nor "SHOULD"...
995 # it just says (paraphrased) "... is prepended with _ to prevent DNS collisions"
996 return ('FAIL',"SRV records must begin with _service._protocol")
997 if $host !~ /^_[A-Za-z]+\._[A-Za-z]+\.[a-z0-9-]+/;
998 $weight = shift;
999 $port = shift;
1000 return ('FAIL',"Need weight and port for SRV record") if !defined($weight) or !defined($port);
1001 $fields .= ",weight,port";
1002 $vallen .= ",?,?";
1003 push @vallist, ($weight,$port);
1004 }
1005
1006 my $sql = "insert into ".($defrec eq 'y' ? 'default_' : '')."records ($fields) values ($vallen)";
1007##fixme: use array for values, replace "vallist" with series of ?,?,? etc
1008# something is bugging me about this...
1009#warn "DEBUG: $sql";
1010 my $sth = $dbh->prepare($sql);
1011 $sth->execute(@vallist);
1012
1013 return ('FAIL',$sth->errstr) if $sth->err;
1014
1015 return ('OK','OK');
1016} # end addRec()
1017
1018
1019## DNSDB::updateRec()
1020# Update a record
1021sub updateRec {
1022 $errstr = '';
1023
1024 my $dbh = shift;
1025 my $defrec = shift;
1026 my $id = shift;
1027
1028# all records have these
1029 my $host = shift;
1030 my $type = shift;
1031 my $val = shift;
1032 my $ttl = shift;
1033
1034 return('FAIL',"Missing standard argument(s)") if !defined($ttl);
1035
1036# only MX and SRV will use these
1037 my $dist = 0;
1038 my $weight = 0;
1039 my $port = 0;
1040
1041 if ($type == $reverse_typemap{MX} || $type == $reverse_typemap{SRV}) {
1042 $dist = shift;
1043 return ('FAIL',"MX or SRV requires distance") if !defined($dist);
1044 if ($type == $reverse_typemap{SRV}) {
1045 $weight = shift;
1046 return ('FAIL',"SRV requires weight") if !defined($weight);
1047 $port = shift;
1048 return ('FAIL',"SRV requires port") if !defined($port);
1049 }
1050 }
1051
1052 my $sth = $dbh->prepare("UPDATE ".($defrec eq 'y' ? 'default_' : '')."records ".
1053 "SET host=?,type=?,val=?,ttl=?,distance=?,weight=?,port=? ".
1054 "WHERE record_id=?");
1055 $sth->execute($host,$type,$val,$ttl,$dist,$weight,$port,$id);
1056
1057 return ('FAIL',$sth->errstr."<br>\n$errstr<br>\n") if $sth->err;
1058
1059 return ('OK','OK');
1060} # end updateRec()
1061
1062
1063## DNSDB::delRec()
1064# Delete a record.
1065sub delRec {
1066 $errstr = '';
1067 my $dbh = shift;
1068 my $defrec = shift;
1069 my $id = shift;
1070
1071return "FAIL", "wakka wakka";
1072 my $sth = $dbh->prepare("DELETE FROM ".($defrec eq 'y' ? 'default_' : '')."records WHERE record_id=?");
1073 $sth->execute($id);
1074
1075 return ('FAIL',"Couldn't remove record: ".$sth->errstr) if $sth->err;
1076
1077 return ('OK','OK');
1078} # end delRec()
1079
1080
1081## DNSDB::domStatus()
1082# Sets and/or returns a domain's status
1083# Takes a database handle, domain ID and optionally a status argument
1084# Returns undef on errors.
1085sub domStatus {
1086 my $dbh = shift;
1087 my $id = shift;
1088 my $newstatus = shift;
1089
1090 return undef if $id !~ /^\d+$/;
1091
1092 my $sth;
1093
1094# ooo, fun! let's see what we were passed for status
1095 if ($newstatus) {
1096 $sth = $dbh->prepare("update domains set status=? where domain_id=?");
1097 # ass-u-me caller knows what's going on in full
1098 if ($newstatus =~ /^[01]$/) { # only two valid for now.
1099 $sth->execute($newstatus,$id);
1100 } elsif ($newstatus =~ /^domo(?:n|ff)$/) {
1101 $sth->execute(($newstatus eq 'domon' ? 1 : 0),$id);
1102 }
1103 }
1104
1105 $sth = $dbh->prepare("select status from domains where domain_id=?");
1106 $sth->execute($id);
1107 my ($status) = $sth->fetchrow_array;
1108 return $status;
1109} # end domStatus()
1110
1111
1112## DNSDB::importAXFR
1113# Import a domain via AXFR
1114# Takes AXFR host, domain to transfer, group to put the domain in,
1115# and optionally:
1116# - active/inactive state flag (defaults to active)
1117# - overwrite-SOA flag (defaults to off)
1118# - overwrite-NS flag (defaults to off, doesn't affect subdomain NS records)
1119# Returns a status code (OK, WARN, or FAIL) and message - message should be blank
1120# if status is OK, but WARN includes conditions that are not fatal but should
1121# really be reported.
1122sub importAXFR {
1123 my $dbh = shift;
1124 my $ifrom_in = shift;
1125 my $domain = shift;
1126 my $group = shift;
1127 my $status = shift || 1;
1128 my $rwsoa = shift || 0;
1129 my $rwns = shift || 0;
1130
1131##fixme: add mode to delete&replace, merge+overwrite, merge new?
1132
1133 my $nrecs = 0;
1134 my $soaflag = 0;
1135 my $nsflag = 0;
1136 my $warnmsg = '';
1137 my $ifrom;
1138
1139 # choke on possible bad setting in ifrom
1140 # IPv4 and v6, and valid hostnames!
1141 ($ifrom) = ($ifrom_in =~ /^([0-9a-f\:.]+|[0-9a-z_.-]+)$/i);
1142 return ('FAIL', "Bad AXFR source host $ifrom")
1143 unless ($ifrom) = ($ifrom_in =~ /^([0-9a-f\:.]+|[0-9a-z_.-]+)$/i);
1144
1145 # Allow transactions, and raise an exception on errors so we can catch it later.
1146 # Use local to make sure these get "reset" properly on exiting this block
1147 local $dbh->{AutoCommit} = 0;
1148 local $dbh->{RaiseError} = 1;
1149
1150 my $sth = $dbh->prepare("SELECT domain_id FROM domains WHERE domain=?");
1151 my $dom_id;
1152
1153# quick check to start to see if we've already got one
1154 $sth->execute($domain);
1155 ($dom_id) = $sth->fetchrow_array;
1156
1157 return ('FAIL', "Domain already exists") if $dom_id;
1158
1159 eval {
1160 # can't do this, can't nest transactions. sigh.
1161 #my ($dcode, $dmsg) = addDomain(dbh, domain, group, status);
1162
1163##fixme: serial
1164 my $sth = $dbh->prepare("INSERT INTO domains (domain,group_id,status) VALUES (?,?,?)");
1165 $sth->execute($domain,$group,$status);
1166
1167## bizarre DBI<->Net::DNS interaction bug:
1168## sometimes a zone will cause an immediate commit-and-exit (sort of) of the while()
1169## fixed, apparently I was doing *something* odd, but not certain what it was that
1170## caused a commit instead of barfing
1171
1172 # get domain id so we can do the records
1173 $sth = $dbh->prepare("SELECT domain_id FROM domains WHERE domain=?");
1174 $sth->execute($domain);
1175 ($dom_id) = $sth->fetchrow_array();
1176
1177 my $res = Net::DNS::Resolver->new;
1178 $res->nameservers($ifrom);
1179 $res->axfr_start($domain)
1180 or die "Couldn't begin AXFR\n";
1181
1182 while (my $rr = $res->axfr_next()) {
1183 my $type = $rr->type;
1184
1185 my $sql = "INSERT INTO records (domain_id,host,type,ttl,val";
1186 my $vallen = "?,?,?,?,?";
1187
1188 $soaflag = 1 if $type eq 'SOA';
1189 $nsflag = 1 if $type eq 'NS';
1190
1191 my @vallist = ($dom_id, $rr->name, $reverse_typemap{$type}, $rr->ttl);
1192
1193# "Primary" types:
1194# A, NS, CNAME, SOA, PTR(warn in forward), MX, TXT, AAAA, SRV, A6(ob), SPF
1195# maybe KEY
1196
1197# nasty big ugly case-like thing here, since we have to do *some* different
1198# processing depending on the record. le sigh.
1199
1200 if ($type eq 'A') {
1201 push @vallist, $rr->address;
1202 } elsif ($type eq 'NS') {
1203# hmm. should we warn here if subdomain NS'es are left alone?
1204 next if ($rwns && ($rr->name eq $domain));
1205 push @vallist, $rr->nsdname;
1206 $nsflag = 1;
1207 } elsif ($type eq 'CNAME') {
1208 push @vallist, $rr->cname;
1209 } elsif ($type eq 'SOA') {
1210 next if $rwsoa;
1211 $vallist[1] = $rr->mname.":".$rr->rname;
1212 push @vallist, ($rr->refresh.":".$rr->retry.":".$rr->expire.":".$rr->minimum);
1213 $soaflag = 1;
1214 } elsif ($type eq 'PTR') {
1215 # hmm. PTR records should not be in forward zones.
1216 } elsif ($type eq 'MX') {
1217 $sql .= ",distance";
1218 $vallen .= ",?";
1219 push @vallist, $rr->exchange;
1220 push @vallist, $rr->preference;
1221 } elsif ($type eq 'TXT') {
1222##fixme: Net::DNS docs say this should be deprecated for rdatastr() or char_str_list(),
1223## but don't really seem enthusiastic about it.
1224 push @vallist, $rr->txtdata;
1225 } elsif ($type eq 'SPF') {
1226##fixme: and the same caveat here, since it is apparently a clone of ::TXT
1227 push @vallist, $rr->txtdata;
1228 } elsif ($type eq 'AAAA') {
1229 push @vallist, $rr->address;
1230 } elsif ($type eq 'SRV') {
1231 $sql .= ",distance,weight,port" if $type eq 'SRV';
1232 $vallen .= ",?,?,?" if $type eq 'SRV';
1233 push @vallist, $rr->target;
1234 push @vallist, $rr->priority;
1235 push @vallist, $rr->weight;
1236 push @vallist, $rr->port;
1237 } elsif ($type eq 'KEY') {
1238 # we don't actually know what to do with these...
1239 push @vallist, ($rr->flags.":".$rr->protocol.":".$rr->algorithm.":".$rr->key.":".$rr->keytag.":".$rr->privatekeyname);
1240 } else {
1241 push @vallist, $rr->rdatastr;
1242 # Finding a different record type is not fatal.... just problematic.
1243 # We may not be able to export it correctly.
1244 $warnmsg .= "Unusual record ".$rr->name." ($type) found\n";
1245 }
1246
1247# BIND supports:
1248# A CNAME HINFO MB(ex) MD(ob) MF(ob) MG(ex) MINFO(ex) MR(ex) MX NS NULL
1249# PTR SOA TXT WKS AFSDB(ex) ISDN(ex) RP(ex) RT(ex) X25(ex) PX
1250# ... if one can ever find the right magic to format them correctly
1251
1252# Net::DNS supports:
1253# RRSIG SIG NSAP NS NIMLOC NAPTR MX MR MINFO MG MB LOC ISDN IPSECKEY HINFO
1254# EID DNAME CNAME CERT APL AFSDB AAAA A DS NXT NSEC3PARAM NSEC3 NSEC KEY
1255# DNSKEY DLV X25 TXT TSIG TKEY SSHFP SRV SPF SOA RT RP PX PTR NULL APL::AplItem
1256
1257 $sth = $dbh->prepare($sql.") VALUES (".$vallen.")") or die "problem preparing record insert SQL\n";
1258 $sth->execute(@vallist) or die "failed to insert ".$rr->string.": ".$sth->errstr."\n";
1259
1260 $nrecs++;
1261
1262 } # while axfr_next
1263
1264 # Overwrite SOA record
1265 if ($rwsoa) {
1266 $soaflag = 1;
1267 my $sthgetsoa = $dbh->prepare("SELECT host,val,ttl FROM default_records WHERE group_id=? AND type=?");
1268 my $sthputsoa = $dbh->prepare("INSERT INTO records (domain_id,host,type,val,ttl) VALUES (?,?,?,?,?)");
1269 $sthgetsoa->execute($group,$reverse_typemap{SOA});
1270 while (my ($host,$val,$ttl) = $sthgetsoa->fetchrow_array()) {
1271 $host =~ s/DOMAIN/$domain/g;
1272 $val =~ s/DOMAIN/$domain/g;
1273 $sthputsoa->execute($dom_id,$host,$reverse_typemap{SOA},$val,$ttl);
1274 }
1275 }
1276
1277 # Overwrite NS records
1278 if ($rwns) {
1279 $nsflag = 1;
1280 my $sthgetns = $dbh->prepare("SELECT host,val,ttl FROM default_records WHERE group_id=? AND type=?");
1281 my $sthputns = $dbh->prepare("INSERT INTO records (domain_id,host,type,val,ttl) VALUES (?,?,?,?,?)");
1282 $sthgetns->execute($group,$reverse_typemap{NS});
1283 while (my ($host,$val,$ttl) = $sthgetns->fetchrow_array()) {
1284 $host =~ s/DOMAIN/$domain/g;
1285 $val =~ s/DOMAIN/$domain/g;
1286 $sthputns->execute($dom_id,$host,$reverse_typemap{NS},$val,$ttl);
1287 }
1288 }
1289
1290 die "No records found; either $ifrom is not authoritative or doesn't allow transfers\n" if !$nrecs;
1291 die "Bad zone: No SOA record!\n" if !$soaflag;
1292 die "Bad zone: No NS records!\n" if !$nsflag;
1293
1294 $dbh->commit;
1295
1296 };
1297
1298 if ($@) {
1299 my $msg = $@;
1300 eval { $dbh->rollback; };
1301 return ('FAIL',$msg." $warnmsg");
1302 } else {
1303 return ('WARN', $warnmsg) if $warnmsg;
1304 return ('OK',"ook");
1305 }
1306
1307 # it should be impossible to get here.
1308 return ('WARN',"OOOK!");
1309} # end importAXFR()
1310
1311
1312# shut Perl up
13131;
Note: See TracBrowser for help on using the repository browser.