]> git.sur5r.net Git - openldap/commitdiff
More dnPrettyNormal
authorHoward Chu <hyc@openldap.org>
Fri, 28 Dec 2001 07:58:54 +0000 (07:58 +0000)
committerHoward Chu <hyc@openldap.org>
Fri, 28 Dec 2001 07:58:54 +0000 (07:58 +0000)
servers/slapd/compare.c
servers/slapd/config.c
servers/slapd/delete.c
servers/slapd/entry.c
servers/slapd/modify.c
servers/slapd/modrdn.c

index 77b1c4cd6471437c9d1ee4245d50695eb5f64a45..c15fee13a9731bb94f509a7a6607d0e249bf90cb 100644 (file)
@@ -37,8 +37,8 @@ do_compare(
 {
        Entry *entry = NULL;
        struct berval dn = { 0, NULL };
-       struct berval *pdn = NULL;
-       struct berval *ndn = NULL;
+       struct berval pdn = { 0, NULL };
+       struct berval ndn = { 0, NULL };
        struct berval desc = { 0, NULL };
        struct berval value = { 0, NULL };
        struct berval *nvalue;
@@ -116,22 +116,7 @@ do_compare(
                goto cleanup;
        } 
 
-       rc = dnPretty( NULL, &dn, &pdn );
-       if( rc != LDAP_SUCCESS ) {
-#ifdef NEW_LOGGING
-               LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
-                       "do_compare: conn %d  invalid dn (%s)\n",
-                       conn->c_connid, dn.bv_val ));
-#else
-               Debug( LDAP_DEBUG_ANY,
-                       "do_compare: invalid dn (%s)\n", dn.bv_val, 0, 0 );
-#endif
-               send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
-                   "invalid DN", NULL, NULL );
-               goto cleanup;
-       }
-
-       rc = dnNormalize( NULL, &dn, &ndn );
+       rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn );
        if( rc != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
@@ -160,20 +145,20 @@ do_compare(
 
        ava.aa_value = nvalue;
 
-       if( strcasecmp( ndn->bv_val, LDAP_ROOT_DSE ) == 0 ) {
+       if( strcasecmp( ndn.bv_val, LDAP_ROOT_DSE ) == 0 ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_ARGS,
                        "do_compare: conn %d  dn (%s) attr(%s) value (%s)\n",
-                       conn->c_connid, pdn->bv_val,
+                       conn->c_connid, pdn.bv_val,
                        ava.aa_desc->ad_cname.bv_val, ava.aa_value->bv_val ));
 #else
                Debug( LDAP_DEBUG_ARGS, "do_compare: dn (%s) attr (%s) value (%s)\n",
-                       pdn->bv_val, ava.aa_desc->ad_cname.bv_val, ava.aa_value->bv_val );
+                       pdn.bv_val, ava.aa_desc->ad_cname.bv_val, ava.aa_value->bv_val );
 #endif
 
                Statslog( LDAP_DEBUG_STATS,
                        "conn=%ld op=%d CMP dn=\"%s\" attr=\"%s\"\n",
-                       op->o_connid, op->o_opid, pdn->bv_val,
+                       op->o_connid, op->o_opid, pdn.bv_val,
                        ava.aa_desc->ad_cname.bv_val, 0 );
 
                rc = backend_check_restrictions( NULL, conn, op, NULL, &text ) ;
@@ -188,20 +173,20 @@ do_compare(
                        goto cleanup;
                }
 
-       } else if ( strcasecmp( ndn->bv_val, SLAPD_SCHEMA_DN ) == 0 ) {
+       } else if ( strcasecmp( ndn.bv_val, SLAPD_SCHEMA_DN ) == 0 ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_ARGS,
                        "do_compare: conn %d  dn (%s) attr(%s) value (%s)\n",
-                       conn->c_connid, pdn->bv_val, ava.aa_desc->ad_cname.bv_val,
+                       conn->c_connid, pdn.bv_val, ava.aa_desc->ad_cname.bv_val,
                        ava.aa_value->bv_val ));
 #else
                Debug( LDAP_DEBUG_ARGS, "do_compare: dn (%s) attr (%s) value (%s)\n",
-                       pdn->bv_val, ava.aa_desc->ad_cname.bv_val, ava.aa_value->bv_val );
+                       pdn.bv_val, ava.aa_desc->ad_cname.bv_val, ava.aa_value->bv_val );
 #endif
 
                Statslog( LDAP_DEBUG_STATS,
                        "conn=%ld op=%d CMP dn=\"%s\" attr=\"%s\"\n",
-                       op->o_connid, op->o_opid, pdn->bv_val,
+                       op->o_connid, op->o_opid, pdn.bv_val,
                        ava.aa_desc->ad_cname.bv_val, 0 );
 
                rc = backend_check_restrictions( NULL, conn, op, NULL, &text ) ;
