From: Pierangelo Masarati Date: Wed, 17 Nov 2004 21:42:59 +0000 (+0000) Subject: import fix of URI test (ITS#3399) X-Git-Tag: OPENLDAP_REL_ENG_2_2_19~13 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=10604669cf79d33614afa7b1bc45acf4e81fff8c;p=openldap import fix of URI test (ITS#3399) --- diff --git a/CHANGES b/CHANGES index 85eb4d25fa..6b47d4d6c3 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,7 @@ OpenLDAP 2.2 Change Log OpenLDAP 2.2.19 Engineering Fixed slapd check for mandatory filter in authz-regexp URI (ITS#3396) + Fixed back-ldap malformed URI check for multiple URIs (ITS#3399) Build Environment Updated BDB mismatch messages diff --git a/servers/slapd/back-ldap/config.c b/servers/slapd/back-ldap/config.c index 665c26ba10..ecdb83a956 100644 --- a/servers/slapd/back-ldap/config.c +++ b/servers/slapd/back-ldap/config.c @@ -31,6 +31,9 @@ #include "slap.h" #include "back-ldap.h" #include "lutil.h" +#undef ldap_debug +/* for advanced URL parsing */ +#include "../../../libraries/libldap/ldap-int.h" static SLAP_EXTOP_MAIN_FN ldap_back_exop_whoami; @@ -70,7 +73,8 @@ ldap_back_db_config( /* URI of server to query (preferred over "server" directive) */ } else if ( strcasecmp( argv[0], "uri" ) == 0 ) { - LDAPURLDesc tmplud; + LDAPURLDesc *tmpludp; + int urlrc, i; if (argc != 2) { fprintf( stderr, "%s: line %d: " @@ -86,47 +90,71 @@ ldap_back_db_config( ldap_free_urldesc( li->lud ); } - if ( ldap_url_parse( argv[ 1 ], &li->lud ) != LDAP_URL_SUCCESS ) { + urlrc = ldap_url_parselist( &li->lud, argv[ 1 ] ); + if ( urlrc != LDAP_URL_SUCCESS ) { + char *why; + + switch ( urlrc ) { + case LDAP_URL_ERR_MEM: + why = "no memory"; + break; + case LDAP_URL_ERR_PARAM: + why = "parameter is bad"; + break; + case LDAP_URL_ERR_BADSCHEME: + why = "URL doesn't begin with \"[c]ldap[si]://\""; + break; + case LDAP_URL_ERR_BADENCLOSURE: + why = "URL is missing trailing \">\""; + break; + case LDAP_URL_ERR_BADURL: + why = "URL is bad"; + case LDAP_URL_ERR_BADHOST: + why = "host/port is bad"; + break; + case LDAP_URL_ERR_BADATTRS: + why = "bad (or missing) attributes"; + break; + case LDAP_URL_ERR_BADSCOPE: + why = "scope string is invalid (or missing)"; + break; + case LDAP_URL_ERR_BADFILTER: + why = "bad or missing filter"; + break; + case LDAP_URL_ERR_BADEXTS: + why = "bad or missing extensions"; + break; + default: + why = "unknown reason"; + break; + } fprintf( stderr, "%s: line %d: " - "unable to parse uri \"%s\" " - "in \"uri \" line\n", - fname, lineno, argv[ 1 ] ); + "unable to parse uri \"%s\" " + "in \"uri \" line: %s\n", + fname, lineno, argv[ 1 ], why ); return 1; } - if ( ( li->lud->lud_dn != NULL && li->lud->lud_dn[0] != '\0' ) - || li->lud->lud_attrs != NULL - || li->lud->lud_filter != NULL - || li->lud->lud_exts != NULL ) + for ( i = 0, tmpludp = li->lud; + tmpludp; + i++, tmpludp = tmpludp->lud_next ) { - fprintf( stderr, "%s: line %d: " - "warning, only protocol, " - "host and port allowed " - "in \"uri \" line\n", - fname, lineno ); + if ( ( tmpludp->lud_dn != NULL + && tmpludp->lud_dn[0] != '\0' ) + || tmpludp->lud_attrs != NULL + || tmpludp->lud_filter != NULL + || tmpludp->lud_exts != NULL ) + { + fprintf( stderr, "%s: line %d: " + "warning, only protocol, " + "host and port allowed " + "in \"uri \" statement " + "for uri #%d of \"%s\"\n", + fname, lineno, i, argv[1] ); + } } -#if 0 - tmplud = *lud; - tmplud.lud_dn = ""; - tmplud.lud_attrs = NULL; - tmplud.lud_filter = NULL; - if ( !ldap_is_ldapi_url( argv[ 1 ] ) ) { - tmplud.lud_exts = NULL; - tmplud.lud_crit_exts = 0; - } - - li->url = ldap_url_desc2str( &tmplud ); - if ( li->url == NULL ) { - fprintf( stderr, "%s: line %d: " - "unable to rebuild uri \"%s\" " - "in \"uri \" line\n", - fname, lineno, argv[ 1 ] ); - return 1; - } -#else li->url = ch_strdup( argv[ 1 ] ); -#endif /* name to use for ldap_back_group */ } else if ( strcasecmp( argv[0], "binddn" ) == 0 ) {