• Willkommen im Linux Club - dem deutschsprachigen Supportforum für GNU/Linux. Registriere dich kostenlos, um alle Inhalte zu sehen und Fragen zu stellen.

[gelöst] wildcard's bei DNS mit LDAP Backend

Mystefix

Newbie
Hallo zusammen,

habe durch das HOWTO http://www.linux-club.de/ftopic35142.html
den DNS mit LDAP Backend zum Laufen gebracht, jedoch gibt es Probleme mit Einträgen, die z.B so aussehen

dn: relativeDomainName=*.abc,ou=xyz.org,ou=forward,ou=zone.master,
ou=dns,dc=xyz,dc=org
aRecord: 10.0.0.245
dNSClass: IN
dNSTTL: 3600
objectClass: dNSZone
objectClass: top
zoneName: xyz.org
relativeDomainName: *.abc

Wenn der DNS mit normaler Konfigurationsdatei läuft funktioniert dieser Eintrag, jedoch nicht in Verbindung mit LDAP.

Könnte dies damit zusammenhängen, dass * bei LDAP ebenfalls als Wildcard verwendet wird ? Gibt es vielleicht eine Möglichkeit dieses zu "escapen", wie z.B unter Linux // oder \/

Aso die eingesetzen Versionen:
CentOS 5
bind-sdb-9.3.3-7
openldap-servers-2.3.27-5

Gruß

mystefix
 
OP
M

Mystefix

Newbie
Hallo zusammen,

nachdem ich mich mal bei der Mailing-liste von bind-sdb angemeldet habe, hat mir Jan-Piet Mens sehr schnell einen Patch für bind-sdb zur Verfügung gestellt durch diesen der bind-sdb mit Wildcards-Einträgen im LDAP zurecht kommt.

Somit habe ich den bind neu kompiliert und vorher die ldapdb.c gepatcht.

Im Verzeichnis wo die ldapdb.c liegt dann folgenden Befehl ausführen:

patch -p0 < "name des Patchfiles"

Hier ist der Patch mit dem die ldapdb.c gepatcht werden muss:

Code:
*** ldapdb.c.orig	Sun May  1 13:35:03 2005
--- ldapdb.c	Wed Oct 24 12:40:50 2007
***************
*** 274,279 ****
--- 274,288 ----
  	fltr = data->filterone;
      }
  
+     /* debug when starting `named -g -d 1 ...' on console */
+     isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER,
+     		ISC_LOG_DEBUG(1),
+ 		"base=%s, zone=[%s], name=[%s], filter=[%s]\n", 
+ 			(data->base) ? data->base : "<NULL>",
+ 			(zone) ? zone : "<NULL>",
+ 			(name) ? name : "<NULL>",
+ 			(fltr) ? fltr : "<NULL>");
+ 
      msgid = ldap_search(*ldp, data->base, data->scope, fltr, data->attrs, 0);
      if (msgid == -1) {
  	ldapdb_bind(data, ldp);
***************
*** 341,347 ****
  			result = dns_sdb_putrr(retdata, type, ttl, vals[i]);
  		    } else {
  			for (j = 0; names[j] != NULL; j++) {
! 			    result = dns_sdb_putnamedrr(retdata, names[j], type, ttl, vals[i]);
  			    if (result != ISC_R_SUCCESS)
  				break;
  			}
--- 350,360 ----
  			result = dns_sdb_putrr(retdata, type, ttl, vals[i]);
  		    } else {
  			for (j = 0; names[j] != NULL; j++) {
! 			    if (names[j][0] == '~') {
! 			    	names[j][0] = '*';
! 				}
! 
! 				result = dns_sdb_putnamedrr(retdata, names[j], type, ttl, vals[i]);
  			    if (result != ISC_R_SUCCESS)
  				break;
  			}
***************
*** 388,394 ****
  static isc_result_t
  ldapdb_lookup(const char *zone, const char *name, void *dbdata,
  	      dns_sdblookup_t *lookup) {
!     return ldapdb_search(zone, name, dbdata, lookup);
  }
  
  static isc_result_t
--- 401,439 ----
  static isc_result_t
  ldapdb_lookup(const char *zone, const char *name, void *dbdata,
  	      dns_sdblookup_t *lookup) {
! 
!     isc_result_t result;
!     char *tname = strdup(name);
! 
!     /* JPM */
! 	/* if no result, attempt wildcard by searching for relativeDomainname=~
! 	 * (tilde) */
!     result = ldapdb_search(zone, name, dbdata, lookup);
!     if ((result != ISC_R_SUCCESS) &&
! 		(name != NULL) &&
! 		(strcmp(name, "@") != 0)) {
! 			char *np;
! 			
! 			/* break up `name' into labels and search for ~.label from left */
! 			if ((np = strpbrk(name, ".")) == NULL)
! 				np = "";		/* empty label, but not null */
! 			for (; np != NULL; np = strpbrk(np + 1, ".")) {
! 				sprintf(tname, "~%s", np);
! 				result = ldapdb_search(zone, tname, dbdata, lookup);
! 				if (result == ISC_R_SUCCESS) {
! 					break;
! 				}
! 			}
! 			if (result != ISC_R_SUCCESS) {
! 				/* last try; wild at apex */
! 				result = ldapdb_search(zone, "~", dbdata, lookup);
! 			}
! 			
! 
!     }
!     
!     free(tname);
!     return (result);
  }
  
  static isc_result_t

Danke nochmal an den Author des Patches :)
 
Oben