Browse Source

Resolves: bug 197997
Bug Description: PTA config parsing broken
Reviewed by: nhosoi (Thanks!)
Fix Description: The problem is that it is very difficult to use a comma as a delimiter between the url and the optional settings. This is because the suffix may contain many commas. The argument string may look like this:
ldap://host1:port1 host2:port2 .... hostN:portN/a,long,suffix1:a,long,suffix2;....;a,long,suffixN optional,numeric,settings
The ldap url may not contain any spaces after the hostlist - the suffixlist part must contain only url encoded spaces if the suffix actually has a space in it. So the solution is to use a space to separate the url from the options list. The parser looks for the first space after the last "/" in the url. This should be ok - at least it will not break the most common use of pta, which is to allow the config DS admin user to log into servers that do not have the o=NetscapeRoot. setup will use something like this:
ldap://configdshost:configdsport/o=NetscapeRoot
with not optional settings - this should parse just fine with the new code.
Platforms tested: RHEL5 x86_64
Flag Day: no
Doc impact: no
QA impact: should be covered by regular nightly and manual testing
New Tests integrated into TET: none

Rich Megginson 18 years ago
parent
commit
b0b81ec8ce
1 changed files with 21 additions and 2 deletions
  1. 21 2
      ldap/servers/plugins/passthru/ptconfig.c

+ 21 - 2
ldap/servers/plugins/passthru/ptconfig.c

@@ -131,10 +131,29 @@ passthru_config( int argc, char **argv )
      */
     prevsrvr = NULL;
     for ( i = 0; i < argc; ++i ) {
+	char *p = NULL;
 	srvr = (PassThruServer *)slapi_ch_calloc( 1, sizeof( PassThruServer ));
 	srvr->ptsrvr_url = slapi_ch_strdup( argv[i] );
 
-	if (( p = strchr( srvr->ptsrvr_url, ',' )) == NULL ) {
+	/* since the ldap url may contain both spaces (to delimit multiple hosts)
+	   and commas (in suffixes), we have to search for the first space
+	   after the last /, then look for any commas after that
+	   This assumes the ldap url looks like this:
+	   ldap(s)://host:port host:port .... host:port/suffixes
+	   That is, it assumes there is always a trailing slash on the ldapurl
+	   and that the url does not look like this: ldap://host
+	   also assumes suffixes do not have any / in them
+	*/
+	if (p = strrchr(srvr->ptsrvr_url, '/')) { /* look for last / */
+	    p = strchr(p, ' '); /* look for first space after last / */
+	    if (p) {
+		if (!strchr(p, ',')) { /* no comma */
+		    p = NULL; /* just use defaults */
+		}
+	    }
+	}
+
+	if (!p) {
 	    /*
 	     * use defaults for maxconnections, maxconcurrency, timeout,
 	     * LDAP version, and connlifetime.
@@ -152,7 +171,7 @@ passthru_config( int argc, char **argv )
 	     *     maxconnections,maxconcurrency,timeout,ldapversion
 	     * OR  maxconnections,maxconcurrency,timeout,ldapversion,lifetime
 	     */
-	    *p++ = '\0';
+	    *p++ = '\0'; /* p points at space preceding optional arguments */
 	    rc = sscanf( p, "%d,%d,%d,%d,%d", &srvr->ptsrvr_maxconnections,
 		    &srvr->ptsrvr_maxconcurrency, &tosecs,
 		    &srvr->ptsrvr_ldapversion, &srvr->ptsrvr_connlifetime );