2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 1998-2004 The OpenLDAP Foundation.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted only as authorized by the OpenLDAP
11 * A copy of this license is available in the file LICENSE in the
12 * top-level directory of the distribution or, alternatively, at
13 * <http://www.OpenLDAP.org/license.html>.
15 /* Portions Copyright (c) 1995 Regents of the University of Michigan.
16 * All rights reserved.
18 * Redistribution and use in source and binary forms are permitted
19 * provided that this notice is preserved and that due credit is given
20 * to the University of Michigan at Ann Arbor. The name of the University
21 * may not be used to endorse or promote products derived from this
22 * software without specific prior written permission. This software
23 * is provided ``as is'' without express or implied warranty.
30 #include <ac/socket.h>
31 #include <ac/string.h>
37 #include "slapi/slapi.h"
47 struct berval dn = BER_BVNULL;
51 Modifications *modlist = NULL;
52 Modifications **modtail = &modlist;
55 Debug( LDAP_DEBUG_TRACE, "do_modify\n", 0, 0, 0 );
58 * Parse the modify request. It looks like this:
60 * ModifyRequest := [APPLICATION 6] SEQUENCE {
61 * name DistinguishedName,
62 * mods SEQUENCE OF SEQUENCE {
63 * operation ENUMERATED {
68 * modification SEQUENCE {
70 * values SET OF AttributeValue
76 if ( ber_scanf( op->o_ber, "{m" /*}*/, &dn ) == LBER_ERROR ) {
77 Debug( LDAP_DEBUG_ANY, "do_modify: ber_scanf failed\n", 0, 0, 0 );
79 send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR, "decoding error" );
80 return SLAPD_DISCONNECT;
83 Debug( LDAP_DEBUG_ARGS, "do_modify: dn (%s)\n", dn.bv_val, 0, 0 );
85 /* collect modifications & save for later */
86 for ( tag = ber_first_element( op->o_ber, &len, &last );
88 tag = ber_next_element( op->o_ber, &len, last ) )
91 Modifications tmp, *mod;
93 tmp.sml_nvalues = NULL;
95 if ( ber_scanf( op->o_ber, "{i{m[W]}}", &mop,
96 &tmp.sml_type, &tmp.sml_values ) == LBER_ERROR )
98 send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR,
99 "decoding modlist error" );
100 rs->sr_err = SLAPD_DISCONNECT;
104 mod = (Modifications *) ch_malloc( sizeof(Modifications) );
106 mod->sml_type = tmp.sml_type;
107 mod->sml_values = tmp.sml_values;
108 mod->sml_nvalues = NULL;
109 mod->sml_desc = NULL;
110 mod->sml_next = NULL;
115 if ( mod->sml_values == NULL ) {
116 Debug( LDAP_DEBUG_ANY,
117 "do_modify: modify/add operation (%ld) requires values\n",
120 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
121 "modify/add operation requires values" );
127 case LDAP_MOD_DELETE:
128 case LDAP_MOD_REPLACE:
131 case LDAP_MOD_INCREMENT:
132 if( op->o_protocol >= LDAP_VERSION3 ) {
134 if ( mod->sml_values == NULL ) {
135 Debug( LDAP_DEBUG_ANY, "do_modify: "
136 "modify/increment operation (%ld) requires value\n",
139 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
140 "modify/increment operation requires value" );
144 if( mod->sml_values[1].bv_val ) {
145 Debug( LDAP_DEBUG_ANY, "do_modify: modify/increment "
146 "operation (%ld) requires single value\n",
149 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
150 "modify/increment operation requires single value" );
159 Debug( LDAP_DEBUG_ANY,
160 "do_modify: unrecognized modify operation (%ld)\n",
163 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
164 "unrecognized modify operation" );
169 modtail = &mod->sml_next;
173 if( get_ctrls( op, rs, 1 ) != LDAP_SUCCESS ) {
174 Debug( LDAP_DEBUG_ANY, "do_modify: get_ctrls failed\n", 0, 0, 0 );
179 rs->sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn,
181 if( rs->sr_err != LDAP_SUCCESS ) {
182 Debug( LDAP_DEBUG_ANY,
183 "do_modify: invalid dn (%s)\n", dn.bv_val, 0, 0 );
184 send_ldap_error( op, rs, LDAP_INVALID_DN_SYNTAX, "invalid DN" );
188 /* FIXME: temporary */
189 op->orm_modlist = modlist;
190 op->orm_increment = increment;
192 op->o_bd = frontendDB;
193 rs->sr_err = frontendDB->be_modify( op, rs );
196 slap_graduate_commit_csn( op );
198 op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
199 op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
200 if ( modlist != NULL ) slap_mods_free( modlist );
206 fe_op_modify( Operation *op, SlapReply *rs )
212 Modifications *modlist = op->orm_modlist;
213 Modifications **modtail = &modlist;
215 LDAPMod **modv = NULL;
217 int increment = op->orm_increment;
219 if( op->o_req_ndn.bv_len == 0 ) {
220 Debug( LDAP_DEBUG_ANY, "do_modify: root dse!\n", 0, 0, 0 );
222 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
223 "modify upon the root DSE not supported" );
226 } else if ( bvmatch( &op->o_req_ndn, &frontendDB->be_schemandn ) ) {
227 Debug( LDAP_DEBUG_ANY, "do_modify: subschema subentry!\n", 0, 0, 0 );
229 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
230 "modification of subschema subentry not supported" );
235 Debug( LDAP_DEBUG_ARGS, "modifications:\n", 0, 0, 0 );
237 for ( tmp = modlist; tmp != NULL; tmp = tmp->sml_next ) {
238 Debug( LDAP_DEBUG_ARGS, "\t%s: %s\n",
239 tmp->sml_op == LDAP_MOD_ADD ? "add" :
240 (tmp->sml_op == LDAP_MOD_INCREMENT ? "increment" :
241 (tmp->sml_op == LDAP_MOD_DELETE ? "delete" :
242 "replace")), tmp->sml_type.bv_val, 0 );
244 if ( tmp->sml_values == NULL ) {
245 Debug( LDAP_DEBUG_ARGS, "%s\n",
246 "\t\tno values", NULL, NULL );
247 } else if ( tmp->sml_values[0].bv_val == NULL ) {
248 Debug( LDAP_DEBUG_ARGS, "%s\n",
249 "\t\tzero values", NULL, NULL );
250 } else if ( tmp->sml_values[1].bv_val == NULL ) {
251 Debug( LDAP_DEBUG_ARGS, "%s, length %ld\n",
252 "\t\tone value", (long) tmp->sml_values[0].bv_len, NULL );
254 Debug( LDAP_DEBUG_ARGS, "%s\n",
255 "\t\tmultiple values", NULL, NULL );
259 if ( StatslogTest( LDAP_DEBUG_STATS ) ) {
260 char abuf[BUFSIZ/2], *ptr = abuf;
263 Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu MOD dn=\"%s\"\n",
264 op->o_connid, op->o_opid, op->o_req_dn.bv_val, 0, 0 );
266 for ( tmp = modlist; tmp != NULL; tmp = tmp->sml_next ) {
267 if (len + 1 + tmp->sml_type.bv_len > sizeof(abuf)) {
268 Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu MOD attr=%s\n",
269 op->o_connid, op->o_opid, abuf, 0, 0 );
274 if( 1 + tmp->sml_type.bv_len > sizeof(abuf)) {
275 Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu MOD attr=%s\n",
276 op->o_connid, op->o_opid, tmp->sml_type.bv_val, 0, 0 );
284 ptr = lutil_strcopy(ptr, tmp->sml_type.bv_val);
285 len += tmp->sml_type.bv_len;
288 Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu MOD attr=%s\n",
289 op->o_connid, op->o_opid, abuf, 0, 0 );
292 #endif /* LDAP_DEBUG */
294 manageDSAit = get_manageDSAit( op );
297 * We could be serving multiple database backends. Select the
298 * appropriate one, or send a referral to our "referral server"
299 * if we don't hold it.
301 op->o_bd = select_backend( &op->o_req_ndn, manageDSAit, 0 );
302 if ( op->o_bd == NULL ) {
303 rs->sr_ref = referral_rewrite( default_referral,
304 NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
305 if (!rs->sr_ref) rs->sr_ref = default_referral;
307 if (rs->sr_ref != NULL ) {
308 rs->sr_err = LDAP_REFERRAL;
309 send_ldap_result( op, rs );
311 if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref );
313 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
314 "no global superior knowledge" );
319 /* check restrictions */
320 if( backend_check_restrictions( op, rs, NULL ) != LDAP_SUCCESS ) {
321 send_ldap_result( op, rs );
325 /* check for referrals */
326 if( backend_check_referrals( op, rs ) != LDAP_SUCCESS ) {
330 /* check for modify/increment support */
331 if( increment && !SLAP_INCREMENT( op->o_bd ) ) {
332 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
333 "modify/increment not supported in context" );
336 #if defined( LDAP_SLAPI )
339 slapi_int_pblock_set_operation( pb, op );
340 slapi_pblock_set( pb, SLAPI_MODIFY_TARGET, (void *)op->o_req_dn.bv_val );
341 slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit );
342 modv = slapi_int_modifications2ldapmods( &modlist );
343 slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)modv );
345 rs->sr_err = slapi_int_call_plugins( op->o_bd,
346 SLAPI_PLUGIN_PRE_MODIFY_FN, pb );
349 * It's possible that the preoperation plugin changed the
350 * modification array, so we need to convert it back to
351 * a Modification list.
353 * Calling slapi_int_modifications2ldapmods() destroyed modlist so
354 * we don't need to free it.
356 slapi_pblock_get( pb, SLAPI_MODIFY_MODS, (void **)&modv );
357 modlist = slapi_int_ldapmods2modifications( modv );
359 if ( rs->sr_err < 0 ) {
361 * A preoperation plugin failure will abort the
364 Debug(LDAP_DEBUG_TRACE,
365 "do_modify: modify preoperation plugin failed.\n",
367 if ( ( slapi_pblock_get( op->o_pb, SLAPI_RESULT_CODE,
368 (void *)&rs->sr_err ) != 0 ) || rs->sr_err == LDAP_SUCCESS )
370 rs->sr_err = LDAP_OTHER;
372 slapi_int_free_ldapmods( modv );
379 * NB: it is valid for the plugin to return no modifications
380 * (for example, a plugin might store some attributes elsewhere
381 * and remove them from the modification list; if only those
382 * attribute types were included in the modification request,
383 * then slapi_int_ldapmods2modifications() above will return
386 * However, the post-operation plugin should still be
389 #endif /* defined( LDAP_SLAPI ) */
392 * do the modify if 1 && (2 || 3)
393 * 1) there is a modify function implemented in this backend;
394 * 2) this backend is master for what it holds;
395 * 3) it's a replica and the dn supplied is the update_ndn.
397 if ( op->o_bd->be_modify ) {
398 /* do the update here */
399 int repl_user = be_isupdate( op );
401 /* Multimaster slapd does not have to check for replicator dn
402 * because it accepts each modify request
404 #ifndef SLAPD_MULTIMASTER
405 if ( !SLAP_SHADOW(op->o_bd) || repl_user )
408 int update = op->o_bd->be_update_ndn.bv_len;
409 char textbuf[SLAP_TEXT_BUFLEN];
410 size_t textlen = sizeof textbuf;
411 slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
413 rs->sr_err = slap_mods_check( modlist, update, &rs->sr_text,
414 textbuf, textlen, NULL );
416 if( rs->sr_err != LDAP_SUCCESS ) {
417 send_ldap_result( op, rs );
422 for( modtail = &modlist;
424 modtail = &(*modtail)->sml_next )
429 rs->sr_err = slap_mods_opattrs( op, modlist, modtail,
430 &rs->sr_text, textbuf, textlen, 1 );
431 if( rs->sr_err != LDAP_SUCCESS ) {
432 send_ldap_result( op, rs );
437 op->orm_modlist = modlist;
438 #ifdef SLAPD_MULTIMASTER
442 /* but we log only the ones not from a replicator user */
443 cb.sc_next = op->o_callback;
444 op->o_callback = &cb;
446 op->o_bd->be_modify( op, rs );
448 #ifndef SLAPD_MULTIMASTER
449 /* send a referral */
451 BerVarray defref = op->o_bd->be_update_refs
452 ? op->o_bd->be_update_refs : default_referral;
453 if ( defref != NULL ) {
454 rs->sr_ref = referral_rewrite( defref,
456 LDAP_SCOPE_DEFAULT );
457 if (!rs->sr_ref) rs->sr_ref = defref;
458 rs->sr_err = LDAP_REFERRAL;
459 send_ldap_result( op, rs );
460 if (rs->sr_ref != defref) {
461 ber_bvarray_free( rs->sr_ref );
464 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
465 "shadow context; no update referral" );
470 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
471 "operation not supported within namingContext" );
474 #if defined( LDAP_SLAPI )
475 if ( pb != NULL && slapi_int_call_plugins( op->o_bd,
476 SLAPI_PLUGIN_POST_MODIFY_FN, pb ) < 0 )
478 Debug(LDAP_DEBUG_TRACE,
479 "do_modify: modify postoperation plugins failed.\n", 0, 0, 0);
481 #endif /* defined( LDAP_SLAPI ) */
484 #if defined( LDAP_SLAPI )
485 if ( modv != NULL ) slapi_int_free_ldapmods( modv );
492 * Do basic attribute type checking and syntax validation.
504 for( ; ml != NULL; ml = ml->sml_next ) {
505 AttributeDescription *ad = NULL;
507 /* convert to attribute description */
508 rc = slap_bv2ad( &ml->sml_type, &ml->sml_desc, text );
510 if( rc != LDAP_SUCCESS ) {
511 snprintf( textbuf, textlen, "%s: %s",
512 ml->sml_type.bv_val, *text );
519 if( slap_syntax_is_binary( ad->ad_type->sat_syntax )
520 && !slap_ad_is_binary( ad ))
522 /* attribute requires binary transfer */
523 snprintf( textbuf, textlen,
524 "%s: requires ;binary transfer",
525 ml->sml_type.bv_val );
527 return LDAP_UNDEFINED_TYPE;
530 if( !slap_syntax_is_binary( ad->ad_type->sat_syntax )
531 && slap_ad_is_binary( ad ))
533 /* attribute does not require binary transfer */
534 snprintf( textbuf, textlen,
535 "%s: disallows ;binary transfer",
536 ml->sml_type.bv_val );
538 return LDAP_UNDEFINED_TYPE;
541 if( slap_ad_is_tag_range( ad )) {
542 /* attribute requires binary transfer */
543 snprintf( textbuf, textlen,
544 "%s: inappropriate use of tag range option",
545 ml->sml_type.bv_val );
547 return LDAP_UNDEFINED_TYPE;
550 if (!update && is_at_no_user_mod( ad->ad_type )) {
551 /* user modification disallowed */
552 snprintf( textbuf, textlen,
553 "%s: no user modification allowed",
554 ml->sml_type.bv_val );
556 return LDAP_CONSTRAINT_VIOLATION;
559 if ( is_at_obsolete( ad->ad_type ) &&
560 (( ml->sml_op != LDAP_MOD_REPLACE &&
561 ml->sml_op != LDAP_MOD_DELETE ) ||
562 ml->sml_values != NULL ))
565 * attribute is obsolete,
566 * only allow replace/delete with no values
568 snprintf( textbuf, textlen,
569 "%s: attribute is obsolete",
570 ml->sml_type.bv_val );
572 return LDAP_CONSTRAINT_VIOLATION;
575 if ( ml->sml_op == LDAP_MOD_INCREMENT &&
576 #ifdef SLAPD_REAL_SYNTAX
577 !is_at_syntax( ad->ad_type, SLAPD_REAL_SYNTAX ) &&
579 !is_at_syntax( ad->ad_type, SLAPD_INTEGER_SYNTAX ) )
582 * attribute values must be INTEGER or REAL
584 snprintf( textbuf, textlen,
585 "%s: attribute syntax inappropriate for increment",
586 ml->sml_type.bv_val );
588 return LDAP_CONSTRAINT_VIOLATION;
594 if( ml->sml_values != NULL ) {
596 slap_syntax_validate_func *validate =
597 ad->ad_type->sat_syntax->ssyn_validate;
598 slap_syntax_transform_func *pretty =
599 ad->ad_type->sat_syntax->ssyn_pretty;
601 if( !pretty && !validate ) {
602 *text = "no validator for syntax";
603 snprintf( textbuf, textlen,
604 "%s: no validator for syntax %s",
606 ad->ad_type->sat_syntax->ssyn_oid );
608 return LDAP_INVALID_SYNTAX;
612 * check that each value is valid per syntax
613 * and pretty if appropriate
615 for( nvals = 0; ml->sml_values[nvals].bv_val; nvals++ ) {
618 rc = pretty( ad->ad_type->sat_syntax,
619 &ml->sml_values[nvals], &pval, ctx );
621 rc = validate( ad->ad_type->sat_syntax,
622 &ml->sml_values[nvals] );
626 snprintf( textbuf, textlen,
627 "%s: value #%ld invalid per syntax",
628 ml->sml_type.bv_val, (long) nvals );
630 return LDAP_INVALID_SYNTAX;
634 ber_memfree_x( ml->sml_values[nvals].bv_val, ctx );
635 ml->sml_values[nvals] = pval;
640 * a rough single value check... an additional check is needed
641 * to catch add of single value to existing single valued attribute
643 if ((ml->sml_op == LDAP_MOD_ADD || ml->sml_op == LDAP_MOD_REPLACE)
644 && nvals > 1 && is_at_single_value( ad->ad_type ))
646 snprintf( textbuf, textlen,
647 "%s: multiple values provided",
648 ml->sml_type.bv_val );
650 return LDAP_CONSTRAINT_VIOLATION;
653 /* if the type has a normalizer, generate the
654 * normalized values. otherwise leave them NULL.
656 * this is different from the rule for attributes
657 * in an entry - in an attribute list, the normalized
658 * value is set equal to the non-normalized value
659 * when there is no normalizer.
661 if( nvals && ad->ad_type->sat_equality &&
662 ad->ad_type->sat_equality->smr_normalize )
664 ml->sml_nvalues = ber_memalloc_x(
665 (nvals+1)*sizeof(struct berval), ctx );
667 for( nvals = 0; ml->sml_values[nvals].bv_val; nvals++ ) {
668 rc = ad->ad_type->sat_equality->smr_normalize(
669 SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
670 ad->ad_type->sat_syntax,
671 ad->ad_type->sat_equality,
672 &ml->sml_values[nvals], &ml->sml_nvalues[nvals], ctx );
674 Debug( LDAP_DEBUG_ANY,
675 "<= str2entry NULL (ssyn_normalize %d)\n",
677 snprintf( textbuf, textlen,
678 "%s: value #%ld normalization failed",
679 ml->sml_type.bv_val, (long) nvals );
685 ml->sml_nvalues[nvals].bv_val = NULL;
686 ml->sml_nvalues[nvals].bv_len = 0;
690 /* check for duplicates */
692 MatchingRule *mr = ad->ad_type->sat_equality;
694 /* check if the values we're adding already exist */
695 if( mr == NULL || !mr->smr_match ) {
696 for ( i = 1; ml->sml_values[i].bv_val != NULL; i++ ) {
697 /* test asserted values against themselves */
698 for( j = 0; j < i; j++ ) {
699 if ( bvmatch( &ml->sml_values[i],
700 &ml->sml_values[j] ) )
702 /* value exists already */
703 snprintf( textbuf, textlen,
704 "%s: value #%d provided more than once",
705 ml->sml_desc->ad_cname.bv_val, j );
707 return LDAP_TYPE_OR_VALUE_EXISTS;
716 for ( i = 1; ml->sml_values[i].bv_val != NULL; i++ ) {
717 /* test asserted values against themselves */
718 for( j = 0; j < i; j++ ) {
719 rc = value_match( &match, ml->sml_desc, mr,
721 | SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX
722 | SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH
723 | SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH,
725 ? &ml->sml_nvalues[i]
726 : &ml->sml_values[i],
728 ? &ml->sml_nvalues[j]
729 : &ml->sml_values[j],
731 if ( rc == LDAP_SUCCESS && match == 0 ) {
732 /* value exists already */
733 snprintf( textbuf, textlen,
734 "%s: value #%d provided more than once",
735 ml->sml_desc->ad_cname.bv_val, j );
737 return LDAP_TYPE_OR_VALUE_EXISTS;
739 } else if ( rc != LDAP_SUCCESS ) {
753 int slap_mods_opattrs(
756 Modifications **modtail,
758 char *textbuf, size_t textlen,
761 struct berval name, timestamp, csn;
763 char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
764 char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
767 int mop = op->o_tag == LDAP_REQ_ADD
768 ? LDAP_MOD_ADD : LDAP_MOD_REPLACE;
770 assert( modtail != NULL );
771 assert( *modtail == NULL );
773 if ( SLAP_LASTMOD( op->o_bd )) {
778 time_t now = slap_get_time();
781 ltm = gmtime_r( &now, <m_buf );
783 ldap_pvt_thread_mutex_lock( &gmtime_mutex );
784 ltm = gmtime( &now );
785 #endif /* HAVE_GMTIME_R */
786 lutil_gentime( timebuf, sizeof(timebuf), ltm );
788 slap_get_csn( op, csnbuf, sizeof(csnbuf), &csn, manage_ctxcsn );
790 #ifndef HAVE_GMTIME_R
791 ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
794 timestamp.bv_val = timebuf;
795 timestamp.bv_len = strlen(timebuf);
797 if( op->o_dn.bv_len == 0 ) {
798 BER_BVSTR( &name, SLAPD_ANONYMOUS );
806 if( op->o_tag == LDAP_REQ_ADD ) {
807 struct berval tmpval;
809 if( global_schemacheck ) {
810 int rc = mods_structural_class( mods, &tmpval,
811 text, textbuf, textlen );
812 if( rc != LDAP_SUCCESS ) return rc;
814 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
816 mod->sml_type.bv_val = NULL;
817 mod->sml_desc = slap_schema.si_ad_structuralObjectClass;
819 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
820 ber_dupbv( &mod->sml_values[0], &tmpval );
821 mod->sml_values[1].bv_len = 0;
822 mod->sml_values[1].bv_val = NULL;
823 assert( mod->sml_values[0].bv_val );
825 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
826 ber_dupbv( &mod->sml_nvalues[0], &tmpval );
827 mod->sml_nvalues[1].bv_len = 0;
828 mod->sml_nvalues[1].bv_val = NULL;
829 assert( mod->sml_nvalues[0].bv_val );
831 modtail = &mod->sml_next;
834 if ( SLAP_LASTMOD( op->o_bd )) {
835 char uuidbuf[ LDAP_LUTIL_UUIDSTR_BUFSIZE ];
837 tmpval.bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) );
838 tmpval.bv_val = uuidbuf;
840 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
842 mod->sml_type.bv_val = NULL;
843 mod->sml_desc = slap_schema.si_ad_entryUUID;
845 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
846 ber_dupbv( &mod->sml_values[0], &tmpval );
847 mod->sml_values[1].bv_len = 0;
848 mod->sml_values[1].bv_val = NULL;
849 assert( mod->sml_values[0].bv_val );
851 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
852 (*mod->sml_desc->ad_type->sat_equality->smr_normalize)(
853 SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
854 mod->sml_desc->ad_type->sat_syntax,
855 mod->sml_desc->ad_type->sat_equality,
856 mod->sml_values, mod->sml_nvalues, NULL );
857 mod->sml_nvalues[1].bv_len = 0;
858 mod->sml_nvalues[1].bv_val = NULL;
860 modtail = &mod->sml_next;
862 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
864 mod->sml_type.bv_val = NULL;
865 mod->sml_desc = slap_schema.si_ad_creatorsName;
867 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
868 ber_dupbv( &mod->sml_values[0], &name );
869 mod->sml_values[1].bv_len = 0;
870 mod->sml_values[1].bv_val = NULL;
871 assert( mod->sml_values[0].bv_val );
873 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
874 ber_dupbv( &mod->sml_nvalues[0], &nname );
875 mod->sml_nvalues[1].bv_len = 0;
876 mod->sml_nvalues[1].bv_val = NULL;
877 assert( mod->sml_nvalues[0].bv_val );
879 modtail = &mod->sml_next;
881 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
883 mod->sml_type.bv_val = NULL;
884 mod->sml_desc = slap_schema.si_ad_createTimestamp;
886 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
887 ber_dupbv( &mod->sml_values[0], ×tamp );
888 mod->sml_values[1].bv_len = 0;
889 mod->sml_values[1].bv_val = NULL;
890 assert( mod->sml_values[0].bv_val );
891 mod->sml_nvalues = NULL;
893 modtail = &mod->sml_next;
897 if ( SLAP_LASTMOD( op->o_bd )) {
898 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
900 mod->sml_type.bv_val = NULL;
901 mod->sml_desc = slap_schema.si_ad_entryCSN;
902 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
903 ber_dupbv( &mod->sml_values[0], &csn );
904 mod->sml_values[1].bv_len = 0;
905 mod->sml_values[1].bv_val = NULL;
906 assert( mod->sml_values[0].bv_val );
907 mod->sml_nvalues = NULL;
909 modtail = &mod->sml_next;
911 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
913 mod->sml_type.bv_val = NULL;
914 mod->sml_desc = slap_schema.si_ad_modifiersName;
915 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
916 ber_dupbv( &mod->sml_values[0], &name );
917 mod->sml_values[1].bv_len = 0;
918 mod->sml_values[1].bv_val = NULL;
919 assert( mod->sml_values[0].bv_val );
921 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
922 ber_dupbv( &mod->sml_nvalues[0], &nname );
923 mod->sml_nvalues[1].bv_len = 0;
924 mod->sml_nvalues[1].bv_val = NULL;
925 assert( mod->sml_nvalues[0].bv_val );
927 modtail = &mod->sml_next;
929 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
931 mod->sml_type.bv_val = NULL;
932 mod->sml_desc = slap_schema.si_ad_modifyTimestamp;
933 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
934 ber_dupbv( &mod->sml_values[0], ×tamp );
935 mod->sml_values[1].bv_len = 0;
936 mod->sml_values[1].bv_val = NULL;
937 assert( mod->sml_values[0].bv_val );
938 mod->sml_nvalues = NULL;
940 modtail = &mod->sml_next;