* Fixed off-by-one when null-terminating password strings which could have led

to LDAP connection errors
* Only print startup message when in daemon mode
* Fix regex when computing the domain name of a FQDN (now properly supports 
  FQDNs more than two levels deep)
* Create baseDN when converting data to ldif



git-svn-id: https://svn.alkaloid.net/gpl/ldap2dns/trunk@314 06cd67b6-e706-0410-b29e-9de616bca6e9
This commit is contained in:
Ben Klang
2006-05-30 19:34:35 +00:00
parent b29d3bee5f
commit d08eba4875
3 changed files with 24 additions and 438 deletions

View File

@@ -48,6 +48,25 @@ if ($output eq '-') {
open($outfh, ">$output") or die ("Unable to open $output for writing!");
open($rejfh, ">$rejout") or die ("Unable to open $rejout for writing");
$basedn =~ /^ou=([^,]+)/;
my $baserdn = $1;
if (!$baserdn) {
die("Unable to determine branch node from supplied DN");
}
# Create the base DN for DNS entries
print $outfh "
# Generated by data2ldif.pl, part of the ldap2dns package
# (C) 2005-2006 Ben Klang <ben\@alkaloid.net>
# http://projects.alkaloid.net
dn: $basedn
objectClass: top
objectClass: organizationalUnit
ou: $baserdn
";
# We run in two iterations. The first attempts to enumerate all zones
# for which we have records and create SOAs in LDAP. The reason for this is
# zones are used as a container for all records so they must be in place before
@@ -205,7 +224,7 @@ LINE: while(<DATA>) {
if (!defined($timestamp)) { $timestamp = ""; }
if (!defined($loc)) { $loc = ""; }
my $id = "NS-$fqdn-$ip-$x-$ttl-$timestamp-$loc";
my $domain = getdomain($fqdn);
my $domain = $fqdn;
print $outfh "dn: cn=$id,cn=$domain,$basedn\n";
print $outfh "objectClass: top\n";
@@ -407,7 +426,7 @@ exit 0;
sub getdomain
{
my $fqdn = shift(@_);
$fqdn =~ /\.*([A-Za-z0-9\-]+\.[A-Za-z0-9\-]+)\.*$/;
$fqdn =~ /[^\.]*\.(.*)/;
return $1;
}