mirror of
https://github.com/bklang/ldap2dns.git
synced 2025-10-26 14:04:14 -04:00
* Add new TXT record handling
* Change struct resourcerecord SRV member names to be consistent with other members git-svn-id: https://svn.alkaloid.net/gpl/ldap2dns/trunk@457 06cd67b6-e706-0410-b29e-9de616bca6e9
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
# $Id$
|
||||
Version 0.4.2 (latest)
|
||||
Version 0.5.0-beta (latest)
|
||||
* BACKWARD COMPATIBILITY BREAK: DNS TXT records now store their data in the new
|
||||
DNSTXT attribute instead of the old DNScname attribute. You must manually
|
||||
update any DNS TXT records for them to continue working.
|
||||
|
||||
Version 0.4.2
|
||||
* Add SMF manifest
|
||||
* Add manpage
|
||||
* Ensure all options get initialized to defaults before any attempts at setting
|
||||
|
||||
2
Makefile
2
Makefile
@@ -1,5 +1,5 @@
|
||||
# $Id$
|
||||
VERSION=0.4.2
|
||||
VERSION=0.5.0
|
||||
RELEASE?=0
|
||||
CC=gcc
|
||||
DEBUG_CFLAGS?=-g -ggdb
|
||||
|
||||
39
ldap2dns.c
39
ldap2dns.c
@@ -98,9 +98,10 @@ struct resourcerecord
|
||||
char aliasedobjectname[256];
|
||||
char macaddress[32];
|
||||
#endif
|
||||
int dnssrvpriority;
|
||||
int dnssrvweight;
|
||||
int dnssrvport;
|
||||
int srvpriority;
|
||||
int srvweight;
|
||||
int srvport;
|
||||
char txt[256];
|
||||
};
|
||||
|
||||
|
||||
@@ -593,7 +594,7 @@ static void write_rr(struct resourcerecord* rr, int ipdx, int znix)
|
||||
fprintf(namedzone, "%s.\t%s\tIN TXT\t%s.\n", rr->dnsdomainname, rr->ttl, rr->cname);
|
||||
} else if (strcasecmp(rr->type, "SRV")==0) {
|
||||
if (tinyfile) {
|
||||
fprintf(tinyfile, ":%s:33:\\%03o\\%03o\\%03o\\%03o\\%03o\\%03o", rr->dnsdomainname, rr->dnssrvpriority >> 8, rr->dnssrvpriority & 0xff, rr->dnssrvweight >> 8, rr->dnssrvweight & 0xff, rr->dnssrvport >> 8, rr->dnssrvport & 0xff);
|
||||
fprintf(tinyfile, ":%s:33:\\%03o\\%03o\\%03o\\%03o\\%03o\\%03o", rr->dnsdomainname, rr->srvpriority >> 8, rr->srvpriority & 0xff, rr->srvweight >> 8, rr->srvweight & 0xff, rr->srvport >> 8, rr->srvport & 0xff);
|
||||
tmp = strdup(rr->cname);
|
||||
while (p = strchr(tmp, '.')) {
|
||||
*p = '\0';
|
||||
@@ -605,7 +606,7 @@ static void write_rr(struct resourcerecord* rr, int ipdx, int znix)
|
||||
fprintf(tinyfile, "\\000:%s:%s:%s\n", rr->ttl, rr->timestamp, rr->location);
|
||||
}
|
||||
if (namedzone) {
|
||||
fprintf(namedzone, "%s.\t%s\tIN SRV\t%d\t%d\t%d\t%s.\n", rr->dnsdomainname, rr->ttl, rr->dnssrvpriority, rr->dnssrvweight, rr->dnssrvport, rr->cname);
|
||||
fprintf(namedzone, "%s.\t%s\tIN SRV\t%d\t%d\t%d\t%s.\n", rr->dnsdomainname, rr->ttl, rr->srvpriority, rr->srvweight, rr->srvport, rr->cname);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -686,9 +687,9 @@ static void read_resourcerecords(char* dn, int znix)
|
||||
rr.aliasedobjectname[0] = '\0';
|
||||
rr.rr[0] = '\0';
|
||||
#endif
|
||||
rr.dnssrvpriority = 0;
|
||||
rr.dnssrvweight = 0;
|
||||
rr.dnssrvport = 0;
|
||||
rr.srvpriority = 0;
|
||||
rr.srvweight = 0;
|
||||
rr.srvport = 0;
|
||||
for (attr = ldap_first_attribute(ldap_con, m, &ber); attr; attr = ldap_next_attribute(ldap_con, m, ber)) {
|
||||
int len = strlen(attr);
|
||||
struct berval** bvals;
|
||||
@@ -740,6 +741,10 @@ static void read_resourcerecords(char* dn, int znix)
|
||||
rr.cname[0] = '\0';
|
||||
else if (options.ldifname[0])
|
||||
fprintf(ldifout, "%s: %s\n", attr, bvals[0]->bv_val);
|
||||
} else if (strcasecmp(attr, "DNStxt")==0) {
|
||||
strncpy(rr.txt, bvals[0]->bv_val, sizeof(rr.txt) - 1);
|
||||
if (options.ldifname[0])
|
||||
fprintf(ldifout, "%s: %s\n", attr, bvals[0]->bv_val);
|
||||
} else if (strcasecmp(attr, "DNSttl")==0) {
|
||||
if (sscanf(bvals[0]->bv_val, "%12s", rr.ttl)!=1)
|
||||
rr.ttl[0] = '\0';
|
||||
@@ -775,20 +780,20 @@ static void read_resourcerecords(char* dn, int znix)
|
||||
}
|
||||
#endif
|
||||
else if (strcasecmp(attr, "DNSsrvpriority")==0) {
|
||||
if (!(rr.dnssrvpriority = atoi(bvals[0]->bv_val)))
|
||||
rr.dnssrvpriority = 0;
|
||||
if (!(rr.srvpriority = atoi(bvals[0]->bv_val)))
|
||||
rr.srvpriority = 0;
|
||||
else if (options.ldifname[0])
|
||||
fprintf(ldifout, "%s: %d\n", attr, rr.dnssrvpriority);
|
||||
fprintf(ldifout, "%s: %d\n", attr, rr.srvpriority);
|
||||
} else if (strcasecmp(attr, "DNSsrvweight")==0) {
|
||||
if (!(rr.dnssrvweight = atoi(bvals[0]->bv_val)))
|
||||
rr.dnssrvweight = 0;
|
||||
if (!(rr.srvweight = atoi(bvals[0]->bv_val)))
|
||||
rr.srvweight = 0;
|
||||
else if (options.ldifname[0])
|
||||
fprintf(ldifout, "%s: %d\n", attr, rr.dnssrvweight);
|
||||
fprintf(ldifout, "%s: %d\n", attr, rr.srvweight);
|
||||
} else if (strcasecmp(attr, "DNSsrvport")==0) {
|
||||
if (!(rr.dnssrvport = atoi(bvals[0]->bv_val)))
|
||||
rr.dnssrvport = 0;
|
||||
if (!(rr.srvport = atoi(bvals[0]->bv_val)))
|
||||
rr.srvport = 0;
|
||||
else if (options.ldifname[0])
|
||||
fprintf(ldifout, "%s: %d\n", attr, rr.dnssrvport);
|
||||
fprintf(ldifout, "%s: %d\n", attr, rr.srvport);
|
||||
}
|
||||
}
|
||||
ldap_value_free_len(bvals);
|
||||
|
||||
@@ -132,6 +132,12 @@ attributetype ( 1.3.6.1.4.1.7222.1.4.26
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
|
||||
SINGLE-VALUE )
|
||||
|
||||
attributetype ( 1.3.6.1.4.1.7222.1.4.27
|
||||
NAME 'dnstxt'
|
||||
EQUALITY caseIgnoreMatch
|
||||
SUBSTR caseIgnoreSubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
|
||||
|
||||
objectclass ( 1.3.6.1.4.1.7222.1.4.19
|
||||
NAME 'dnszone'
|
||||
MUST ( objectclass $ cn )
|
||||
|
||||
@@ -215,7 +215,11 @@ sub read_zone
|
||||
$attr{'DNSttl'} = $2;
|
||||
$attr{'DNSclass'} = $3;
|
||||
$attr{'DNStype'} = $4;
|
||||
if ($rr->type eq "CNAME") {
|
||||
$attr{'DNScname'} = $5;
|
||||
} elsif ($rr->type eq "TXT") {
|
||||
$attr{'DNStxt'} = $5;
|
||||
}
|
||||
add_attrs(\%attr, $zonename);
|
||||
} elsif ($rr->type eq "PTR") {
|
||||
die "Invalid PTR record for ", $rr->name, " " unless ($rr->string =~ /^([0-9.]+\.in-addr\.arpa)\.\s+(\d+)\s+(\w+)\s+(\w+)\s+([0-9a-zA-Z_.+-]+)/);
|
||||
|
||||
@@ -338,12 +338,7 @@ LINE: while(<DATA>) {
|
||||
};
|
||||
|
||||
/^'/ && do {
|
||||
# Currently unsupported
|
||||
print STDERR "Ignoring unsupported TXT record: $_\n";
|
||||
$errorrecs++;
|
||||
print $rejfh "$_\n";
|
||||
next LINE;
|
||||
# Found an MX
|
||||
# Found a TXT record
|
||||
my ($fqdn, $s, $ttl, $timestamp, $loc) = split /:/;
|
||||
$fqdn =~ s/^'//;
|
||||
if (!defined($ttl)) { $ttl = ""; }
|
||||
@@ -359,8 +354,7 @@ LINE: while(<DATA>) {
|
||||
print $outfh "cn: $id\n";
|
||||
print $outfh "dnstype: txt\n";
|
||||
print $outfh "dnsdomainname: $fqdn.\n";
|
||||
# FIXME Add TXT support to ldap2dns
|
||||
# print $outfh "dnstxt: $s\n";
|
||||
print $outfh "dnstxt: $s\n";
|
||||
if ($ttl) { print $outfh "dnsttl: $ttl\n"; }
|
||||
if ($timestamp) { print $outfh "dnstimestamp: $timestamp\n"; }
|
||||
if ($loc) { print $outfh "dnsloc: $loc\n"; }
|
||||
|
||||
Reference in New Issue
Block a user