@@ -239,9 +224,9 @@ do_compare(
         * appropriate one, or send a referral to our "referral server"
         * if we don't hold it.
         */
-       if ( (be = select_backend( ndn, manageDSAit, 0 )) == NULL ) {
+       if ( (be = select_backend( &ndn, manageDSAit, 0 )) == NULL ) {
                struct berval **ref = referral_rewrite( default_referral,
-                       NULL, pdn, LDAP_SCOPE_DEFAULT );
+                       NULL, &pdn, LDAP_SCOPE_DEFAULT );
 
                send_ldap_result( conn, op, rc = LDAP_REFERRAL,
                        NULL, NULL, ref ? ref : default_referral, NULL );
@@ -260,7 +245,7 @@ do_compare(
        }
 
        /* check for referrals */
-       rc = backend_check_referrals( be, conn, op, pdn, ndn );
+       rc = backend_check_referrals( be, conn, op, &pdn, &ndn );
        if ( rc != LDAP_SUCCESS ) {
                goto cleanup;
        }
@@ -268,23 +253,23 @@ do_compare(
 #ifdef NEW_LOGGING
        LDAP_LOG(( "operation", LDAP_LEVEL_ARGS,
                "do_compare: conn %d     dn (%s) attr(%s) value (%s)\n",
-               conn->c_connid, pdn->bv_val, ava.aa_desc->ad_cname.bv_val,
+               conn->c_connid, pdn.bv_val, ava.aa_desc->ad_cname.bv_val,
                ava.aa_value->bv_val ));
 #else
        Debug( LDAP_DEBUG_ARGS, "do_compare: dn (%s) attr (%s) value (%s)\n",
-           pdn->bv_val, ava.aa_desc->ad_cname.bv_val, ava.aa_value->bv_val );
+           pdn.bv_val, ava.aa_desc->ad_cname.bv_val, ava.aa_value->bv_val );
 #endif
 
        Statslog( LDAP_DEBUG_STATS, "conn=%ld op=%d CMP dn=\"%s\" attr=\"%s\"\n",
-           op->o_connid, op->o_opid, pdn->bv_val,
+           op->o_connid, op->o_opid, pdn.bv_val,
                ava.aa_desc->ad_cname.bv_val, 0 );
 
 
        /* deref suffix alias if appropriate */
-       suffix_alias( be, ndn );
+       suffix_alias( be, &ndn );
 
        if ( be->be_compare ) {
-               (*be->be_compare)( be, conn, op, pdn, ndn, &ava );
+               (*be->be_compare)( be, conn, op, &pdn, &ndn, &ava );
        } else {
                send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
                        NULL, "operation not supported within namingContext",
@@ -293,8 +278,8 @@ do_compare(
 
 cleanup:
        free( dn.bv_val );
-       ber_bvfree( pdn );
-       ber_bvfree( ndn );
+       free( pdn.bv_val );
+       free( ndn.bv_val );
        free( desc.bv_val );
        free( value.bv_val );
 
index 11b5dd8c8aa3999a0598c7baecc36cf7ff3ce02b..ffaaadf66afc3be4f36b9485d61c9db9a291ef26 100644 (file)
@@ -395,26 +395,15 @@ read_config( const char *fname )
                        if ( load_ucdata( NULL ) < 0 ) return 1;
 
                        {
-                               struct berval dn, *pdn, *ndn;
+                               struct berval dn;
 
                                dn.bv_val = cargv[1];
                                dn.bv_len = strlen( dn.bv_val );
 
-                               rc = dnPretty( NULL, &dn, &pdn );
-                               if( rc != LDAP_SUCCESS ) {
-#ifdef NEW_LOGGING
-                                       LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
-                                               "%s: line %d: defaultSearchBase DN is invalid.\n",
-                                               fname, lineno ));
-#else
-                                       Debug( LDAP_DEBUG_ANY,
-                                               "%s: line %d: defaultSearchBase DN is invalid\n",
-                                          fname, lineno, 0 );
-#endif
-                                       return( 1 );
-                               }
+                               rc = dnPrettyNormal( NULL, &dn,
+                                       &default_search_base,
+                                       &default_search_nbase );
 
-                               rc = dnNormalize( NULL, &dn, &ndn );
                                if( rc != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
                                        LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
@@ -425,15 +414,8 @@ read_config( const char *fname )
                                                "%s: line %d: defaultSearchBase DN is invalid\n",
                                           fname, lineno, 0 );
 #endif
-                                       ber_bvfree( ndn );
                                        return( 1 );
                                }
-
-                               default_search_base = *pdn;
-                               default_search_nbase = *ndn;
-
-                               free( pdn );
-                               free( ndn );
                        }
 
                /* set maximum threads in thread pool */
@@ -930,22 +912,10 @@ read_config( const char *fname )
 
                        dn.bv_val = cargv[1];
                        dn.bv_len = strlen( cargv[1] );
+                       pdn = ch_malloc( sizeof( struct berval ));
+                       ndn = ch_malloc( sizeof( struct berval ));
 
-                       rc = dnPretty( NULL, &dn, &pdn );
-                       if( rc != LDAP_SUCCESS ) {
-#ifdef NEW_LOGGING
-                               LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
-                                       "%s: line %d: suffix DN is invalid.\n",
-                                       fname, lineno ));
-#else
-                               Debug( LDAP_DEBUG_ANY,
-                                       "%s: line %d: suffix DN is invalid\n",
-                                  fname, lineno, 0 );
-#endif
-                               return( 1 );
-                       }
-
-                       rc = dnNormalize( NULL, &dn, &ndn );
+                       rc = dnPrettyNormal( NULL, &dn, pdn, ndn );
                        if( rc != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
                                LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
@@ -956,7 +926,6 @@ read_config( const char *fname )
                                        "%s: line %d: suffix DN is invalid\n",
                                   fname, lineno, 0 );
 #endif
