]> git.sur5r.net Git - openldap/commitdiff
Misc cleanup and dn_normalize() zapping
authorKurt Zeilenga <kurt@openldap.org>
Wed, 26 Dec 2001 16:42:35 +0000 (16:42 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Wed, 26 Dec 2001 16:42:35 +0000 (16:42 +0000)
Fix nameAndOptionalIdentifer syntax.

servers/slapd/acl.c
servers/slapd/back-passwd/search.c
servers/slapd/configinfo.c
servers/slapd/entry.c
servers/slapd/limits.c
servers/slapd/proto-slap.h
servers/slapd/result.c
servers/slapd/root_dse.c
servers/slapd/schema.c
servers/slapd/schema_init.c

index 4d48065e0df2b75d05669fb272957b5b0cfd7f7a..912279a1112676bf9e3e3ae8eb862067e8b53b67 100644 (file)
@@ -1674,7 +1674,7 @@ string_expand(
        char *match,
        regmatch_t *matches)
 {
-       int     size;
+       ber_len_t       size;
        char   *sp;
        char   *dp;
        int     flag;
index 8054077f6bc0e02db853da16d968da2611ee55ae..28785fc692b49bbde003ce739beac88179f5a680 100644 (file)
@@ -83,10 +83,12 @@ passwd_back_search(
                        /* Create an entry corresponding to the base DN */
                        e = (Entry *) ch_calloc(1, sizeof(Entry));
                        e->e_attrs = NULL;
-                       e->e_dn = ch_strdup( base );
+                       e->e_name.bv_val = ch_strdup( base );
+                       e->e_name.bv_len = strlen( e->e_name.bv_val );
 
-                       e->e_ndn = ch_strdup( e->e_dn );
-                       (void) dn_normalize( e->e_ndn );
+                       e->e_nname.bv_val = ch_strdup( base );
+                       (void) dn_normalize( e->e_nname.bv_val );
+                       e->e_nname.bv_len = strlen( e->e_nname.bv_val );
 
                        /* Use the first attribute of the DN
                        * as an attribute within the entry itself.
index 5102bb2004de0c7b0a95794e233ae8db5794f2ff..f40f0af470baaf8f0363e38e54a44c9265bb508e 100644 (file)
@@ -44,10 +44,16 @@ config_info(
        vals[1] = NULL;
 
        e = (Entry *) ch_calloc( 1, sizeof(Entry) );
+       e->e_private = NULL;
+       e->e_attrs = NULL;
+
+       e->e_name.bv_val = SLAPD_CONFIG_DN;
+       e->e_name.bv_len = sizeof( SLAPD_CONFIG_DN ) - 1;
+
 
        e->e_attrs = NULL;
        ber_str2bv( SLAPD_CONFIG_DN, sizeof(SLAPD_CONFIG_DN)-1, 1, &e->e_name );
-       dnNormalize( NULL, &e->e_name, &ndn );
+       (void) dnNormalize( NULL, &e->e_name, &ndn );
        e->e_nname = *ndn;
        free( ndn );
        e->e_private = NULL;
index 6bf1fac5358b748aae8460950d3e67f05fafa52d..78ca41f9af6f62ee41d7ee65fc3aab26466759ca 100644 (file)
@@ -307,8 +307,7 @@ str2entry( char *s )
                        return NULL;
                }
 
-               e->e_nname.bv_val = ndn->bv_val;
-               e->e_nname.bv_len = ndn->bv_len;
+               e->e_nname = *ndn;
                free( ndn );
        }
 
index 78388097ec16962b77e0a118d5f068304f2fca49..49ac0375b8045fd182b2a885f9f501ea980e7844 100644 (file)
@@ -68,7 +68,9 @@ get_limits(
                                }
                        } else {
                                /* check for unescaped rdn separator */
-                               if ( !DN_SEPARATOR( ndn->bv_val[d-1] ) || DN_ESCAPE( ndn->bv_val[d-2] ) ) {
+                               if ( !DN_SEPARATOR( ndn->bv_val[d-1] )
+                                       || DN_ESCAPE( ndn->bv_val[d-2] ) )
+                               {
                                        break;
                                }
                        }
@@ -97,7 +99,9 @@ get_limits(
                        if ( ndn->bv_len == 0 ) {
                                break;
                        }
-                       if ( regexec( &lm[0]->lm_dn_regex, ndn->bv_val, 0, NULL, 0 ) == 0 ) {
+                       if ( regexec( &lm[0]->lm_dn_regex, ndn->bv_val, 0, NULL, 0 )
+                               == 0 )
+                       {
                                *limit = &lm[0]->lm_limits;
                                return( 0 );
                        }
@@ -126,7 +130,7 @@ get_limits(
        return( 0 );
 }
 
-int
+static int
 add_limits(
        Backend                 *be,
        int                     type,
index 6e76c3e3b0f5d62413419b450f616426784b6d74..9d9b7638bde26a65ce7244408b599f0e6ccd9d7c 100644 (file)
@@ -464,9 +464,6 @@ LDAP_SLAPD_F (int) test_filter LDAP_P((
  */
 LDAP_SLAPD_F (int) get_limits LDAP_P((
        Backend *be, struct berval *ndn, struct slap_limits_set **limit ));
-LDAP_SLAPD_F (int) add_limits LDAP_P((
-       Backend *be, int type, const char *pattern, 
-       struct slap_limits_set *limit ));
 LDAP_SLAPD_F (int) parse_limits LDAP_P((
        Backend *be, const char *fname, int lineno, int argc, char **argv ));
 LDAP_SLAPD_F (int) parse_limit LDAP_P(( const char *arg, 
index e6f16ae79bc46ad8905b93f730a08442a31f9df8..8c175d9313be02a3b94854cf7d1ab5d0012f8223 100644 (file)
@@ -762,11 +762,12 @@ send_search_entry(
 
                if ( ! access_allowed( be, conn, op, e, desc, NULL, ACL_READ ) ) {
 #ifdef NEW_LOGGING
-                       LDAP_LOG(( "acl", LDAP_LEVEL_INFO,
-                                  "send_search_entry: conn %d  access to attribute %s not allowed\n",
-                                  op->o_connid, desc->ad_cname.bv_val ));
+                       LDAP_LOG(( "acl", LDAP_LEVEL_INFO, "send_search_entry: "
+                               "conn %d  access to attribute %s not allowed\n",
+                               op->o_connid, desc->ad_cname.bv_val ));
 #else
-                       Debug( LDAP_DEBUG_ACL, "acl: access to attribute %s not allowed\n",
+                       Debug( LDAP_DEBUG_ACL, "acl: "
+                               "access to attribute %s not allowed\n",
                            desc->ad_cname.bv_val, 0, 0 );
 #endif
 
@@ -776,8 +777,8 @@ send_search_entry(
                if (( rc = ber_printf( ber, "{O[" /*]}*/ , &desc->ad_cname )) == -1 ) {
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
-                                  "send_search_entry: conn %d  ber_printf failed\n",
-                                  op->o_connid ));
+                               "send_search_entry: conn %d  ber_printf failed\n",
+                               op->o_connid ));
 #else
                        Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 );
 #endif
index 06762df6536faddc875267823fe1ddcfdcb42843..6e1d4b0809040e4f102112f8f94219616ec234cc 100644 (file)
@@ -66,9 +66,16 @@ root_dse_info(
        e = (Entry *) ch_calloc( 1, sizeof(Entry) );
 
        e->e_attrs = NULL;
-       e->e_dn = ch_strdup( LDAP_ROOT_DSE );
-       e->e_ndn = ch_strdup( LDAP_ROOT_DSE );
-       /* the DN is an empty string so no normalization needed */
+       e->e_name.bv_val = ch_strdup( LDAP_ROOT_DSE );
+       e->e_name.bv_len = sizeof( LDAP_ROOT_DSE )-1;
+       e->e_nname.bv_val = ch_strdup( LDAP_ROOT_DSE );
+       e->e_nname.bv_len = sizeof( LDAP_ROOT_DSE )-1;
+
+       /* the DN is an empty string so no pretty/normalization is needed */
+       assert( !e->e_name.bv_len );
+       assert( !e->e_nname.bv_len );
+       
+
        e->e_private = NULL;
 
        val.bv_val = "OpenLDAProotDSE";
@@ -191,8 +198,8 @@ int read_root_dse_file( const char *fname )
                        return EXIT_FAILURE;
                }
 
-               /* make sure the DN is a valid rootdse(rootdse is a null string) */
-               if( strcmp(e->e_ndn, "") != 0 ) {
+               /* make sure the DN is the empty DN */
+               if( e->e_nname.bv_len ) {
                        fprintf( stderr,
                                "root_dse: invalid rootDSE - dn=\"%s\" (line=%d)\n",
                                e->e_dn, lineno );
index d3f602b8997427e7890bd11b3827b1baec3bbf6f..7337bee924a1bd8583e86fd74f8ff5238e22ab0d 100644 (file)
@@ -38,7 +38,7 @@ schema_info( Entry **entry, const char **text )
 
        e->e_attrs = NULL;
        ber_str2bv( SLAPD_SCHEMA_DN, sizeof(SLAPD_SCHEMA_DN)-1, 1, &e->e_name);
-       dnNormalize( NULL, &e->e_name, &ndn );
+       (void) dnNormalize( NULL, &e->e_name, &ndn );
        e->e_nname = *ndn;
        free( ndn );
        e->e_private = NULL;
index 514c3c8610c8c2bad8c0266e493574e0e60d3f9b..291a71a2bfebc5373219bf3ce9788ae4781b4b6a 100644 (file)
@@ -227,30 +227,31 @@ nameUIDValidate(
        if( in->bv_len == 0 ) return LDAP_SUCCESS;
 
        dn = ber_bvdup( in );
+       if( !dn ) return LDAP_OTHER;
 
-       if( dn->bv_val[dn->bv_len-1] == '\'' ) {
+       if( dn->bv_val[dn->bv_len-1] == 'B'
+               && dn->bv_val[dn->bv_len-2] == '\'' )
+       {
                /* assume presence of optional UID */
                ber_len_t i;
 
-               for(i=dn->bv_len-2; i>2; i--) {
+               for(i=dn->bv_len-3; i>1; i--) {
                        if( dn->bv_val[i] != '0' &&     dn->bv_val[i] != '1' ) {
                                break;
                        }
                }
                if( dn->bv_val[i] != '\'' ||
-                   dn->bv_val[i-1] != 'B' ||
-                   dn->bv_val[i-2] != '#' ) {
+                   dn->bv_val[i-1] != '#' ) {
                        ber_bvfree( dn );
                        return LDAP_INVALID_SYNTAX;
                }
 
-               /* trim the UID to allow use of dn_validate */
-               dn->bv_val[i-2] = '\0';
+               /* trim the UID to allow use of dnValidate */
+               dn->bv_val[i-1] = '\0';
+               dn->bv_len = i-1;
        }
 
-       /* FIXME: should use dnValidate */
-       rc = dn_validate( dn->bv_val ) == NULL
-               ? LDAP_INVALID_SYNTAX : LDAP_SUCCESS;
+       rc = dnValidate( NULL, dn );
 
        ber_bvfree( dn );
        return rc;
@@ -266,7 +267,6 @@ nameUIDNormalize(
        int rc;
 
        if( out->bv_len != 0 ) {
-               char *dn;
                ber_len_t dnlen;
                char *uid = NULL;
                ber_len_t uidlen = 0;