From 7a0b0b2bbf7777cf009ab746654d67ea0abef6ee Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Fri, 24 Sep 1999 01:46:37 +0000 Subject: [PATCH] In preparation for adding dn_rewrite()... s/dn_normalize/dn_validate/ s/dn_normalize_case/dn_normalize/ --- servers/slapd/acl.c | 6 +++--- servers/slapd/add.c | 2 +- servers/slapd/back-bdb2/cache.c | 2 +- servers/slapd/back-bdb2/modrdn.c | 4 ++-- servers/slapd/back-bdb2/search.c | 2 +- servers/slapd/back-ldap/search.c | 2 +- servers/slapd/back-ldbm/cache.c | 2 +- servers/slapd/back-ldbm/modrdn.c | 4 ++-- servers/slapd/back-ldbm/search.c | 2 +- servers/slapd/back-passwd/search.c | 2 +- servers/slapd/bind.c | 3 ++- servers/slapd/compare.c | 2 +- servers/slapd/config.c | 8 +++----- servers/slapd/configinfo.c | 2 +- servers/slapd/connection.c | 2 +- servers/slapd/delete.c | 2 +- servers/slapd/dn.c | 16 ++++++++-------- servers/slapd/entry.c | 2 +- servers/slapd/modify.c | 2 +- servers/slapd/modrdn.c | 4 ++-- servers/slapd/monitor.c | 2 +- servers/slapd/proto-slap.h | 2 +- servers/slapd/root_dse.c | 2 +- servers/slapd/schema.c | 2 +- servers/slapd/search.c | 2 +- servers/slapd/tools/ldbmtest.c | 2 +- servers/slapd/tools/slapadd.c | 2 +- servers/slapd/tools/slapcommon.c | 2 +- servers/slapd/value.c | 2 +- 29 files changed, 44 insertions(+), 45 deletions(-) diff --git a/servers/slapd/acl.c b/servers/slapd/acl.c index 027ad39fed..1558fc7330 100644 --- a/servers/slapd/acl.c +++ b/servers/slapd/acl.c @@ -371,7 +371,7 @@ acl_access_allowed( */ /* see if asker is listed in dnattr */ string_expand(buf, sizeof(buf), b->a_group_pat, edn, matches); - if ( dn_normalize_case(buf) == NULL ) { + if ( dn_normalize(buf) == NULL ) { /* did not expand to a valid dn */ continue; } @@ -748,7 +748,7 @@ aci_group_member ( grpdn = (char *)ch_malloc(1024); if (grpoc != NULL && grpat != NULL && grpdn != NULL) { string_expand(grpdn, 1024, subjdn, edn, matches); - if ( dn_normalize_case(grpdn) != NULL ) { + if ( dn_normalize(grpdn) != NULL ) { rc = (backend_group(be, e, grpdn, op->o_ndn, grpoc, grpat) == 0); } ch_free(grpdn); @@ -826,7 +826,7 @@ aci_access_allowed ( if (subjdn == NULL) return(0); rc = 0; - if (dn_normalize_case(subjdn) != NULL) + if ( dn_normalize(subjdn) != NULL ) rc = (strcasecmp(op->o_ndn, subjdn) == 0); ch_free(subjdn); return(rc); diff --git a/servers/slapd/add.c b/servers/slapd/add.c index 388ad9d629..930608c763 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -69,7 +69,7 @@ do_add( Connection *conn, Operation *op ) ndn = ch_strdup( dn ); - if ( dn_normalize_case( ndn ) == NULL ) { + if ( dn_normalize( ndn ) == NULL ) { Debug( LDAP_DEBUG_ANY, "do_add: invalid dn (%s)\n", dn, 0, 0 ); send_ldap_result( conn, op, LDAP_INVALID_DN_SYNTAX, NULL, "invalid DN", NULL, NULL ); diff --git a/servers/slapd/back-bdb2/cache.c b/servers/slapd/back-bdb2/cache.c index 4c44dbcc46..0725d23073 100644 --- a/servers/slapd/back-bdb2/cache.c +++ b/servers/slapd/back-bdb2/cache.c @@ -360,7 +360,7 @@ bdb2i_cache_find_entry_dn2id( e.e_dn = (char *) dn; e.e_ndn = ch_strdup( dn ); - (void) dn_normalize_case( e.e_ndn ); + (void) dn_normalize( e.e_ndn ); try_again: /* set cache mutex */ diff --git a/servers/slapd/back-bdb2/modrdn.c b/servers/slapd/back-bdb2/modrdn.c index 43b49cdb75..8b136df3b7 100644 --- a/servers/slapd/back-bdb2/modrdn.c +++ b/servers/slapd/back-bdb2/modrdn.c @@ -172,7 +172,7 @@ bdb2i_back_modrdn_internal( 0, 0, 0 ); np_ndn = ch_strdup( np_dn ); - (void) dn_normalize_case( np_ndn ); + (void) dn_normalize( np_ndn ); /* newSuperior == oldParent?, if so ==> ERROR */ @@ -221,7 +221,7 @@ bdb2i_back_modrdn_internal( new_ndn = ch_strdup( new_dn ); - (void) dn_normalize_case( new_ndn ); + (void) dn_normalize( new_ndn ); Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: new ndn=%s\n", new_ndn, 0, 0 ); diff --git a/servers/slapd/back-bdb2/search.c b/servers/slapd/back-bdb2/search.c index d40dbd1a4f..516493453e 100644 --- a/servers/slapd/back-bdb2/search.c +++ b/servers/slapd/back-bdb2/search.c @@ -246,7 +246,7 @@ bdb2i_back_search_internal( /* check scope */ if ( !scopeok && scope == LDAP_SCOPE_ONELEVEL ) { if ( (dn = dn_parent( be, e->e_ndn )) != NULL ) { - (void) dn_normalize_case( dn ); + (void) dn_normalize( dn ); scopeok = (dn == realbase) ? 1 : (strcmp( dn, realbase ) ? 0 : 1 ); diff --git a/servers/slapd/back-ldap/search.c b/servers/slapd/back-ldap/search.c index 9e8619cd47..8f8ef5dfa1 100644 --- a/servers/slapd/back-ldap/search.c +++ b/servers/slapd/back-ldap/search.c @@ -148,7 +148,7 @@ ldap_send_entry( ent.e_dn = ldap_get_dn(lc->ld, e); ent.e_ndn = ch_strdup( ent.e_dn); - (void) dn_normalize_case( ent.e_ndn ); + (void) dn_normalize( ent.e_ndn ); ent.e_id = 0; ent.e_attrs = 0; ent.e_private = 0; diff --git a/servers/slapd/back-ldbm/cache.c b/servers/slapd/back-ldbm/cache.c index 0ef36d7d34..c1875562f6 100644 --- a/servers/slapd/back-ldbm/cache.c +++ b/servers/slapd/back-ldbm/cache.c @@ -445,7 +445,7 @@ cache_find_entry_dn2id( e.e_dn = (char *) dn; e.e_ndn = ch_strdup( dn ); - (void) dn_normalize_case( e.e_ndn ); + (void) dn_normalize( e.e_ndn ); try_again: /* set cache mutex */ diff --git a/servers/slapd/back-ldbm/modrdn.c b/servers/slapd/back-ldbm/modrdn.c index e1e71b05d4..6152c952a4 100644 --- a/servers/slapd/back-ldbm/modrdn.c +++ b/servers/slapd/back-ldbm/modrdn.c @@ -191,7 +191,7 @@ ldbm_back_modrdn( 0, 0, 0 ); np_ndn = ch_strdup( np_dn ); - (void) dn_normalize_case( np_ndn ); + (void) dn_normalize( np_ndn ); /* newSuperior == oldParent?, if so ==> ERROR */ /* newSuperior == entry being moved?, if so ==> ERROR */ @@ -258,7 +258,7 @@ ldbm_back_modrdn( new_ndn = ch_strdup(new_dn); - (void) dn_normalize_case( new_ndn ); + (void) dn_normalize( new_ndn ); Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: new ndn=%s\n", new_ndn, 0, 0 ); diff --git a/servers/slapd/back-ldbm/search.c b/servers/slapd/back-ldbm/search.c index 556653720f..36203bdaa4 100644 --- a/servers/slapd/back-ldbm/search.c +++ b/servers/slapd/back-ldbm/search.c @@ -251,7 +251,7 @@ ldbm_back_search( /* check scope */ if ( !scopeok && scope == LDAP_SCOPE_ONELEVEL ) { if ( (dn = dn_parent( be, e->e_ndn )) != NULL ) { - (void) dn_normalize_case( dn ); + (void) dn_normalize( dn ); scopeok = (dn == realbase) ? 1 : (strcmp( dn, realbase ) ? 0 : 1 ); diff --git a/servers/slapd/back-passwd/search.c b/servers/slapd/back-passwd/search.c index 5e86049dc9..1da4023edf 100644 --- a/servers/slapd/back-passwd/search.c +++ b/servers/slapd/back-passwd/search.c @@ -240,7 +240,7 @@ pw2entry( Backend *be, struct passwd *pw, char *rdn ) sprintf( buf, "uid=%s,%s", pw->pw_name, be->be_suffix[0] ); e->e_dn = ch_strdup( buf ); e->e_ndn = ch_strdup( buf ); - (void) dn_normalize_case( e->e_ndn ); + (void) dn_normalize( e->e_ndn ); val.bv_val = pw->pw_name; val.bv_len = strlen( pw->pw_name ); diff --git a/servers/slapd/bind.c b/servers/slapd/bind.c index e02108e00a..9650d62b01 100644 --- a/servers/slapd/bind.c +++ b/servers/slapd/bind.c @@ -111,7 +111,7 @@ do_bind( ndn = ch_strdup( dn ); - if ( dn_normalize_case( ndn ) == NULL ) { + if ( dn_normalize( ndn ) == NULL ) { Debug( LDAP_DEBUG_ANY, "bind: invalid dn (%s)\n", dn, 0, 0 ); send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL, "invalid DN", NULL, NULL ); @@ -272,6 +272,7 @@ do_bind( NULL, NULL, default_referral, NULL ); } else { + /* noSuchObject is not allowed to be returned by bind */ send_ldap_result( conn, op, rc = LDAP_INVALID_CREDENTIALS, NULL, NULL, NULL, NULL ); } diff --git a/servers/slapd/compare.c b/servers/slapd/compare.c index 8e1338dc92..d47d854cb0 100644 --- a/servers/slapd/compare.c +++ b/servers/slapd/compare.c @@ -67,7 +67,7 @@ do_compare( ndn = ch_strdup( dn ); - if( dn_normalize_case( ndn ) == NULL ) { + if( dn_normalize( ndn ) == NULL ) { Debug( LDAP_DEBUG_ANY, "do_compare: invalid dn (%s)\n", dn, 0, 0 ); send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL, "invalid DN", NULL, NULL ); diff --git a/servers/slapd/config.c b/servers/slapd/config.c index cc3ea8416e..1d6367907d 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -247,7 +247,7 @@ read_config( const char *fname ) fname, lineno, tmp_be->be_suffix[0] ); } else { char *dn = ch_strdup( cargv[1] ); - (void) dn_normalize( dn ); + (void) dn_validate( dn ); charray_add( &be->be_suffix, dn ); (void) ldap_pvt_str2upper( dn ); charray_add( &be->be_nsuffix, dn ); @@ -299,8 +299,6 @@ read_config( const char *fname ) aliased_dn = ch_strdup( cargv[2] ); (void) dn_normalize( aliased_dn ); - (void) dn_normalize_case( alias ); - (void) dn_normalize_case( aliased_dn ); charray_add( &be->be_suffixAlias, alias ); charray_add( &be->be_suffixAlias, aliased_dn ); @@ -347,7 +345,7 @@ read_config( const char *fname ) be->be_root_dn = ch_strdup( cargv[1] ); be->be_root_ndn = ch_strdup( cargv[1] ); - if( dn_normalize_case( be->be_root_ndn ) == NULL ) { + if( dn_normalize( be->be_root_ndn ) == NULL ) { free( be->be_root_dn ); free( be->be_root_ndn ); Debug( LDAP_DEBUG_ANY, @@ -556,7 +554,7 @@ read_config( const char *fname ) fname, lineno, 0 ); } else { be->be_update_ndn = ch_strdup( cargv[1] ); - if( dn_normalize_case( be->be_update_ndn ) == NULL ) { + if( dn_normalize( be->be_update_ndn ) == NULL ) { Debug( LDAP_DEBUG_ANY, "%s: line %d: updatedn DN is invalid\n", fname, lineno, 0 ); diff --git a/servers/slapd/configinfo.c b/servers/slapd/configinfo.c index 692b8575f2..82e2ab0fcd 100644 --- a/servers/slapd/configinfo.c +++ b/servers/slapd/configinfo.c @@ -51,7 +51,7 @@ config_info( e->e_attrs = NULL; e->e_dn = ch_strdup( SLAPD_CONFIG_DN ); e->e_ndn = ch_strdup( SLAPD_CONFIG_DN ); - (void) dn_normalize_case( e->e_ndn ); + (void) dn_normalize( e->e_ndn ); e->e_private = NULL; { diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index 9c6e61d593..483c7d68b2 100644 --- a/servers/slapd/connection.c +++ b/servers/slapd/connection.c @@ -1053,7 +1053,7 @@ static int connection_op_activate( Connection *conn, Operation *op ) arg->co_op->o_dn = ch_strdup( tmpdn != NULL ? tmpdn : "" ); arg->co_op->o_ndn = ch_strdup( arg->co_op->o_dn ); - (void) dn_normalize_case( arg->co_op->o_ndn ); + (void) dn_normalize( arg->co_op->o_ndn ); arg->co_op->o_protocol = conn->c_protocol; arg->co_op->o_connid = conn->c_connid; diff --git a/servers/slapd/delete.c b/servers/slapd/delete.c index ae27648ab5..08c05ab811 100644 --- a/servers/slapd/delete.c +++ b/servers/slapd/delete.c @@ -59,7 +59,7 @@ do_delete( ndn = ch_strdup( dn ); - if( dn_normalize_case( ndn ) == NULL ) { + if( dn_normalize( ndn ) == NULL ) { Debug( LDAP_DEBUG_ANY, "do_delete: invalid dn (%s)\n", dn, 0, 0 ); send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL, "invalid DN", NULL, NULL ); diff --git a/servers/slapd/dn.c b/servers/slapd/dn.c index d2a7daa8e8..a8419c59a6 100644 --- a/servers/slapd/dn.c +++ b/servers/slapd/dn.c @@ -29,12 +29,12 @@ #define B4SEPARATOR 8 /* - * dn_normalize - put dn into a canonical format. the dn is - * normalized in place, as well as returned if valid. + * dn_validate - validate and compress dn. the dn is + * compressed in place are returned if valid. */ char * -dn_normalize( char *dn ) +dn_validate( char *dn ) { char *d, *s; int state, gotesc; @@ -146,7 +146,7 @@ dn_normalize( char *dn ) default: dn = NULL; Debug( LDAP_DEBUG_ANY, - "dn_normalize - unknown state %d\n", state, 0, 0 ); + "dn_validate - unknown state %d\n", state, 0, 0 ); break; } if ( *s == '\\' ) { @@ -176,18 +176,18 @@ dn_normalize( char *dn ) } /* - * dn_normalize_case - put dn into a canonical form suitable for storing + * dn_normalize - put dn into a canonical form suitable for storing * in a hash database. this involves normalizing the case as well as * the format. the dn is normalized in place as well as returned if valid. */ char * -dn_normalize_case( char *dn ) +dn_normalize( char *dn ) { ldap_pvt_str2upper( dn ); - /* normalize format */ - dn = dn_normalize( dn ); + /* validate and compress dn */ + dn = dn_validate( dn ); /* and upper case it */ return( dn ); diff --git a/servers/slapd/entry.c b/servers/slapd/entry.c index 6d003b9428..b0cd52e28f 100644 --- a/servers/slapd/entry.c +++ b/servers/slapd/entry.c @@ -145,7 +145,7 @@ str2entry( char *s ) /* generate normalized dn */ e->e_ndn = ch_strdup( e->e_dn ); - (void) dn_normalize_case( e->e_ndn ); + (void) dn_normalize( e->e_ndn ); Debug(LDAP_DEBUG_TRACE, "<= str2entry(%s) -> %ld (0x%lx)\n", e->e_dn, e->e_id, (unsigned long)e ); diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 6a6d3d6b82..0ab325d8ed 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -87,7 +87,7 @@ do_modify( ndn = ch_strdup( dn ); - if( dn_normalize_case( ndn ) == NULL ) { + if( dn_normalize( ndn ) == NULL ) { Debug( LDAP_DEBUG_ANY, "do_modify: invalid dn (%s)\n", dn, 0, 0 ); send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL, "invalid DN", NULL, NULL ); diff --git a/servers/slapd/modrdn.c b/servers/slapd/modrdn.c index 7c8004cff8..a849af2cbe 100644 --- a/servers/slapd/modrdn.c +++ b/servers/slapd/modrdn.c @@ -84,7 +84,7 @@ do_modrdn( ndn = ch_strdup( dn ); - if( dn_normalize_case( ndn ) == NULL ) { + if( dn_normalize( ndn ) == NULL ) { Debug( LDAP_DEBUG_ANY, "do_modrdn: invalid dn (%s)\n", dn, 0, 0 ); send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL, "invalid DN", NULL, NULL ); @@ -127,7 +127,7 @@ do_modrdn( nnewSuperior = ch_strdup( newSuperior ); - if( dn_normalize_case( nnewSuperior ) == NULL ) { + if( dn_normalize( nnewSuperior ) == NULL ) { Debug( LDAP_DEBUG_ANY, "do_modrdn: invalid new superior (%s)\n", newSuperior, 0, 0 ); send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL, diff --git a/servers/slapd/monitor.c b/servers/slapd/monitor.c index 9ad7fbc080..506771f3e4 100644 --- a/servers/slapd/monitor.c +++ b/servers/slapd/monitor.c @@ -55,7 +55,7 @@ monitor_info( e->e_attrs = NULL; e->e_dn = ch_strdup( SLAPD_MONITOR_DN ); e->e_ndn = ch_strdup(SLAPD_MONITOR_DN); - (void) dn_normalize_case( e->e_ndn ); + (void) dn_normalize( e->e_ndn ); e->e_private = NULL; { diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 1e95a28052..139a37eb40 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -205,8 +205,8 @@ void connection_done LDAP_P((Connection *)); * dn.c */ +char * dn_validate LDAP_P(( char *dn )); char * dn_normalize LDAP_P(( char *dn )); -char * dn_normalize_case LDAP_P(( char *dn )); char * dn_parent LDAP_P(( Backend *be, const char *dn )); char ** dn_subtree LDAP_P(( Backend *be, const char *dn )); char * dn_rdn LDAP_P(( Backend *be, char *dn )); diff --git a/servers/slapd/root_dse.c b/servers/slapd/root_dse.c index d30e6e3869..fc5b1d432f 100644 --- a/servers/slapd/root_dse.c +++ b/servers/slapd/root_dse.c @@ -34,7 +34,7 @@ root_dse_info( Connection *conn, Operation *op, char **attrs, int attrsonly ) e->e_attrs = NULL; e->e_dn = ch_strdup( LDAP_ROOT_DSE ); e->e_ndn = ch_strdup( LDAP_ROOT_DSE ); - (void) dn_normalize_case( e->e_ndn ); + (void) dn_normalize( e->e_ndn ); e->e_private = NULL; for ( i = 0; i < nbackends; i++ ) { diff --git a/servers/slapd/schema.c b/servers/slapd/schema.c index c4b20a7e8d..d835f60182 100644 --- a/servers/slapd/schema.c +++ b/servers/slapd/schema.c @@ -1174,7 +1174,7 @@ schema_info( Connection *conn, Operation *op, char **attrs, int attrsonly ) e->e_attrs = NULL; e->e_dn = ch_strdup( SLAPD_SCHEMA_DN ); e->e_ndn = ch_strdup( SLAPD_SCHEMA_DN ); - (void) dn_normalize_case( e->e_ndn ); + (void) dn_normalize( e->e_ndn ); e->e_private = NULL; { diff --git a/servers/slapd/search.c b/servers/slapd/search.c index 8d98fb0ae4..1e13332128 100644 --- a/servers/slapd/search.c +++ b/servers/slapd/search.c @@ -107,7 +107,7 @@ do_search( nbase = ch_strdup( base ); - if( dn_normalize_case( nbase ) == NULL ) { + if( dn_normalize( nbase ) == NULL ) { send_ldap_result( conn, op, LDAP_INVALID_DN_SYNTAX, NULL, "invalid DN", NULL, NULL ); rc = -1; diff --git a/servers/slapd/tools/ldbmtest.c b/servers/slapd/tools/ldbmtest.c index 1897c0245b..35b265a291 100644 --- a/servers/slapd/tools/ldbmtest.c +++ b/servers/slapd/tools/ldbmtest.c @@ -298,7 +298,7 @@ main( int argc, char **argv ) } else { buf[strlen( buf ) - 1] = '\0'; } - (void) dn_normalize_case( buf ); + (void) dn_normalize( buf ); if ( (tbe = select_backend( buf )) == NULL ) { fprintf( stderr, "unknown suffix \"%s\"\n", buf ); diff --git a/servers/slapd/tools/slapadd.c b/servers/slapd/tools/slapadd.c index 606a2f4aac..73a4b7656a 100644 --- a/servers/slapd/tools/slapadd.c +++ b/servers/slapd/tools/slapadd.c @@ -59,7 +59,7 @@ main( int argc, char **argv ) if( !noschemacheck ) { /* make sure the DN is valid */ - if( dn_normalize_case( e->e_ndn ) == NULL ) { + if( dn_normalize( e->e_ndn ) == NULL ) { fprintf( stderr, "%s: bad dn=\"%s\" (line=%d)\n", progname, e->e_dn, lineno ); rc = EXIT_FAILURE; diff --git a/servers/slapd/tools/slapcommon.c b/servers/slapd/tools/slapcommon.c index 8b41f22323..9b4259c393 100644 --- a/servers/slapd/tools/slapcommon.c +++ b/servers/slapd/tools/slapcommon.c @@ -198,7 +198,7 @@ slap_tool_init( if( base != NULL ) { char *tbase = ch_strdup( base ); - if( dn_normalize_case( tbase ) == NULL ) { + if( dn_normalize( tbase ) == NULL ) { fprintf( stderr, "%s: slap_init invalid suffix (\"%s\")\n", progname, base ); exit( EXIT_FAILURE ); diff --git a/servers/slapd/value.c b/servers/slapd/value.c index 1405fd176e..58f1711d1c 100644 --- a/servers/slapd/value.c +++ b/servers/slapd/value.c @@ -96,7 +96,7 @@ value_normalize( } if ( syntax & SYNTAX_DN ) { - (void) dn_normalize_case( s ); + (void) dn_normalize( s ); return; } -- 2.39.5