-                               ber_bvfree( ndn );
                                return( 1 );
                        }
 
@@ -1009,8 +978,8 @@ read_config( const char *fname )
                /* set database suffixAlias */
                } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
                        Backend *tmp_be;
-                       struct berval alias, *palias, *nalias;
-                       struct berval aliased, *paliased, *naliased;
+                       struct berval alias, *palias, nalias;
+                       struct berval aliased, *paliased, naliased;
 
                        if ( cargc < 2 ) {
 #ifdef NEW_LOGGING
@@ -1070,8 +1039,9 @@ read_config( const char *fname )
                        
                        alias.bv_val = cargv[1];
                        alias.bv_len = strlen( cargv[1] );
+                       palias = ch_malloc(sizeof(struct berval));
 
-                       rc = dnPretty( NULL, &alias, &palias );
+                       rc = dnPrettyNormal( NULL, &alias, palias, &nalias );
                        if( rc != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
                                LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
@@ -1085,23 +1055,8 @@ read_config( const char *fname )
                                return( 1 );
                        }
 
-                       rc = dnNormalize( NULL, &alias, &nalias );
-                       if( rc != LDAP_SUCCESS ) {
-#ifdef NEW_LOGGING
-                               LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
-                                       "%s: line %d: alias DN is invalid.\n",
-                                       fname, lineno ));
-#else
-                               Debug( LDAP_DEBUG_ANY,
-                                       "%s: line %d: alias DN is invalid\n",
-                                  fname, lineno, 0 );
-#endif
-                               ber_bvfree( palias );
-                               return( 1 );
-                       }
-
-                       tmp_be = select_backend( nalias, 0, 0 );
-                       ber_bvfree( nalias );
+                       tmp_be = select_backend( &nalias, 0, 0 );
+                       free( nalias.bv_val );
                        if ( tmp_be != be ) {
 #ifdef NEW_LOGGING
                                LDAP_LOG(( "config", LDAP_LEVEL_INFO,
@@ -1120,8 +1075,9 @@ read_config( const char *fname )
 
                        aliased.bv_val = cargv[2];
                        aliased.bv_len = strlen( cargv[2] );
+                       paliased = ch_malloc(sizeof(struct berval));
 
-                       rc = dnPretty( NULL, &aliased, &paliased );
+                       rc = dnPrettyNormal( NULL, &aliased, paliased, &naliased );
                        if( rc != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
                                LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
@@ -1136,24 +1092,8 @@ read_config( const char *fname )
                                return( 1 );
                        }
 
-                       rc = dnNormalize( NULL, &aliased, &naliased );
-                       if( rc != LDAP_SUCCESS ) {
-#ifdef NEW_LOGGING
-                               LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
-                                       "%s: line %d: aliased DN is invalid.\n",
-                                       fname, lineno ));
-#else
-                               Debug( LDAP_DEBUG_ANY,
-                                       "%s: line %d: aliased DN is invalid\n",
-                                  fname, lineno, 0 );
-#endif
-                               ber_bvfree( palias );
-                               ber_bvfree( paliased );
-                               return( 1 );
-                       }
-
-                       tmp_be = select_backend( naliased, 0, 0 );
-                       ber_bvfree( naliased );
+                       tmp_be = select_backend( &naliased, 0, 0 );
+                       free( naliased.bv_val );
                        if ( tmp_be != be ) {
 #ifdef NEW_LOGGING
                                LDAP_LOG(( "config", LDAP_LEVEL_INFO,
@@ -1245,28 +1185,17 @@ read_config( const char *fname )
 #endif
 
                        } else {
-                               struct berval dn, *pdn = NULL, *ndn = NULL;
+                               struct berval dn;
                                
                                if ( load_ucdata( NULL ) < 0 ) return 1;
 
                                dn.bv_val = cargv[1];
                                dn.bv_len = strlen( cargv[1] );
 
-                               rc = dnPretty( NULL, &dn, &pdn );
-                               if( rc != LDAP_SUCCESS ) {
-#ifdef NEW_LOGGING
-                                       LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
-                                               "%s: line %d: rootdn DN is invalid.\n",
-                                               fname, lineno ));
-#else
-                                       Debug( LDAP_DEBUG_ANY,
-                                               "%s: line %d: rootdn DN is invalid\n",
-                                          fname, lineno, 0 );
-#endif
-                                       return( 1 );
-                               }
+                               rc = dnPrettyNormal( NULL, &dn,
+                                       &be->be_rootdn,
+                                       &be->be_rootndn );
 
-                               rc = dnNormalize( NULL, &dn, &ndn );
                                if( rc != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
                                        LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
@@ -1277,15 +1206,8 @@ read_config( const char *fname )
                                                "%s: line %d: rootdn DN is invalid\n",
                                           fname, lineno, 0 );
 #endif
-                                       ber_bvfree( ndn );
                                        return( 1 );
                                }
-
-                               be->be_rootdn = *pdn;
-                               be->be_rootndn = *ndn;
-
-                               free( pdn );
-                               free( ndn );
                        }
 
                /* set super-secret magic database password */
