static int add_values(Entry *e, LDAPMod *mod, char *dn);
static int delete_values(Entry *e, LDAPMod *mod, char *dn);
static int replace_values(Entry *e, LDAPMod *mod, char *dn);
-static void add_lastmods(Operation *op, LDAPMod **mods);
-
-
-static void
-add_lastmods( Operation *op, LDAPMod **mods )
-{
- char buf[22];
- struct berval bv;
- struct berval *bvals[2];
- LDAPMod **m;
- LDAPMod *tmp;
- struct tm *ltm;
-
- Debug( LDAP_DEBUG_TRACE, "add_lastmods\n", 0, 0, 0 );
-
- bvals[0] = &bv;
- bvals[1] = NULL;
-
- /* remove any attempts by the user to modify these attrs */
- for ( m = mods; *m != NULL; m = &(*m)->mod_next ) {
- if ( strcasecmp( (*m)->mod_type, "modifytimestamp" ) == 0 ||
- strcasecmp( (*m)->mod_type, "modifiersname" ) == 0 ||
- strcasecmp( (*m)->mod_type, "createtimestamp" ) == 0 ||
- strcasecmp( (*m)->mod_type, "creatorsname" ) == 0 ) {
-
- Debug( LDAP_DEBUG_TRACE,
- "add_lastmods: found lastmod attr: %s\n",
- (*m)->mod_type, 0, 0 );
- tmp = *m;
- *m = (*m)->mod_next;
- free( tmp->mod_type );
- if ( tmp->mod_bvalues != NULL ) {
- ber_bvecfree( tmp->mod_bvalues );
- }
- free( tmp );
- if (!*m)
- break;
- }
- }
-
- if ( op->o_dn == NULL || op->o_dn[0] == '\0' ) {
- bv.bv_val = "NULLDN";
- bv.bv_len = strlen( bv.bv_val );
- } else {
- bv.bv_val = op->o_dn;
- bv.bv_len = strlen( bv.bv_val );
- }
- tmp = (LDAPMod *) ch_calloc( 1, sizeof(LDAPMod) );
- tmp->mod_type = ch_strdup( "modifiersname" );
- tmp->mod_op = LDAP_MOD_REPLACE;
- tmp->mod_bvalues = (struct berval **) ch_calloc( 1,
- 2 * sizeof(struct berval *) );
- tmp->mod_bvalues[0] = ber_bvdup( &bv );
- tmp->mod_next = *mods;
- *mods = tmp;
-
- ldap_pvt_thread_mutex_lock( ¤ttime_mutex );
-#ifndef LDAP_LOCALTIME
- ltm = gmtime( ¤ttime );
- strftime( buf, sizeof(buf), "%Y%m%d%H%M%SZ", ltm );
-#else
- ltm = localtime( ¤ttime );
- strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm );
-#endif
- ldap_pvt_thread_mutex_unlock( ¤ttime_mutex );
- bv.bv_val = buf;
- bv.bv_len = strlen( bv.bv_val );
- tmp = (LDAPMod *) ch_calloc( 1, sizeof(LDAPMod) );
- tmp->mod_type = ch_strdup( "modifytimestamp" );
- tmp->mod_op = LDAP_MOD_REPLACE;
- tmp->mod_bvalues = (struct berval **) ch_calloc( 1, 2 * sizeof(struct berval *) );
- tmp->mod_bvalues[0] = ber_bvdup( &bv );
- tmp->mod_next = *mods;
- *mods = tmp;
-}
/* We need this function because of LDAP modrdn. If we do not
* add this there would be a bunch of code replication here
Attribute *a;
Attribute *save_attrs;
- if ( ((be->be_lastmod == ON)
- || ((be->be_lastmod == UNDEFINED)&&(global_lastmod == ON)))
- && (be->be_update_ndn == NULL)) {
-
- /* XXX: It may be wrong, it changes mod time even if
- * mod fails! I also Think this is leaking memory...
- */
- add_lastmods( op, &mods );
-
- }
-
if ( (err = acl_check_mods( be, conn, op, e, mods )) != LDAP_SUCCESS ) {
send_ldap_result( conn, op, err, NULL, NULL );
return -1;
#include "slap.h"
+static void add_lastmods( Operation *op, LDAPMod **mods );
static void modlist_free(LDAPMod *mods);
if ( be->be_update_ndn == NULL ||
strcmp( be->be_update_ndn, op->o_ndn ) == 0 )
{
+ if(( be->be_lastmod == ON || (be->be_lastmod == UNDEFINED
+ && global_lastmod == ON )) && be->be_update_ndn == NULL )
+ {
+ add_lastmods( op, &mods );
+ }
if ( (*be->be_modify)( be, conn, op, ndn, mods ) == 0 ) {
replog( be, LDAP_REQ_MODIFY, ndn, mods, 0 );
modlist_free( mods );
}
+static void
+add_lastmods( Operation *op, LDAPMod **mods )
+{
+ char buf[22];
+ struct berval bv;
+ struct berval *bvals[2];
+ LDAPMod **m;
+ LDAPMod *tmp;
+ struct tm *ltm;
+
+ Debug( LDAP_DEBUG_TRACE, "add_lastmods\n", 0, 0, 0 );
+
+ bvals[0] = &bv;
+ bvals[1] = NULL;
+
+ /* remove any attempts by the user to modify these attrs */
+ for ( m = mods; *m != NULL; m = &(*m)->mod_next ) {
+ if ( strcasecmp( (*m)->mod_type, "modifytimestamp" ) == 0 ||
+ strcasecmp( (*m)->mod_type, "modifiersname" ) == 0 ||
+ strcasecmp( (*m)->mod_type, "createtimestamp" ) == 0 ||
+ strcasecmp( (*m)->mod_type, "creatorsname" ) == 0 ) {
+
+ Debug( LDAP_DEBUG_TRACE,
+ "add_lastmods: found lastmod attr: %s\n",
+ (*m)->mod_type, 0, 0 );
+ tmp = *m;
+ *m = (*m)->mod_next;
+ free( tmp->mod_type );
+ if ( tmp->mod_bvalues != NULL ) {
+ ber_bvecfree( tmp->mod_bvalues );
+ }
+ free( tmp );
+ if (!*m)
+ break;
+ }
+ }
+
+ if ( op->o_dn == NULL || op->o_dn[0] == '\0' ) {
+ bv.bv_val = "NULLDN";
+ bv.bv_len = strlen( bv.bv_val );
+ } else {
+ bv.bv_val = op->o_dn;
+ bv.bv_len = strlen( bv.bv_val );
+ }
+ tmp = (LDAPMod *) ch_calloc( 1, sizeof(LDAPMod) );
+ tmp->mod_type = ch_strdup( "modifiersname" );
+ tmp->mod_op = LDAP_MOD_REPLACE;
+ tmp->mod_bvalues = (struct berval **) ch_calloc( 1,
+ 2 * sizeof(struct berval *) );
+ tmp->mod_bvalues[0] = ber_bvdup( &bv );
+ tmp->mod_next = *mods;
+ *mods = tmp;
+
+ ldap_pvt_thread_mutex_lock( ¤ttime_mutex );
+#ifndef LDAP_LOCALTIME
+ ltm = gmtime( ¤ttime );
+ strftime( buf, sizeof(buf), "%Y%m%d%H%M%SZ", ltm );
+#else
+ ltm = localtime( ¤ttime );
+ strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm );
+#endif
+ ldap_pvt_thread_mutex_unlock( ¤ttime_mutex );
+ bv.bv_val = buf;
+ bv.bv_len = strlen( bv.bv_val );
+ tmp = (LDAPMod *) ch_calloc( 1, sizeof(LDAPMod) );
+ tmp->mod_type = ch_strdup( "modifytimestamp" );
+ tmp->mod_op = LDAP_MOD_REPLACE;
+ tmp->mod_bvalues = (struct berval **) ch_calloc( 1, 2 * sizeof(struct berval *) );
+ tmp->mod_bvalues[0] = ber_bvdup( &bv );
+ tmp->mod_next = *mods;
+ *mods = tmp;
+}
+
+
static void
modlist_free(
LDAPMod *mods