]> git.sur5r.net Git - openldap/commitdiff
import fix of URI test (ITS#3399)
authorPierangelo Masarati <ando@openldap.org>
Wed, 17 Nov 2004 21:42:59 +0000 (21:42 +0000)
committerPierangelo Masarati <ando@openldap.org>
Wed, 17 Nov 2004 21:42:59 +0000 (21:42 +0000)
CHANGES
servers/slapd/back-ldap/config.c

diff --git a/CHANGES b/CHANGES
index 85eb4d25fab20bc8ec4177e686faec8b22f5bda7..6b47d4d6c3287ffaf52f963cafcbbea033024fc8 100644 (file)
--- 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
 
index 665c26ba109b5072e392916c389b791af790186d..ecdb83a956a736d0a415a495dc7e85a5514729b9 100644 (file)
@@ -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 <uri>\" line\n",
-                               fname, lineno, argv[ 1 ] );
+                                       "unable to parse uri \"%s\" "
+                                       "in \"uri <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 <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 <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 <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 ) {