index 035ed744558036f8e9f2cf231d46f217c3c5f5d3..5fd4f7f55d48c8bb25894e6374ef7d7925936ce5 100644 (file)
@@ -32,8 +32,8 @@ do_delete(
 )
 {
        struct berval dn = { 0, NULL };
-       struct berval *ndn = NULL;
-       struct berval *pdn = NULL;
+       struct berval pdn = { 0, NULL };
+       struct berval ndn = { 0, NULL };
        const char *text;
        Backend *be;
        int rc;
@@ -74,7 +74,7 @@ do_delete(
                goto cleanup;
        } 
 
-       rc = dnPretty( NULL, &dn, &pdn );
+       rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn );
        if( rc != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
@@ -89,22 +89,7 @@ do_delete(
                goto cleanup;
        }
 
-       rc = dnNormalize( NULL, &dn, &ndn );
-       if( rc != LDAP_SUCCESS ) {
-#ifdef NEW_LOGGING
-               LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
-                       "do_delete: conn %d  invalid dn (%s)\n",
-                       conn->c_connid, dn.bv_val ));
-#else
-               Debug( LDAP_DEBUG_ANY,
-                       "do_delete: invalid dn (%s)\n", dn.bv_val, 0, 0 );
-#endif
-               send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
-                   "invalid DN", NULL, NULL );
-               goto cleanup;
-       }
-
-       if( ndn->bv_len == 0 ) {
+       if( ndn.bv_len == 0 ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_INFO, "do_delete: conn %d: "
                        "Attempt to delete root DSE.\n", conn->c_connid ));
@@ -118,7 +103,7 @@ do_delete(
 
 #ifdef SLAPD_SCHEMA_DN
 
-       } else if ( strcasecmp( ndn->bv_val, SLAPD_SCHEMA_DN ) == 0 ) {
+       } else if ( strcasecmp( ndn.bv_val, SLAPD_SCHEMA_DN ) == 0 ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_INFO, "do_delete: conn %d: "
                        "Attempt to delete subschema subentry.\n", conn->c_connid ));
@@ -134,7 +119,7 @@ do_delete(
        }
 
        Statslog( LDAP_DEBUG_STATS, "conn=%ld op=%d DEL dn=\"%s\"\n",
-               op->o_connid, op->o_opid, pdn->bv_val, 0, 0 );
+               op->o_connid, op->o_opid, pdn.bv_val, 0, 0 );
 
        manageDSAit = get_manageDSAit( op );
 
