summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRich Megginson <rmeggins@redhat.com>2010-08-12 17:51:10 -0600
committerRich Megginson <rmeggins@redhat.com>2010-08-31 10:36:01 -0600
commita4ff189106ab6f9df1823d5c45b3d8068e3665e6 (patch)
tree0a046300ab4795850288c32b17c0163e665e1695
parentbda5011116ed2afe4aee3cf4a2fb03456031a2cd (diff)
downloadds-a4ff189106ab6f9df1823d5c45b3d8068e3665e6.tar.gz
ds-a4ff189106ab6f9df1823d5c45b3d8068e3665e6.tar.xz
ds-a4ff189106ab6f9df1823d5c45b3d8068e3665e6.zip
fix the url_parse logic when looking for a missing suffix DN
The logic looking for a missing suffix DN in a parsed URL was incorrect. In addition, since passthru requires a suffix DN, pass the require_dn flag.
-rw-r--r--ldap/servers/plugins/passthru/ptconfig.c2
-rw-r--r--ldap/servers/slapd/ldaputil.c5
2 files changed, 5 insertions, 2 deletions
diff --git a/ldap/servers/plugins/passthru/ptconfig.c b/ldap/servers/plugins/passthru/ptconfig.c
index 92629d88..850bd3d9 100644
--- a/ldap/servers/plugins/passthru/ptconfig.c
+++ b/ldap/servers/plugins/passthru/ptconfig.c
@@ -238,7 +238,7 @@ passthru_config( int argc, char **argv )
/*
* parse the LDAP URL
*/
- if (( rc = slapi_ldap_url_parse( srvr->ptsrvr_url, &ludp, 0, &secure )) != 0 ) {
+ if (( rc = slapi_ldap_url_parse( srvr->ptsrvr_url, &ludp, 1, &secure )) != 0 ) {
slapi_log_error( SLAPI_LOG_FATAL, PASSTHRU_PLUGIN_SUBSYSTEM,
"unable to parse LDAP URL \"%s\" (%s)\n",
srvr->ptsrvr_url, slapi_urlparse_err2string( rc ));
diff --git a/ldap/servers/slapd/ldaputil.c b/ldap/servers/slapd/ldaputil.c
index 97162874..837f23eb 100644
--- a/ldap/servers/slapd/ldaputil.c
+++ b/ldap/servers/slapd/ldaputil.c
@@ -155,13 +155,16 @@ slapi_ldap_url_parse(const char *url, LDAPURLDesc **ludpp, int require_dn, int *
rc = ldap_url_parse_ext(url, ludpp, require_dn ? LDAP_PVT_URL_PARSE_NONE : LDAP_PVT_URL_PARSE_NOEMPTY_DN);
#else
rc = ldap_url_parse(url, ludpp);
- if (rc || !*ludpp || !require_dn) { /* failed - see if failure was due to missing dn */
+ if ((rc || !*ludpp) && !require_dn) { /* failed - see if failure was due to missing dn */
size_t len = strlen(url);
/* assume the url is just scheme://host:port[/] - add the empty string
as the DN (adding a trailing / first if needed) and try to parse
again
*/
char *urlcopy = slapi_ch_smprintf("%s%s%s", url, (url[len-1] == '/' ? "" : "/"), "");
+ if (*ludpp) {
+ ldap_free_urldesc(*ludpp); /* free the old one, if any */
+ }
rc = ldap_url_parse(urlcopy, ludpp);
slapi_ch_free_string(&urlcopy);
if (0 == rc) { /* only problem was the DN - free it */