2000-09-28 06:28:59 +08:00
|
|
|
/* modrdn.c - bdb backend modrdn routine */
|
|
|
|
/* $OpenLDAP$ */
|
|
|
|
/*
|
2003-01-04 04:20:47 +08:00
|
|
|
* Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
|
2000-09-28 06:28:59 +08:00
|
|
|
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "portable.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <ac/string.h>
|
|
|
|
|
|
|
|
#include "back-bdb.h"
|
|
|
|
#include "external.h"
|
|
|
|
|
|
|
|
int
|
2003-03-30 17:03:54 +08:00
|
|
|
bdb_modrdn( Operation *op, SlapReply *rs )
|
2000-09-28 06:28:59 +08:00
|
|
|
{
|
2003-03-30 17:03:54 +08:00
|
|
|
struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
|
2000-09-28 06:28:59 +08:00
|
|
|
AttributeDescription *children = slap_schema.si_ad_children;
|
2002-10-05 07:26:28 +08:00
|
|
|
AttributeDescription *entry = slap_schema.si_ad_entry;
|
2001-12-27 08:58:14 +08:00
|
|
|
struct berval p_dn, p_ndn;
|
2001-12-29 12:48:00 +08:00
|
|
|
struct berval new_dn = {0, NULL}, new_ndn = {0, NULL};
|
2001-11-16 23:00:03 +08:00
|
|
|
int isroot = -1;
|
2002-04-30 00:42:41 +08:00
|
|
|
Entry *e = NULL;
|
|
|
|
Entry *p = NULL;
|
2000-09-28 06:28:59 +08:00
|
|
|
Entry *matched;
|
2002-08-17 00:35:16 +08:00
|
|
|
/* LDAP v2 supporting correct attribute handling. */
|
2003-04-11 09:29:28 +08:00
|
|
|
LDAPRDN new_rdn = NULL;
|
|
|
|
LDAPRDN old_rdn = NULL;
|
2001-06-15 15:08:37 +08:00
|
|
|
char textbuf[SLAP_TEXT_BUFLEN];
|
|
|
|
size_t textlen = sizeof textbuf;
|
2001-10-22 23:57:58 +08:00
|
|
|
DB_TXN * ltid = NULL;
|
2000-09-28 06:28:59 +08:00
|
|
|
struct bdb_op_info opinfo;
|
|
|
|
|
|
|
|
ID id;
|
|
|
|
|
2002-01-25 15:19:01 +08:00
|
|
|
Entry *np = NULL; /* newSuperior Entry */
|
2001-12-27 08:58:14 +08:00
|
|
|
struct berval *np_dn = NULL; /* newSuperior dn */
|
|
|
|
struct berval *np_ndn = NULL; /* newSuperior ndn */
|
|
|
|
struct berval *new_parent_dn = NULL; /* np_dn, p_dn, or NULL */
|
2000-09-28 06:28:59 +08:00
|
|
|
|
|
|
|
/* Used to interface with bdb_modify_internal() */
|
2001-10-02 18:39:04 +08:00
|
|
|
Modifications *mod = NULL; /* Used to delete old rdn */
|
2000-09-28 06:28:59 +08:00
|
|
|
|
|
|
|
int manageDSAit = get_manageDSAit( op );
|
|
|
|
|
2003-02-07 23:47:32 +08:00
|
|
|
u_int32_t locker = 0;
|
2002-06-01 04:49:19 +08:00
|
|
|
DB_LOCK lock;
|
|
|
|
|
2002-08-31 20:00:39 +08:00
|
|
|
int noop = 0;
|
|
|
|
|
2003-02-05 15:37:02 +08:00
|
|
|
#if defined(LDAP_CLIENT_UPDATE) || defined(LDAP_SYNC)
|
2003-03-30 17:03:54 +08:00
|
|
|
Operation *ps_list;
|
|
|
|
struct psid_entry *pm_list, *pm_prev;
|
2002-10-26 01:51:30 +08:00
|
|
|
#endif
|
|
|
|
|
2002-03-15 06:23:44 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ENTRY, "==>bdb_modrdn(%s,%s,%s)\n",
|
2003-03-30 17:03:54 +08:00
|
|
|
op->o_req_dn.bv_val,op->oq_modrdn.rs_newrdn.bv_val,
|
|
|
|
op->oq_modrdn.rs_newSup ? op->oq_modrdn.rs_newSup->bv_val : "NULL" );
|
2002-03-15 06:23:44 +08:00
|
|
|
#else
|
2000-09-28 06:28:59 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE, "==>bdb_modrdn(%s,%s,%s)\n",
|
2003-03-30 17:03:54 +08:00
|
|
|
op->o_req_dn.bv_val,op->oq_modrdn.rs_newrdn.bv_val,
|
|
|
|
op->oq_modrdn.rs_newSup ? op->oq_modrdn.rs_newSup->bv_val : "NULL" );
|
2002-03-15 06:23:44 +08:00
|
|
|
#endif
|
2000-09-28 06:28:59 +08:00
|
|
|
|
2001-11-28 05:59:56 +08:00
|
|
|
if( 0 ) {
|
2000-09-29 02:29:50 +08:00
|
|
|
retry: /* transaction retry */
|
2002-01-25 15:19:01 +08:00
|
|
|
if (e != NULL) {
|
|
|
|
bdb_cache_delete_entry(&bdb->bi_cache, e);
|
2002-06-06 18:14:14 +08:00
|
|
|
bdb_unlocked_cache_return_entry_w(&bdb->bi_cache, e);
|
2003-03-12 23:20:51 +08:00
|
|
|
e = NULL;
|
2002-01-25 15:19:01 +08:00
|
|
|
}
|
|
|
|
if (p != NULL) {
|
2002-06-06 18:14:14 +08:00
|
|
|
bdb_unlocked_cache_return_entry_r(&bdb->bi_cache, p);
|
2003-03-12 23:20:51 +08:00
|
|
|
p = NULL;
|
2002-01-25 15:19:01 +08:00
|
|
|
}
|
|
|
|
if (np != NULL) {
|
2002-06-06 18:14:14 +08:00
|
|
|
bdb_unlocked_cache_return_entry_r(&bdb->bi_cache, np);
|
2003-03-12 23:20:51 +08:00
|
|
|
np = NULL;
|
2002-01-25 15:19:01 +08:00
|
|
|
}
|
2002-03-15 06:23:44 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, DETAIL1, "==>bdb_modrdn: retrying...\n", 0, 0, 0);
|
2002-03-15 06:23:44 +08:00
|
|
|
#else
|
2000-09-29 02:29:50 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE, "==>bdb_modrdn: retrying...\n", 0, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#endif
|
2002-10-26 01:51:30 +08:00
|
|
|
|
2003-02-05 15:37:02 +08:00
|
|
|
#if defined(LDAP_CLIENT_UPDATE) || defined(LDAP_SYNC)
|
2003-03-30 17:03:54 +08:00
|
|
|
pm_list = LDAP_LIST_FIRST(&op->o_pm_list);
|
2002-10-26 01:51:30 +08:00
|
|
|
while ( pm_list != NULL ) {
|
2003-03-30 17:03:54 +08:00
|
|
|
LDAP_LIST_REMOVE ( pm_list, ps_link );
|
|
|
|
pm_prev = pm_list;
|
|
|
|
pm_list = LDAP_LIST_NEXT ( pm_list, ps_link );
|
|
|
|
ch_free( pm_prev );
|
2002-10-26 01:51:30 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = TXN_ABORT( ltid );
|
2000-09-28 06:28:59 +08:00
|
|
|
ltid = NULL;
|
|
|
|
op->o_private = NULL;
|
2003-02-26 20:09:10 +08:00
|
|
|
op->o_do_not_cache = opinfo.boi_acl_cache;
|
2003-03-30 17:03:54 +08:00
|
|
|
if( rs->sr_err != 0 ) {
|
|
|
|
rs->sr_err = LDAP_OTHER;
|
|
|
|
rs->sr_text = "internal error";
|
2000-09-28 06:28:59 +08:00
|
|
|
goto return_results;
|
|
|
|
}
|
2002-01-18 21:34:50 +08:00
|
|
|
ldap_pvt_thread_yield();
|
2000-09-28 06:28:59 +08:00
|
|
|
}
|
|
|
|
|
2002-01-29 06:57:50 +08:00
|
|
|
/* begin transaction */
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = TXN_BEGIN( bdb->bi_dbenv, NULL, <id,
|
2002-01-29 06:57:50 +08:00
|
|
|
bdb->bi_db_opflags );
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_text = NULL;
|
|
|
|
if( rs->sr_err != 0 ) {
|
2002-03-15 06:23:44 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR,
|
|
|
|
"==>bdb_modrdn: txn_begin failed: %s (%d)\n",
|
2003-03-30 17:03:54 +08:00
|
|
|
db_strerror(rs->sr_err), rs->sr_err, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#else
|
2002-01-29 06:57:50 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE,
|
|
|
|
"bdb_delete: txn_begin failed: %s (%d)\n",
|
2003-03-30 17:03:54 +08:00
|
|
|
db_strerror(rs->sr_err), rs->sr_err, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#endif
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = LDAP_OTHER;
|
|
|
|
rs->sr_text = "internal error";
|
2002-01-29 06:57:50 +08:00
|
|
|
goto return_results;
|
2000-09-28 06:28:59 +08:00
|
|
|
}
|
|
|
|
|
2002-06-01 04:49:19 +08:00
|
|
|
locker = TXN_ID ( ltid );
|
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
opinfo.boi_bdb = op->o_bd;
|
2000-09-28 06:28:59 +08:00
|
|
|
opinfo.boi_txn = ltid;
|
2003-02-07 23:47:32 +08:00
|
|
|
opinfo.boi_locker = locker;
|
2000-09-28 06:28:59 +08:00
|
|
|
opinfo.boi_err = 0;
|
2003-02-26 20:09:10 +08:00
|
|
|
opinfo.boi_acl_cache = op->o_do_not_cache;
|
2000-09-28 06:28:59 +08:00
|
|
|
op->o_private = &opinfo;
|
|
|
|
|
|
|
|
/* get entry */
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = bdb_dn2entry_w( op->o_bd, ltid, &op->o_req_ndn, &e, &matched, DB_RMW, locker, &lock );
|
2000-09-28 06:28:59 +08:00
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
switch( rs->sr_err ) {
|
2000-09-28 06:28:59 +08:00
|
|
|
case 0:
|
|
|
|
case DB_NOTFOUND:
|
|
|
|
break;
|
|
|
|
case DB_LOCK_DEADLOCK:
|
|
|
|
case DB_LOCK_NOTGRANTED:
|
|
|
|
goto retry;
|
2002-04-20 05:41:32 +08:00
|
|
|
case LDAP_BUSY:
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_text = "ldap server busy";
|
2002-04-20 05:41:32 +08:00
|
|
|
goto return_results;
|
2000-09-28 06:28:59 +08:00
|
|
|
default:
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = LDAP_OTHER;
|
|
|
|
rs->sr_text = "internal error";
|
2000-09-28 06:28:59 +08:00
|
|
|
goto return_results;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( e == NULL ) {
|
|
|
|
if( matched != NULL ) {
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_matched = ch_strdup( matched->e_dn );
|
|
|
|
rs->sr_ref = is_entry_referral( matched )
|
|
|
|
? get_entry_referrals( op, matched )
|
2000-09-28 06:28:59 +08:00
|
|
|
: NULL;
|
2002-06-06 18:14:14 +08:00
|
|
|
bdb_unlocked_cache_return_entry_r( &bdb->bi_cache, matched);
|
2000-09-28 10:27:49 +08:00
|
|
|
matched = NULL;
|
|
|
|
|
2000-09-28 06:28:59 +08:00
|
|
|
} else {
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_ref = referral_rewrite( default_referral,
|
|
|
|
NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
|
2000-09-28 06:28:59 +08:00
|
|
|
}
|
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = LDAP_REFERRAL;
|
|
|
|
send_ldap_result( op, rs );
|
2000-09-28 06:28:59 +08:00
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
ber_bvarray_free( rs->sr_ref );
|
|
|
|
free( (char *)rs->sr_matched );
|
|
|
|
rs->sr_ref = NULL;
|
|
|
|
rs->sr_matched = NULL;
|
2000-09-28 06:28:59 +08:00
|
|
|
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2002-12-30 09:02:31 +08:00
|
|
|
/* check write on old entry */
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = access_allowed( op, e, entry, NULL, ACL_WRITE, NULL );
|
2002-12-30 09:02:31 +08:00
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
if ( ! rs->sr_err ) {
|
2003-02-26 20:49:21 +08:00
|
|
|
switch( opinfo.boi_err ) {
|
|
|
|
case DB_LOCK_DEADLOCK:
|
|
|
|
case DB_LOCK_NOTGRANTED:
|
|
|
|
goto retry;
|
|
|
|
}
|
|
|
|
|
2002-10-05 07:42:27 +08:00
|
|
|
#ifdef NEW_LOGGING
|
|
|
|
LDAP_LOG ( OPERATION, ERR,
|
|
|
|
"==>bdb_modrdn: no access to entry\n", 0, 0, 0 );
|
|
|
|
#else
|
|
|
|
Debug( LDAP_DEBUG_TRACE, "no access to entry\n", 0,
|
|
|
|
0, 0 );
|
|
|
|
#endif
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_text = "no write access to old entry";
|
|
|
|
rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
|
2002-10-05 07:42:27 +08:00
|
|
|
goto return_results;
|
|
|
|
}
|
|
|
|
|
2003-02-28 13:18:29 +08:00
|
|
|
#ifndef BDB_HIER
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = bdb_dn2id_children( op->o_bd, ltid, &e->e_nname, 0 );
|
|
|
|
if ( rs->sr_err != DB_NOTFOUND ) {
|
|
|
|
switch( rs->sr_err ) {
|
2003-02-28 13:18:29 +08:00
|
|
|
case DB_LOCK_DEADLOCK:
|
|
|
|
case DB_LOCK_NOTGRANTED:
|
|
|
|
goto retry;
|
|
|
|
case 0:
|
|
|
|
#ifdef NEW_LOGGING
|
|
|
|
LDAP_LOG ( OPERATION, DETAIL1,
|
2003-03-30 17:03:54 +08:00
|
|
|
"<=- bdb_modrdn: non-leaf %s\n", op->o_req_dn.bv_val, 0, 0 );
|
2003-02-28 13:18:29 +08:00
|
|
|
#else
|
|
|
|
Debug(LDAP_DEBUG_ARGS,
|
|
|
|
"<=- bdb_modrdn: non-leaf %s\n",
|
2003-03-30 17:03:54 +08:00
|
|
|
op->o_req_dn.bv_val, 0, 0);
|
2003-02-28 13:18:29 +08:00
|
|
|
#endif
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = LDAP_NOT_ALLOWED_ON_NONLEAF;
|
|
|
|
rs->sr_text = "subtree rename not supported";
|
2003-02-28 13:18:29 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
#ifdef NEW_LOGGING
|
|
|
|
LDAP_LOG ( OPERATION, ERR,
|
|
|
|
"<=- bdb_modrdn: has_children failed %s (%d)\n",
|
2003-03-30 17:03:54 +08:00
|
|
|
db_strerror(rs->sr_err), rs->sr_err, 0 );
|
2003-02-28 13:18:29 +08:00
|
|
|
#else
|
|
|
|
Debug(LDAP_DEBUG_ARGS,
|
|
|
|
"<=- bdb_modrdn: has_children failed: %s (%d)\n",
|
2003-03-30 17:03:54 +08:00
|
|
|
db_strerror(rs->sr_err), rs->sr_err, 0 );
|
2003-02-28 13:18:29 +08:00
|
|
|
#endif
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = LDAP_OTHER;
|
|
|
|
rs->sr_text = "internal error";
|
2003-02-28 13:18:29 +08:00
|
|
|
}
|
|
|
|
goto return_results;
|
|
|
|
}
|
|
|
|
#endif
|
2000-09-28 06:28:59 +08:00
|
|
|
if (!manageDSAit && is_entry_referral( e ) ) {
|
|
|
|
/* parent is a referral, don't allow add */
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_ref = get_entry_referrals( op, e );
|
2000-09-28 06:28:59 +08:00
|
|
|
|
2002-03-15 06:23:44 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, DETAIL1,
|
|
|
|
"==>bdb_modrdn: entry %s is referral \n", e->e_dn, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#else
|
2001-11-05 14:24:11 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: entry %s is referral\n",
|
|
|
|
e->e_dn, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#endif
|
2000-09-28 06:28:59 +08:00
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = LDAP_REFERRAL,
|
|
|
|
rs->sr_matched = e->e_name.bv_val;
|
|
|
|
send_ldap_result( op, rs );
|
2000-09-28 06:28:59 +08:00
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
ber_bvarray_free( rs->sr_ref );
|
|
|
|
rs->sr_ref = NULL;
|
|
|
|
rs->sr_matched = NULL;
|
2000-09-28 06:28:59 +08:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
if ( be_issuffix( op->o_bd, &e->e_nname ) ) {
|
2002-01-26 14:40:56 +08:00
|
|
|
p_ndn = slap_empty_bv;
|
2002-01-18 06:47:55 +08:00
|
|
|
} else {
|
2002-01-26 16:44:59 +08:00
|
|
|
dnParent( &e->e_nname, &p_ndn );
|
2002-01-18 06:47:55 +08:00
|
|
|
}
|
2001-12-27 08:58:14 +08:00
|
|
|
np_ndn = &p_ndn;
|
|
|
|
if ( p_ndn.bv_len != 0 ) {
|
2000-09-28 06:28:59 +08:00
|
|
|
/* Make sure parent entry exist and we can write its
|
|
|
|
* children.
|
|
|
|
*/
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = bdb_dn2entry_r( op->o_bd, ltid, &p_ndn, &p, NULL, 0, locker, &lock );
|
2000-09-28 06:28:59 +08:00
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
switch( rs->sr_err ) {
|
2000-09-28 06:28:59 +08:00
|
|
|
case 0:
|
|
|
|
case DB_NOTFOUND:
|
|
|
|
break;
|
|
|
|
case DB_LOCK_DEADLOCK:
|
|
|
|
case DB_LOCK_NOTGRANTED:
|
|
|
|
goto retry;
|
2002-04-20 05:41:32 +08:00
|
|
|
case LDAP_BUSY:
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_text = "ldap server busy";
|
2002-04-20 05:41:32 +08:00
|
|
|
goto return_results;
|
2000-09-28 06:28:59 +08:00
|
|
|
default:
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = LDAP_OTHER;
|
|
|
|
rs->sr_text = "internal error";
|
2000-09-28 06:28:59 +08:00
|
|
|
goto return_results;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( p == NULL) {
|
2002-03-15 06:23:44 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR,
|
|
|
|
"==>bdb_modrdn: parent does not exist\n", 0, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#else
|
2000-09-28 06:28:59 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: parent does not exist\n",
|
|
|
|
0, 0, 0);
|
2002-03-15 06:23:44 +08:00
|
|
|
#endif
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = LDAP_OTHER;
|
|
|
|
rs->sr_text = "old entry's parent does not exist";
|
2000-09-28 06:28:59 +08:00
|
|
|
goto return_results;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check parent for "children" acl */
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = access_allowed( op, p,
|
2002-12-30 12:23:31 +08:00
|
|
|
children, NULL, ACL_WRITE, NULL );
|
2002-12-30 09:12:10 +08:00
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
if ( ! rs->sr_err ) {
|
2003-02-26 20:49:21 +08:00
|
|
|
switch( opinfo.boi_err ) {
|
|
|
|
case DB_LOCK_DEADLOCK:
|
|
|
|
case DB_LOCK_NOTGRANTED:
|
|
|
|
goto retry;
|
|
|
|
}
|
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
|
2002-03-15 06:23:44 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR,
|
|
|
|
"==>bdb_modrdn: no access to parent\n", 0, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#else
|
2000-09-28 06:28:59 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE, "no access to parent\n", 0,
|
|
|
|
0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#endif
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_text = "no write access to old parent's children";
|
2000-09-28 06:28:59 +08:00
|
|
|
goto return_results;
|
|
|
|
}
|
|
|
|
|
2002-03-15 06:23:44 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, DETAIL1,
|
|
|
|
"==>bdb_modrdn: wr to children %s is OK\n", p_ndn.bv_val, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#else
|
2000-09-28 06:28:59 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE,
|
|
|
|
"bdb_modrdn: wr to children of entry %s OK\n",
|
2001-12-27 08:58:14 +08:00
|
|
|
p_ndn.bv_val, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#endif
|
2000-09-28 06:28:59 +08:00
|
|
|
|
2002-01-26 14:40:56 +08:00
|
|
|
if ( p_ndn.bv_val == slap_empty_bv.bv_val ) {
|
|
|
|
p_dn = slap_empty_bv;
|
2002-01-18 06:47:55 +08:00
|
|
|
} else {
|
2002-01-26 16:44:59 +08:00
|
|
|
dnParent( &e->e_name, &p_dn );
|
2002-01-18 06:47:55 +08:00
|
|
|
}
|
2000-09-28 06:28:59 +08:00
|
|
|
|
2002-03-15 06:23:44 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, DETAIL1,
|
|
|
|
"==>bdb_modrdn: parent dn=%s\n", p_dn.bv_val, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#else
|
2000-09-28 06:28:59 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE,
|
|
|
|
"bdb_modrdn: parent dn=%s\n",
|
2001-12-27 08:58:14 +08:00
|
|
|
p_dn.bv_val, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#endif
|
2000-09-28 06:28:59 +08:00
|
|
|
|
|
|
|
} else {
|
|
|
|
/* no parent, modrdn entry directly under root */
|
2003-03-30 17:03:54 +08:00
|
|
|
isroot = be_isroot( op->o_bd, &op->o_ndn );
|
2001-11-16 23:00:03 +08:00
|
|
|
if ( ! isroot ) {
|
2003-03-30 17:03:54 +08:00
|
|
|
if ( be_issuffix( op->o_bd, (struct berval *)&slap_empty_bv )
|
|
|
|
|| be_isupdate( op->o_bd, &op->o_ndn ) ) {
|
2001-11-16 23:00:03 +08:00
|
|
|
|
2001-11-17 01:05:32 +08:00
|
|
|
p = (Entry *)&slap_entry_root;
|
2001-11-16 23:00:03 +08:00
|
|
|
|
|
|
|
/* check parent for "children" acl */
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = access_allowed( op, p,
|
2002-02-09 13:14:17 +08:00
|
|
|
children, NULL, ACL_WRITE, NULL );
|
2001-11-16 23:00:03 +08:00
|
|
|
|
|
|
|
p = NULL;
|
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
if ( ! rs->sr_err ) {
|
2003-02-26 20:49:21 +08:00
|
|
|
switch( opinfo.boi_err ) {
|
|
|
|
case DB_LOCK_DEADLOCK:
|
|
|
|
case DB_LOCK_NOTGRANTED:
|
|
|
|
goto retry;
|
|
|
|
}
|
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
|
2002-03-15 06:23:44 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR,
|
|
|
|
"==>bdb_modrdn: no access to parent\n", 0, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#else
|
2001-11-16 23:00:03 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE,
|
|
|
|
"no access to parent\n",
|
|
|
|
0, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#endif
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_text = "no write access to old parent";
|
2001-11-16 23:00:03 +08:00
|
|
|
goto return_results;
|
|
|
|
}
|
|
|
|
|
2002-03-15 06:23:44 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, DETAIL1,
|
|
|
|
"==>bdb_modrdn: wr to children of entry \"%s\" OK\n",
|
|
|
|
p_dn.bv_val, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#else
|
2001-11-16 23:00:03 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE,
|
|
|
|
"bdb_modrdn: wr to children of entry \"\" OK\n",
|
|
|
|
0, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#endif
|
2001-11-16 23:00:03 +08:00
|
|
|
|
2001-12-27 08:58:14 +08:00
|
|
|
p_dn.bv_val = "";
|
|
|
|
p_dn.bv_len = 0;
|
2001-11-16 23:00:03 +08:00
|
|
|
|
2002-03-15 06:23:44 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, DETAIL1,
|
|
|
|
"==>bdb_modrdn: parent dn=\"\" \n", 0, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#else
|
2001-11-16 23:00:03 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE,
|
|
|
|
"bdb_modrdn: parent dn=\"\"\n",
|
|
|
|
0, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#endif
|
2001-11-16 23:00:03 +08:00
|
|
|
|
|
|
|
} else {
|
2002-03-15 06:23:44 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR,
|
|
|
|
"==>bdb_modrdn: no parent, not root &\"\" is not "
|
|
|
|
"suffix\n", 0, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#else
|
2001-11-16 23:00:03 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE,
|
|
|
|
"bdb_modrdn: no parent, not root "
|
|
|
|
"& \"\" is not suffix\n",
|
|
|
|
0, 0, 0);
|
2002-03-15 06:23:44 +08:00
|
|
|
#endif
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_text = "no write access to old parent";
|
|
|
|
rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
|
2001-11-16 23:00:03 +08:00
|
|
|
goto return_results;
|
|
|
|
}
|
2000-09-28 06:28:59 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-12-27 08:58:14 +08:00
|
|
|
new_parent_dn = &p_dn; /* New Parent unless newSuperior given */
|
2000-09-28 06:28:59 +08:00
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
if ( op->oq_modrdn.rs_newSup != NULL ) {
|
2002-03-15 06:23:44 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, DETAIL1,
|
|
|
|
"==>bdb_modrdn: new parent \"%s\" requested...\n",
|
2003-03-30 17:03:54 +08:00
|
|
|
op->oq_modrdn.rs_newSup->bv_val, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#else
|
2000-09-28 06:28:59 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE,
|
|
|
|
"bdb_modrdn: new parent \"%s\" requested...\n",
|
2003-03-30 17:03:54 +08:00
|
|
|
op->oq_modrdn.rs_newSup->bv_val, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#endif
|
2000-09-28 06:28:59 +08:00
|
|
|
|
2002-10-25 09:09:50 +08:00
|
|
|
/* newSuperior == oldParent? */
|
2003-03-30 17:03:54 +08:00
|
|
|
if( dn_match( &p_ndn, op->oq_modrdn.rs_nnewSup ) ) {
|
2002-10-25 09:09:50 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2003-02-28 13:24:08 +08:00
|
|
|
LDAP_LOG( BACK_BDB, INFO, "bdb_back_modrdn: "
|
2002-10-25 09:09:50 +08:00
|
|
|
"new parent \"%s\" same as the old parent \"%s\"\n",
|
2003-03-30 17:03:54 +08:00
|
|
|
op->oq_modrdn.rs_newSup->bv_val, p_dn.bv_val, 0 );
|
2002-10-25 09:09:50 +08:00
|
|
|
#else
|
|
|
|
Debug( LDAP_DEBUG_TRACE, "bdb_back_modrdn: "
|
|
|
|
"new parent \"%s\" same as the old parent \"%s\"\n",
|
2003-03-30 17:03:54 +08:00
|
|
|
op->oq_modrdn.rs_newSup->bv_val, p_dn.bv_val, 0 );
|
2002-10-25 09:09:50 +08:00
|
|
|
#endif
|
2003-03-30 17:03:54 +08:00
|
|
|
op->oq_modrdn.rs_newSup = NULL; /* ignore newSuperior */
|
2002-10-25 09:09:50 +08:00
|
|
|
}
|
|
|
|
}
|
2002-12-30 09:12:10 +08:00
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
if ( op->oq_modrdn.rs_newSup != NULL ) {
|
|
|
|
if ( op->oq_modrdn.rs_newSup->bv_len ) {
|
|
|
|
np_dn = op->oq_modrdn.rs_newSup;
|
|
|
|
np_ndn = op->oq_modrdn.rs_nnewSup;
|
2001-11-16 23:00:03 +08:00
|
|
|
|
|
|
|
/* newSuperior == oldParent?, if so ==> ERROR */
|
|
|
|
/* newSuperior == entry being moved?, if so ==> ERROR */
|
|
|
|
/* Get Entry with dn=newSuperior. Does newSuperior exist? */
|
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = bdb_dn2entry_r( op->o_bd,
|
|
|
|
ltid, np_ndn, &np, NULL, 0, locker, &lock );
|
2001-11-16 23:00:03 +08:00
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
switch( rs->sr_err ) {
|
2001-11-16 23:00:03 +08:00
|
|
|
case 0:
|
|
|
|
case DB_NOTFOUND:
|
|
|
|
break;
|
|
|
|
case DB_LOCK_DEADLOCK:
|
|
|
|
case DB_LOCK_NOTGRANTED:
|
|
|
|
goto retry;
|
2002-04-20 05:41:32 +08:00
|
|
|
case LDAP_BUSY:
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_text = "ldap server busy";
|
2002-04-20 05:41:32 +08:00
|
|
|
goto return_results;
|
2001-11-16 23:00:03 +08:00
|
|
|
default:
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = LDAP_OTHER;
|
|
|
|
rs->sr_text = "internal error";
|
2001-11-16 23:00:03 +08:00
|
|
|
goto return_results;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( np == NULL) {
|
2002-03-15 06:23:44 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, DETAIL1,
|
|
|
|
"==>bdb_modrdn: newSup(ndn=%s) not here!\n",
|
|
|
|
np_ndn->bv_val, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#else
|
2001-11-16 23:00:03 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE,
|
|
|
|
"bdb_modrdn: newSup(ndn=%s) not here!\n",
|
2001-12-27 08:58:14 +08:00
|
|
|
np_ndn->bv_val, 0, 0);
|
2002-03-15 06:23:44 +08:00
|
|
|
#endif
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_text = "new superior not found";
|
|
|
|
rs->sr_err = LDAP_OTHER;
|
2001-11-16 23:00:03 +08:00
|
|
|
goto return_results;
|
|
|
|
}
|
2000-09-28 06:28:59 +08:00
|
|
|
|
2002-03-15 06:23:44 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, DETAIL1,
|
|
|
|
"==>bdb_modrdn: wr to new parent OK np=%p, id=%ld\n",
|
|
|
|
np, (long) np->e_id, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#else
|
2000-09-28 06:28:59 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE,
|
2001-11-16 23:00:03 +08:00
|
|
|
"bdb_modrdn: wr to new parent OK np=%p, id=%ld\n",
|
|
|
|
np, (long) np->e_id, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#endif
|
2001-11-16 23:00:03 +08:00
|
|
|
|
|
|
|
/* check newSuperior for "children" acl */
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = access_allowed( op, np, children,
|
2002-12-30 09:12:10 +08:00
|
|
|
NULL, ACL_WRITE, NULL );
|
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
if( ! rs->sr_err ) {
|
2003-02-26 20:49:21 +08:00
|
|
|
switch( opinfo.boi_err ) {
|
|
|
|
case DB_LOCK_DEADLOCK:
|
|
|
|
case DB_LOCK_NOTGRANTED:
|
|
|
|
goto retry;
|
|
|
|
}
|
|
|
|
|
2002-03-15 06:23:44 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, DETAIL1,
|
|
|
|
"==>bdb_modrdn: no wr to newSup children\n", 0, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#else
|
2001-11-16 23:00:03 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE,
|
|
|
|
"bdb_modrdn: no wr to newSup children\n",
|
|
|
|
0, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#endif
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_text = "no write access to new superior's children";
|
|
|
|
rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
|
2001-11-16 23:00:03 +08:00
|
|
|
goto return_results;
|
|
|
|
}
|
|
|
|
|
2002-01-29 12:53:47 +08:00
|
|
|
#ifdef BDB_ALIASES
|
2001-11-16 23:00:03 +08:00
|
|
|
if ( is_entry_alias( np ) ) {
|
|
|
|
/* parent is an alias, don't allow add */
|
2002-03-15 06:23:44 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, DETAIL1,
|
|
|
|
"==>bdb_modrdn: entry is alias\n", 0, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#else
|
2001-11-16 23:00:03 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: entry is alias\n",
|
|
|
|
0, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#endif
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_text = "new superior is an alias";
|
|
|
|
rs->sr_err = LDAP_ALIAS_PROBLEM;
|
2001-11-16 23:00:03 +08:00
|
|
|
goto return_results;
|
|
|
|
}
|
2002-01-29 12:53:47 +08:00
|
|
|
#endif
|
2001-11-16 23:00:03 +08:00
|
|
|
|
|
|
|
if ( is_entry_referral( np ) ) {
|
|
|
|
/* parent is a referral, don't allow add */
|
2002-03-15 06:23:44 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, DETAIL1,
|
|
|
|
"==>bdb_modrdn: entry is referral\n", 0, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#else
|
2001-11-16 23:00:03 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: entry is referral\n",
|
|
|
|
0, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#endif
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_text = "new superior is a referral";
|
|
|
|
rs->sr_err = LDAP_OTHER;
|
2001-11-16 23:00:03 +08:00
|
|
|
goto return_results;
|
|
|
|
}
|
2000-09-28 06:28:59 +08:00
|
|
|
|
2001-11-16 23:00:03 +08:00
|
|
|
} else {
|
|
|
|
if ( isroot == -1 ) {
|
2003-03-30 17:03:54 +08:00
|
|
|
isroot = be_isroot( op->o_bd, &op->o_ndn );
|
2001-11-16 23:00:03 +08:00
|
|
|
}
|
|
|
|
|
2001-12-27 08:58:14 +08:00
|
|
|
np_dn = NULL;
|
2001-11-16 23:00:03 +08:00
|
|
|
|
|
|
|
/* no parent, modrdn entry directly under root */
|
|
|
|
if ( ! isroot ) {
|
2003-03-30 17:03:54 +08:00
|
|
|
if ( be_issuffix( op->o_bd, (struct berval *)&slap_empty_bv )
|
|
|
|
|| be_isupdate( op->o_bd, &op->o_ndn ) ) {
|
2001-11-17 01:05:32 +08:00
|
|
|
np = (Entry *)&slap_entry_root;
|
2001-11-16 23:00:03 +08:00
|
|
|
|
|
|
|
/* check parent for "children" acl */
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = access_allowed( op, np,
|
2002-02-09 13:14:17 +08:00
|
|
|
children, NULL, ACL_WRITE, NULL );
|
2001-11-16 23:00:03 +08:00
|
|
|
|
|
|
|
np = NULL;
|
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
if ( ! rs->sr_err ) {
|
2003-02-26 20:49:21 +08:00
|
|
|
switch( opinfo.boi_err ) {
|
|
|
|
case DB_LOCK_DEADLOCK:
|
|
|
|
case DB_LOCK_NOTGRANTED:
|
|
|
|
goto retry;
|
|
|
|
}
|
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
|
2002-03-15 06:23:44 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR,
|
|
|
|
"==>bdb_modrdn: no access to superior\n", 0, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#else
|
2001-11-16 23:00:03 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE,
|
|
|
|
"no access to new superior\n",
|
|
|
|
0, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#endif
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_text = "no write access to new superior's children";
|
2001-11-16 23:00:03 +08:00
|
|
|
goto return_results;
|
|
|
|
}
|
|
|
|
|
2002-03-15 06:23:44 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, DETAIL1,
|
|
|
|
"bdb_modrdn: wr to children entry \"\" OK\n", 0, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#else
|
2001-11-16 23:00:03 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE,
|
|
|
|
"bdb_modrdn: wr to children of entry \"\" OK\n",
|
|
|
|
0, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#endif
|
2001-11-16 23:00:03 +08:00
|
|
|
|
|
|
|
} else {
|
2002-03-15 06:23:44 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR,
|
|
|
|
"bdb_modrdn: new superior=\"\", not root & \"\" "
|
|
|
|
"is not suffix\n", 0, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#else
|
2001-11-16 23:00:03 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE,
|
|
|
|
"bdb_modrdn: new superior=\"\", not root "
|
|
|
|
"& \"\" is not suffix\n",
|
|
|
|
0, 0, 0);
|
2002-03-15 06:23:44 +08:00
|
|
|
#endif
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_text = "no write access to new superior's children";
|
|
|
|
rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
|
2001-11-16 23:00:03 +08:00
|
|
|
goto return_results;
|
|
|
|
}
|
|
|
|
}
|
2000-09-28 06:28:59 +08:00
|
|
|
|
2002-03-15 06:23:44 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, DETAIL1,
|
|
|
|
"bdb_modrdn: new superior=\"\"\n", 0, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#else
|
2000-09-28 06:28:59 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE,
|
2001-11-16 23:00:03 +08:00
|
|
|
"bdb_modrdn: new superior=\"\"\n",
|
2000-09-28 06:28:59 +08:00
|
|
|
0, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#endif
|
2000-09-28 06:28:59 +08:00
|
|
|
}
|
|
|
|
|
2002-03-15 06:23:44 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, DETAIL1,
|
|
|
|
"bdb_modrdn: wr to new parent's children OK\n", 0, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#else
|
2000-09-28 06:28:59 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE,
|
|
|
|
"bdb_modrdn: wr to new parent's children OK\n",
|
|
|
|
0, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#endif
|
2000-09-28 06:28:59 +08:00
|
|
|
|
|
|
|
new_parent_dn = np_dn;
|
|
|
|
}
|
2002-10-05 07:26:28 +08:00
|
|
|
|
2000-09-28 06:28:59 +08:00
|
|
|
/* Build target dn and make sure target entry doesn't exist already. */
|
2003-03-30 17:03:54 +08:00
|
|
|
if (!new_dn.bv_val) build_new_dn( &new_dn, new_parent_dn, &op->oq_modrdn.rs_newrdn );
|
2000-09-28 06:28:59 +08:00
|
|
|
|
2003-04-11 09:29:28 +08:00
|
|
|
if (!new_ndn.bv_val) dnNormalize2( NULL, &new_dn, &new_ndn, op->o_tmpmemctx );
|
2000-09-28 06:28:59 +08:00
|
|
|
|
2002-03-15 06:23:44 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, RESULTS,
|
|
|
|
"bdb_modrdn: new ndn=%s\n", new_ndn.bv_val, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#else
|
2000-09-28 06:28:59 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: new ndn=%s\n",
|
2001-12-29 12:48:00 +08:00
|
|
|
new_ndn.bv_val, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#endif
|
2000-09-28 06:28:59 +08:00
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = bdb_dn2id ( op->o_bd, ltid, &new_ndn, &id, 0 );
|
|
|
|
switch( rs->sr_err ) {
|
2000-09-28 10:42:20 +08:00
|
|
|
case DB_LOCK_DEADLOCK:
|
|
|
|
case DB_LOCK_NOTGRANTED:
|
|
|
|
goto retry;
|
|
|
|
case DB_NOTFOUND:
|
|
|
|
break;
|
|
|
|
case 0:
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = LDAP_ALREADY_EXISTS;
|
2000-09-28 10:42:20 +08:00
|
|
|
goto return_results;
|
|
|
|
default:
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = LDAP_OTHER;
|
|
|
|
rs->sr_text = "internal error";
|
2000-09-28 06:28:59 +08:00
|
|
|
goto return_results;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get attribute type and attribute value of our new rdn, we will
|
|
|
|
* need to add that to our new entry
|
|
|
|
*/
|
2003-04-11 09:29:28 +08:00
|
|
|
if ( !new_rdn && ldap_bv2rdn_x( &op->oq_modrdn.rs_newrdn, &new_rdn, (char **)&rs->sr_text,
|
|
|
|
LDAP_DN_FORMAT_LDAP, op->o_tmpmemctx ) )
|
2002-01-09 14:30:23 +08:00
|
|
|
{
|
2002-03-15 06:23:44 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR,
|
2002-08-17 00:35:16 +08:00
|
|
|
"bdb_modrdn: can't figure out "
|
|
|
|
"type(s)/values(s) of newrdn\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
0, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#else
|
2000-09-28 06:28:59 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE,
|
2002-08-17 00:35:16 +08:00
|
|
|
"bdb_modrdn: can't figure out "
|
|
|
|
"type(s)/values(s) of newrdn\n",
|
|
|
|
0, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#endif
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = LDAP_INVALID_DN_SYNTAX;
|
|
|
|
rs->sr_text = "unknown type(s) used in RDN";
|
2002-08-17 00:35:16 +08:00
|
|
|
goto return_results;
|
2000-09-28 06:28:59 +08:00
|
|
|
}
|
|
|
|
|
2002-03-15 06:23:44 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, RESULTS,
|
2002-08-17 00:35:16 +08:00
|
|
|
"bdb_modrdn: new_rdn_type=\"%s\", "
|
|
|
|
"new_rdn_val=\"%s\"\n",
|
2003-04-11 09:29:28 +08:00
|
|
|
new_rdn[ 0 ]->la_attr.bv_val,
|
|
|
|
new_rdn[ 0 ]->la_value.bv_val, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#else
|
2000-09-28 06:28:59 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE,
|
2002-08-17 00:35:16 +08:00
|
|
|
"bdb_modrdn: new_rdn_type=\"%s\", "
|
|
|
|
"new_rdn_val=\"%s\"\n",
|
2003-04-11 09:29:28 +08:00
|
|
|
new_rdn[ 0 ]->la_attr.bv_val,
|
|
|
|
new_rdn[ 0 ]->la_value.bv_val, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#endif
|
2000-09-28 06:28:59 +08:00
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
if ( op->oq_modrdn.rs_deleteoldrdn ) {
|
2003-04-11 09:29:28 +08:00
|
|
|
if ( !old_rdn && ldap_bv2rdn_x( &op->o_req_dn, &old_rdn, (char **)&rs->sr_text,
|
|
|
|
LDAP_DN_FORMAT_LDAP, op->o_tmpmemctx ) )
|
2002-08-17 00:35:16 +08:00
|
|
|
{
|
2002-03-15 06:23:44 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, ERR,
|
2002-08-17 00:35:16 +08:00
|
|
|
"bdb_modrdn: can't figure out "
|
|
|
|
"type(s)/values(s) of old_rdn\n",
|
|
|
|
0, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#else
|
2000-09-28 06:28:59 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE,
|
2002-08-17 00:35:16 +08:00
|
|
|
"bdb_modrdn: can't figure out "
|
|
|
|
"the old_rdn type(s)/value(s)\n",
|
|
|
|
0, 0, 0 );
|
2002-03-15 06:23:44 +08:00
|
|
|
#endif
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = LDAP_OTHER;
|
|
|
|
rs->sr_text = "cannot parse RDN from old DN";
|
2000-09-28 06:28:59 +08:00
|
|
|
goto return_results;
|
|
|
|
}
|
2002-08-17 00:35:16 +08:00
|
|
|
}
|
2000-09-28 06:28:59 +08:00
|
|
|
|
2002-08-17 00:35:16 +08:00
|
|
|
/* prepare modlist of modifications from old/new rdn */
|
2003-03-12 21:04:23 +08:00
|
|
|
if (!mod) {
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = slap_modrdn2mods( op, rs, e, old_rdn, new_rdn, &mod );
|
|
|
|
if ( rs->sr_err != LDAP_SUCCESS ) {
|
2003-03-12 21:04:23 +08:00
|
|
|
goto return_results;
|
|
|
|
}
|
2000-09-28 06:28:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* delete old one */
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = bdb_dn2id_delete( op->o_bd, ltid, p_ndn.bv_val, e );
|
|
|
|
if ( rs->sr_err != 0 ) {
|
|
|
|
switch( rs->sr_err ) {
|
2000-09-28 10:27:49 +08:00
|
|
|
case DB_LOCK_DEADLOCK:
|
|
|
|
case DB_LOCK_NOTGRANTED:
|
|
|
|
goto retry;
|
|
|
|
}
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = LDAP_OTHER;
|
|
|
|
rs->sr_text = "DN index delete fail";
|
2000-09-28 06:28:59 +08:00
|
|
|
goto return_results;
|
|
|
|
}
|
|
|
|
|
2002-01-25 15:19:01 +08:00
|
|
|
(void) bdb_cache_delete_entry(&bdb->bi_cache, e);
|
|
|
|
|
2001-10-20 04:28:48 +08:00
|
|
|
/* Binary format uses a single contiguous block, cannot
|
2003-03-12 21:04:23 +08:00
|
|
|
* free individual fields. But if a previous modrdn has
|
|
|
|
* already happened, must free the names.
|
2001-10-20 04:28:48 +08:00
|
|
|
*/
|
2003-03-30 17:03:54 +08:00
|
|
|
#ifdef BDB_HIER
|
|
|
|
ch_free(e->e_name.bv_val);
|
|
|
|
e->e_name.bv_val = ch_malloc(new_dn.bv_len + new_ndn.bv_len + 2);
|
|
|
|
e->e_name.bv_len = new_dn.bv_len;
|
|
|
|
e->e_nname.bv_val = e->e_name.bv_val + new_dn.bv_len + 1;
|
|
|
|
e->e_nname.bv_len = new_ndn.bv_len;
|
|
|
|
strcpy(e->e_name.bv_val, new_dn.bv_val);
|
|
|
|
strcpy(e->e_nname.bv_val, new_ndn.bv_val);
|
|
|
|
#else
|
2003-03-12 21:04:23 +08:00
|
|
|
if( e->e_nname.bv_val < e->e_bv.bv_val || e->e_nname.bv_val >
|
|
|
|
e->e_bv.bv_val + e->e_bv.bv_len ) {
|
|
|
|
ch_free(e->e_name.bv_val);
|
|
|
|
ch_free(e->e_nname.bv_val);
|
|
|
|
e->e_name.bv_val = NULL;
|
|
|
|
e->e_nname.bv_val = NULL;
|
|
|
|
}
|
2001-12-27 08:58:14 +08:00
|
|
|
e->e_name = new_dn;
|
2001-12-29 12:48:00 +08:00
|
|
|
e->e_nname = new_ndn;
|
2002-01-25 15:19:01 +08:00
|
|
|
new_dn.bv_val = NULL;
|
2002-02-02 11:28:32 +08:00
|
|
|
new_ndn.bv_val = NULL;
|
2003-03-30 17:03:54 +08:00
|
|
|
#endif
|
2000-09-28 06:28:59 +08:00
|
|
|
/* add new one */
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = bdb_dn2id_add( op->o_bd, ltid, np_ndn, e );
|
|
|
|
if ( rs->sr_err != 0 ) {
|
|
|
|
switch( rs->sr_err ) {
|
2000-09-28 10:27:49 +08:00
|
|
|
case DB_LOCK_DEADLOCK:
|
|
|
|
case DB_LOCK_NOTGRANTED:
|
|
|
|
goto retry;
|
|
|
|
}
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = LDAP_OTHER;
|
|
|
|
rs->sr_text = "DN index add failed";
|
2000-09-28 06:28:59 +08:00
|
|
|
goto return_results;
|
|
|
|
}
|
|
|
|
|
2003-02-05 15:37:02 +08:00
|
|
|
#if defined(LDAP_CLIENT_UPDATE) || defined(LDAP_SYNC)
|
2003-03-30 17:03:54 +08:00
|
|
|
if ( rs->sr_err == LDAP_SUCCESS && !op->o_noop ) {
|
|
|
|
LDAP_LIST_FOREACH ( ps_list, &bdb->bi_psearch_list, o_ps_link ) {
|
|
|
|
bdb_psearch( op, rs, ps_list, e, LDAP_PSEARCH_BY_PREMODIFY );
|
2002-10-26 01:51:30 +08:00
|
|
|
}
|
|
|
|
}
|
2003-02-05 15:37:02 +08:00
|
|
|
#endif
|
2002-10-26 01:51:30 +08:00
|
|
|
|
2000-09-28 06:28:59 +08:00
|
|
|
/* modify entry */
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = bdb_modify_internal( op, ltid, &mod[0], e,
|
|
|
|
&rs->sr_text, textbuf, textlen );
|
2000-09-28 06:28:59 +08:00
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
if( rs->sr_err != LDAP_SUCCESS ) {
|
|
|
|
if ( ( rs->sr_err == LDAP_INSUFFICIENT_ACCESS ) && opinfo.boi_err ) {
|
|
|
|
rs->sr_err = opinfo.boi_err;
|
2003-02-26 20:49:21 +08:00
|
|
|
}
|
2003-03-30 17:03:54 +08:00
|
|
|
switch( rs->sr_err ) {
|
2000-09-28 10:27:49 +08:00
|
|
|
case DB_LOCK_DEADLOCK:
|
|
|
|
case DB_LOCK_NOTGRANTED:
|
|
|
|
goto retry;
|
|
|
|
}
|
2000-09-28 06:28:59 +08:00
|
|
|
goto return_results;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* id2entry index */
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = bdb_id2entry_update( op->o_bd, ltid, e );
|
|
|
|
if ( rs->sr_err != 0 ) {
|
|
|
|
switch( rs->sr_err ) {
|
2000-09-28 10:27:49 +08:00
|
|
|
case DB_LOCK_DEADLOCK:
|
|
|
|
case DB_LOCK_NOTGRANTED:
|
|
|
|
goto retry;
|
|
|
|
}
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = LDAP_OTHER;
|
|
|
|
rs->sr_text = "entry update failed";
|
2000-09-28 06:28:59 +08:00
|
|
|
goto return_results;
|
|
|
|
}
|
|
|
|
|
2002-01-29 08:02:27 +08:00
|
|
|
if( op->o_noop ) {
|
2003-03-30 17:03:54 +08:00
|
|
|
if(( rs->sr_err=TXN_ABORT( ltid )) != 0 ) {
|
|
|
|
rs->sr_text = "txn_abort (no-op) failed";
|
2002-02-02 11:28:32 +08:00
|
|
|
} else {
|
2002-08-31 20:00:39 +08:00
|
|
|
noop = 1;
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = LDAP_SUCCESS;
|
2002-02-02 11:28:32 +08:00
|
|
|
}
|
|
|
|
|
2002-01-29 08:02:27 +08:00
|
|
|
} else {
|
2002-02-12 01:45:39 +08:00
|
|
|
char gid[DB_XIDDATASIZE];
|
|
|
|
|
|
|
|
snprintf( gid, sizeof( gid ), "%s-%08lx-%08lx",
|
2002-02-12 05:07:55 +08:00
|
|
|
bdb_uuid.bv_val, (long) op->o_connid, (long) op->o_opid );
|
2002-02-12 01:45:39 +08:00
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
if(( rs->sr_err=TXN_PREPARE( ltid, gid )) != 0 ) {
|
|
|
|
rs->sr_text = "txn_prepare failed";
|
2002-02-02 11:28:32 +08:00
|
|
|
} else {
|
|
|
|
if( bdb_cache_update_entry(&bdb->bi_cache, e) == -1 ) {
|
2003-03-30 17:03:54 +08:00
|
|
|
if(( rs->sr_err=TXN_ABORT( ltid )) != 0 ) {
|
|
|
|
rs->sr_text ="cache update & txn_abort failed";
|
2002-02-02 11:28:32 +08:00
|
|
|
} else {
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = LDAP_OTHER;
|
|
|
|
rs->sr_text = "cache update failed";
|
2002-02-02 11:28:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2003-03-26 01:49:35 +08:00
|
|
|
bdb_cache_entry_commit( e );
|
2003-03-30 17:03:54 +08:00
|
|
|
if(( rs->sr_err=TXN_COMMIT( ltid, 0 )) != 0 ) {
|
|
|
|
rs->sr_text = "txn_commit failed";
|
2002-02-02 11:28:32 +08:00
|
|
|
} else {
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = LDAP_SUCCESS;
|
2002-02-02 11:28:32 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-01-29 08:02:27 +08:00
|
|
|
}
|
2002-02-02 11:28:32 +08:00
|
|
|
|
2000-09-28 06:28:59 +08:00
|
|
|
ltid = NULL;
|
|
|
|
op->o_private = NULL;
|
2002-02-02 11:28:32 +08:00
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
if( rs->sr_err == LDAP_SUCCESS ) {
|
2002-03-15 06:23:44 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, RESULTS,
|
|
|
|
"bdb_modrdn: rdn modified%s id=%08lx dn=\"%s\"\n",
|
|
|
|
op->o_noop ? " (no-op)" : "", e->e_id, e->e_dn );
|
2002-03-15 06:23:44 +08:00
|
|
|
#else
|
2002-02-02 11:28:32 +08:00
|
|
|
Debug(LDAP_DEBUG_TRACE,
|
|
|
|
"bdb_modrdn: rdn modified%s id=%08lx dn=\"%s\"\n",
|
2002-03-18 16:55:21 +08:00
|
|
|
op->o_noop ? " (no-op)" : "", e->e_id, e->e_dn );
|
2002-03-15 06:23:44 +08:00
|
|
|
#endif
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_text = NULL;
|
2002-02-02 11:28:32 +08:00
|
|
|
} else {
|
2002-03-15 06:23:44 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG ( OPERATION, RESULTS, "bdb_modrdn: %s : %s (%d)\n",
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_text, db_strerror(rs->sr_err), rs->sr_err );
|
2002-03-15 06:23:44 +08:00
|
|
|
#else
|
2002-02-02 11:28:32 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE, "bdb_add: %s : %s (%d)\n",
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_text, db_strerror(rs->sr_err), rs->sr_err );
|
2002-03-15 06:23:44 +08:00
|
|
|
#endif
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = LDAP_OTHER;
|
2000-09-28 06:28:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return_results:
|
2003-03-30 17:03:54 +08:00
|
|
|
send_ldap_result( op, rs );
|
2000-09-28 06:28:59 +08:00
|
|
|
|
2003-02-05 15:37:02 +08:00
|
|
|
#if defined(LDAP_CLIENT_UPDATE) || defined(LDAP_SYNC)
|
2003-03-30 17:03:54 +08:00
|
|
|
if ( rs->sr_err == LDAP_SUCCESS && !op->o_noop ) {
|
2002-10-26 01:51:30 +08:00
|
|
|
/* Loop through in-scope entries for each psearch spec */
|
2003-03-30 17:03:54 +08:00
|
|
|
LDAP_LIST_FOREACH ( ps_list, &bdb->bi_psearch_list, o_ps_link ) {
|
|
|
|
bdb_psearch( op, rs, ps_list, e, LDAP_PSEARCH_BY_MODIFY );
|
2002-10-26 01:51:30 +08:00
|
|
|
}
|
2003-03-30 17:03:54 +08:00
|
|
|
pm_list = LDAP_LIST_FIRST(&op->o_pm_list);
|
2002-10-26 01:51:30 +08:00
|
|
|
while ( pm_list != NULL ) {
|
2003-03-30 17:03:54 +08:00
|
|
|
bdb_psearch(op, rs, pm_list->ps_op,
|
2003-02-05 15:37:02 +08:00
|
|
|
e, LDAP_PSEARCH_BY_SCOPEOUT);
|
2002-10-26 01:51:30 +08:00
|
|
|
pm_prev = pm_list;
|
2003-03-30 17:03:54 +08:00
|
|
|
LDAP_LIST_REMOVE ( pm_list, ps_link );
|
|
|
|
pm_list = LDAP_LIST_NEXT ( pm_list, ps_link );
|
|
|
|
ch_free( pm_prev );
|
2002-10-26 01:51:30 +08:00
|
|
|
}
|
|
|
|
}
|
2003-02-05 15:37:02 +08:00
|
|
|
#endif
|
2002-10-26 01:51:30 +08:00
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
if( rs->sr_err == LDAP_SUCCESS && bdb->bi_txn_cp ) {
|
2000-09-28 12:09:13 +08:00
|
|
|
ldap_pvt_thread_yield();
|
2001-12-07 13:05:00 +08:00
|
|
|
TXN_CHECKPOINT( bdb->bi_dbenv,
|
2000-09-28 12:09:13 +08:00
|
|
|
bdb->bi_txn_cp_kbyte, bdb->bi_txn_cp_min, 0 );
|
|
|
|
}
|
|
|
|
|
2000-09-28 06:28:59 +08:00
|
|
|
done:
|
2001-12-27 08:58:14 +08:00
|
|
|
if( new_dn.bv_val != NULL ) free( new_dn.bv_val );
|
2001-12-29 12:48:00 +08:00
|
|
|
if( new_ndn.bv_val != NULL ) free( new_ndn.bv_val );
|
2000-09-28 06:28:59 +08:00
|
|
|
|
|
|
|
/* LDAP v2 supporting correct attribute handling. */
|
2002-08-17 00:35:16 +08:00
|
|
|
if ( new_rdn != NULL ) {
|
|
|
|
ldap_rdnfree( new_rdn );
|
|
|
|
}
|
|
|
|
if ( old_rdn != NULL ) {
|
|
|
|
ldap_rdnfree( old_rdn );
|
|
|
|
}
|
2002-01-01 17:18:34 +08:00
|
|
|
if( mod != NULL ) {
|
|
|
|
Modifications *tmp;
|
|
|
|
for (; mod; mod=tmp ) {
|
|
|
|
tmp = mod->sml_next;
|
2003-03-24 09:56:56 +08:00
|
|
|
if ( mod->sml_nvalues ) free( mod->sml_nvalues[0].bv_val );
|
2002-01-01 17:18:34 +08:00
|
|
|
free( mod );
|
|
|
|
}
|
|
|
|
}
|
2000-09-28 06:28:59 +08:00
|
|
|
|
|
|
|
/* LDAP v3 Support */
|
|
|
|
if( np != NULL ) {
|
2002-01-25 15:19:01 +08:00
|
|
|
/* free new parent and reader lock */
|
2002-06-06 18:14:14 +08:00
|
|
|
bdb_unlocked_cache_return_entry_r(&bdb->bi_cache, np);
|
2000-09-28 06:28:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if( p != NULL ) {
|
2002-01-25 15:19:01 +08:00
|
|
|
/* free parent and reader lock */
|
2002-06-06 18:14:14 +08:00
|
|
|
bdb_unlocked_cache_return_entry_r(&bdb->bi_cache, p);
|
2000-09-28 06:28:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* free entry */
|
|
|
|
if( e != NULL ) {
|
2002-06-06 18:14:14 +08:00
|
|
|
bdb_unlocked_cache_return_entry_w( &bdb->bi_cache, e);
|
2000-09-28 06:28:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if( ltid != NULL ) {
|
2003-02-05 15:37:02 +08:00
|
|
|
#if defined(LDAP_CLIENT_UPDATE) || defined(LDAP_SYNC)
|
2003-03-30 17:03:54 +08:00
|
|
|
pm_list = LDAP_LIST_FIRST(&op->o_pm_list);
|
2002-10-26 01:51:30 +08:00
|
|
|
while ( pm_list != NULL ) {
|
2003-03-30 17:03:54 +08:00
|
|
|
LDAP_LIST_REMOVE ( pm_list, ps_link );
|
|
|
|
pm_prev = pm_list;
|
|
|
|
pm_list = LDAP_LIST_NEXT ( pm_list, ps_link );
|
|
|
|
ch_free( pm_prev );
|
2002-10-26 01:51:30 +08:00
|
|
|
}
|
|
|
|
#endif
|
2002-02-02 11:28:32 +08:00
|
|
|
TXN_ABORT( ltid );
|
2000-09-28 06:28:59 +08:00
|
|
|
op->o_private = NULL;
|
|
|
|
}
|
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
return ( ( rs->sr_err == LDAP_SUCCESS ) ? noop : rs->sr_err );
|
2000-09-28 06:28:59 +08:00
|
|
|
}
|