@@ -143,9 +128,9 @@ do_delete(
         * appropriate one, or send a referral to our "referral server"
         * if we don't hold it.
         */
-       if ( (be = select_backend( ndn, manageDSAit, 0 )) == NULL ) {
+       if ( (be = select_backend( &ndn, manageDSAit, 0 )) == NULL ) {
                struct berval **ref = referral_rewrite( default_referral,
-                       NULL, pdn, LDAP_SCOPE_DEFAULT );
+                       NULL, &pdn, LDAP_SCOPE_DEFAULT );
 
                send_ldap_result( conn, op, rc = LDAP_REFERRAL,
                        NULL, NULL, ref ? ref : default_referral, NULL );
@@ -163,13 +148,13 @@ do_delete(
        }
 
        /* check for referrals */
-       rc = backend_check_referrals( be, conn, op, pdn, ndn );
+       rc = backend_check_referrals( be, conn, op, &pdn, &ndn );
        if ( rc != LDAP_SUCCESS ) {
                goto cleanup;
        }
 
        /* deref suffix alias if appropriate */
-       suffix_alias( be, ndn );
+       suffix_alias( be, &ndn );
 
        /*
         * do the delete if 1 && (2 || 3)
@@ -184,12 +169,12 @@ do_delete(
                if ( !be->be_update_ndn.bv_len || repl_user )
 #endif
                {
-                       if ( (*be->be_delete)( be, conn, op, pdn, ndn ) == 0 ) {
+                       if ( (*be->be_delete)( be, conn, op, &pdn, &ndn ) == 0 ) {
 #ifdef SLAPD_MULTIMASTER
                                if ( !be->be_update_ndn.bv_len || !repl_user )
 #endif
                                {
-                                       replog( be, op, pdn, ndn, NULL );
+                                       replog( be, op, &pdn, &ndn, NULL );
                                }
                        }
 #ifndef SLAPD_MULTIMASTER
@@ -197,7 +182,7 @@ do_delete(
                        struct berval **defref = be->be_update_refs
                                ? be->be_update_refs : default_referral;
                        struct berval **ref = referral_rewrite( default_referral,
-                               NULL, pdn, LDAP_SCOPE_DEFAULT );
+                               NULL, &pdn, LDAP_SCOPE_DEFAULT );
 
                        send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL,
                                ref ? ref : defref, NULL );
@@ -213,7 +198,7 @@ do_delete(
 
 cleanup:
        free( dn.bv_val );
-       if( pdn != NULL ) ber_bvfree( pdn );
-       if( ndn != NULL ) ber_bvfree( ndn );
+       if( pdn.bv_val != NULL ) ber_bvfree( pdn.bv_val );
+       if( ndn.bv_val != NULL ) ber_bvfree( ndn.bv_val );
        return rc;
 }
index afc4272132759e7133ac52ad80e5446e4bb9dbb8..0e99f108f3f30fb466ebc7d2e524316b3645a61f 100644 (file)
@@ -138,7 +138,7 @@ str2entry( char *s )
                                return NULL;
                        }
 
-                       rc = dnPretty( NULL, &value, &pdn );
+                       rc = dnPrettyNormal( NULL, &value, &e->e_name, &e->e_nname );
                        free( value.bv_val );
                        if( rc != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
@@ -155,11 +155,6 @@ str2entry( char *s )
                                entry_free( e );
                                return NULL;
                        }
-
-                       e->e_name.bv_val = ( pdn->bv_val != NULL )
-                               ? pdn->bv_val : ch_strdup( "" );
-                       e->e_name.bv_len = pdn->bv_len;
-                       free( pdn );
                        continue;
                }
 
@@ -288,29 +283,6 @@ str2entry( char *s )
                return( NULL );
        }
 
-       /* generate normalized dn */
-       {
-               struct berval *ndn = NULL;
-
-               rc = dnNormalize( NULL, &e->e_name, &ndn );
-               if( rc != LDAP_SUCCESS ) {
-#ifdef NEW_LOGGING
-                       LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
-                               "str2entry:  entry %ld has invalid dn: %s\n",
-                               (long) e->e_id, e->e_dn ));
-#else
-                       Debug( LDAP_DEBUG_ANY,
-                               "str2entry: entry %ld has invalid dn: %s\n",
-                           (long) e->e_id, e->e_dn, 0 );
-#endif
-                       entry_free( e );
-                       return NULL;
-               }
-
-               e->e_nname = *ndn;
-               free( ndn );
-       }
-
 #ifdef NEW_LOGGING
        LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL2,
                "str2entry(%s) -> 0x%lx\n", e->e_dn, (unsigned long)e ));
