2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 1998-2005 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>
43 struct berval dn = BER_BVNULL;
47 Modifications *modlist = NULL;
48 Modifications **modtail = &modlist;
50 char textbuf[ SLAP_TEXT_BUFLEN ];
51 size_t textlen = sizeof( textbuf );
53 Debug( LDAP_DEBUG_TRACE, "do_modify\n", 0, 0, 0 );
56 * Parse the modify request. It looks like this:
58 * ModifyRequest := [APPLICATION 6] SEQUENCE {
59 * name DistinguishedName,
60 * mods SEQUENCE OF SEQUENCE {
61 * operation ENUMERATED {
66 * modification SEQUENCE {
68 * values SET OF AttributeValue
74 if ( ber_scanf( op->o_ber, "{m" /*}*/, &dn ) == LBER_ERROR ) {
75 Debug( LDAP_DEBUG_ANY, "do_modify: ber_scanf failed\n", 0, 0, 0 );
77 send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR, "decoding error" );
78 return SLAPD_DISCONNECT;
81 Debug( LDAP_DEBUG_ARGS, "do_modify: dn (%s)\n", dn.bv_val, 0, 0 );
83 /* collect modifications & save for later */
84 for ( tag = ber_first_element( op->o_ber, &len, &last );
86 tag = ber_next_element( op->o_ber, &len, last ) )
89 Modifications tmp, *mod;
91 tmp.sml_nvalues = NULL;
93 if ( ber_scanf( op->o_ber, "{i{m[W]}}", &mop,
94 &tmp.sml_type, &tmp.sml_values ) == LBER_ERROR )
96 send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR,
97 "decoding modlist error" );
98 rs->sr_err = SLAPD_DISCONNECT;
102 mod = (Modifications *) ch_malloc( sizeof(Modifications) );
105 mod->sml_type = tmp.sml_type;
106 mod->sml_values = tmp.sml_values;
107 mod->sml_nvalues = NULL;
108 mod->sml_desc = NULL;
109 mod->sml_next = NULL;
114 if ( mod->sml_values == NULL ) {
115 Debug( LDAP_DEBUG_ANY,
116 "do_modify: modify/add operation (%ld) requires values\n",
119 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
120 "modify/add operation requires values" );
126 case LDAP_MOD_DELETE:
127 case LDAP_MOD_REPLACE:
130 case LDAP_MOD_INCREMENT:
131 if( op->o_protocol >= LDAP_VERSION3 ) {
133 if ( mod->sml_values == NULL ) {
134 Debug( LDAP_DEBUG_ANY, "do_modify: "
135 "modify/increment operation (%ld) requires value\n",
138 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
139 "modify/increment operation requires value" );
143 if( mod->sml_values[1].bv_val ) {
144 Debug( LDAP_DEBUG_ANY, "do_modify: modify/increment "
145 "operation (%ld) requires single value\n",
148 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
149 "modify/increment operation requires single value" );
158 Debug( LDAP_DEBUG_ANY,
159 "do_modify: unrecognized modify operation (%ld)\n",
162 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
163 "unrecognized modify operation" );
168 modtail = &mod->sml_next;
172 if( get_ctrls( op, rs, 1 ) != LDAP_SUCCESS ) {
173 Debug( LDAP_DEBUG_ANY, "do_modify: get_ctrls failed\n", 0, 0, 0 );
178 rs->sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn,
180 if( rs->sr_err != LDAP_SUCCESS ) {
181 Debug( LDAP_DEBUG_ANY,
182 "do_modify: invalid dn (%s)\n", dn.bv_val, 0, 0 );
183 send_ldap_error( op, rs, LDAP_INVALID_DN_SYNTAX, "invalid DN" );
187 rs->sr_err = slap_mods_check( modlist, &rs->sr_text,
188 textbuf, textlen, NULL );
190 if ( rs->sr_err != LDAP_SUCCESS ) {
191 send_ldap_result( op, rs );
195 /* FIXME: needs review */
196 op->orm_modlist = modlist;
197 op->orm_increment = increment;
199 op->o_bd = frontendDB;
200 rs->sr_err = frontendDB->be_modify( op, rs );
203 slap_graduate_commit_csn( op );
205 op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
206 op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
207 if ( op->orm_modlist != NULL ) slap_mods_free( op->orm_modlist );
213 fe_op_modify( Operation *op, SlapReply *rs )
219 Modifications *modlist = op->orm_modlist;
220 Modifications **modtail = &modlist;
221 int increment = op->orm_increment;
223 char textbuf[ SLAP_TEXT_BUFLEN ];
224 size_t textlen = sizeof( textbuf );
226 if( op->o_req_ndn.bv_len == 0 ) {
227 Debug( LDAP_DEBUG_ANY, "do_modify: root dse!\n", 0, 0, 0 );
229 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
230 "modify upon the root DSE not supported" );
233 } else if ( bvmatch( &op->o_req_ndn, &frontendDB->be_schemandn ) ) {
234 Debug( LDAP_DEBUG_ANY, "do_modify: subschema subentry!\n", 0, 0, 0 );
236 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
237 "modification of subschema subentry not supported" );
242 Debug( LDAP_DEBUG_ARGS, "modifications:\n", 0, 0, 0 );
244 for ( tmp = modlist; tmp != NULL; tmp = tmp->sml_next ) {
245 Debug( LDAP_DEBUG_ARGS, "\t%s: %s\n",
246 tmp->sml_op == LDAP_MOD_ADD ? "add" :
247 (tmp->sml_op == LDAP_MOD_INCREMENT ? "increment" :
248 (tmp->sml_op == LDAP_MOD_DELETE ? "delete" :
249 "replace")), tmp->sml_type.bv_val, 0 );
251 if ( tmp->sml_values == NULL ) {
252 Debug( LDAP_DEBUG_ARGS, "%s\n",
253 "\t\tno values", NULL, NULL );
254 } else if ( tmp->sml_values[0].bv_val == NULL ) {
255 Debug( LDAP_DEBUG_ARGS, "%s\n",
256 "\t\tzero values", NULL, NULL );
257 } else if ( tmp->sml_values[1].bv_val == NULL ) {
258 Debug( LDAP_DEBUG_ARGS, "%s, length %ld\n",
259 "\t\tone value", (long) tmp->sml_values[0].bv_len, NULL );
261 Debug( LDAP_DEBUG_ARGS, "%s\n",
262 "\t\tmultiple values", NULL, NULL );
266 if ( StatslogTest( LDAP_DEBUG_STATS ) ) {
267 char abuf[BUFSIZ/2], *ptr = abuf;
270 Statslog( LDAP_DEBUG_STATS, "%s MOD dn=\"%s\"\n",
271 op->o_log_prefix, op->o_req_dn.bv_val, 0, 0, 0 );
273 for ( tmp = modlist; tmp != NULL; tmp = tmp->sml_next ) {
274 if (len + 1 + tmp->sml_type.bv_len > sizeof(abuf)) {
275 Statslog( LDAP_DEBUG_STATS, "%s MOD attr=%s\n",
276 op->o_log_prefix, abuf, 0, 0, 0 );
281 if( 1 + tmp->sml_type.bv_len > sizeof(abuf)) {
282 Statslog( LDAP_DEBUG_STATS, "%s MOD attr=%s\n",
283 op->o_log_prefix, tmp->sml_type.bv_val, 0, 0, 0 );
291 ptr = lutil_strcopy(ptr, tmp->sml_type.bv_val);
292 len += tmp->sml_type.bv_len;
295 Statslog( LDAP_DEBUG_STATS, "%s MOD attr=%s\n",
296 op->o_log_prefix, abuf, 0, 0, 0 );
299 #endif /* LDAP_DEBUG */
301 manageDSAit = get_manageDSAit( op );
304 * We could be serving multiple database backends. Select the
305 * appropriate one, or send a referral to our "referral server"
306 * if we don't hold it.
308 op->o_bd = select_backend( &op->o_req_ndn, manageDSAit, 1 );
309 if ( op->o_bd == NULL ) {
310 rs->sr_ref = referral_rewrite( default_referral,
311 NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
312 if (!rs->sr_ref) rs->sr_ref = default_referral;
314 if (rs->sr_ref != NULL ) {
315 rs->sr_err = LDAP_REFERRAL;
316 op->o_bd = frontendDB;
317 send_ldap_result( op, rs );
320 if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref );
322 op->o_bd = frontendDB;
323 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
324 "no global superior knowledge" );
330 /* If we've got a glued backend, check the real backend */
332 if ( SLAP_GLUE_INSTANCE( op->o_bd )) {
333 op->o_bd = select_backend( &op->o_req_ndn, manageDSAit, 0 );
336 /* check restrictions */
337 if( backend_check_restrictions( op, rs, NULL ) != LDAP_SUCCESS ) {
338 send_ldap_result( op, rs );
342 /* check for referrals */
343 if( backend_check_referrals( op, rs ) != LDAP_SUCCESS ) {
348 rs->sr_err = slap_mods_obsolete_check( op, modlist,
349 &rs->sr_text, textbuf, textlen );
350 if ( rs->sr_err != LDAP_SUCCESS ) {
351 send_ldap_result( op, rs );
356 /* check for modify/increment support */
357 if( increment && !SLAP_INCREMENT( op->o_bd ) ) {
358 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
359 "modify/increment not supported in context" );
363 * do the modify if 1 && (2 || 3)
364 * 1) there is a modify function implemented in this backend;
365 * 2) this backend is master for what it holds;
366 * 3) it's a replica and the dn supplied is the update_ndn.
368 if ( op->o_bd->be_modify ) {
369 /* do the update here */
370 int repl_user = be_isupdate( op );
372 /* Multimaster slapd does not have to check for replicator dn
373 * because it accepts each modify request
375 #ifndef SLAPD_MULTIMASTER
376 if ( !SLAP_SHADOW(op->o_bd) || repl_user )
379 int update = !BER_BVISEMPTY( &op->o_bd->be_update_ndn );
380 slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
385 rs->sr_err = slap_mods_no_user_mod_check( op, modlist,
386 &rs->sr_text, textbuf, textlen );
387 if ( rs->sr_err != LDAP_SUCCESS ) {
388 send_ldap_result( op, rs );
394 for( modtail = &modlist;
396 modtail = &(*modtail)->sml_next )
401 rs->sr_err = slap_mods_opattrs( op, modlist, modtail,
402 &rs->sr_text, textbuf, textlen, 1 );
403 if( rs->sr_err != LDAP_SUCCESS ) {
404 send_ldap_result( op, rs );
409 op->orm_modlist = modlist;
410 #ifdef SLAPD_MULTIMASTER
414 /* but multimaster slapd logs only the ones
415 * not from a replicator user */
416 cb.sc_next = op->o_callback;
417 op->o_callback = &cb;
419 op->o_bd->be_modify( op, rs );
421 #ifndef SLAPD_MULTIMASTER
422 /* send a referral */
424 BerVarray defref = op->o_bd->be_update_refs
425 ? op->o_bd->be_update_refs : default_referral;
426 if ( defref != NULL ) {
427 rs->sr_ref = referral_rewrite( defref,
429 LDAP_SCOPE_DEFAULT );
430 if ( rs->sr_ref == NULL ) {
431 /* FIXME: must duplicate, because
432 * overlays may muck with it */
435 rs->sr_err = LDAP_REFERRAL;
436 send_ldap_result( op, rs );
437 if ( rs->sr_ref != defref ) {
438 ber_bvarray_free( rs->sr_ref );
442 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
443 "shadow context; no update referral" );
448 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
449 "operation not supported within namingContext" );
457 * Obsolete constraint checking.
460 slap_mods_obsolete_check(
467 if( get_manageDIT( op ) ) return LDAP_SUCCESS;
469 for ( ; ml != NULL; ml = ml->sml_next ) {
470 if ( is_at_obsolete( ml->sml_desc->ad_type ) &&
471 (( ml->sml_op != LDAP_MOD_REPLACE &&
472 ml->sml_op != LDAP_MOD_DELETE ) ||
473 ml->sml_values != NULL ))
476 * attribute is obsolete,
477 * only allow replace/delete with no values
479 snprintf( textbuf, textlen,
480 "%s: attribute is obsolete",
481 ml->sml_type.bv_val );
483 return LDAP_CONSTRAINT_VIOLATION;
491 * No-user-modification constraint checking.
494 slap_mods_no_user_mod_check(
501 for ( ; ml != NULL; ml = ml->sml_next ) {
502 if ( !is_at_no_user_mod( ml->sml_desc->ad_type ) ) continue;
504 if( get_manageDIT( op )) {
505 if ( ml->sml_desc->ad_type->sat_flags & SLAP_AT_MANAGEABLE ) {
509 /* attribute not manageable */
510 snprintf( textbuf, textlen,
511 "%s: no-user-modification attribute not manageable",
512 ml->sml_type.bv_val );
515 /* user modification disallowed */
516 snprintf( textbuf, textlen,
517 "%s: no user modification allowed",
518 ml->sml_type.bv_val );
522 return LDAP_CONSTRAINT_VIOLATION;
529 slap_mods_no_repl_user_mod_check(
539 for ( mods = ml; mods != NULL; mods = mods->sml_next ) {
540 assert( mods->sml_op == LDAP_MOD_ADD );
542 /* check doesn't already appear */
543 for ( modp = ml; modp != NULL; modp = modp->sml_next ) {
544 if ( mods->sml_desc == modp->sml_desc ) {
545 snprintf( textbuf, textlen,
546 "attribute '%s' provided more than once",
547 mods->sml_desc->ad_cname.bv_val );
548 return LDAP_TYPE_OR_VALUE_EXISTS;
557 * Do basic attribute type checking and syntax validation.
568 for( ; ml != NULL; ml = ml->sml_next ) {
569 AttributeDescription *ad = NULL;
571 /* convert to attribute description */
572 if ( ml->sml_desc == NULL ) {
573 rc = slap_bv2ad( &ml->sml_type, &ml->sml_desc, text );
574 if( rc != LDAP_SUCCESS ) {
575 snprintf( textbuf, textlen, "%s: %s",
576 ml->sml_type.bv_val, *text );
584 if( slap_syntax_is_binary( ad->ad_type->sat_syntax )
585 && !slap_ad_is_binary( ad ))
587 /* attribute requires binary transfer */
588 snprintf( textbuf, textlen,
589 "%s: requires ;binary transfer",
590 ml->sml_type.bv_val );
592 return LDAP_UNDEFINED_TYPE;
595 if( !slap_syntax_is_binary( ad->ad_type->sat_syntax )
596 && slap_ad_is_binary( ad ))
598 /* attribute does not require binary transfer */
599 snprintf( textbuf, textlen,
600 "%s: disallows ;binary transfer",
601 ml->sml_type.bv_val );
603 return LDAP_UNDEFINED_TYPE;
606 if( slap_ad_is_tag_range( ad )) {
607 /* attribute requires binary transfer */
608 snprintf( textbuf, textlen,
609 "%s: inappropriate use of tag range option",
610 ml->sml_type.bv_val );
612 return LDAP_UNDEFINED_TYPE;
616 if ( is_at_obsolete( ad->ad_type ) &&
617 (( ml->sml_op != LDAP_MOD_REPLACE &&
618 ml->sml_op != LDAP_MOD_DELETE ) ||
619 ml->sml_values != NULL ))
622 * attribute is obsolete,
623 * only allow replace/delete with no values
625 snprintf( textbuf, textlen,
626 "%s: attribute is obsolete",
627 ml->sml_type.bv_val );
629 return LDAP_CONSTRAINT_VIOLATION;
633 if ( ml->sml_op == LDAP_MOD_INCREMENT &&
634 #ifdef SLAPD_REAL_SYNTAX
635 !is_at_syntax( ad->ad_type, SLAPD_REAL_SYNTAX ) &&
637 !is_at_syntax( ad->ad_type, SLAPD_INTEGER_SYNTAX ) )
640 * attribute values must be INTEGER or REAL
642 snprintf( textbuf, textlen,
643 "%s: attribute syntax inappropriate for increment",
644 ml->sml_type.bv_val );
646 return LDAP_CONSTRAINT_VIOLATION;
652 if( ml->sml_values != NULL ) {
654 slap_syntax_validate_func *validate =
655 ad->ad_type->sat_syntax->ssyn_validate;
656 slap_syntax_transform_func *pretty =
657 ad->ad_type->sat_syntax->ssyn_pretty;
659 if( !pretty && !validate ) {
660 *text = "no validator for syntax";
661 snprintf( textbuf, textlen,
662 "%s: no validator for syntax %s",
664 ad->ad_type->sat_syntax->ssyn_oid );
666 return LDAP_INVALID_SYNTAX;
670 * check that each value is valid per syntax
671 * and pretty if appropriate
673 for( nvals = 0; ml->sml_values[nvals].bv_val; nvals++ ) {
676 rc = pretty( ad->ad_type->sat_syntax,
677 &ml->sml_values[nvals], &pval, ctx );
679 rc = validate( ad->ad_type->sat_syntax,
680 &ml->sml_values[nvals] );
684 snprintf( textbuf, textlen,
685 "%s: value #%ld invalid per syntax",
686 ml->sml_type.bv_val, (long) nvals );
688 return LDAP_INVALID_SYNTAX;
692 ber_memfree_x( ml->sml_values[nvals].bv_val, ctx );
693 ml->sml_values[nvals] = pval;
698 * a rough single value check... an additional check is needed
699 * to catch add of single value to existing single valued attribute
701 if ((ml->sml_op == LDAP_MOD_ADD || ml->sml_op == LDAP_MOD_REPLACE)
702 && nvals > 1 && is_at_single_value( ad->ad_type ))
704 snprintf( textbuf, textlen,
705 "%s: multiple values provided",
706 ml->sml_type.bv_val );
708 return LDAP_CONSTRAINT_VIOLATION;
711 /* if the type has a normalizer, generate the
712 * normalized values. otherwise leave them NULL.
714 * this is different from the rule for attributes
715 * in an entry - in an attribute list, the normalized
716 * value is set equal to the non-normalized value
717 * when there is no normalizer.
719 if( nvals && ad->ad_type->sat_equality &&
720 ad->ad_type->sat_equality->smr_normalize )
722 ml->sml_nvalues = ber_memalloc_x(
723 (nvals+1)*sizeof(struct berval), ctx );
725 for( nvals = 0; ml->sml_values[nvals].bv_val; nvals++ ) {
726 rc = ad->ad_type->sat_equality->smr_normalize(
727 SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
728 ad->ad_type->sat_syntax,
729 ad->ad_type->sat_equality,
730 &ml->sml_values[nvals], &ml->sml_nvalues[nvals], ctx );
732 Debug( LDAP_DEBUG_ANY,
733 "<= str2entry NULL (ssyn_normalize %d)\n",
735 snprintf( textbuf, textlen,
736 "%s: value #%ld normalization failed",
737 ml->sml_type.bv_val, (long) nvals );
743 ml->sml_nvalues[nvals].bv_val = NULL;
744 ml->sml_nvalues[nvals].bv_len = 0;
747 /* check for duplicates, but ignore Deletes.
749 if( nvals > 1 && ml->sml_op != LDAP_MOD_DELETE ) {
751 MatchingRule *mr = ad->ad_type->sat_equality;
753 for ( i = 1; i < nvals ; i++ ) {
754 /* test asserted values against themselves */
755 for( j = 0; j < i; j++ ) {
756 rc = ordered_value_match( &match, ml->sml_desc, mr,
758 | SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX
759 | SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH
760 | SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH,
762 ? &ml->sml_nvalues[i]
763 : &ml->sml_values[i],
765 ? &ml->sml_nvalues[j]
766 : &ml->sml_values[j],
768 if ( rc == LDAP_SUCCESS && match == 0 ) {
769 /* value exists already */
770 snprintf( textbuf, textlen,
771 "%s: value #%d provided more than once",
772 ml->sml_desc->ad_cname.bv_val, j );
774 return LDAP_TYPE_OR_VALUE_EXISTS;
776 } else if ( rc != LDAP_SUCCESS ) {
789 /* Enter with bv->bv_len = sizeof buffer, returns with
790 * actual length of string
792 void slap_timestamp( time_t *tm, struct berval *bv )
798 ltm = gmtime_r( tm, <m_buf );
800 ldap_pvt_thread_mutex_lock( &gmtime_mutex );
804 bv->bv_len = lutil_gentime( bv->bv_val, bv->bv_len, ltm );
806 #ifndef HAVE_GMTIME_R
807 ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
811 int slap_mods_opattrs(
814 Modifications **modtail,
816 char *textbuf, size_t textlen,
819 struct berval name, timestamp, csn;
821 char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
822 char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
825 int mop = op->o_tag == LDAP_REQ_ADD
826 ? LDAP_MOD_ADD : LDAP_MOD_REPLACE;
828 assert( modtail != NULL );
829 assert( *modtail == NULL );
831 if ( SLAP_LASTMOD( op->o_bd )) {
832 time_t now = slap_get_time();
834 slap_get_csn( op, csnbuf, sizeof(csnbuf), &csn, manage_ctxcsn );
836 timestamp.bv_val = timebuf;
837 timestamp.bv_len = sizeof(timebuf);
839 slap_timestamp( &now, ×tamp );
841 if( op->o_dn.bv_len == 0 ) {
842 BER_BVSTR( &name, SLAPD_ANONYMOUS );
850 if( op->o_tag == LDAP_REQ_ADD ) {
851 struct berval tmpval;
854 int rc = mods_structural_class( mods, &tmpval,
855 text, textbuf, textlen );
856 if( rc != LDAP_SUCCESS ) return rc;
858 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
860 mod->sml_flags = SLAP_MOD_INTERNAL;
861 mod->sml_type.bv_val = NULL;
862 mod->sml_desc = slap_schema.si_ad_structuralObjectClass;
864 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
865 ber_dupbv( &mod->sml_values[0], &tmpval );
866 mod->sml_values[1].bv_len = 0;
867 mod->sml_values[1].bv_val = NULL;
868 assert( mod->sml_values[0].bv_val != NULL );
870 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
871 ber_dupbv( &mod->sml_nvalues[0], &tmpval );
872 mod->sml_nvalues[1].bv_len = 0;
873 mod->sml_nvalues[1].bv_val = NULL;
874 assert( mod->sml_nvalues[0].bv_val != NULL );
876 modtail = &mod->sml_next;
879 if ( SLAP_LASTMOD( op->o_bd )) {
880 char uuidbuf[ LDAP_LUTIL_UUIDSTR_BUFSIZE ];
882 tmpval.bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) );
883 tmpval.bv_val = uuidbuf;
885 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
887 mod->sml_flags = SLAP_MOD_INTERNAL;
888 mod->sml_type.bv_val = NULL;
889 mod->sml_desc = slap_schema.si_ad_entryUUID;
891 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
892 ber_dupbv( &mod->sml_values[0], &tmpval );
893 mod->sml_values[1].bv_len = 0;
894 mod->sml_values[1].bv_val = NULL;
895 assert( mod->sml_values[0].bv_val != NULL );
897 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
898 (*mod->sml_desc->ad_type->sat_equality->smr_normalize)(
899 SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
900 mod->sml_desc->ad_type->sat_syntax,
901 mod->sml_desc->ad_type->sat_equality,
902 mod->sml_values, mod->sml_nvalues, NULL );
903 mod->sml_nvalues[1].bv_len = 0;
904 mod->sml_nvalues[1].bv_val = NULL;
906 modtail = &mod->sml_next;
908 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
910 mod->sml_flags = SLAP_MOD_INTERNAL;
911 mod->sml_type.bv_val = NULL;
912 mod->sml_desc = slap_schema.si_ad_creatorsName;
914 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
915 ber_dupbv( &mod->sml_values[0], &name );
916 mod->sml_values[1].bv_len = 0;
917 mod->sml_values[1].bv_val = NULL;
918 assert( mod->sml_values[0].bv_val != NULL );
920 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
921 ber_dupbv( &mod->sml_nvalues[0], &nname );
922 mod->sml_nvalues[1].bv_len = 0;
923 mod->sml_nvalues[1].bv_val = NULL;
924 assert( mod->sml_nvalues[0].bv_val != NULL );
926 modtail = &mod->sml_next;
928 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
930 mod->sml_flags = SLAP_MOD_INTERNAL;
931 mod->sml_type.bv_val = NULL;
932 mod->sml_desc = slap_schema.si_ad_createTimestamp;
934 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
935 ber_dupbv( &mod->sml_values[0], ×tamp );
936 mod->sml_values[1].bv_len = 0;
937 mod->sml_values[1].bv_val = NULL;
938 assert( mod->sml_values[0].bv_val != NULL );
939 mod->sml_nvalues = NULL;
941 modtail = &mod->sml_next;
945 if ( SLAP_LASTMOD( op->o_bd )) {
946 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
948 mod->sml_flags = SLAP_MOD_INTERNAL;
949 mod->sml_type.bv_val = NULL;
950 mod->sml_desc = slap_schema.si_ad_entryCSN;
951 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
952 ber_dupbv( &mod->sml_values[0], &csn );
953 mod->sml_values[1].bv_len = 0;
954 mod->sml_values[1].bv_val = NULL;
955 assert( mod->sml_values[0].bv_val != NULL );
956 mod->sml_nvalues = NULL;
958 modtail = &mod->sml_next;
960 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
962 mod->sml_flags = SLAP_MOD_INTERNAL;
963 mod->sml_type.bv_val = NULL;
964 mod->sml_desc = slap_schema.si_ad_modifiersName;
965 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
966 ber_dupbv( &mod->sml_values[0], &name );
967 mod->sml_values[1].bv_len = 0;
968 mod->sml_values[1].bv_val = NULL;
969 assert( mod->sml_values[0].bv_val != NULL );
971 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
972 ber_dupbv( &mod->sml_nvalues[0], &nname );
973 mod->sml_nvalues[1].bv_len = 0;
974 mod->sml_nvalues[1].bv_val = NULL;
975 assert( mod->sml_nvalues[0].bv_val != NULL );
977 modtail = &mod->sml_next;
979 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
981 mod->sml_flags = SLAP_MOD_INTERNAL;
982 mod->sml_type.bv_val = NULL;
983 mod->sml_desc = slap_schema.si_ad_modifyTimestamp;
984 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
985 ber_dupbv( &mod->sml_values[0], ×tamp );
986 mod->sml_values[1].bv_len = 0;
987 mod->sml_values[1].bv_val = NULL;
988 assert( mod->sml_values[0].bv_val != NULL );
989 mod->sml_nvalues = NULL;
991 modtail = &mod->sml_next;