mirror of
https://github.com/bklang/ldap2dns.git
synced 2025-10-27 06:14:15 -04:00
Removing deprecated ldan2dns-loccode.patch as it has already been applied.
Added support for dnslocation to dns.schema-2.2 (already in dns.schema-2.0) git-svn-id: https://svn.alkaloid.net/gpl/ldap2dns/trunk@121 06cd67b6-e706-0410-b29e-9de616bca6e9
This commit is contained in:
@@ -126,12 +126,20 @@ attributetype ( 1.3.6.1.4.1.7222.1.4.25
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
|
||||
SINGLE-VALUE )
|
||||
|
||||
attributetype ( 1.3.6.1.4.1.7222.1.4.23
|
||||
NAME 'dnslocation'
|
||||
EQUALITY caseExactIA5Match
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{2}
|
||||
SINGLE-VALUE )
|
||||
|
||||
|
||||
objectclass ( 1.3.6.1.4.1.7222.1.4.19
|
||||
NAME 'dnszone'
|
||||
MUST ( objectclass $ cn )
|
||||
MAY ( dnszonename $ dnsserial $ dnsrefresh $ dnsretry $ dnsexpire
|
||||
$ dnsminimum $ dnsadminmailbox $ dnszonemaster $ dnstype $ dnsclass
|
||||
$ dnsttl $ dnstimestamp $ owner $ NIChandle $ TIShandle ) )
|
||||
$ dnsttl $ dnstimestamp $ owner $ NIChandle $ TIShandle
|
||||
$ dnslocation ) )
|
||||
|
||||
objectclass ( 1.3.6.1.4.1.7222.1.4.20
|
||||
NAME 'dnsrrset'
|
||||
@@ -143,3 +151,7 @@ objectclass ( 1.3.6.1.4.1.7222.1.4.20
|
||||
|
||||
|
||||
|
||||
objectclass ( 1.3.6.1.4.1.7222.1.4.24
|
||||
NAME 'dnsloccodes'
|
||||
MUST ( objectclass $ dnslocation )
|
||||
MAY ( dnsipaddr $ uid $ description ) )
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
diff -bu ldap2dns-0.3.1-p1/dns.schema ldap2dns-0.3.1/dns.schema
|
||||
--- ldap2dns-0.3.1-p1/dns.schema 2002-08-13 14:23:53.000000000 +0200
|
||||
+++ ldap2dns-0.3.1/dns.schema 2002-09-02 10:10:32.000000000 +0200
|
||||
diff -bu ldap2dns-0.3.1-p1/dns.schema-2.2 ldap2dns-0.3.1/dns.schema-2.2
|
||||
--- ldap2dns-0.3.1-p1/dns.schema-2.2 2002-08-13 14:23:53.000000000 +0200
|
||||
+++ ldap2dns-0.3.1/dns.schema-2.2 2002-09-02 10:10:32.000000000 +0200
|
||||
@@ -99,12 +99,18 @@
|
||||
SUBSTR caseIgnoreSubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{16} )
|
||||
@@ -29,271 +29,3 @@ diff -bu ldap2dns-0.3.1-p1/dns.schema ldap2dns-0.3.1/dns.schema
|
||||
+ NAME 'dnsloccodes'
|
||||
+ MUST ( objectclass $ dnslocation )
|
||||
+ MAY ( dnsipaddr $ uid $ description ) )
|
||||
diff -bu ldap2dns-0.3.1-p1/ldap2dns.c ldap2dns-0.3.1/ldap2dns.c
|
||||
--- ldap2dns-0.3.1-p1/ldap2dns.c 2002-09-02 10:45:43.000000000 +0200
|
||||
+++ ldap2dns-0.3.1/ldap2dns.c 2002-09-02 10:04:50.000000000 +0200
|
||||
@@ -58,8 +58,15 @@
|
||||
char minimum[12];
|
||||
char ttl[12];
|
||||
char timestamp[20];
|
||||
+ char location[2];
|
||||
} zone;
|
||||
|
||||
+static struct
|
||||
+{
|
||||
+ char locname[3];
|
||||
+ char member[256][16];
|
||||
+} loc_rec;
|
||||
+
|
||||
struct resourcerecord
|
||||
{
|
||||
char cn[64];
|
||||
@@ -72,6 +79,7 @@
|
||||
char ttl[12];
|
||||
char timestamp[20];
|
||||
char preference[12];
|
||||
+ char location[2];
|
||||
#if defined DRAFT_RFC
|
||||
char rr[1024];
|
||||
char aliasedobjectname[256];
|
||||
@@ -360,19 +368,19 @@
|
||||
if (tinyfile) {
|
||||
if (znix==0) {
|
||||
if (ipdx<=0 && rr->cipaddr[0]) {
|
||||
- fprintf(tinyfile, "&%s::%s:%s:%s\n", rr->dnsdomainname, rr->cname, rr->ttl, rr->timestamp);
|
||||
+ fprintf(tinyfile, "&%s::%s:%s:%s:%s\n", rr->dnsdomainname, rr->cname, rr->ttl, rr->timestamp, rr->location);
|
||||
if (rr->cname[0])
|
||||
- fprintf(tinyfile, "=%s:%s:%s:%s\n", rr->cname, rr->cipaddr, rr->ttl, rr->timestamp);
|
||||
+ fprintf(tinyfile, "=%s:%s:%s:%s:%s\n", rr->cname, rr->cipaddr, rr->ttl, rr->timestamp, rr->location);
|
||||
if (ipdx==0)
|
||||
- fprintf(tinyfile, "+%s:%s:%s:%s\n", rr->cname, rr->ipaddr[0], rr->ttl, rr->timestamp);
|
||||
+ fprintf(tinyfile, "+%s:%s:%s:%s:%s\n", rr->cname, rr->ipaddr[0], rr->ttl, rr->timestamp, rr->location);
|
||||
} else if (ipdx<0)
|
||||
- fprintf(tinyfile, "&%s::%s:%s:%s\n", rr->dnsdomainname, rr->cname, rr->ttl, rr->timestamp);
|
||||
+ fprintf(tinyfile, "&%s::%s:%s:%s:%s\n", rr->dnsdomainname, rr->cname, rr->ttl, rr->timestamp, rr->location);
|
||||
else if (ipdx==0)
|
||||
- fprintf(tinyfile, "&%s:%s:%s:%s:%s\n", rr->dnsdomainname, rr->ipaddr[0], rr->cname, rr->ttl, rr->timestamp);
|
||||
+ fprintf(tinyfile, "&%s:%s:%s:%s:%s:%s\n", rr->dnsdomainname, rr->ipaddr[0], rr->cname, rr->ttl, rr->timestamp, rr->location);
|
||||
else if (ipdx>0 && rr->cname[0])
|
||||
- fprintf(tinyfile, "+%s:%s:%s:%s\n", rr->cname, rr->ipaddr[ipdx], rr->ttl, rr->timestamp);
|
||||
+ fprintf(tinyfile, "+%s:%s:%s:%s:%s\n", rr->cname, rr->ipaddr[ipdx], rr->ttl, rr->timestamp, rr->location);
|
||||
} else if (ipdx<=0) {
|
||||
- fprintf(tinyfile, "&%s::%s:%s:%s\n", rr->dnsdomainname, rr->cname, rr->ttl, rr->timestamp);
|
||||
+ fprintf(tinyfile, "&%s::%s:%s:%s:%s\n", rr->dnsdomainname, rr->cname, rr->ttl, rr->timestamp, rr->location);
|
||||
}
|
||||
}
|
||||
if (namedzone) {
|
||||
@@ -384,19 +392,19 @@
|
||||
if (tinyfile) {
|
||||
if (znix==0) {
|
||||
if (ipdx<=0 && rr->cipaddr[0]) {
|
||||
- fprintf(tinyfile, "@%s::%s:%s:%s:%s\n", rr->dnsdomainname, rr->cname, rr->preference, rr->ttl, rr->timestamp);
|
||||
+ fprintf(tinyfile, "@%s::%s:%s:%s:%s:%s\n", rr->dnsdomainname, rr->cname, rr->preference, rr->ttl, rr->timestamp, rr->location);
|
||||
if (rr->cname[0])
|
||||
- fprintf(tinyfile, "=%s:%s:%s:%s\n", rr->cname, rr->cipaddr, rr->ttl, rr->timestamp);
|
||||
+ fprintf(tinyfile, "=%s:%s:%s:%s:%s\n", rr->cname, rr->cipaddr, rr->ttl, rr->timestamp, rr->location);
|
||||
if (ipdx==0)
|
||||
- fprintf(tinyfile, "+%s:%s:%s:%s\n", rr->cname, rr->ipaddr[0], rr->ttl, rr->timestamp);
|
||||
+ fprintf(tinyfile, "+%s:%s:%s:%s:%s\n", rr->cname, rr->ipaddr[0], rr->ttl, rr->timestamp, rr->location);
|
||||
} else if (ipdx<0)
|
||||
- fprintf(tinyfile, "@%s::%s:%s:%s:%s\n", rr->dnsdomainname, rr->cname, rr->preference, rr->ttl, rr->timestamp);
|
||||
+ fprintf(tinyfile, "@%s::%s:%s:%s:%s:%s\n", rr->dnsdomainname, rr->cname, rr->preference, rr->ttl, rr->timestamp, rr->location);
|
||||
else if (ipdx==0)
|
||||
- fprintf(tinyfile, "@%s:%s:%s:%s:%s:%s\n", rr->dnsdomainname, rr->ipaddr[0], rr->cname, rr->preference, rr->ttl, rr->timestamp);
|
||||
+ fprintf(tinyfile, "@%s:%s:%s:%s:%s:%s:%s\n", rr->dnsdomainname, rr->ipaddr[0], rr->cname, rr->preference, rr->ttl, rr->timestamp, rr->location);
|
||||
else if (ipdx>0 && rr->cname[0])
|
||||
- fprintf(tinyfile, "+%s:%s:%s:%s\n", rr->cname, rr->ipaddr[ipdx], rr->ttl, rr->timestamp);
|
||||
+ fprintf(tinyfile, "+%s:%s:%s:%s:%s\n", rr->cname, rr->ipaddr[ipdx], rr->ttl, rr->timestamp, rr->location);
|
||||
} else if (ipdx<=0) {
|
||||
- fprintf(tinyfile, "@%s::%s:%s:%s:%s\n", rr->dnsdomainname, rr->cname, rr->preference, rr->ttl, rr->timestamp);
|
||||
+ fprintf(tinyfile, "@%s::%s:%s:%s:%s:%s\n", rr->dnsdomainname, rr->cname, rr->preference, rr->ttl, rr->timestamp, rr->location);
|
||||
}
|
||||
}
|
||||
if (namedzone) {
|
||||
@@ -407,9 +415,9 @@
|
||||
} else if ( strcasecmp(rr->type, "A")==0) {
|
||||
if (tinyfile) {
|
||||
if (ipdx<=0 && rr->cipaddr[0])
|
||||
- fprintf(tinyfile, "%s%s:%s:%s:%s\n", (znix==0 ? "=" : "+"), rr->dnsdomainname, rr->cipaddr, rr->ttl, rr->timestamp);
|
||||
+ fprintf(tinyfile, "%s%s:%s:%s:%s:%s\n", (znix==0 ? "=" : "+"), rr->dnsdomainname, rr->cipaddr, rr->ttl, rr->timestamp, rr->location);
|
||||
if (ipdx>=0)
|
||||
- fprintf(tinyfile, "+%s:%s:%s:%s\n", rr->dnsdomainname, rr->ipaddr[ipdx], rr->ttl, rr->timestamp);
|
||||
+ fprintf(tinyfile, "+%s:%s:%s:%s:%s\n", rr->dnsdomainname, rr->ipaddr[ipdx], rr->ttl, rr->timestamp, rr->location);
|
||||
}
|
||||
if (namedzone) {
|
||||
if (ipdx<=0 && rr->cipaddr[0])
|
||||
@@ -431,17 +439,17 @@
|
||||
strcpy(buf, rr->dnsdomainname);
|
||||
}
|
||||
if (tinyfile)
|
||||
- fprintf(tinyfile, "^%s:%s:%s:%s\n", buf, rr->cname, rr->ttl, rr->timestamp);
|
||||
+ fprintf(tinyfile, "^%s:%s:%s:%s:%s\n", buf, rr->cname, rr->ttl, rr->timestamp, rr->location);
|
||||
if (namedzone)
|
||||
fprintf(namedzone, "%s.\tIN PTR\t%s.\n", buf, rr->cname);
|
||||
} else if (strcasecmp(rr->type, "CNAME")==0) {
|
||||
if (tinyfile)
|
||||
- fprintf(tinyfile, "C%s:%s:%s:%s\n", rr->dnsdomainname, rr->cname, rr->ttl, rr->timestamp);
|
||||
+ fprintf(tinyfile, "C%s:%s:%s:%s:%s\n", rr->dnsdomainname, rr->cname, rr->ttl, rr->timestamp, rr->location);
|
||||
if (namedzone)
|
||||
fprintf(namedzone, "%s.\tIN CNAME\t%s.\n", rr->dnsdomainname, rr->cname);
|
||||
} else if (strcasecmp(rr->type, "TXT")==0) {
|
||||
if (tinyfile)
|
||||
- fprintf(tinyfile, "'%s:%s:%s:%s\n", rr->dnsdomainname, rr->cname, rr->ttl, rr->timestamp);
|
||||
+ fprintf(tinyfile, "'%s:%s:%s:%s:%s\n", rr->dnsdomainname, rr->cname, rr->ttl, rr->timestamp, rr->location);
|
||||
if (namedzone)
|
||||
fprintf(namedzone, "%s.\tIN TXT\t%s.\n", rr->dnsdomainname, rr->cname);
|
||||
}
|
||||
@@ -515,6 +523,7 @@
|
||||
rr.ttl[0] = '\0';
|
||||
rr.timestamp[0] = '\0';
|
||||
rr.preference[0] = '\0';
|
||||
+ rr.location[0] = '\0';
|
||||
#if defined DRAFT_RFC
|
||||
rr.aliasedobjectname[0] = '\0';
|
||||
rr.rr[0] = '\0';
|
||||
@@ -585,6 +594,11 @@
|
||||
rr.preference[0] = '\0';
|
||||
else if (options.ldifname[0])
|
||||
fprintf(ldifout, "%s: %s\n", attr, bvals[0]->bv_val);
|
||||
+ } else if (strcasecmp(attr, "DNSlocation")==0) {
|
||||
+ if (sscanf(bvals[0]->bv_val, "%s", rr.location)!=1)
|
||||
+ rr.location[0] = '\0';
|
||||
+ else if (options.ldifname[0])
|
||||
+ fprintf(ldifout, "%s: %s\n", attr, bvals[0]->bv_val);
|
||||
}
|
||||
#if defined DRAFT_RFC
|
||||
else if (strcasecmp(attr, "DNSrr")==0) {
|
||||
@@ -632,10 +646,10 @@
|
||||
char soa[20];
|
||||
|
||||
if (tinyfile) {
|
||||
- fprintf(tinyfile, "Z%s:%s:%s:%s:%s:%s:%s:%s:%s:%s\n",
|
||||
+ fprintf(tinyfile, "Z%s:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s\n",
|
||||
zone.domainname, zone.zonemaster, zone.adminmailbox,
|
||||
zone.serial, zone.refresh, zone.retry, zone.expire,
|
||||
- zone.minimum, zone.ttl, zone.timestamp);
|
||||
+ zone.minimum, zone.ttl, zone.timestamp, zone.location);
|
||||
}
|
||||
if (namedmaster) {
|
||||
fprintf(namedmaster, "zone \"%s\" %s {\n\ttype master;\n\tfile \"%s.db\";\n};\n",
|
||||
@@ -717,6 +731,7 @@
|
||||
zone.minimum[0] = '\0';
|
||||
zone.ttl[0] = '\0';
|
||||
zone.timestamp[0] = '\0';
|
||||
+ zone.location[0] = '\0';
|
||||
dn = ldap_get_dn(ldap_con, m);
|
||||
if (options.ldifname[0])
|
||||
fprintf(ldifout, "dn: %s\n", dn);
|
||||
@@ -782,6 +797,11 @@
|
||||
zone.timestamp[0] = '\0';
|
||||
else if (options.ldifname[0])
|
||||
fprintf(ldifout, "%s: %s\n", attr, zone.timestamp);
|
||||
+ } else if (strcasecmp(attr, "DNSlocation")==0) {
|
||||
+ if (sscanf(bvals[0]->bv_val, "%2s", zone.location)!=1)
|
||||
+ zone.location[0] = '\0';
|
||||
+ else if (options.ldifname[0])
|
||||
+ fprintf(ldifout, "%s: %s\n", attr, zone.location);
|
||||
}
|
||||
}
|
||||
ldap_value_free_len(bvals);
|
||||
@@ -815,6 +835,91 @@
|
||||
ldap_msgfree(res);
|
||||
}
|
||||
|
||||
+static void write_loccode(int lidx)
|
||||
+{
|
||||
+ if (tinyfile) {
|
||||
+ fprintf(tinyfile, "%%%s:%s\n", loc_rec.locname, loc_rec.member[lidx]);
|
||||
+ }
|
||||
+ if (options.ldifname[0])
|
||||
+ fprintf(ldifout, "\n");
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static void read_loccodes(void)
|
||||
+{
|
||||
+ LDAPMessage* res = NULL;
|
||||
+ LDAPMessage* m;
|
||||
+ int ldaperr;
|
||||
+
|
||||
+ if (tinyfile)
|
||||
+ fprintf(tinyfile, "# Location Codes (if any) - generated by ldap2dns - DO NOT EDIT!\n");
|
||||
+
|
||||
+ if ( (ldaperr = ldap_search_s(ldap_con, options.searchbase[0] ? options.searchbase : NULL,
|
||||
+ LDAP_SCOPE_SUBTREE,
|
||||
+ "objectclass=DNSloccodes",
|
||||
+ NULL,
|
||||
+ 0,
|
||||
+ &res)
|
||||
+ )!=LDAP_SUCCESS )
|
||||
+ die_ldap(ldaperr);
|
||||
+ for (m = ldap_first_entry(ldap_con, res); m; m = ldap_next_entry(ldap_con, m)) {
|
||||
+ BerElement* ber = NULL;
|
||||
+ char* attr;
|
||||
+ char* dn = ldap_get_dn(ldap_con, m);
|
||||
+ int i, locmembers = 0;
|
||||
+ char l_members[256][15];
|
||||
+ //char loc[256][64];
|
||||
+ char loc[2];
|
||||
+ char ldif0;
|
||||
+
|
||||
+ loc_rec.locname[0] = '\0';
|
||||
+ if (options.ldifname[0])
|
||||
+ fprintf(ldifout, "dn: %s\n", dn);
|
||||
+ for (attr = ldap_first_attribute(ldap_con, m, &ber); attr; attr = ldap_next_attribute(ldap_con, m, ber)) {
|
||||
+ struct berval** bvals = ldap_get_values_len(ldap_con, m, attr);
|
||||
+ if (bvals!=NULL) {
|
||||
+ if (bvals[0] && bvals[0]->bv_len>0) {
|
||||
+ if (strcasecmp(attr, "objectclass")==0
|
||||
+ || strcasecmp(attr, "cn")==0) {
|
||||
+ if (options.ldifname[0])
|
||||
+ fprintf(ldifout, "%s: %s\n", attr, bvals[0]->bv_val);
|
||||
+ } else if (strcasecmp(attr, "DNSlocation")==0) {
|
||||
+ if (sscanf(bvals[0]->bv_val, "%2s", loc_rec.locname)!=1)
|
||||
+ loc_rec.locname[0] = '\0';
|
||||
+ else if (options.ldifname[0])
|
||||
+ fprintf(ldifout, "%s: %s\n", attr, loc_rec.locname);
|
||||
+ } else if (strcasecmp(attr, "DNSipaddr")==0) {
|
||||
+ for (locmembers = 0; bvals[locmembers] && locmembers<256; locmembers++) {
|
||||
+ if (sscanf(bvals[locmembers]->bv_val, "%15s", loc_rec.member[locmembers])!=1)
|
||||
+ loc_rec.member[locmembers][0] = '\0';
|
||||
+ else if (options.ldifname[0])
|
||||
+ fprintf(ldifout, "%s: %s\n", attr, loc_rec.member[locmembers]);
|
||||
+ }
|
||||
+ } else {
|
||||
+ if (options.ldifname[0])
|
||||
+ fprintf(ldifout, "%s: %s\n", attr, bvals[0]->bv_val);
|
||||
+ }
|
||||
+ }
|
||||
+ ldap_value_free_len(bvals);
|
||||
+ }
|
||||
+ }
|
||||
+ ldif0 = options.ldifname[0];
|
||||
+ if (options.verbose&1)
|
||||
+ printf("locationcodename: %s (%d members)\n", loc_rec.locname, locmembers);
|
||||
+ for (i = 0; i<locmembers; i++) {
|
||||
+ if (i>0)
|
||||
+ options.ldifname[0] = '\0';
|
||||
+ write_loccode(i);
|
||||
+ if (options.ldifname[0])
|
||||
+ fprintf(ldifout, "\n");
|
||||
+ }
|
||||
+ options.ldifname[0] = ldif0;
|
||||
+ free(dn);
|
||||
+ }
|
||||
+ ldap_msgfree(res);
|
||||
+}
|
||||
+
|
||||
+
|
||||
static int connect()
|
||||
{
|
||||
int i, rc, version;
|
||||
@@ -906,6 +1011,7 @@
|
||||
die_exit("Unable to open file 'data.temp' for writing");
|
||||
if ( options.output&OUTPUT_DB && !(namedmaster = fopen("named.zones", "w")) )
|
||||
die_exit("Unable to open file 'named.zones' for writing");
|
||||
+ read_loccodes();
|
||||
read_dnszones();
|
||||
if (namedmaster)
|
||||
fclose(namedmaster);
|
||||
Gemeinsame Unterverzeichnisse: ldap2dns-0.3.1-p1/webadmin und ldap2dns-0.3.1/webadmin.
|
||||
|
||||
Reference in New Issue
Block a user