index 7b337c889461d9e2817742f985174912113b0e08..38f5952c0a38ad0d5fd6024ad0bb37360ace18f4 100644 (file)
@@ -34,8 +34,8 @@ do_modify(
     Operation  *op )
 {
        struct berval dn = { 0, NULL };
-       struct berval *pdn = NULL;
-       struct berval *ndn = NULL;
+       struct berval pdn = { 0, NULL };
+       struct berval ndn = { 0, NULL };
        char            *last;
        ber_tag_t       tag;
        ber_len_t       len;
@@ -177,7 +177,7 @@ do_modify(
                goto cleanup;
        }
 
-       rc = dnPretty( NULL, &dn, &pdn );
+       rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn );
        if( rc != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
@@ -192,22 +192,7 @@ do_modify(
                goto cleanup;
        }
 
-       rc = dnNormalize( NULL, &dn, &ndn );
-       if( rc != LDAP_SUCCESS ) {
-#ifdef NEW_LOGGING
-               LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
-                       "do_modify: conn %d  invalid dn (%s)\n",
-                       conn->c_connid, dn.bv_val ));
-#else
-               Debug( LDAP_DEBUG_ANY,
-                       "do_modify: invalid dn (%s)\n", dn.bv_val, 0, 0 );
-#endif
-               send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
-                   "invalid DN", NULL, NULL );
-               goto cleanup;
-       }
-
-       if( ndn->bv_len == 0 ) {
+       if( ndn.bv_len == 0 ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
                        "do_modify: attempt to modify root DSE.\n" ));
@@ -220,7 +205,7 @@ do_modify(
                goto cleanup;
 
 #if defined( SLAPD_SCHEMA_DN )
-       } else if ( strcasecmp( ndn->bv_val, SLAPD_SCHEMA_DN ) == 0 ) {
+       } else if ( strcasecmp( ndn.bv_val, SLAPD_SCHEMA_DN ) == 0 ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
                        "do_modify: attempt to modify subschema subentry.\n" ));
@@ -297,9 +282,9 @@ do_modify(
         * appropriate one, or send a referral to our "referral server"
         * if we don't hold it.
         */
-       if ( (be = select_backend( ndn, manageDSAit, 0 )) == NULL ) {
+       if ( (be = select_backend( &ndn, manageDSAit, 0 )) == NULL ) {
                struct berval **ref = referral_rewrite( default_referral,
-                       NULL, pdn, LDAP_SCOPE_DEFAULT );
+                       NULL, &pdn, LDAP_SCOPE_DEFAULT );
 
                send_ldap_result( conn, op, rc = LDAP_REFERRAL,
                        NULL, NULL, ref ? ref : default_referral, NULL );
@@ -317,13 +302,13 @@ do_modify(
        }
 
        /* check for referrals */
-       rc = backend_check_referrals( be, conn, op, pdn, ndn );
+       rc = backend_check_referrals( be, conn, op, &pdn, &ndn );
        if ( rc != LDAP_SUCCESS ) {
                goto cleanup;
        }
 
        /* deref suffix alias if appropriate */
-       suffix_alias( be, ndn );
+       suffix_alias( be, &ndn );
 
        /*
         * do the modify if 1 && (2 || 3)
@@ -376,13 +361,13 @@ do_modify(
                                }
                        }
 
-                       if ( (*be->be_modify)( be, conn, op, pdn, ndn, mods ) == 0
+                       if ( (*be->be_modify)( be, conn, op, &pdn, &ndn, mods ) == 0
 #ifdef SLAPD_MULTIMASTER
                                && !repl_user
 #endif
                        ) {
                                /* but we log only the ones not from a replicator user */
-                               replog( be, op, pdn, ndn, mods );
+                               replog( be, op, &pdn, &ndn, mods );
                        }
 
 #ifndef SLAPD_MULTIMASTER
@@ -391,7 +376,7 @@ do_modify(
                        struct berval **defref = be->be_update_refs
                                ? be->be_update_refs : default_referral;
                        struct berval **ref = referral_rewrite( defref,
-                               NULL, pdn, LDAP_SCOPE_DEFAULT );
+                               NULL, &pdn, LDAP_SCOPE_DEFAULT );
 
                        send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL,
                                ref ? ref : defref, NULL );
@@ -407,8 +392,8 @@ do_modify(
 
 cleanup:
        free( dn.bv_val );
-       if( pdn != NULL ) ber_bvfree( pdn );
-       if( ndn != NULL ) ber_bvfree( ndn );
+       free( pdn.bv_val );
+       free( ndn.bv_val );
        if ( modlist != NULL )
                slap_modlist_free( modlist );
        if ( mods != NULL )
index e5a9de9bb529f283f47cab4f3623d57b8c517cc4..628f68497f2b992db9d992977432dc83dbae0678 100644 (file)
@@ -49,13 +49,13 @@ do_modrdn(
        struct berval newSuperior = { 0, NULL };
        ber_int_t       deloldrdn;
 
-       struct berval *pdn = NULL;
-       struct berval *pnewrdn = NULL;
-       struct berval *pnewSuperior = NULL;
+       struct berval pdn = { 0, NULL };
+       struct berval pnewrdn = { 0, NULL };
+       struct berval pnewSuperior = { 0, NULL };
 
-       struct berval *ndn = NULL;
-       struct berval *nnewrdn = NULL;
-       struct berval *nnewSuperior = NULL;
+       struct berval ndn = { 0, NULL };
+       struct berval nnewrdn = { 0, NULL };
+       struct berval nnewSuperior = { 0, NULL };
 
        Backend *be;
        Backend *newSuperior_be = NULL;
@@ -176,7 +176,7 @@ do_modrdn(
                goto cleanup;
        } 
 
-       rc = dnPretty( NULL, &dn, &pdn );
+       rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn );
        if( rc != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
@@ -191,22 +191,7 @@ do_modrdn(
                goto cleanup;
        }
 
-       rc = dnNormalize( NULL, &dn, &ndn );
-       if( rc != LDAP_SUCCESS ) {
-#ifdef NEW_LOGGING
-               LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
-                       "do_modrdn: conn %d  invalid dn (%s)\n",
-                       conn->c_connid, pdn->bv_val ));
-#else
-               Debug( LDAP_DEBUG_ANY,
-                       "do_modrdn: invalid dn (%s)\n", pdn->bv_val, 0, 0 );
-#endif
-               send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
-                   "invalid DN", NULL, NULL );
-               goto cleanup;
-       }
-
-       if( ndn->bv_len == 0 ) {
+       if( ndn.bv_len == 0 ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
                           "do_modrdn:  attempt to modify root DSE.\n" ));
