]> git.sur5r.net Git - openldap/commitdiff
first round at eliminating dn_parent ...
authorPierangelo Masarati <ando@openldap.org>
Thu, 17 Jan 2002 19:05:21 +0000 (19:05 +0000)
committerPierangelo Masarati <ando@openldap.org>
Thu, 17 Jan 2002 19:05:21 +0000 (19:05 +0000)
servers/slapd/backend.c
servers/slapd/backglue.c
servers/slapd/dn.c

index e01ccc6dae7bd215aae54c638cfe1910b3431b96..2f183cb1b12149ca8c0ce9d5651858cdf72bad40 100644 (file)
@@ -581,13 +581,10 @@ be_issuffix(
 )
 {
        int     i;
-       size_t len = strlen(suffix);
+       struct berval   bvsuffix = { strlen( suffix ), suffix };
 
        for ( i = 0; be->be_nsuffix != NULL && be->be_nsuffix[i] != NULL; i++ ) {
-               if ( len != be->be_nsuffix[i]->bv_len ) {
-                       continue;
-               }
-               if ( strcmp( be->be_nsuffix[i]->bv_val, suffix ) == 0 ) {
+               if ( ber_bvcmp( be->be_nsuffix[i], &bvsuffix ) == 0 ) {
                        return( 1 );
                }
        }
index 59dc6ecec49494b4fd1e5e06c5e0e861fdc63195..fb85602599ea4976de6f45e19541257050c75911 100644 (file)
@@ -884,8 +884,11 @@ glue_sub_init( )
                                        gi->nodes * sizeof(gluenode));
                        }
                        gi->n[gi->nodes].be = be;
-                       gi->n[gi->nodes].pdn = dn_parent(NULL,
-                               be->be_nsuffix[0]->bv_val);
+                       if ( dnParent( be->be_nsuffix[0]->bv_val, 
+                                       (const char **)&gi->n[gi->nodes].pdn ) 
+                                       != LDAP_SUCCESS ) {
+                               return -1;
+                       }
                        gi->nodes++;
                }
                if (gi) {
@@ -893,8 +896,11 @@ glue_sub_init( )
                        gi = (glueinfo *)ch_realloc(gi,
                                sizeof(glueinfo) + gi->nodes * sizeof(gluenode));
                        gi->n[gi->nodes].be = gi->be;
-                       gi->n[gi->nodes].pdn = dn_parent(NULL,
-                               b1->be_nsuffix[0]->bv_val);
+                       if ( dnParent( b1->be_nsuffix[0]->bv_val, 
+                                       (const char **)&gi->n[gi->nodes].pdn ) 
+                                       != LDAP_SUCCESS ) {
+                               return -1;
+                       }
                        gi->nodes++;
                        b1->be_private = gi;
                        b1->bd_info = bi;
index 19960cebf4339ed1336d750f60dadd5d3af655fb..7165ff0530e19cec10be222e90d378a06db0cef2 100644 (file)
@@ -604,6 +604,9 @@ dn_normalize( char *dn )
 
 /*
  * dnParent - dn's parent, in-place
+ *
+ * note: the incoming dn is assumed to be normalized/prettyfied,
+ * so that escaped rdn/ava separators are in '\'+hexpair form
  */
 int
 dnParent( 
@@ -611,27 +614,17 @@ dnParent(
        const char      **pdn )
 {
        const char      *p;
-       int             rc;
 
-       rc = ldap_str2rdn( dn, NULL, (char **)&p,
-               LDAP_DN_FORMAT_LDAP | LDAP_DN_SKIP );
-       if ( rc != LDAP_SUCCESS ) {
-               return rc;
-       }
+       p = strchr( dn, ',' );
 
-       /* Parent is root */
-       if (*p == '\0') {
-               *pdn = "";
-               return LDAP_SUCCESS;
+       if ( p == NULL ) {
+               return LDAP_INVALID_DN_SYNTAX;
        }
 
        assert( DN_SEPARATOR( p[ 0 ] ) );
        p++;
 
-       while ( ASCII_SPACE( p[ 0 ] ) ) {
-               p++;
-       }
-
+       assert( ! ASCII_SPACE( p[ 0 ] ) );
        *pdn = p;
 
        return LDAP_SUCCESS;