]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/modify.c
ITS#1716 is_entry_subentr/ies/y/
[openldap] / servers / slapd / modify.c
index 543594a5d2fb68758a6d07243db1270ae88b5222..62a6a6da30923e25208f619afaf15711e9b7ecf8 100644 (file)
@@ -1,6 +1,6 @@
 /* $OpenLDAP$ */
 /*
- * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 /*
@@ -75,7 +75,7 @@ do_modify(
         *      }
         */
 
-       if ( ber_scanf( op->o_ber, "{o" /*}*/, &dn ) == LBER_ERROR ) {
+       if ( ber_scanf( op->o_ber, "{m" /*}*/, &dn ) == LBER_ERROR ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
                        "do_modify: ber_scanf failed\n" ));
@@ -106,7 +106,7 @@ do_modify(
                Modifications tmp, *mod;
 
 
-               if ( ber_scanf( op->o_ber, "{i{o[W]}}", &mop,
+               if ( ber_scanf( op->o_ber, "{i{m[W]}}", &mop,
                    &tmp.sml_type, &tmp.sml_bvalues )
                    == LBER_ERROR )
                {
@@ -116,13 +116,12 @@ do_modify(
                        goto cleanup;
                }
 
-               mod = (Modifications *) ch_malloc( sizeof(Modifications) 
-                       + tmp.sml_type.bv_len + 1);
-               mod->sml_type.bv_val = (char *)(mod+1);
-               strcpy(mod->sml_type.bv_val, tmp.sml_type.bv_val);
-               mod->sml_type.bv_len = tmp.sml_type.bv_len;
+               mod = (Modifications *) ch_malloc( sizeof(Modifications) );
+               mod->sml_op = mop;
+               mod->sml_type = tmp.sml_type;
                mod->sml_bvalues = tmp.sml_bvalues;
                mod->sml_desc = NULL;
+               mod->sml_next =NULL;
                *modtail = mod;
 
                switch( mop ) {
@@ -169,7 +168,6 @@ do_modify(
                        }
                }
 
-               mod->sml_op = mop;
                modtail = &mod->sml_next;
        }
        *modtail = NULL;
@@ -291,13 +289,13 @@ do_modify(
         * if we don't hold it.
         */
        if ( (be = select_backend( &ndn, manageDSAit, 0 )) == NULL ) {
-               BVarray ref = referral_rewrite( default_referral,
+               BerVarray ref = referral_rewrite( default_referral,
                        NULL, &pdn, LDAP_SCOPE_DEFAULT );
 
                send_ldap_result( conn, op, rc = LDAP_REFERRAL,
                        NULL, NULL, ref ? ref : default_referral, NULL );
 
-               bvarray_free( ref );
+               ber_bvarray_free( ref );
                goto cleanup;
        }
 
@@ -348,9 +346,7 @@ do_modify(
                                goto cleanup;
                        }
 
-                       if ( (be->be_lastmod == ON || (be->be_lastmod == UNDEFINED &&
-                               global_lastmod == ON)) && !repl_user )
-                       {
+                       if ( SLAP_LASTMOD(be) && !repl_user ) {
                                for( modtail = &modlist;
                                        *modtail != NULL;
                                        modtail = &(*modtail)->sml_next )
@@ -380,15 +376,15 @@ do_modify(
 #ifndef SLAPD_MULTIMASTER
                /* send a referral */
                } else {
-                       BVarray defref = be->be_update_refs
+                       BerVarray defref = be->be_update_refs
                                ? be->be_update_refs : default_referral;
-                       BVarray ref = referral_rewrite( defref,
+                       BerVarray ref = referral_rewrite( defref,
                                NULL, &pdn, LDAP_SCOPE_DEFAULT );
 
                        send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL,
                                ref ? ref : defref, NULL );
 
-                       bvarray_free( ref );
+                       ber_bvarray_free( ref );
 #endif
                }
        } else {
@@ -398,7 +394,6 @@ do_modify(
        }
 
 cleanup:
-       free( dn.bv_val );
        free( pdn.bv_val );
        free( ndn.bv_val );
        if ( modlist != NULL )
@@ -455,6 +450,15 @@ int slap_mods_check(
                        return LDAP_UNDEFINED_TYPE;
                }
 
+               if( slap_ad_is_lang_range( ad )) {
+                       /* attribute requires binary transfer */
+                       snprintf( textbuf, textlen,
+                               "%s: inappropriate use of language range option",
+                               ml->sml_type.bv_val );
+                       *text = textbuf;
+                       return LDAP_UNDEFINED_TYPE;
+               }
+
                if (!update && is_at_no_user_mod( ad->ad_type )) {
                        /* user modification disallowed */
                        snprintf( textbuf, textlen,
@@ -595,8 +599,9 @@ int slap_mods_opattrs(
                if ( tmpval.bv_len ) {
                        mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
                        mod->sml_op = mop;
+                       mod->sml_type.bv_val = NULL;
                        mod->sml_desc = slap_schema.si_ad_structuralObjectClass;
-                       mod->sml_bvalues = (BVarray) ch_malloc( 2 * sizeof( struct berval ) );
+                       mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
                        ber_dupbv( &mod->sml_bvalues[0], &tmpval );
                        mod->sml_bvalues[1].bv_val = NULL;
                        assert( mod->sml_bvalues[0].bv_val );
@@ -609,8 +614,9 @@ int slap_mods_opattrs(
                
                mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
                mod->sml_op = mop;
+               mod->sml_type.bv_val = NULL;
                mod->sml_desc = slap_schema.si_ad_entryUUID;
-               mod->sml_bvalues = (BVarray) ch_malloc( 2 * sizeof( struct berval ) );
+               mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
                ber_dupbv( &mod->sml_bvalues[0], &tmpval );
                mod->sml_bvalues[1].bv_val = NULL;
                assert( mod->sml_bvalues[0].bv_val );
@@ -619,8 +625,9 @@ int slap_mods_opattrs(
 
                mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
                mod->sml_op = mop;
+               mod->sml_type.bv_val = NULL;
                mod->sml_desc = slap_schema.si_ad_creatorsName;
-               mod->sml_bvalues = (BVarray) ch_malloc( 2 * sizeof( struct berval ) );
+               mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
                ber_dupbv( &mod->sml_bvalues[0], &name );
                mod->sml_bvalues[1].bv_val = NULL;
                assert( mod->sml_bvalues[0].bv_val );
@@ -629,8 +636,9 @@ int slap_mods_opattrs(
 
                mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
                mod->sml_op = mop;
+               mod->sml_type.bv_val = NULL;
                mod->sml_desc = slap_schema.si_ad_createTimestamp;
-               mod->sml_bvalues = (BVarray) ch_malloc( 2 * sizeof( struct berval ) );
+               mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
                ber_dupbv( &mod->sml_bvalues[0], &timestamp );
                mod->sml_bvalues[1].bv_val = NULL;
                assert( mod->sml_bvalues[0].bv_val );
@@ -640,8 +648,9 @@ int slap_mods_opattrs(
 
        mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
        mod->sml_op = mop;
+       mod->sml_type.bv_val = NULL;
        mod->sml_desc = slap_schema.si_ad_entryCSN;
-       mod->sml_bvalues = (BVarray) ch_malloc( 2 * sizeof( struct berval ) );
+       mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
        ber_dupbv( &mod->sml_bvalues[0], &csn );
        mod->sml_bvalues[1].bv_val = NULL;
        assert( mod->sml_bvalues[0].bv_val );
@@ -650,8 +659,9 @@ int slap_mods_opattrs(
 
        mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
        mod->sml_op = mop;
+       mod->sml_type.bv_val = NULL;
        mod->sml_desc = slap_schema.si_ad_modifiersName;
-       mod->sml_bvalues = (BVarray) ch_malloc( 2 * sizeof( struct berval ) );
+       mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
        ber_dupbv( &mod->sml_bvalues[0], &name );
        mod->sml_bvalues[1].bv_val = NULL;
        assert( mod->sml_bvalues[0].bv_val );
@@ -660,8 +670,9 @@ int slap_mods_opattrs(
 
        mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
        mod->sml_op = mop;
+       mod->sml_type.bv_val = NULL;
        mod->sml_desc = slap_schema.si_ad_modifyTimestamp;
-       mod->sml_bvalues = (BVarray) ch_malloc( 2 * sizeof( struct berval ) );
+       mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
        ber_dupbv( &mod->sml_bvalues[0], &timestamp );
        mod->sml_bvalues[1].bv_val = NULL;
        assert( mod->sml_bvalues[0].bv_val );