1 /* lastmod.c - returns last modification info */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 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>.
16 * This work was initially developed by Pierangelo Masarati for inclusion in
22 #ifdef SLAPD_OVER_LASTMOD
26 #include <ac/string.h>
27 #include <ac/socket.h>
32 typedef struct lastmod_info_t {
33 struct berval lmi_rdnvalue;
35 ldap_pvt_thread_mutex_t lmi_entry_mutex;
38 struct lastmod_schema_t {
39 ObjectClass *lms_oc_lastmod;
40 AttributeDescription *lms_ad_lastmodDN;
41 AttributeDescription *lms_ad_lastmodType;
53 struct berval lastmodType[] = {
69 { "lastmod", "( 1.3.6.1.4.1.4203.666.3.13"
71 "DESC 'OpenLDAP per-database last modification monitoring' "
80 ") )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
81 offsetof(struct lastmod_schema_t, lms_oc_lastmod) },
84 { "lastmodDN", "( 1.3.6.1.4.1.4203.666.1.28"
86 "DESC 'DN of last modification' "
87 "EQUALITY distinguishedNameMatch "
88 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
89 "NO-USER-MODIFICATION "
90 "USAGE directoryOperation )", SLAP_AT_HIDE,
91 offsetof(struct lastmod_schema_t, lms_ad_lastmodDN) },
92 { "lastmodType", "( 1.3.6.1.4.1.4203.666.1.29"
94 "DESC 'Type of last modification' "
95 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 "
96 "EQUALITY caseIgnoreMatch "
98 "NO-USER-MODIFICATION "
99 "USAGE directoryOperation )", SLAP_AT_HIDE,
100 offsetof( struct lastmod_schema_t, lms_ad_lastmodType ) },
104 static const struct berval *write_exop[] = {
105 &slap_EXOP_MODIFY_PASSWD,
110 lastmod_search( Operation *op, SlapReply *rs )
112 slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
113 lastmod_info_t *lmi = (lastmod_info_t *)on->on_bi.bi_private;
116 /* if we get here, it must be a success */
117 rs->sr_err = LDAP_SUCCESS;
119 ldap_pvt_thread_mutex_lock( &lmi->lmi_entry_mutex );
121 rc = test_filter( op, lmi->lmi_e, op->oq_search.rs_filter );
122 if ( rc == LDAP_COMPARE_TRUE ) {
123 rs->sr_attrs = op->ors_attrs;
125 rs->sr_entry = lmi->lmi_e;
126 rs->sr_err = send_search_entry( op, rs );
132 ldap_pvt_thread_mutex_unlock( &lmi->lmi_entry_mutex );
134 send_ldap_result( op, rs );
140 lastmod_compare( Operation *op, SlapReply *rs )
142 slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
143 lastmod_info_t *lmi = (lastmod_info_t *)on->on_bi.bi_private;
146 ldap_pvt_thread_mutex_lock( &lmi->lmi_entry_mutex );
148 if ( get_assert( op ) &&
149 ( test_filter( op, lmi->lmi_e, get_assertion( op ) ) != LDAP_COMPARE_TRUE ) )
151 rs->sr_err = LDAP_ASSERTION_FAILED;
155 rs->sr_err = access_allowed( op, lmi->lmi_e, op->oq_compare.rs_ava->aa_desc,
156 &op->oq_compare.rs_ava->aa_value, ACL_COMPARE, NULL );
157 if ( ! rs->sr_err ) {
158 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
162 rs->sr_err = LDAP_NO_SUCH_ATTRIBUTE;
164 for ( a = attr_find( lmi->lmi_e->e_attrs, op->oq_compare.rs_ava->aa_desc );
166 a = attr_find( a->a_next, op->oq_compare.rs_ava->aa_desc ) )
168 rs->sr_err = LDAP_COMPARE_FALSE;
170 if ( value_find_ex( op->oq_compare.rs_ava->aa_desc,
171 SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH |
172 SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
173 a->a_nvals, &op->oq_compare.rs_ava->aa_value, op->o_tmpmemctx ) == 0 )
175 rs->sr_err = LDAP_COMPARE_TRUE;
182 ldap_pvt_thread_mutex_unlock( &lmi->lmi_entry_mutex );
184 send_ldap_result( op, rs );
186 if( rs->sr_err == LDAP_COMPARE_FALSE || rs->sr_err == LDAP_COMPARE_TRUE ) {
187 rs->sr_err = LDAP_SUCCESS;
194 lastmod_exop( Operation *op, SlapReply *rs )
196 slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
200 op->o_bd->bd_info = (BackendInfo *)on->on_info;
201 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
202 rs->sr_text = "not allowed within namingContext";
203 send_ldap_result( op, rs );
210 lastmod_op_func( Operation *op, SlapReply *rs )
212 slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
213 lastmod_info_t *lmi = (lastmod_info_t *)on->on_bi.bi_private;
216 if ( dn_match( &op->o_req_ndn, &lmi->lmi_e->e_nname ) ) {
217 switch ( op->o_tag ) {
218 case LDAP_REQ_SEARCH:
219 if ( op->ors_scope != LDAP_SCOPE_BASE ) {
220 goto return_referral;
223 return lastmod_search( op, rs );
225 case LDAP_REQ_COMPARE:
226 return lastmod_compare( op, rs );
228 case LDAP_REQ_EXTENDED:
229 /* if write, reject; otherwise process */
230 for ( i = 0; write_exop[ i ] != NULL; i++ ) {
231 if ( ber_bvcmp( write_exop[ i ], &op->oq_extended.rs_reqoid ) == 0 ) {
232 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
233 rs->sr_text = "not allowed within namingContext";
237 return lastmod_exop( op, rs );
240 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
241 rs->sr_text = "not allowed within namingContext";
246 if ( dnIsSuffix( &op->o_req_ndn, &lmi->lmi_e->e_nname ) ) {
247 goto return_referral;
250 return SLAP_CB_CONTINUE;
253 op->o_bd->bd_info = (BackendInfo *)on->on_info;
254 rs->sr_ref = referral_rewrite( default_referral,
255 NULL, &op->o_req_dn, op->ors_scope );
258 rs->sr_ref = default_referral;
260 rs->sr_err = LDAP_REFERRAL;
261 send_ldap_result( op, rs );
263 if ( rs->sr_ref != default_referral ) {
264 ber_bvarray_free( rs->sr_ref );
271 op->o_bd->bd_info = (BackendInfo *)on->on_info;
272 send_ldap_result( op, rs );
279 best_guess( Operation *op,
280 struct berval *bv_modifyTimestamp, struct berval *bv_nmodifyTimestamp,
281 struct berval *bv_modifiersName, struct berval *bv_nmodifiersName )
287 char tmbuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
292 currtime = slap_get_time();
294 /* maybe we better use the time the operation was initiated */
295 currtime = op->o_time;
297 #ifndef HAVE_GMTIME_R
298 ldap_pvt_thread_mutex_lock( &gmtime_mutex );
299 tm = gmtime( &currtime );
300 #else /* HAVE_GMTIME_R */
301 tm = gmtime_r( &currtime, &tm_buf );
302 #endif /* HAVE_GMTIME_R */
303 lutil_gentime( tmbuf, sizeof( tmbuf ), tm );
304 #ifndef HAVE_GMTIME_R
305 ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
308 ber_str2bv( tmbuf, 0, 1, bv_modifyTimestamp );
309 ber_dupbv( bv_nmodifyTimestamp, bv_modifyTimestamp );
312 ber_dupbv( bv_modifiersName, &op->o_dn );
313 ber_dupbv( bv_nmodifiersName, &op->o_ndn );
319 lastmod_update( Operation *op, SlapReply *rs )
321 slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
322 lastmod_info_t *lmi = (lastmod_info_t *)on->on_bi.bi_private;
324 Modifications *ml = NULL;
325 struct berval bv_modifyTimestamp = BER_BVNULL,
326 bv_nmodifyTimestamp = BER_BVNULL,
327 bv_modifiersName = BER_BVNULL,
328 bv_nmodifiersName = BER_BVNULL,
329 bv_name = BER_BVNULL,
330 bv_nname = BER_BVNULL;
331 enum lastmodType_e lmt = LASTMOD_UNKNOWN;
335 /* FIXME: timestamp? modifier? */
336 switch ( op->o_tag ) {
340 a = attr_find( e->e_attrs, slap_schema.si_ad_modifiersName );
342 ber_dupbv( &bv_modifiersName, &a->a_vals[0] );
343 ber_dupbv( &bv_nmodifiersName, &a->a_nvals[0] );
345 a = attr_find( e->e_attrs, slap_schema.si_ad_modifyTimestamp );
347 ber_dupbv( &bv_modifyTimestamp, &a->a_vals[0] );
348 if ( a->a_nvals && !BER_BVISNULL( &a->a_nvals[0] ) ) {
349 ber_dupbv( &bv_nmodifyTimestamp, &a->a_nvals[0] );
351 ber_dupbv( &bv_nmodifyTimestamp, &a->a_vals[0] );
354 ber_dupbv( &bv_name, &e->e_name );
355 ber_dupbv( &bv_nname, &e->e_nname );
358 case LDAP_REQ_DELETE:
359 lmt = LASTMOD_DELETE;
361 best_guess( op, &bv_modifyTimestamp, &bv_nmodifyTimestamp,
362 &bv_modifiersName, &bv_nmodifiersName );
364 ber_dupbv( &bv_name, &op->o_req_dn );
365 ber_dupbv( &bv_nname, &op->o_req_ndn );
368 case LDAP_REQ_EXTENDED:
371 /* actually, password change is wrapped around a backend
372 * call to modify, so it never shows up as an exop... */
373 best_guess( op, &bv_modifyTimestamp, &bv_nmodifyTimestamp,
374 &bv_modifiersName, &bv_nmodifiersName );
376 ber_dupbv( &bv_name, &op->o_req_dn );
377 ber_dupbv( &bv_nname, &op->o_req_ndn );
380 case LDAP_REQ_MODIFY:
381 lmt = LASTMOD_MODIFY;
383 for ( ml = op->orm_modlist; ml; ml = ml->sml_next ) {
384 if ( ad_cmp( ml->sml_desc , slap_schema.si_ad_modifiersName ) == 0 ) {
385 ber_dupbv( &bv_modifiersName, &ml->sml_values[0] );
386 ber_dupbv( &bv_nmodifiersName, &ml->sml_nvalues[0] );
388 if ( !BER_BVISNULL( &bv_modifyTimestamp ) ) {
392 } else if ( ad_cmp( ml->sml_desc, slap_schema.si_ad_modifyTimestamp ) == 0 ) {
393 ber_dupbv( &bv_modifyTimestamp, &ml->sml_values[0] );
394 if ( ml->sml_nvalues && !BER_BVISNULL( &ml->sml_nvalues[0] ) ) {
395 ber_dupbv( &bv_nmodifyTimestamp, &ml->sml_nvalues[0] );
397 ber_dupbv( &bv_nmodifyTimestamp, &ml->sml_values[0] );
400 if ( !BER_BVISNULL( &bv_modifiersName ) ) {
406 ber_dupbv( &bv_name, &op->o_req_dn );
407 ber_dupbv( &bv_nname, &op->o_req_ndn );
410 case LDAP_REQ_MODRDN:
411 lmt = LASTMOD_MODRDN;
414 if ( op->orr_newSup && !BER_BVISNULL( op->orr_newSup ) ) {
415 build_new_dn( &bv_name, op->orr_newSup, &op->orr_newrdn, NULL );
416 build_new_dn( &bv_nname, op->orr_nnewSup, &op->orr_nnewrdn, NULL );
421 dnParent( &op->o_req_dn, &pdn );
422 build_new_dn( &bv_name, &pdn, &op->orr_newrdn, NULL );
424 dnParent( &op->o_req_ndn, &pdn );
425 build_new_dn( &bv_nname, &pdn, &op->orr_nnewrdn, NULL );
428 if ( on->on_info->oi_orig->bi_entry_get_rw ) {
429 BackendInfo *bi = op->o_bd->bd_info;
432 op->o_bd->bd_info = (BackendInfo *)on->on_info->oi_orig;
433 rc = (*op->o_bd->bd_info->bi_entry_get_rw)( op, &bv_name, NULL, NULL, 0, &e );
434 if ( rc == LDAP_SUCCESS ) {
435 a = attr_find( e->e_attrs, slap_schema.si_ad_modifiersName );
437 ber_dupbv( &bv_modifiersName, &a->a_vals[0] );
438 ber_dupbv( &bv_nmodifiersName, &a->a_nvals[0] );
440 a = attr_find( e->e_attrs, slap_schema.si_ad_modifyTimestamp );
442 ber_dupbv( &bv_modifyTimestamp, &a->a_vals[0] );
443 if ( a->a_nvals && !BER_BVISNULL( &a->a_nvals[0] ) ) {
444 ber_dupbv( &bv_nmodifyTimestamp, &a->a_nvals[0] );
446 ber_dupbv( &bv_nmodifyTimestamp, &a->a_vals[0] );
450 assert( dn_match( &bv_name, &e->e_name ) );
451 assert( dn_match( &bv_nname, &e->e_nname ) );
453 (*op->o_bd->bd_info->bi_entry_release_rw)( op, e, 0 );
456 op->o_bd->bd_info = bi;
460 /* if !bi_entry_get_rw || bi_entry_get_rw failed for any reason... */
462 best_guess( op, &bv_modifyTimestamp, &bv_nmodifyTimestamp,
463 &bv_modifiersName, &bv_nmodifiersName );
472 ldap_pvt_thread_mutex_lock( &lmi->lmi_entry_mutex );
475 fprintf( stderr, "### lastmodDN: %s %s\n", bv_name.bv_val, bv_nname.bv_val );
478 a = attr_find( lmi->lmi_e->e_attrs, lastmod_schema.lms_ad_lastmodDN );
482 ch_free( a->a_vals[0].bv_val );
483 a->a_vals[0] = bv_name;
484 ch_free( a->a_nvals[0].bv_val );
485 a->a_nvals[0] = bv_nname;
488 fprintf( stderr, "### lastmodType: %s %s\n", lastmodType[ lmt ].bv_val, lastmodType[ lmt ].bv_val );
491 a = attr_find( lmi->lmi_e->e_attrs, lastmod_schema.lms_ad_lastmodType );
495 ch_free( a->a_vals[0].bv_val );
496 ber_dupbv( &a->a_vals[0], &lastmodType[ lmt ] );
497 ch_free( a->a_nvals[0].bv_val );
498 ber_dupbv( &a->a_nvals[0], &lastmodType[ lmt ] );
501 fprintf( stderr, "### modifiersName: %s %s\n", bv_modifiersName.bv_val, bv_nmodifiersName.bv_val );
504 a = attr_find( lmi->lmi_e->e_attrs, slap_schema.si_ad_modifiersName );
508 ch_free( a->a_vals[0].bv_val );
509 a->a_vals[0] = bv_modifiersName;
510 ch_free( a->a_nvals[0].bv_val );
511 a->a_nvals[0] = bv_nmodifiersName;
514 fprintf( stderr, "### modifyTimestamp: %s %s\n", bv_nmodifyTimestamp.bv_val, bv_modifyTimestamp.bv_val );
517 a = attr_find( lmi->lmi_e->e_attrs, slap_schema.si_ad_modifyTimestamp );
521 ch_free( a->a_vals[0].bv_val );
522 a->a_vals[0] = bv_modifyTimestamp;
523 ch_free( a->a_nvals[0].bv_val );
524 a->a_nvals[0] = bv_nmodifyTimestamp;
529 ldap_pvt_thread_mutex_unlock( &lmi->lmi_entry_mutex );
535 lastmod_response( Operation *op, SlapReply *rs )
539 /* don't record failed operations */
540 switch ( rs->sr_err ) {
542 /* FIXME: other cases? */
546 return SLAP_CB_CONTINUE;
549 /* record only write operations */
550 switch ( op->o_tag ) {
552 case LDAP_REQ_MODIFY:
553 case LDAP_REQ_MODRDN:
554 case LDAP_REQ_DELETE:
557 case LDAP_REQ_EXTENDED:
558 /* if write, process */
559 for ( i = 0; write_exop[ i ] != NULL; i++ ) {
560 if ( ber_bvcmp( write_exop[ i ], &op->oq_extended.rs_reqoid ) == 0 ) {
567 return SLAP_CB_CONTINUE;
571 (void)lastmod_update( op, rs );
573 return SLAP_CB_CONTINUE;
581 slap_overinst *on = (slap_overinst *)be->bd_info;
584 if ( lastmod_schema.lms_oc_lastmod == NULL ) {
588 /* schema integration */
589 for ( i = 0; mat[i].name; i++ ) {
590 LDAPAttributeType *at;
593 AttributeDescription **ad;
595 at = ldap_str2attributetype( mat[i].schema, &code,
596 &err, LDAP_SCHEMA_ALLOW_ALL );
599 LDAP_LOG( OPERATION, CRIT, "lastmod_init: "
600 "in AttributeType '%s' %s before %s\n",
601 mat[i].name, ldap_scherr2str(code), err );
603 Debug( LDAP_DEBUG_ANY, "lastmod_init: "
604 "in AttributeType '%s' %s before %s\n",
605 mat[i].name, ldap_scherr2str(code), err );
610 if ( at->at_oid == NULL ) {
612 LDAP_LOG( OPERATION, CRIT, "lastmod_init: "
613 "null OID for attributeType '%s'\n",
616 Debug( LDAP_DEBUG_ANY, "lastmod_init: "
617 "null OID for attributeType '%s'\n",
623 code = at_add(at, &err);
626 LDAP_LOG( OPERATION, CRIT, "lastmod_init: "
627 "%s in attributeType '%s'\n",
628 scherr2str(code), mat[i].name, 0 );
630 Debug( LDAP_DEBUG_ANY, "lastmod_init: "
631 "%s in attributeType '%s'\n",
632 scherr2str(code), mat[i].name, 0 );
638 ad = ((AttributeDescription **)&(((char *)&lastmod_schema)[mat[i].offset]));
640 if ( slap_str2ad( mat[i].name, ad, &text ) ) {
642 LDAP_LOG( OPERATION, CRIT,
643 "lastmod_init: %s\n", text, 0, 0 );
645 Debug( LDAP_DEBUG_ANY,
646 "lastmod_init: %s\n", text, 0, 0 );
651 (*ad)->ad_type->sat_flags |= mat[i].flags;
654 for ( i = 0; moc[i].name; i++ ) {
660 oc = ldap_str2objectclass(moc[i].schema, &code, &err,
661 LDAP_SCHEMA_ALLOW_ALL );
664 LDAP_LOG( OPERATION, CRIT,
665 "unable to parse lastmod objectClass '%s': "
666 "%s before %s\n" , moc[i].name,
667 ldap_scherr2str(code), err );
669 Debug( LDAP_DEBUG_ANY,
670 "unable to parse lastmod objectClass '%s': "
671 "%s before %s\n" , moc[i].name,
672 ldap_scherr2str(code), err );
677 if ( oc->oc_oid == NULL ) {
679 LDAP_LOG( OPERATION, CRIT,
680 "objectClass '%s' has no OID\n" ,
683 Debug( LDAP_DEBUG_ANY,
684 "objectClass '%s' has no OID\n" ,
690 code = oc_add(oc, 0, &err);
693 LDAP_LOG( OPERATION, CRIT,
694 "objectClass '%s': %s \"%s\"\n" ,
695 moc[i].name, scherr2str(code), err );
697 Debug( LDAP_DEBUG_ANY,
698 "objectClass '%s': %s \"%s\"\n" ,
699 moc[i].name, scherr2str(code), err );
706 Oc = oc_find( moc[i].name );
709 LDAP_LOG( OPERATION, CRIT, "lastmod_init: "
710 "unable to find objectClass %s "
711 "(just added)\n", moc[i].name, 0, 0 );
713 Debug( LDAP_DEBUG_ANY, "lastmod_init: "
714 "unable to find objectClass %s "
715 "(just added)\n", moc[i].name, 0, 0 );
720 Oc->soc_flags |= moc[i].flags;
722 ((ObjectClass **)&(((char *)&lastmod_schema)[moc[i].offset]))[0] = Oc;
726 lmi = (lastmod_info_t *)ch_malloc( sizeof( lastmod_info_t ) );
727 memset( lmi, 0, sizeof( lastmod_info_t ) );
728 on->on_bi.bi_private = lmi;
742 slap_overinst *on = (slap_overinst *)be->bd_info;
743 lastmod_info_t *lmi = (lastmod_info_t *)on->on_bi.bi_private;
745 if ( strcasecmp( argv[ 0 ], "lastmod-rdnvalue" ) == 0 ) {
746 if ( lmi->lmi_rdnvalue.bv_val ) {
747 /* already defined! */
748 ch_free( lmi->lmi_rdnvalue.bv_val );
751 ber_str2bv( argv[ 1 ], 0, 1, &lmi->lmi_rdnvalue );
754 return SLAP_CONF_UNKNOWN;
765 slap_overinst *on = (slap_overinst *) be->bd_info;
766 lastmod_info_t *lmi = (lastmod_info_t *)on->on_bi.bi_private;
772 static char tmbuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
774 if ( !SLAP_LASTMOD( be ) ) {
775 fprintf( stderr, "set \"lastmod on\" to make this overlay effective\n" );
782 #ifndef HAVE_GMTIME_R
783 ldap_pvt_thread_mutex_lock( &gmtime_mutex );
784 tms = gmtime( &starttime );
785 #else /* HAVE_GMTIME_R */
786 tms = gmtime_r( &starttime, &tm_buf );
787 #endif /* HAVE_GMTIME_R */
788 lutil_gentime( tmbuf, sizeof(tmbuf), tms );
789 #ifndef HAVE_GMTIME_R
790 ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
793 if ( BER_BVISNULL( &lmi->lmi_rdnvalue ) ) {
794 ber_str2bv( "Lastmod", 0, 1, &lmi->lmi_rdnvalue );
797 snprintf( buf, sizeof( buf ),
800 "structuralObjectClass: %s\n"
802 "description: This object contains the last modification to this database\n"
805 "createTimestamp: %s\n"
807 "modifyTimestamp: %s\n"
808 "modifiersName: %s\n"
809 "hasSubordinates: FALSE\n",
810 lmi->lmi_rdnvalue.bv_val, be->be_suffix[ 0 ].bv_val,
811 lastmod_schema.lms_oc_lastmod->soc_cname.bv_val,
812 lastmod_schema.lms_oc_lastmod->soc_cname.bv_val,
813 lmi->lmi_rdnvalue.bv_val,
814 lastmod_schema.lms_ad_lastmodDN->ad_cname.bv_val, lmi->lmi_rdnvalue.bv_val, be->be_suffix[ 0 ].bv_val,
815 lastmod_schema.lms_ad_lastmodType->ad_cname.bv_val, lastmodType[ LASTMOD_ADD ].bv_val,
817 BER_BVISNULL( &be->be_rootdn ) ? "" : be->be_rootdn.bv_val,
819 BER_BVISNULL( &be->be_rootdn ) ? "" : be->be_rootdn.bv_val );
822 fprintf( stderr, "# entry:\n%s\n", buf );
825 lmi->lmi_e = str2entry( buf );
826 if ( lmi->lmi_e == NULL ) {
830 ldap_pvt_thread_mutex_init( &lmi->lmi_entry_mutex );
840 slap_overinst *on = (slap_overinst *)be->bd_info;
841 lastmod_info_t *lmi = (lastmod_info_t *)on->on_bi.bi_private;
844 if ( !BER_BVISNULL( &lmi->lmi_rdnvalue ) ) {
845 ch_free( lmi->lmi_rdnvalue.bv_val );
849 entry_free( lmi->lmi_e );
851 ldap_pvt_thread_mutex_destroy( &lmi->lmi_entry_mutex );
860 /* This overlay is set up for dynamic loading via moduleload. For static
861 * configuration, you'll need to arrange for the slap_overinst to be
862 * initialized and registered by some other function inside slapd.
865 static slap_overinst lastmod;
870 memset( &lastmod, 0, sizeof( slap_overinst ) );
871 lastmod.on_bi.bi_type = "lastmod";
872 lastmod.on_bi.bi_db_init = lastmod_db_init;
873 lastmod.on_bi.bi_db_config = lastmod_db_config;
874 lastmod.on_bi.bi_db_destroy = lastmod_db_destroy;
875 lastmod.on_bi.bi_db_open = lastmod_db_open;
877 lastmod.on_bi.bi_op_add = lastmod_op_func;
878 lastmod.on_bi.bi_op_compare = lastmod_op_func;
879 lastmod.on_bi.bi_op_delete = lastmod_op_func;
880 lastmod.on_bi.bi_op_modify = lastmod_op_func;
881 lastmod.on_bi.bi_op_modrdn = lastmod_op_func;
882 lastmod.on_bi.bi_op_search = lastmod_op_func;
883 lastmod.on_bi.bi_extended = lastmod_op_func;
885 lastmod.on_response = lastmod_response;
887 return overlay_register( &lastmod );
890 #if SLAPD_OVER_LASTMOD == SLAPD_MOD_DYNAMIC
892 init_module( int argc, char *argv[] )
894 return lastmod_init();
896 #endif /* SLAPD_OVER_LASTMOD == SLAPD_MOD_DYNAMIC */
898 #endif /* defined(SLAPD_OVER_LASTMOD) */