@@ -219,7 +204,7 @@ do_modrdn(
                goto cleanup;
 
 #ifdef SLAPD_SCHEMA_DN
-       } else if ( strcasecmp( ndn->bv_val, SLAPD_SCHEMA_DN ) == 0 ) {
+       } else if ( strcasecmp( ndn.bv_val, SLAPD_SCHEMA_DN ) == 0 ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
                        "do_modrdn: attempt to modify subschema subentry\n" ));
@@ -235,7 +220,7 @@ do_modrdn(
 
        /* FIXME: should have/use rdnPretty / rdnNormalize routines */
 
-       rc = dnPretty( NULL, &newrdn, &pnewrdn );
+       rc = dnPrettyNormal( NULL, &newrdn, &pnewrdn, &nnewrdn );
        if( rc != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
@@ -250,28 +235,13 @@ do_modrdn(
                goto cleanup;
        }
 
-       rc = dnNormalize( NULL, &newrdn, &nnewrdn );
-       if( rc != LDAP_SUCCESS ) {
-#ifdef NEW_LOGGING
-               LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
-                       "do_modrdn: conn %d  invalid newrdn (%s)\n",
-                       conn->c_connid, pnewrdn->bv_val ));
-#else
-               Debug( LDAP_DEBUG_ANY,
-                       "do_modrdn: invalid newrdn (%s)\n", pnewrdn->bv_val, 0, 0 );
-#endif
-               send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
-                   "invalid new RDN", NULL, NULL );
-               goto cleanup;
-       }
-
-       if( rdnValidate( pnewrdn ) != LDAP_SUCCESS ) {
+       if( rdnValidate( &pnewrdn ) != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
-                       "do_modrdn: invalid rdn (%s).\n", pnewrdn->bv_val ));
+                       "do_modrdn: invalid rdn (%s).\n", pnewrdn.bv_val ));
 #else
                Debug( LDAP_DEBUG_ANY, "do_modrdn: invalid rdn (%s)\n",
-                       pnewrdn->bv_val, 0, 0 );
+                       pnewrdn.bv_val, 0, 0 );
 #endif
 
                send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
@@ -280,7 +250,8 @@ do_modrdn(
        }
 
        if( newSuperior.bv_len ) {
-               rc = dnPretty( NULL, &newSuperior, &pnewSuperior );
+               rc = dnPrettyNormal( NULL, &newSuperior, &pnewSuperior,
+                       &nnewSuperior );
                if( rc != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
@@ -290,22 +261,6 @@ do_modrdn(
                        Debug( LDAP_DEBUG_ANY,
                                "do_modrdn: invalid newSuperior (%s)\n",
                                newSuperior.bv_val, 0, 0 );
-#endif
-                       send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
-                               "invalid newSuperior", NULL, NULL );
-                       goto cleanup;
-               }
-
-               rc = dnNormalize( NULL, &newSuperior, &nnewSuperior );
-               if( rc != LDAP_SUCCESS ) {
-#ifdef NEW_LOGGING
-                       LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
-                               "do_modrdn: conn %d  invalid newSuperior (%s)\n",
-                               conn->c_connid, pnewSuperior->bv_val ));
-#else
-                       Debug( LDAP_DEBUG_ANY,
-                               "do_modrdn: invalid newSuperior (%s)\n",
-                               pnewSuperior->bv_val, 0, 0 );
 #endif
                        send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
                                "invalid newSuperior", NULL, NULL );
