From: Kurt Zeilenga Date: Wed, 26 Dec 2001 16:42:35 +0000 (+0000) Subject: Misc cleanup and dn_normalize() zapping X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~494 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=21288fbb210af9912ea3148a04c36c87bebfd7a2;p=openldap Misc cleanup and dn_normalize() zapping Fix nameAndOptionalIdentifer syntax. --- diff --git a/servers/slapd/acl.c b/servers/slapd/acl.c index 4d48065e0d..912279a111 100644 --- a/servers/slapd/acl.c +++ b/servers/slapd/acl.c @@ -1674,7 +1674,7 @@ string_expand( char *match, regmatch_t *matches) { - int size; + ber_len_t size; char *sp; char *dp; int flag; diff --git a/servers/slapd/back-passwd/search.c b/servers/slapd/back-passwd/search.c index 8054077f6b..28785fc692 100644 --- a/servers/slapd/back-passwd/search.c +++ b/servers/slapd/back-passwd/search.c @@ -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. diff --git a/servers/slapd/configinfo.c b/servers/slapd/configinfo.c index 5102bb2004..f40f0af470 100644 --- a/servers/slapd/configinfo.c +++ b/servers/slapd/configinfo.c @@ -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; diff --git a/servers/slapd/entry.c b/servers/slapd/entry.c index 6bf1fac535..78ca41f9af 100644 --- a/servers/slapd/entry.c +++ b/servers/slapd/entry.c @@ -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 ); } diff --git a/servers/slapd/limits.c b/servers/slapd/limits.c index 78388097ec..49ac0375b8 100644 --- a/servers/slapd/limits.c +++ b/servers/slapd/limits.c @@ -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, diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 6e76c3e3b0..9d9b7638bd 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -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, diff --git a/servers/slapd/result.c b/servers/slapd/result.c index e6f16ae79b..8c175d9313 100644 --- a/servers/slapd/result.c +++ b/servers/slapd/result.c @@ -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 diff --git a/servers/slapd/root_dse.c b/servers/slapd/root_dse.c index 06762df653..6e1d4b0809 100644 --- a/servers/slapd/root_dse.c +++ b/servers/slapd/root_dse.c @@ -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 ); diff --git a/servers/slapd/schema.c b/servers/slapd/schema.c index d3f602b899..7337bee924 100644 --- a/servers/slapd/schema.c +++ b/servers/slapd/schema.c @@ -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; diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index 514c3c8610..291a71a2bf 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -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;