[389-commits] ldap/servers

Noriko Hosoi nhosoi at fedoraproject.org
Tue Jan 24 22:43:53 UTC 2012


 ldap/servers/slapd/daemon.c |   35 +++++++++++++++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)

New commits:
commit 9760c1c05179f04702fcb9c97feda200fbc52ac0
Author: Noriko Hosoi <nhosoi at jiji.usersys.redhat.com>
Date:   Tue Jan 24 11:59:51 2012 -0800

    Trac Ticket #52 - FQDN set to nsslapd-listenhost
                      makes the server start fail if
                      IPv4-mapped-IPv6 address is given
    
    https://fedorahosted.org/389/ticket/52
    
    Fix description: Added a code to check netaddr is duplicated or
    not.  When the address is IPv4-mapped-IPv6, cut the IPv4 part
    out of the address and use it to compare.

diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index a6ed94f..3333e8a 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -2776,18 +2776,49 @@ slapd_listenhost2addr(const char *listenhost, PRNetAddr ***addr)
 					slapd_pr_strerror(prerr));
 				rval = -1;
 			} else {
+				char **strnetaddrs = NULL;
 				*addr = (PRNetAddr **)slapi_ch_calloc(addrcnt + 1, sizeof (PRNetAddr *));
 				iter = NULL; /* from the beginning */
 				memset( netaddr, 0, sizeof( PRNetAddr ));
 				for  ( i = 0; i < addrcnt; i++ ) {
+					char abuf[256];
+					char *abp = abuf;
 					iter = PR_EnumerateAddrInfo( iter, infop, 0, netaddr );
 					if ( NULL == iter ) {
 						break;
 					}
-					(*addr)[i] = netaddr;
-					netaddr = (PRNetAddr *)slapi_ch_calloc(1, sizeof(PRNetAddr));
+					/* 
+					 * Check if the netaddr is duplicated or not.
+					 * IPv4 mapped IPv6 could be the identical to IPv4 addr.
+					 */
+					netaddr2string(netaddr, abuf, sizeof(abuf));
+					if (PR_IsNetAddrType(netaddr, PR_IpAddrV4Mapped)) {
+						/* IPv4 mapped IPv6; redundant to IPv4;
+						 * cut the "::ffff:" part. */
+						abp = strrchr(abuf, ':');
+						if (abp) {
+							abp++;
+						} else {
+							abp = abuf;
+						}
+					}
+					if (charray_inlist(strnetaddrs, abp)) {
+						LDAPDebug2Args(LDAP_DEBUG_ANY, 
+						               "slapd_listenhost2addr: "
+						               "detected duplicated address %s "
+						               "[%s]\n", abuf, abp);
+					} else {
+						LDAPDebug1Arg(LDAP_DEBUG_TRACE,
+						              "slapd_listenhost2addr: "
+						              "registering address %s\n", abp);
+						slapi_ch_array_add(&strnetaddrs, slapi_ch_strdup(abp));
+						(*addr)[i] = netaddr;
+						netaddr = 
+						    (PRNetAddr *)slapi_ch_calloc(1, sizeof(PRNetAddr));
+					}
 				}
 				slapi_ch_free((void **)&netaddr); /* not used */
+				slapi_ch_array_free(strnetaddrs);
 			}
 			PR_FreeAddrInfo( infop );
 		} else {




More information about the 389-commits mailing list