diff -r -u -P orig/CVS/Entries new/CVS/Entries --- orig/CVS/Entries Tue Jun 24 10:56:14 2008 +++ new/CVS/Entries Tue Jun 24 10:56:14 2008 @@ -6,3 +6,4 @@ /timeDnsLatency.pl/1.1.1.1/Tue Jun 24 17:55:49 2008// /timeDnsRefresh.pl/1.1.1.1/Tue Jun 24 17:55:49 2008// D/binddlz//// +D/contrib//// diff -r -u -P orig/CVS/Repository new/CVS/Repository --- orig/CVS/Repository Tue Jun 24 10:56:14 2008 +++ new/CVS/Repository Tue Jun 24 10:56:14 2008 @@ -1 +1 @@ -bind-dlz-jmiller/orig +bind-dlz-jmiller/new diff -r -u -P orig/binddlz/CVS/Repository new/binddlz/CVS/Repository --- orig/binddlz/CVS/Repository Tue Jun 24 10:56:14 2008 +++ new/binddlz/CVS/Repository Tue Jun 24 10:56:14 2008 @@ -1 +1 @@ -bind-dlz-jmiller/orig/binddlz +bind-dlz-jmiller/new/binddlz diff -r -u -P orig/binddlz/writers/CVS/Repository new/binddlz/writers/CVS/Repository --- orig/binddlz/writers/CVS/Repository Tue Jun 24 10:56:14 2008 +++ new/binddlz/writers/CVS/Repository Tue Jun 24 10:56:14 2008 @@ -1 +1 @@ -bind-dlz-jmiller/orig/binddlz/writers +bind-dlz-jmiller/new/binddlz/writers diff -r -u -P orig/binddlz/writers/bdb/CVS/Repository new/binddlz/writers/bdb/CVS/Repository --- orig/binddlz/writers/bdb/CVS/Repository Tue Jun 24 10:56:14 2008 +++ new/binddlz/writers/bdb/CVS/Repository Tue Jun 24 10:56:14 2008 @@ -1 +1 @@ -bind-dlz-jmiller/orig/binddlz/writers/bdb +bind-dlz-jmiller/new/binddlz/writers/bdb diff -r -u -P orig/binddlz/writers/ldap/CVS/Repository new/binddlz/writers/ldap/CVS/Repository --- orig/binddlz/writers/ldap/CVS/Repository Tue Jun 24 10:56:14 2008 +++ new/binddlz/writers/ldap/CVS/Repository Tue Jun 24 10:56:14 2008 @@ -1 +1 @@ -bind-dlz-jmiller/orig/binddlz/writers/ldap +bind-dlz-jmiller/new/binddlz/writers/ldap diff -r -u -P orig/binddlz/writers/mysql/CVS/Repository new/binddlz/writers/mysql/CVS/Repository --- orig/binddlz/writers/mysql/CVS/Repository Tue Jun 24 10:56:14 2008 +++ new/binddlz/writers/mysql/CVS/Repository Tue Jun 24 10:56:14 2008 @@ -1 +1 @@ -bind-dlz-jmiller/orig/binddlz/writers/mysql +bind-dlz-jmiller/new/binddlz/writers/mysql diff -r -u -P orig/binddlz/writers/postgres/CVS/Repository new/binddlz/writers/postgres/CVS/Repository --- orig/binddlz/writers/postgres/CVS/Repository Tue Jun 24 10:56:14 2008 +++ new/binddlz/writers/postgres/CVS/Repository Tue Jun 24 10:56:14 2008 @@ -1 +1 @@ -bind-dlz-jmiller/orig/binddlz/writers/postgres +bind-dlz-jmiller/new/binddlz/writers/postgres diff -r -u -P orig/contrib/CVS/Entries new/contrib/CVS/Entries --- orig/contrib/CVS/Entries Wed Dec 31 17:00:00 1969 +++ new/contrib/CVS/Entries Tue Jun 24 10:56:14 2008 @@ -0,0 +1 @@ +D/writers//// diff -r -u -P orig/contrib/CVS/Repository new/contrib/CVS/Repository --- orig/contrib/CVS/Repository Wed Dec 31 17:00:00 1969 +++ new/contrib/CVS/Repository Tue Jun 24 10:56:14 2008 @@ -0,0 +1 @@ +bind-dlz-jmiller/new/contrib diff -r -u -P orig/contrib/CVS/Root new/contrib/CVS/Root --- orig/contrib/CVS/Root Wed Dec 31 17:00:00 1969 +++ new/contrib/CVS/Root Tue Jun 24 10:56:14 2008 @@ -0,0 +1 @@ +/home/joeym/testcvs2 diff -r -u -P orig/contrib/writers/CVS/Entries new/contrib/writers/CVS/Entries --- orig/contrib/writers/CVS/Entries Wed Dec 31 17:00:00 1969 +++ new/contrib/writers/CVS/Entries Tue Jun 24 10:56:14 2008 @@ -0,0 +1,3 @@ +D/mydns//// +D/powerdns//// +D/windowsdns//// diff -r -u -P orig/contrib/writers/CVS/Repository new/contrib/writers/CVS/Repository --- orig/contrib/writers/CVS/Repository Wed Dec 31 17:00:00 1969 +++ new/contrib/writers/CVS/Repository Tue Jun 24 10:56:14 2008 @@ -0,0 +1 @@ +bind-dlz-jmiller/new/contrib/writers diff -r -u -P orig/contrib/writers/CVS/Root new/contrib/writers/CVS/Root --- orig/contrib/writers/CVS/Root Wed Dec 31 17:00:00 1969 +++ new/contrib/writers/CVS/Root Tue Jun 24 10:56:14 2008 @@ -0,0 +1 @@ +/home/joeym/testcvs2 diff -r -u -P orig/contrib/writers/bindzone.pm new/contrib/writers/bindzone.pm --- orig/contrib/writers/bindzone.pm Wed Dec 31 17:00:00 1969 +++ new/contrib/writers/bindzone.pm Tue Jul 8 11:14:20 2008 @@ -0,0 +1,197 @@ +package contrib::writers::bindzone; +require Exporter; + +@ISA = qw(Exporter); + +# export methods +@EXPORT = qw(getParameters, init, cleanup, addRecord); + +# forward declaration of private methods +sub mkdirR; +sub openZoneFile; +sub genZoneFilePath; + + # Constructor. + # Don't do much, Just return a pointer to this class. +sub new { + my $this = {}; + bless $this; + return $this; +} + + # Check parameters are correct and + # prepare this instance to write DNS data +sub init { + my $this = shift; + local (*params) = @_; + + my $file; + + # The "base" parameter is the base directory we should write to. + my $base = $params{"base"}; + my $pathSep = $base; + + # verify a base was passed. + if(length($base) < 1){ + my $tmp = "A \"base\" parameter must be supplied to the\n"; + $tmp .= "contrib::writers::bindzone writer\n"; + die $tmp; + } + + # attempt to determine path separator, and store in this "instance". + $pathSep =~ s/.*([\\\/]).*/$1/; + if(length($pathSep) != 1){ + die "Could not determine path separator.\n"; + } + $this->{'pathSep'} = $pathSep; + + # if $base has ending "/" or "\" get rid of it. + $base =~ s/[\\\/]$//; + + # attempt to create base directory, die if we can't + if($base !~ /[ \t]*\|/){ + mkdirR($base) || + die ("Directory ${base} doesn't exist and could not be created.\n"); + } else { + die ("The contrib::writers::bindzone writer does not support piping.\n"); + } + + # store the base in this instance so we can use it later. + $this->{'base'} = $base; + + # create a named.conf file. + open($file, ">" . $base . $pathSep . "named.conf-data") || + die "contrib::writers::bidnzone could not open\n" . + "'${base}${pathSep}named.conf' for writing\n"; + + $this->{'named.conf'} = $file; +} + + # add "write" a DNS record. +sub addRecord { + my $this = shift; + local (*zone, *host, *ttl, *type, *mx_priority, + *data, *adminEmail, *serial, *refresh, + *retry, *expire, *minimum) = @_; + + # get the base to write to. + my $base = $this->{'base'}; + + # get path separator. + my $pathSep = $this->{'pathSep'}; + + # get named.conf file handle + my $namedFile = $this->{'named.conf'}; + + # get the zone file handle for the last one we worked on. + my $zoneFile = $this->{'zoneFile'}; + + # get the name of the zone we last worked on. + my $lastZone = $this->{'lastZone'}; + + # if we don't already have a zoneFile open, this is the + # first time through, so open one. + if(!$zoneFile){ + $zoneFile = openZoneFile($pathSep, + genZoneFilePath($base, $pathSep, $zone), + $zone . ".db", $zoneFile); + } + + # if we have a lastZone (not first time through) AND it is + # not the same as the one we are working on now, open a new + # zoneFile, and add a new entry to named.conf file. + if($lastZone ne $zone){ + $zoneFile = openZoneFile($pathSep, + genZoneFilePath($base, $pathSep, $zone), + $zone . ".db", $zoneFile); + + # write new entry to named.conf file. + print $namedFile ("zone \"${zone}\" {\n"); + print $namedFile ("\ttype master;\n"); + print $namedFile ("\tfile \"" . + genZoneFilePath($base, $pathSep, $zone) . $pathSep . $zone . + ".db\";\n"); + print $namedFile ("\tnotify no;\n"); + print $namedFile ("};\n\n"); + } # close if($lastZone && $lastZone ne $zone) + + # write entry to zoneFile. + if ( $type eq "soa" ) { + print $zoneFile ("${zone}.\t${ttl}\tIN\t${type}\t${data} ${adminEmail} ( ${serial} ${refresh} ${retry} "); + print $zoneFile ("${expire} ${minimum} )"); + } else { + + print $zoneFile ("${host}\t${ttl}\tIN\t${type}\t"); + + if($type eq "mx"){ + print $zoneFile ("${mx_priority} "); + } + print $zoneFile ("${data}"); + } + print $zoneFile ("\n"); + + #store zoneFile to use next time. + $this->{'zoneFile'} = $zoneFile; + + #store lastZone to compare with next time. + $this->{'lastZone'} = $zone; +} + + # cleanup this instance after writing DNS data +sub cleanup() { + # no cleanup needed for zoneFile +} + + # closes current zone file handle if one is open. + # then opens a new one for writing, and returns it. +sub openZoneFile { + my $pathSep = shift; + my $path = shift; + my $fileName = shift; + my $file = shift; + + # close old file + if($file){ + close($file); + } + + # make sure directory exists + mkdirR($path); + + # open new file for writing + open($file, ">" . $path . $pathSep . $fileName) || + die "contrib::writers::bidnzone could not open zone file\n" . + "'${path}${pathSep}${fileName}' for writing\n"; + + return $file; +} + + # constructs a zone file path +sub genZoneFilePath { + my $base = shift; + my $pathSep = shift; + my $name = shift; + + my $path = $base . $pathSep . substr($name, 0, 1) . $pathSep . substr($name, 0, 2); + + return $path; +} + + # recursively make directory path + # Parameter 1 - directory path to be created. +sub mkdirR { + # get passed in dir name. + my $dir = shift; + + # determine Parent directory + my $pDir = $dir; + $pDir =~ s/(.*)([\\\/].*$)/$1/; + + # stat dir, if it doesn't exist recursively make its parent. + # if everything fails horribly, die. + stat($dir) || (mkdirR($pDir) && mkdir($dir, 0777)) || + die ("Could not create directory '${dir}'.\n");; +} + +# last line of a perl module must be 1; +1; diff -r -u -P orig/contrib/writers/mydns/CVS/Entries new/contrib/writers/mydns/CVS/Entries --- orig/contrib/writers/mydns/CVS/Entries Wed Dec 31 17:00:00 1969 +++ new/contrib/writers/mydns/CVS/Entries Tue Jun 24 10:56:14 2008 @@ -0,0 +1,2 @@ +/file.pm/1.1.1.1/Tue Jun 24 17:55:49 2008// +D diff -r -u -P orig/contrib/writers/mydns/CVS/Repository new/contrib/writers/mydns/CVS/Repository --- orig/contrib/writers/mydns/CVS/Repository Wed Dec 31 17:00:00 1969 +++ new/contrib/writers/mydns/CVS/Repository Tue Jun 24 10:56:14 2008 @@ -0,0 +1 @@ +bind-dlz-jmiller/new/contrib/writers/mydns diff -r -u -P orig/contrib/writers/mydns/CVS/Root new/contrib/writers/mydns/CVS/Root --- orig/contrib/writers/mydns/CVS/Root Wed Dec 31 17:00:00 1969 +++ new/contrib/writers/mydns/CVS/Root Tue Jun 24 10:56:14 2008 @@ -0,0 +1 @@ +/home/joeym/testcvs2 diff -r -u -P orig/contrib/writers/mydns/file.pm new/contrib/writers/mydns/file.pm --- orig/contrib/writers/mydns/file.pm Wed Dec 31 17:00:00 1969 +++ new/contrib/writers/mydns/file.pm Tue Jun 24 10:55:49 2008 @@ -0,0 +1,159 @@ +package contrib::writers::mydns::file; +require Exporter; + +@ISA = qw(Exporter); + +# export methods +@EXPORT = qw(getParameters, init, cleanup, addRecord); + +my $buffer = ''; + +# forward declaration of private methods +sub mysql_fix; + + # Constructor. + # Don't do much, Just return a pointer to this class. +sub new { + my $this = {}; + bless $this; + return $this; +} + + # Check parameters are correct and + # prepare this instance to write DNS data +sub init { + my $this = shift; + local (*params) = @_; + + my $file; + + # The "file" parameter is the filename of the file we should write to. + my $filename = $params{"file"}; + my $tabletype = $params{"tabletype"}; + + # verify a filename was passed. + if(length($filename) < 1){ + my $tmp = "A \"file\" parameter must be supplied to the\n"; + $tmp .= "contrib::writers::mydns::file\n"; + die $tmp; + } + + if (length($tabletype) < 1){ + $tabletype = "MyISAM"; + } + + # attempt to open file or pipe, die if we can't + if($filename !~ /[ \t]*\|/){ + open($file, ">$filename") || + die ("Couldn't open file: ${filename}\n"); + } else { + open($file, "$filename") || + die ("Couldn't pipe to: ${filename}\n"); + } + + # store the file handle in this instance so we can + # write to it later. + $this->{'filehandle'} = $file; + + # after the file is opened, write out the "header" + # this will create the appropriate tables + + print $file ("CREATE TABLE IF NOT EXISTS soa (\n"); + print $file (" id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,\n"); + print $file (" origin CHAR(255) NOT NULL,\n"); + print $file (" ns CHAR(255) NOT NULL,\n"); + print $file (" mbox CHAR(255) NOT NULL,\n"); + print $file (" serial INT UNSIGNED NOT NULL default '1',\n"); + print $file (" refresh INT UNSIGNED NOT NULL default '28800',\n"); + print $file (" retry INT UNSIGNED NOT NULL default '7200',\n"); + print $file (" expire INT UNSIGNED NOT NULL default '604800',\n"); + print $file (" minimum INT UNSIGNED NOT NULL default '86400',\n"); + print $file (" ttl INT UNSIGNED NOT NULL default '86400',\n"); + print $file (" UNIQUE KEY (origin)\n"); + print $file (") TYPE=$tabletype;\n\n"); + + print $file ("CREATE TABLE IF NOT EXISTS rr (\n"); + print $file (" id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,\n"); + print $file (" zone INT UNSIGNED NOT NULL,\n"); + print $file (" name CHAR(64) NOT NULL,\n"); + print $file (" type ENUM('A','AAAA','CNAME','HINFO','MX','NAPTR','NS','PTR','RP','SRV','TXT'),\n"); + print $file (" data CHAR(128) NOT NULL,\n"); + print $file (" aux INT UNSIGNED NOT NULL,\n"); + print $file (" ttl INT UNSIGNED NOT NULL default '86400',\n"); + print $file (" UNIQUE KEY rr (zone,name,type,data)\n"); + print $file (") TYPE=$tabletype;\n\n"); +} + + # add "write" a DNS record. +sub addRecord { + my $this = shift; + local (*zone, *host, *ttl, *type, *mx_priority, + *data, *adminEmail, *serial, *refresh, + *retry, *expire, *minimum) = @_; + + # get the filehandle to write to. + my $file = $this->{'filehandle'}; + + # for wildcard type entries, mydns wants empty field ('') but + # binddlz send us '@'. So let's convert @ to '' + my $host = $host; + if ( $host eq "\@" ) { + $host = "''"; + } else { + $host = mysql_fix($host, "'"); + } + # properly wrap or convert data for the SQL query. + my $zone = mysql_fix($zone, "'"); + my $ttl = mysql_fix($ttl); + my $type = mysql_fix($type, "'"); + my $mx_priority = mysql_fix($mx_priority); + my $data = mysql_fix($data, "'"); + my $adminEmail = mysql_fix($adminEmail, "'"); + my $serial = mysql_fix($serial); + my $refresh = mysql_fix($refresh); + my $retry = mysql_fix($retry); + my $expire = mysql_fix($expire); + my $minimum = mysql_fix($minimum); + + + # note that we use subselects when inserting into the 'rr' table + # because mydns expects the 'zone' column to be a reference + # to an 'id' from the soa table. subselect may only be available in + # newer version of mysql (4.1+ ?) + # + + if ( $type eq "'soa'" ) { + print $file ("\nINSERT INTO soa VALUES ("); + print $file ("NULL, $zone, $data, $adminEmail, $serial, $refresh, $retry, $expire, $minimum, $ttl"); + print $file (");\n"); + } else { + print $file ("INSERT INTO rr VALUES ("); + print $file ("NULL, (SELECT id FROM soa WHERE origin = $zone), $host, $type, $data, 0, $ttl"); + print $file (");\n"); + } + +} + + # cleanup this instance after writing DNS data +sub cleanup() { + # for mysql don't do anything. + + # Don't close output file. + # Perl does automatically when the program completes. +} + + # converts zero length strings to the word NULL that postgres SQL + # statements expect. If a second argument is supplied wrap input + # string with that argument. +sub mysql_fix { + $in = shift; + $wrap = shift; + + if (length($in) < 1) { + return "NULL"; + } + return "${wrap}${in}${wrap}"; +} + +# last line of a perl module must be 1; +1; diff -r -u -P orig/contrib/writers/powerdns/CVS/Entries new/contrib/writers/powerdns/CVS/Entries --- orig/contrib/writers/powerdns/CVS/Entries Wed Dec 31 17:00:00 1969 +++ new/contrib/writers/powerdns/CVS/Entries Tue Jun 24 10:56:14 2008 @@ -0,0 +1,4 @@ +/gmysql.pm/1.1.1.1/Tue Jun 24 17:55:49 2008// +/sqlite3.pm/1.1.1.1/Tue Jun 24 17:55:49 2008// +/xdb.pm/1.1.1.1/Tue Jun 24 17:55:49 2008// +D diff -r -u -P orig/contrib/writers/powerdns/CVS/Repository new/contrib/writers/powerdns/CVS/Repository --- orig/contrib/writers/powerdns/CVS/Repository Wed Dec 31 17:00:00 1969 +++ new/contrib/writers/powerdns/CVS/Repository Tue Jun 24 10:56:14 2008 @@ -0,0 +1 @@ +bind-dlz-jmiller/new/contrib/writers/powerdns diff -r -u -P orig/contrib/writers/powerdns/CVS/Root new/contrib/writers/powerdns/CVS/Root --- orig/contrib/writers/powerdns/CVS/Root Wed Dec 31 17:00:00 1969 +++ new/contrib/writers/powerdns/CVS/Root Tue Jun 24 10:56:14 2008 @@ -0,0 +1 @@ +/home/joeym/testcvs2 diff -r -u -P orig/contrib/writers/powerdns/gmysql.pm new/contrib/writers/powerdns/gmysql.pm --- orig/contrib/writers/powerdns/gmysql.pm Wed Dec 31 17:00:00 1969 +++ new/contrib/writers/powerdns/gmysql.pm Tue Jun 24 10:55:49 2008 @@ -0,0 +1,171 @@ +package contrib::writers::powerdns::gmysql; +require Exporter; + +@ISA = qw(Exporter); + +# export methods +@EXPORT = qw(getParameters, init, cleanup, addRecord); + +my $buffer = ''; + +# forward declaration of private methods +sub mysql_fix; + + # Constructor. + # Don't do much, Just return a pointer to this class. +sub new { + my $this = {}; + bless $this; + return $this; +} + + # Check parameters are correct and + # prepare this instance to write DNS data +sub init { + my $this = shift; + local (*params) = @_; + + my $file; + + # The "file" parameter is the filename of the file we should write to. + my $filename = $params{"file"}; + + # verify a filename was passed. + if(length($filename) < 1){ + my $tmp = "A \"file\" parameter must be supplied to the\n"; + $tmp .= "contrib::writers::powerdns::gmysql\n"; + die $tmp; + } + + my $tabletype = $params{"tabletype"}; + if (length($tabletype) < 1){ + $tabletype = "InnoDB"; + } + + # attempt to open file or pipe, die if we can't + if($filename !~ /[ \t]*\|/){ + open($file, ">$filename") || + die ("Couldn't open file: ${filename}\n"); + } else { + open($file, "$filename") || + die ("Couldn't pipe to: ${filename}\n"); + } + + # store the file handle in this instance so we can + # write to it later. + $this->{'filehandle'} = $file; + + # after the file is opened, write out the "header" + # this will create the appropriate tables + print $file ("create table domains (\n"); + print $file (" id INT auto_increment,\n"); + print $file (" name VARCHAR(255) NOT NULL,\n"); + print $file (" master VARCHAR(128) DEFAULT NULL,\n"); + print $file (" last_check INT DEFAULT NULL,\n"); + print $file (" type VARCHAR(6) NOT NULL,\n"); + print $file (" notified_serial INT DEFAULT NULL, \n"); + print $file (" account VARCHAR(40) DEFAULT NULL,\n"); + print $file (" primary key (id)\n"); + print $file (")type=InnoDB;\n"); + + print $file ("CREATE UNIQUE INDEX name_index ON domains(name);\n"); + + print $file ("CREATE TABLE records (\n"); + print $file (" id INT auto_increment,\n"); + print $file (" domain_id INT DEFAULT NULL,\n"); + print $file (" name VARCHAR(255) DEFAULT NULL,\n"); + print $file (" type VARCHAR(6) DEFAULT NULL,\n"); + print $file (" content VARCHAR(255) DEFAULT NULL,\n"); + print $file (" ttl INT DEFAULT NULL,\n"); + print $file (" prio INT DEFAULT NULL,\n"); + print $file (" change_date INT DEFAULT NULL,\n"); + print $file (" primary key(id)\n"); + print $file (")type=InnoDB;\n"); + + print $file ("CREATE INDEX rec_name_index ON records(name);\n"); + print $file ("CREATE INDEX nametype_index ON records(name,type);\n"); + print $file ("CREATE INDEX domain_id ON records(domain_id);\n"); + + print $file ("create table supermasters (\n"); + print $file (" ip VARCHAR(25) NOT NULL, \n"); + print $file (" nameserver VARCHAR(255) NOT NULL, \n"); + print $file (" account VARCHAR(40) DEFAULT NULL\n"); + print $file (");\n"); +} + + # add "write" a DNS record. +sub addRecord { + my $this = shift; + local (*zone, *host, *ttl, *type, *mx_priority, + *data, *adminEmail, *serial, *refresh, + *retry, *expire, *minimum) = @_; + + # get the filehandle to write to. + my $file = $this->{'filehandle'}; + + my $zone = $zone; + my $host = $host; + my $ttl = $ttl; + my $type = $type; + my $mx_priority = $mx_priority || 0; + my $data = $data; + my $adminEmail = $adminEmail; + my $serial = $serial; + my $refresh = $refresh; + my $retry = $retry; + my $expire = $expire; + my $minimum = $minimum; + + $zone =~ s/\.$//; + $data =~ s/\.$//; + $adminEmail =~ s/\.$//; + $type =~ tr/a-z/A-Z/; + + if ( $type eq "SOA" ) { + $host =~ s/^\.//; + + print $file ("\n"); + print $file ("INSERT INTO domains (name,type) VALUES ("); + print $file ("'$zone', 'NATIVE');\n"); + + print $file ("INSERT INTO records (domain_id, name, type, content, ttl, prio) "); + print $file ("select id, '$zone', '$type', 'ns1.$zone $adminEmail $serial $refresh $retry $expire $minimum', $ttl, 0 FROM domains WHERE name='$zone';\n"); + + } else { + my $name; + if ( $host eq "\@" ) { + $name = $zone; + } else { + $name = $host . "." . $zone; + } + + print $file ("INSERT INTO records (domain_id, name,type,content,ttl,prio) "); + print $file ("select id, '$name', '$type', '$data', $ttl, $mx_priority "); + print $file ("FROM domains WHERE name='$zone';\n"); + } + +} + + # cleanup this instance after writing DNS data +sub cleanup() { + # for mysql don't do anything. + + # Don't close output file. + # Perl does automatically when the program completes. +} + + # converts zero length strings to the word NULL that postgres SQL + # statements expect. If a second argument is supplied wrap input + # string with that argument. +sub mysql_fix { + $in = shift; + $wrap = shift; + + if (length($in) < 1) { + return "NULL"; + } + return "${wrap}${in}${wrap}"; +} + +# last line of a perl module must be 1; +1; diff -r -u -P orig/contrib/writers/powerdns/sqlite3.pm new/contrib/writers/powerdns/sqlite3.pm --- orig/contrib/writers/powerdns/sqlite3.pm Wed Dec 31 17:00:00 1969 +++ new/contrib/writers/powerdns/sqlite3.pm Tue Jun 24 10:55:49 2008 @@ -0,0 +1,163 @@ +package contrib::writers::powerdns::sqlite3; +require Exporter; + +@ISA = qw(Exporter); + +# export methods +@EXPORT = qw(getParameters, init, cleanup, addRecord); + +my $buffer = ''; + +# forward declaration of private methods +sub mysql_fix; + + # Constructor. + # Don't do much, Just return a pointer to this class. +sub new { + my $this = {}; + bless $this; + return $this; +} + + # Check parameters are correct and + # prepare this instance to write DNS data +sub init { + my $this = shift; + local (*params) = @_; + + my $file; + + # The "file" parameter is the filename of the file we should write to. + my $filename = $params{"file"}; + + # verify a filename was passed. + if(length($filename) < 1){ + my $tmp = "A \"file\" parameter must be supplied to the\n"; + $tmp .= "contrib::writers::powerdns::sqlite3\n"; + die $tmp; + } + + # attempt to open file or pipe, die if we can't + if($filename !~ /[ \t]*\|/){ + open($file, ">$filename") || + die ("Couldn't open file: ${filename}\n"); + } else { + open($file, "$filename") || + die ("Couldn't pipe to: ${filename}\n"); + } + + # store the file handle in this instance so we can + # write to it later. + $this->{'filehandle'} = $file; + + # after the file is opened, write out the "header" + # this will create the appropriate tables + + print $file ("CREATE TABLE domains (\n"); + print $file (" id INTEGER PRIMARY KEY,\n"); + print $file (" name VARCHAR(255) NOT NULL,\n"); + print $file (" master VARCHAR(128) DEFAULT NULL,\n"); + print $file (" last_check INTEGER DEFAULT NULL,\n"); + print $file (" type VARCHAR(6) NOT NULL,\n"); + print $file (" notified_serial INTEGER DEFAULT NULL,\n"); + print $file (" account VARCHAR(40) DEFAULT NULL\n"); + print $file (");\n"); + print $file ("CREATE UNIQUE INDEX name_index ON domains(name);\n"); + + print $file ("CREATE TABLE records (\n"); + print $file (" id INTEGER PRIMARY KEY,\n"); + print $file (" domain_id INTEGER DEFAULT NULL,\n"); + print $file (" name VARCHAR(255) DEFAULT NULL,\n"); + print $file (" type VARCHAR(6) DEFAULT NULL,\n"); + print $file (" content VARCHAR(255) DEFAULT NULL,\n"); + print $file (" ttl INTEGER DEFAULT NULL,\n"); + print $file (" prio INTEGER DEFAULT NULL,\n"); + print $file (" change_date INTEGER DEFAULT NULL\n"); + print $file (");\n"); + print $file ("CREATE INDEX rec_name_index ON records(name);\n"); + print $file ("CREATE INDEX nametype_index ON records(name,type);\n"); + print $file ("CREATE INDEX domain_id ON records(domain_id);\n"); + + print $file ("CREATE TABLE supermasters (\n"); + print $file (" ip VARCHAR(25) NOT NULL,\n"); + print $file (" nameserver VARCHAR(255) NOT NULL,\n"); + print $file (" account VARCHAR(40) DEFAULT NULL\n"); + print $file (");\n"); +} + + # add "write" a DNS record. +sub addRecord { + my $this = shift; + local (*zone, *host, *ttl, *type, *mx_priority, + *data, *adminEmail, *serial, *refresh, + *retry, *expire, *minimum) = @_; + + # get the filehandle to write to. + my $file = $this->{'filehandle'}; + + my $zone = $zone; + my $host = $host; + my $ttl = $ttl; + my $type = $type; + my $mx_priority = $mx_priority || 0; + my $data = $data; + my $adminEmail = $adminEmail; + my $serial = $serial; + my $refresh = $refresh; + my $retry = $retry; + my $expire = $expire; + my $minimum = $minimum; + + $zone =~ s/\.$//; + $data =~ s/\.$//; + $adminEmail =~ s/\.$//; + $type =~ tr/a-z/A-Z/; + + if ( $type eq "SOA" ) { + $host =~ s/^\.//; + + print $file ("\n"); + print $file ("INSERT INTO domains (name,type) VALUES ("); + print $file ("'$zone', 'NATIVE');\n"); + + print $file ("INSERT INTO records (domain_id, name, type, content, ttl, prio) "); + print $file ("select id, '$zone', '$type', 'ns1.$zone $adminEmail $serial $refresh $retry $expire $minimum', $ttl, 0 FROM domains WHERE name='$zone';\n"); + + } else { + my $name; + if ( $host eq "\@" ) { + $name = $zone; + } else { + $name = $host . "." . $zone; + } + + print $file ("INSERT INTO records (domain_id, name,type,content,ttl,prio) "); + print $file ("select id, '$name', '$type', '$data', $ttl, $mx_priority "); + print $file ("FROM domains WHERE name='$zone';\n"); + } + +} + + # cleanup this instance after writing DNS data +sub cleanup() { + # for mysql don't do anything. + + # Don't close output file. + # Perl does automatically when the program completes. +} + + # converts zero length strings to the word NULL that postgres SQL + # statements expect. If a second argument is supplied wrap input + # string with that argument. +sub mysql_fix { + $in = shift; + $wrap = shift; + + if (length($in) < 1) { + return "NULL"; + } + return "${wrap}${in}${wrap}"; +} + +# last line of a perl module must be 1; +1; diff -r -u -P orig/contrib/writers/powerdns/xdb.pm new/contrib/writers/powerdns/xdb.pm --- orig/contrib/writers/powerdns/xdb.pm Wed Dec 31 17:00:00 1969 +++ new/contrib/writers/powerdns/xdb.pm Tue Jun 24 10:55:49 2008 @@ -0,0 +1,78 @@ +package contrib::writers::powerdns::xdb; +require Exporter; + +@ISA = qw(Exporter); + +# export methods +@EXPORT = qw(getParameters, init, cleanup, addRecord); + + # Constructor. + # Don't do much, Just return a pointer to this class. +sub new { + my $this = {}; + bless $this; + return $this; +} + + # Check parameters are correct and + # prepare this instance to write DNS data +sub init { + my $this = shift; + local (*params) = @_; + + my $file; + + # The "file" parameter is the filename of the file we should write to. + my $filename = $params{"file"}; + + # verify a filename was passed. + if(length($filename) < 1){ + my $tmp = "A \"file\" parameter must be supplied to the\n"; + $tmp .= "contrib::writers::powerdns::xdb writer\n"; + die $tmp; + } + + # attempt to open file or pipe, die if we can't + if($filename !~ /[ \t]*\|/){ + open($file, ">$filename") || + die ("Couldn't open file: ${filename}\n"); + } else { + open($file, "$filename") || + die ("Couldn't pipe to: ${filename}\n"); + } + + # store the file handle in this instance so we can + # write to it later. + $this->{'filehandle'} = $file; + + $this->{'id'} = 0; +} + + # add "write" a DNS record. +sub addRecord { + my $this = shift; + local (*zone, *host, *ttl, *type, *mx_priority, + *data, *adminEmail, *serial, *refresh, + *retry, *expire, *minimum) = @_; + + # get the filehandle to write to. + my $file = $this->{'filehandle'}; + + if ( $type == 'a' || $type == 'A' ) { + print $file $this->{'id'}++ . " '$host.$zone' '$type' '$data' 0 360 0\n"; + } elsif ( $type == 'SOA' || $type == 'soa' ) { + print $file $this->{'id'}++ . " '$zone' '$type' '$data|$adminEmail|$serial|$refresh|$retry|$expire|$minimum' 0 360 0\n"; + } + +} + + # cleanup this instance after writing DNS data +sub cleanup() { + # no cleanup is needed for xdb + + # Don't close output file. + # Perl does automatically when the program completes. +} + +# last line of a perl module must be 1; +1; diff -r -u -P orig/contrib/writers/windowsdns/CVS/Entries new/contrib/writers/windowsdns/CVS/Entries --- orig/contrib/writers/windowsdns/CVS/Entries Wed Dec 31 17:00:00 1969 +++ new/contrib/writers/windowsdns/CVS/Entries Tue Jun 24 10:56:14 2008 @@ -0,0 +1,2 @@ +/file.pm/1.1.1.1/Tue Jun 24 17:55:49 2008// +D diff -r -u -P orig/contrib/writers/windowsdns/CVS/Repository new/contrib/writers/windowsdns/CVS/Repository --- orig/contrib/writers/windowsdns/CVS/Repository Wed Dec 31 17:00:00 1969 +++ new/contrib/writers/windowsdns/CVS/Repository Tue Jun 24 10:56:14 2008 @@ -0,0 +1 @@ +bind-dlz-jmiller/new/contrib/writers/windowsdns diff -r -u -P orig/contrib/writers/windowsdns/CVS/Root new/contrib/writers/windowsdns/CVS/Root --- orig/contrib/writers/windowsdns/CVS/Root Wed Dec 31 17:00:00 1969 +++ new/contrib/writers/windowsdns/CVS/Root Tue Jun 24 10:56:14 2008 @@ -0,0 +1 @@ +/home/joeym/testcvs2 diff -r -u -P orig/contrib/writers/windowsdns/file.pm new/contrib/writers/windowsdns/file.pm --- orig/contrib/writers/windowsdns/file.pm Wed Dec 31 17:00:00 1969 +++ new/contrib/writers/windowsdns/file.pm Tue Jun 24 10:55:49 2008 @@ -0,0 +1,76 @@ +package contrib::writers::windowsdns::file; +require Exporter; + +@ISA = qw(Exporter); + +# export methods +@EXPORT = qw(getParameters, init, cleanup, addRecord); + + # Constructor. + # Don't do much, Just return a pointer to this class. +sub new { + my $this = {}; + bless $this; + return $this; +} + + # Check parameters are correct and + # prepare this instance to write DNS data +sub init { + my $this = shift; + local (*params) = @_; + + my $file; + + # The "file" parameter is the filename of the file we should write to. + my $filename = $params{"file"}; + + # verify a filename was passed. + if(length($filename) < 1){ + my $tmp = "A \"file\" parameter must be supplied to the\n"; + $tmp .= "contrib::writers::windowsdns::file writer\n"; + die $tmp; + } + + # attempt to open file or pipe, die if we can't + if($filename !~ /[ \t]*\|/){ + open($file, ">$filename") || + die ("Couldn't open file: ${filename}\n"); + } else { + open($file, "$filename") || + die ("Couldn't pipe to: ${filename}\n"); + } + + # store the file handle in this instance so we can + # write to it later. + $this->{'filehandle'} = $file; +} + + # add "write" a DNS record. +sub addRecord { + my $this = shift; + local (*zone, *host, *ttl, *type, *mx_priority, + *data, *adminEmail, *serial, *refresh, + *retry, *expire, *minimum) = @_; + + # get the filehandle to write to. + my $file = $this->{'filehandle'}; + + if ( $type eq "soa" ) { + print $file ("\n"); + print $file ("dnscmd /ZoneAdd ${zone} /DsPrimary /dp ${zone} /a ${adminEmail} /DP /forest\n"); + } else { + print $file ("dnscmd /recordadd ${zone} ${host} ${ttl} ${type} ${mx_priority} ${data}\n"); + } +} + + # cleanup this instance after writing DNS data +sub cleanup() { + # no cleanup is needed + + # Don't close output file. + # Perl does automatically when the program completes. +} + +# last line of a perl module must be 1; +1; diff -r -u -P orig/dnsDataGen.pl new/dnsDataGen.pl --- orig/dnsDataGen.pl Tue Jun 24 10:55:49 2008 +++ new/dnsDataGen.pl Tue Jun 24 10:55:49 2008 @@ -98,6 +98,30 @@ $zone = getName(); $zone .= getTLD(); + # for mydns, we need the soa before any RR's, so I moved the + # soa generation to the first step of the zone creation. i hope + # this doesn't break other binddlz::writer's -jmiller, 5/23/2008 + $type = "soa"; + $data = "ns1." . $zone . "."; + $adminEmail = "root." . $zone . "."; + + # these numbers don't really matter. They are only needed + # for zone transfers. We aren't testing the performance of + # zone transfers. Infact if you are using DLZ properly you + # never need zone transfers. + $serial = 2; + $refresh = 28000; + $retry = 2800; + $expire = 64800; + $minimum = 10; + $ttl = 86400; + + # adding SOA record + addRecord(*zone, *host, *ttl, *type, *mx_priority, + *data, *adminEmail, *serial, *refresh, + *retry, *expire, *minimum); + + # We always create data at the zone apex. # This data can be referred to from the other generated zones. # This will allow the DNS data to be "proper". @@ -140,25 +164,6 @@ *data, *adminEmail, *serial, *refresh, *retry, *expire, *minimum); - $type = "soa"; - $data = "ns1." . $zone . "."; - $adminEmail = "root." . $zone . "."; - - # these numbers don't really matter. They are only needed - # for zone transfers. We aren't testing the performance of - # zone transfers. Infact if you are using DLZ properly you - # never need zone transfers. - $serial = 2; - $refresh = 28000; - $retry = 2800; - $expire = 64800; - $minimum = 10; - - # adding SOA record - addRecord(*zone, *host, *ttl, *type, *mx_priority, - *data, *adminEmail, *serial, *refresh, - *retry, *expire, *minimum); - if($hosts[$hostsIDX] > 10){ print $zones . ". Hosts remaining: "; }