@@ -314,7 +269,7 @@ do_modrdn(
        }
 
        Statslog( LDAP_DEBUG_STATS, "conn=%ld op=%d MODRDN dn=\"%s\"\n",
-           op->o_connid, op->o_opid, pdn->bv_val, 0, 0 );
+           op->o_connid, op->o_opid, pdn.bv_val, 0, 0 );
 
        manageDSAit = get_manageDSAit( op );
 
@@ -323,9 +278,9 @@ do_modrdn(
         * appropriate one, or send a referral to our "referral server"
         * if we don't hold it.
         */
-       if ( (be = select_backend( ndn, manageDSAit, 0 )) == NULL ) {
+       if ( (be = select_backend( &ndn, manageDSAit, 0 )) == NULL ) {
                struct berval **ref = referral_rewrite( default_referral,
-                       NULL, pdn, LDAP_SCOPE_DEFAULT );
+                       NULL, &pdn, LDAP_SCOPE_DEFAULT );
 
                send_ldap_result( conn, op, rc = LDAP_REFERRAL,
                        NULL, NULL, ref ? ref : default_referral, NULL );
@@ -343,7 +298,7 @@ do_modrdn(
        }
 
        /* check for referrals */
-       rc = backend_check_referrals( be, conn, op, pdn, ndn );
+       rc = backend_check_referrals( be, conn, op, &pdn, &ndn );
        if ( rc != LDAP_SUCCESS ) {
                goto cleanup;
        }
@@ -352,7 +307,7 @@ do_modrdn(
         * the same backend, otherwise we return an error.
         */
        if( newSuperior.bv_len ) {
-               newSuperior_be = select_backend( nnewSuperior, 0, 0 );
+               newSuperior_be = select_backend( &nnewSuperior, 0, 0 );
 
                if ( newSuperior_be != be ) {
                        /* newSuperior is in same backend */
@@ -365,11 +320,11 @@ do_modrdn(
                }
 
                /* deref suffix alias if appropriate */
-               suffix_alias( be, nnewSuperior );
+               suffix_alias( be, &nnewSuperior );
        }
 
        /* deref suffix alias if appropriate */
-       suffix_alias( be, ndn );
+       suffix_alias( be, &ndn );
 
        /*
         * do the add if 1 && (2 || 3)
@@ -384,26 +339,26 @@ do_modrdn(
                if ( !be->be_update_ndn.bv_len || repl_user )
 #endif
                {
-                       if ( (*be->be_modrdn)( be, conn, op, pdn, ndn,
-                               pnewrdn, nnewrdn, deloldrdn,
-                               pnewSuperior, nnewSuperior ) == 0
+                       if ( (*be->be_modrdn)( be, conn, op, &pdn, &ndn,
+                               &pnewrdn, &nnewrdn, deloldrdn,
+                               &pnewSuperior, &nnewSuperior ) == 0
 #ifdef SLAPD_MULTIMASTER
                                && ( !be->be_update_ndn.bv_len || !repl_user )
 #endif
                        ) {
                                struct slap_replog_moddn moddn;
-                               moddn.newrdn = pnewrdn;
+                               moddn.newrdn = &pnewrdn;
                                moddn.deloldrdn = deloldrdn;
-                               moddn.newsup = pnewSuperior;
+                               moddn.newsup = &pnewSuperior;
 
-                               replog( be, op, pdn, ndn, &moddn );
+                               replog( be, op, &pdn, &ndn, &moddn );
                        }
 #ifndef SLAPD_MULTIMASTER
                } else {
                        struct berval **defref = be->be_update_refs
                                ? be->be_update_refs : default_referral;
                        struct berval **ref = referral_rewrite( defref,
-                               NULL, pdn, LDAP_SCOPE_DEFAULT );
+                               NULL, &pdn, LDAP_SCOPE_DEFAULT );
 
                        send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL,
                                ref ? ref : defref, NULL );
@@ -419,16 +374,16 @@ do_modrdn(
 
 cleanup:
        free( dn.bv_val );
-       if( pdn != NULL ) ber_bvfree( pdn );
-       if( ndn != NULL ) ber_bvfree( ndn );
+       free( pdn.bv_val );
+       free( ndn.bv_val );
 
        free( newrdn.bv_val );  
-       if( pnewrdn != NULL ) ber_bvfree( pnewrdn );
-       if( nnewrdn != NULL ) ber_bvfree( nnewrdn );
+       free( pnewrdn.bv_val ); 
+       free( nnewrdn.bv_val ); 
 
        free( newSuperior.bv_val );
-       if ( pnewSuperior != NULL ) ber_bvfree( pnewSuperior );
-       if ( nnewSuperior != NULL ) ber_bvfree( nnewSuperior );
+       free( pnewSuperior.bv_val );
+       free( nnewSuperior.bv_val );
 
        return rc;
 }