]> git.sur5r.net Git - openldap/blob - servers/slapd/modify.c
Add a safety check to bvcasechr
[openldap] / servers / slapd / modify.c
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6 /*
7  * Copyright (c) 1995 Regents of the University of Michigan.
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms are permitted
11  * provided that this notice is preserved and that due credit is given
12  * to the University of Michigan at Ann Arbor. The name of the University
13  * may not be used to endorse or promote products derived from this
14  * software without specific prior written permission. This software
15  * is provided ``as is'' without express or implied warranty.
16  */
17
18 #include "portable.h"
19
20 #include <stdio.h>
21
22 #include <ac/socket.h>
23 #include <ac/string.h>
24 #include <ac/time.h>
25
26 #include "lutil.h"
27
28 #include "ldap_pvt.h"
29 #include "slap.h"
30
31 int
32 do_modify(
33     Connection  *conn,
34     Operation   *op )
35 {
36         struct berval dn = { 0, NULL };
37         struct berval pdn = { 0, NULL };
38         struct berval ndn = { 0, NULL };
39         char            *last;
40         ber_tag_t       tag;
41         ber_len_t       len;
42         Modifications   *modlist = NULL;
43         Modifications   **modtail = &modlist;
44 #ifdef LDAP_DEBUG
45         Modifications *tmp;
46 #endif
47         Backend         *be;
48         int rc;
49         const char      *text;
50         int manageDSAit;
51
52 #ifdef NEW_LOGGING
53         LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY,
54                 "do_modify: enter\n" ));
55 #else
56         Debug( LDAP_DEBUG_TRACE, "do_modify\n", 0, 0, 0 );
57 #endif
58
59         /*
60          * Parse the modify request.  It looks like this:
61          *
62          *      ModifyRequest := [APPLICATION 6] SEQUENCE {
63          *              name    DistinguishedName,
64          *              mods    SEQUENCE OF SEQUENCE {
65          *                      operation       ENUMERATED {
66          *                              add     (0),
67          *                              delete  (1),
68          *                              replace (2)
69          *                      },
70          *                      modification    SEQUENCE {
71          *                              type    AttributeType,
72          *                              values  SET OF AttributeValue
73          *                      }
74          *              }
75          *      }
76          */
77
78         if ( ber_scanf( op->o_ber, "{m" /*}*/, &dn ) == LBER_ERROR ) {
79 #ifdef NEW_LOGGING
80                 LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
81                         "do_modify: ber_scanf failed\n" ));
82 #else
83                 Debug( LDAP_DEBUG_ANY, "do_modify: ber_scanf failed\n", 0, 0, 0 );
84 #endif
85
86                 send_ldap_disconnect( conn, op,
87                         LDAP_PROTOCOL_ERROR, "decoding error" );
88                 return SLAPD_DISCONNECT;
89         }
90
91 #ifdef NEW_LOGGING
92         LDAP_LOG(( "operation", LDAP_LEVEL_ARGS,
93                    "do_modify: dn (%s)\n", dn.bv_val ));
94 #else
95         Debug( LDAP_DEBUG_ARGS, "do_modify: dn (%s)\n", dn.bv_val, 0, 0 );
96 #endif
97
98
99         /* collect modifications & save for later */
100
101         for ( tag = ber_first_element( op->o_ber, &len, &last );
102             tag != LBER_DEFAULT;
103             tag = ber_next_element( op->o_ber, &len, last ) )
104         {
105                 ber_int_t mop;
106                 Modifications tmp, *mod;
107
108
109                 if ( ber_scanf( op->o_ber, "{i{m[W]}}", &mop,
110                     &tmp.sml_type, &tmp.sml_bvalues )
111                     == LBER_ERROR )
112                 {
113                         send_ldap_disconnect( conn, op,
114                                 LDAP_PROTOCOL_ERROR, "decoding modlist error" );
115                         rc = SLAPD_DISCONNECT;
116                         goto cleanup;
117                 }
118
119                 mod = (Modifications *) ch_malloc( sizeof(Modifications) );
120                 mod->sml_type = tmp.sml_type;
121                 mod->sml_bvalues = tmp.sml_bvalues;
122                 mod->sml_desc = NULL;
123                 *modtail = mod;
124
125                 switch( mop ) {
126                 case LDAP_MOD_ADD:
127                         if ( mod->sml_bvalues == NULL ) {
128 #ifdef NEW_LOGGING
129                                 LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
130                                         "do_modify: modify/add operation (%ld) requires values\n",
131                                         (long)mop ));
132 #else
133                                 Debug( LDAP_DEBUG_ANY,
134                                         "do_modify: modify/add operation (%ld) requires values\n",
135                                         (long) mop, 0, 0 );
136 #endif
137
138                                 send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR,
139                                         NULL, "modify/add operation requires values",
140                                         NULL, NULL );
141                                 rc = LDAP_PROTOCOL_ERROR;
142                                 goto cleanup;
143                         }
144
145                         /* fall through */
146
147                 case LDAP_MOD_DELETE:
148                 case LDAP_MOD_REPLACE:
149                         break;
150
151                 default: {
152 #ifdef NEW_LOGGING
153                                 LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
154                                         "do_modify: invalid modify operation (%ld)\n",
155                                         (long)mop ));
156 #else
157                                 Debug( LDAP_DEBUG_ANY,
158                                         "do_modify: invalid modify operation (%ld)\n",
159                                         (long) mop, 0, 0 );
160 #endif
161
162                                 send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR,
163                                         NULL, "unrecognized modify operation", NULL, NULL );
164                                 rc = LDAP_PROTOCOL_ERROR;
165                                 goto cleanup;
166                         }
167                 }
168
169                 mod->sml_op = mop;
170                 modtail = &mod->sml_next;
171         }
172         *modtail = NULL;
173
174         if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) {
175 #ifdef NEW_LOGGING
176                 LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
177                         "do_modify: get_ctrls failed\n" ));
178 #else
179                 Debug( LDAP_DEBUG_ANY, "do_modify: get_ctrls failed\n", 0, 0, 0 );
180 #endif
181
182                 goto cleanup;
183         }
184
185         rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn );
186         if( rc != LDAP_SUCCESS ) {
187 #ifdef NEW_LOGGING
188                 LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
189                         "do_modify: conn %d  invalid dn (%s)\n",
190                         conn->c_connid, dn.bv_val ));
191 #else
192                 Debug( LDAP_DEBUG_ANY,
193                         "do_modify: invalid dn (%s)\n", dn.bv_val, 0, 0 );
194 #endif
195                 send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
196                     "invalid DN", NULL, NULL );
197                 goto cleanup;
198         }
199
200         if( ndn.bv_len == 0 ) {
201 #ifdef NEW_LOGGING
202                 LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
203                         "do_modify: attempt to modify root DSE.\n" ));
204 #else
205                 Debug( LDAP_DEBUG_ANY, "do_modify: root dse!\n", 0, 0, 0 );
206 #endif
207
208                 send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
209                         NULL, "modify upon the root DSE not supported", NULL, NULL );
210                 goto cleanup;
211
212 #if defined( SLAPD_SCHEMA_DN )
213         } else if ( strcasecmp( ndn.bv_val, SLAPD_SCHEMA_DN ) == 0 ) {
214 #ifdef NEW_LOGGING
215                 LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
216                         "do_modify: attempt to modify subschema subentry.\n" ));
217 #else
218                 Debug( LDAP_DEBUG_ANY, "do_modify: subschema subentry!\n", 0, 0, 0 );
219 #endif
220
221                 send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
222                         NULL, "modification of subschema subentry not supported",
223                         NULL, NULL );
224                 goto cleanup;
225 #endif
226         }
227
228 #ifdef LDAP_DEBUG
229 #ifdef NEW_LOGGING
230         LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1,
231                 "do_modify: modifications:\n" ));
232 #else
233         Debug( LDAP_DEBUG_ARGS, "modifications:\n", 0, 0, 0 );
234 #endif
235
236         for ( tmp = modlist; tmp != NULL; tmp = tmp->sml_next ) {
237 #ifdef NEW_LOGGING
238                 LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1,
239                         "\t%s:  %s\n", tmp->sml_op == LDAP_MOD_ADD ?
240                                 "add" : (tmp->sml_op == LDAP_MOD_DELETE ?
241                                         "delete" : "replace"), tmp->sml_type.bv_val ));
242
243                 if ( tmp->sml_bvalues == NULL ) {
244                         LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1,
245                            "\t\tno values" ));
246                 } else if ( tmp->sml_bvalues[0].bv_val == NULL ) {
247                         LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1,
248                            "\t\tzero values" ));
249                 } else if ( tmp->sml_bvalues[1].bv_val == NULL ) {
250                         LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1,
251                            "\t\tone value" ));
252                 } else {
253                         LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1,
254                            "\t\tmultiple values" ));
255                 }
256
257 #else
258                 Debug( LDAP_DEBUG_ARGS, "\t%s: %s\n",
259                         tmp->sml_op == LDAP_MOD_ADD
260                                 ? "add" : (tmp->sml_op == LDAP_MOD_DELETE
261                                         ? "delete" : "replace"), tmp->sml_type.bv_val, 0 );
262
263                 if ( tmp->sml_bvalues == NULL ) {
264                         Debug( LDAP_DEBUG_ARGS, "%s\n",
265                            "\t\tno values", NULL, NULL );
266                 } else if ( tmp->sml_bvalues[0].bv_val == NULL ) {
267                         Debug( LDAP_DEBUG_ARGS, "%s\n",
268                            "\t\tzero values", NULL, NULL );
269                 } else if ( tmp->sml_bvalues[1].bv_val == NULL ) {
270                         Debug( LDAP_DEBUG_ARGS, "%s, length %ld\n",
271                            "\t\tone value", (long) tmp->sml_bvalues[0].bv_len, NULL );
272                 } else {
273                         Debug( LDAP_DEBUG_ARGS, "%s\n",
274                            "\t\tmultiple values", NULL, NULL );
275                 }
276 #endif
277         }
278 #endif
279
280         Statslog( LDAP_DEBUG_STATS, "conn=%ld op=%d MOD dn=\"%s\"\n",
281             op->o_connid, op->o_opid, dn.bv_val, 0, 0 );
282
283         manageDSAit = get_manageDSAit( op );
284
285         /*
286          * We could be serving multiple database backends.  Select the
287          * appropriate one, or send a referral to our "referral server"
288          * if we don't hold it.
289          */
290         if ( (be = select_backend( &ndn, manageDSAit, 0 )) == NULL ) {
291                 BerVarray ref = referral_rewrite( default_referral,
292                         NULL, &pdn, LDAP_SCOPE_DEFAULT );
293
294                 send_ldap_result( conn, op, rc = LDAP_REFERRAL,
295                         NULL, NULL, ref ? ref : default_referral, NULL );
296
297                 ber_bvarray_free( ref );
298                 goto cleanup;
299         }
300
301         /* check restrictions */
302         rc = backend_check_restrictions( be, conn, op, NULL, &text ) ;
303         if( rc != LDAP_SUCCESS ) {
304                 send_ldap_result( conn, op, rc,
305                         NULL, text, NULL, NULL );
306                 goto cleanup;
307         }
308
309         /* check for referrals */
310         rc = backend_check_referrals( be, conn, op, &pdn, &ndn );
311         if ( rc != LDAP_SUCCESS ) {
312                 goto cleanup;
313         }
314
315         /* deref suffix alias if appropriate */
316         suffix_alias( be, &ndn );
317
318         /*
319          * do the modify if 1 && (2 || 3)
320          * 1) there is a modify function implemented in this backend;
321          * 2) this backend is master for what it holds;
322          * 3) it's a replica and the dn supplied is the update_ndn.
323          */
324         if ( be->be_modify ) {
325                 /* do the update here */
326                 int repl_user = be_isupdate( be, &op->o_ndn );
327 #ifndef SLAPD_MULTIMASTER
328                 /* Multimaster slapd does not have to check for replicator dn
329                  * because it accepts each modify request
330                  */
331                 if ( !be->be_update_ndn.bv_len || repl_user )
332 #endif
333                 {
334                         int update = be->be_update_ndn.bv_len;
335                         const char *text;
336                         char textbuf[SLAP_TEXT_BUFLEN];
337                         size_t textlen = sizeof textbuf;
338
339                         rc = slap_mods_check( modlist, update, &text,
340                                 textbuf, textlen );
341
342                         if( rc != LDAP_SUCCESS ) {
343                                 send_ldap_result( conn, op, rc,
344                                         NULL, text, NULL, NULL );
345                                 goto cleanup;
346                         }
347
348                         if ( SLAP_LASTMOD(be) && !repl_user ) {
349                                 for( modtail = &modlist;
350                                         *modtail != NULL;
351                                         modtail = &(*modtail)->sml_next )
352                                 {
353                                         /* empty */
354                                 }
355
356                                 rc = slap_mods_opattrs( op, modlist, modtail, &text,
357                                         textbuf, textlen );
358                                 if( rc != LDAP_SUCCESS ) {
359                                         send_ldap_result( conn, op, rc,
360                                                 NULL, text,
361                                                 NULL, NULL );
362                                         goto cleanup;
363                                 }
364                         }
365
366                         if ( (*be->be_modify)( be, conn, op, &pdn, &ndn, modlist ) == 0
367 #ifdef SLAPD_MULTIMASTER
368                                 && !repl_user
369 #endif
370                         ) {
371                                 /* but we log only the ones not from a replicator user */
372                                 replog( be, op, &pdn, &ndn, modlist );
373                         }
374
375 #ifndef SLAPD_MULTIMASTER
376                 /* send a referral */
377                 } else {
378                         BerVarray defref = be->be_update_refs
379                                 ? be->be_update_refs : default_referral;
380                         BerVarray ref = referral_rewrite( defref,
381                                 NULL, &pdn, LDAP_SCOPE_DEFAULT );
382
383                         send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL,
384                                 ref ? ref : defref, NULL );
385
386                         ber_bvarray_free( ref );
387 #endif
388                 }
389         } else {
390                 send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
391                     NULL, "operation not supported within namingContext",
392                         NULL, NULL );
393         }
394
395 cleanup:
396         free( pdn.bv_val );
397         free( ndn.bv_val );
398         if ( modlist != NULL )
399                 slap_mods_free( modlist );
400         return rc;
401 }
402
403 /*
404  * Do basic attribute type checking and syntax validation.
405  */
406 int slap_mods_check(
407         Modifications *ml,
408         int update,
409         const char **text,
410         char *textbuf,
411         size_t textlen )
412 {
413         int rc;
414
415         for( ; ml != NULL; ml = ml->sml_next ) {
416                 AttributeDescription *ad = NULL;
417
418                 /* convert to attribute description */
419                 rc = slap_bv2ad( &ml->sml_type, &ml->sml_desc, text );
420
421                 if( rc != LDAP_SUCCESS ) {
422                         snprintf( textbuf, textlen, "%s: %s",
423                                 ml->sml_type.bv_val, *text );
424                         *text = textbuf;
425                         return rc;
426                 }
427
428                 ad = ml->sml_desc;
429
430                 if( slap_syntax_is_binary( ad->ad_type->sat_syntax )
431                         && !slap_ad_is_binary( ad ))
432                 {
433                         /* attribute requires binary transfer */
434                         snprintf( textbuf, textlen,
435                                 "%s: requires ;binary transfer",
436                                 ml->sml_type.bv_val );
437                         *text = textbuf;
438                         return LDAP_UNDEFINED_TYPE;
439                 }
440
441                 if( !slap_syntax_is_binary( ad->ad_type->sat_syntax )
442                         && slap_ad_is_binary( ad ))
443                 {
444                         /* attribute requires binary transfer */
445                         snprintf( textbuf, textlen,
446                                 "%s: disallows ;binary transfer",
447                                 ml->sml_type.bv_val );
448                         *text = textbuf;
449                         return LDAP_UNDEFINED_TYPE;
450                 }
451
452                 if (!update && is_at_no_user_mod( ad->ad_type )) {
453                         /* user modification disallowed */
454                         snprintf( textbuf, textlen,
455                                 "%s: no user modification allowed",
456                                 ml->sml_type.bv_val );
457                         *text = textbuf;
458                         return LDAP_CONSTRAINT_VIOLATION;
459                 }
460
461                 if ( is_at_obsolete( ad->ad_type ) &&
462                         ( ml->sml_op == LDAP_MOD_ADD || ml->sml_bvalues != NULL ) )
463                 {
464                         /*
465                          * attribute is obsolete,
466                          * only allow replace/delete with no values
467                          */
468                         snprintf( textbuf, textlen,
469                                 "%s: attribute is obsolete",
470                                 ml->sml_type.bv_val );
471                         *text = textbuf;
472                         return LDAP_CONSTRAINT_VIOLATION;
473                 }
474
475                 /*
476                  * check values
477                  */
478                 if( ml->sml_bvalues != NULL ) {
479                         ber_len_t nvals;
480                         slap_syntax_validate_func *validate =
481                                 ad->ad_type->sat_syntax->ssyn_validate;
482                         slap_syntax_transform_func *pretty =
483                                 ad->ad_type->sat_syntax->ssyn_pretty;
484  
485                         if( !pretty && !validate ) {
486                                 *text = "no validator for syntax";
487                                 snprintf( textbuf, textlen,
488                                         "%s: no validator for syntax %s",
489                                         ml->sml_type.bv_val,
490                                         ad->ad_type->sat_syntax->ssyn_oid );
491                                 *text = textbuf;
492                                 return LDAP_INVALID_SYNTAX;
493                         }
494
495                         /*
496                          * check that each value is valid per syntax
497                          *      and pretty if appropriate
498                          */
499                         for( nvals = 0; ml->sml_bvalues[nvals].bv_val; nvals++ ) {
500                                 struct berval pval;
501                                 if( pretty ) {
502                                         rc = pretty( ad->ad_type->sat_syntax,
503                                                 &ml->sml_bvalues[nvals], &pval );
504                                 } else {
505                                         rc = validate( ad->ad_type->sat_syntax,
506                                                 &ml->sml_bvalues[nvals] );
507                                 }
508
509                                 if( rc != 0 ) {
510                                         snprintf( textbuf, textlen,
511                                                 "%s: value #%ld invalid per syntax",
512                                                 ml->sml_type.bv_val, (long) nvals );
513                                         *text = textbuf;
514                                         return LDAP_INVALID_SYNTAX;
515                                 }
516
517                                 if( pretty ) {
518                                         ber_memfree( ml->sml_bvalues[nvals].bv_val );
519                                         ml->sml_bvalues[nvals] = pval;
520                                 }
521                         }
522
523                         /*
524                          * a rough single value check... an additional check is needed
525                          * to catch add of single value to existing single valued attribute
526                          */
527                         if( ( ml->sml_op == LDAP_MOD_ADD || ml->sml_op == LDAP_MOD_REPLACE )
528                                 && nvals > 1 && is_at_single_value( ad->ad_type ))
529                         {
530                                 snprintf( textbuf, textlen,
531                                         "%s: multiple value provided",
532                                         ml->sml_type.bv_val );
533                                 *text = textbuf;
534                                 return LDAP_CONSTRAINT_VIOLATION;
535                         }
536                 }
537         }
538
539         return LDAP_SUCCESS;
540 }
541
542 int slap_mods_opattrs(
543         Operation *op,
544         Modifications *mods,
545         Modifications **modtail,
546         const char **text,
547         char *textbuf, size_t textlen )
548 {
549         struct berval name, timestamp, csn;
550         time_t now = slap_get_time();
551         char timebuf[22];
552         char csnbuf[64];
553         struct tm *ltm;
554         Modifications *mod;
555
556         int mop = op->o_tag == LDAP_REQ_ADD
557                 ? LDAP_MOD_ADD : LDAP_MOD_REPLACE;
558
559         assert( modtail != NULL );
560         assert( *modtail == NULL );
561
562         ldap_pvt_thread_mutex_lock( &gmtime_mutex );
563         ltm = gmtime( &now );
564         strftime( timebuf, sizeof(timebuf), "%Y%m%d%H%M%SZ", ltm );
565
566         csn.bv_len = lutil_csnstr( csnbuf, sizeof( csnbuf ), 0, 0 );
567         ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
568         csn.bv_val = csnbuf;
569
570         timestamp.bv_val = timebuf;
571         timestamp.bv_len = strlen(timebuf);
572
573         if( op->o_dn.bv_len == 0 ) {
574                 name.bv_val = SLAPD_ANONYMOUS;
575                 name.bv_len = sizeof(SLAPD_ANONYMOUS)-1;
576         } else {
577                 name = op->o_dn;
578         }
579
580         if( op->o_tag == LDAP_REQ_ADD ) {
581                 struct berval tmpval;
582                 char uuidbuf[40];
583                 int rc;
584
585                 rc = mods_structural_class( mods, &tmpval, text, textbuf, textlen );
586                 if( rc != LDAP_SUCCESS ) {
587                         return rc;
588                 }
589                 if ( tmpval.bv_len ) {
590                         mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
591                         mod->sml_op = mop;
592                         mod->sml_type.bv_val = NULL;
593                         mod->sml_desc = slap_schema.si_ad_structuralObjectClass;
594                         mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
595                         ber_dupbv( &mod->sml_bvalues[0], &tmpval );
596                         mod->sml_bvalues[1].bv_val = NULL;
597                         assert( mod->sml_bvalues[0].bv_val );
598                         *modtail = mod;
599                         modtail = &mod->sml_next;
600                 }
601
602                 tmpval.bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) );
603                 tmpval.bv_val = uuidbuf;
604                 
605                 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
606                 mod->sml_op = mop;
607                 mod->sml_type.bv_val = NULL;
608                 mod->sml_desc = slap_schema.si_ad_entryUUID;
609                 mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
610                 ber_dupbv( &mod->sml_bvalues[0], &tmpval );
611                 mod->sml_bvalues[1].bv_val = NULL;
612                 assert( mod->sml_bvalues[0].bv_val );
613                 *modtail = mod;
614                 modtail = &mod->sml_next;
615
616                 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
617                 mod->sml_op = mop;
618                 mod->sml_type.bv_val = NULL;
619                 mod->sml_desc = slap_schema.si_ad_creatorsName;
620                 mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
621                 ber_dupbv( &mod->sml_bvalues[0], &name );
622                 mod->sml_bvalues[1].bv_val = NULL;
623                 assert( mod->sml_bvalues[0].bv_val );
624                 *modtail = mod;
625                 modtail = &mod->sml_next;
626
627                 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
628                 mod->sml_op = mop;
629                 mod->sml_type.bv_val = NULL;
630                 mod->sml_desc = slap_schema.si_ad_createTimestamp;
631                 mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
632                 ber_dupbv( &mod->sml_bvalues[0], &timestamp );
633                 mod->sml_bvalues[1].bv_val = NULL;
634                 assert( mod->sml_bvalues[0].bv_val );
635                 *modtail = mod;
636                 modtail = &mod->sml_next;
637         }
638
639         mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
640         mod->sml_op = mop;
641         mod->sml_type.bv_val = NULL;
642         mod->sml_desc = slap_schema.si_ad_entryCSN;
643         mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
644         ber_dupbv( &mod->sml_bvalues[0], &csn );
645         mod->sml_bvalues[1].bv_val = NULL;
646         assert( mod->sml_bvalues[0].bv_val );
647         *modtail = mod;
648         modtail = &mod->sml_next;
649
650         mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
651         mod->sml_op = mop;
652         mod->sml_type.bv_val = NULL;
653         mod->sml_desc = slap_schema.si_ad_modifiersName;
654         mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
655         ber_dupbv( &mod->sml_bvalues[0], &name );
656         mod->sml_bvalues[1].bv_val = NULL;
657         assert( mod->sml_bvalues[0].bv_val );
658         *modtail = mod;
659         modtail = &mod->sml_next;
660
661         mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
662         mod->sml_op = mop;
663         mod->sml_type.bv_val = NULL;
664         mod->sml_desc = slap_schema.si_ad_modifyTimestamp;
665         mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
666         ber_dupbv( &mod->sml_bvalues[0], &timestamp );
667         mod->sml_bvalues[1].bv_val = NULL;
668         assert( mod->sml_bvalues[0].bv_val );
669         *modtail = mod;
670         modtail = &mod->sml_next;
671
672         *modtail = NULL;
673
674         return LDAP_SUCCESS;
675 }