1998-08-09 08:43:13 +08:00
|
|
|
/* modify.c - ldbm backend modify routine */
|
1999-09-09 03:06:24 +08:00
|
|
|
/* $OpenLDAP$ */
|
1999-08-07 07:07:46 +08:00
|
|
|
/*
|
2003-01-04 04:20:47 +08:00
|
|
|
* Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
|
1999-08-07 07:07:46 +08:00
|
|
|
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
|
|
|
|
*/
|
1998-08-09 08:43:13 +08:00
|
|
|
|
1998-10-25 09:41:42 +08:00
|
|
|
#include "portable.h"
|
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
#include <stdio.h>
|
1998-10-25 09:41:42 +08:00
|
|
|
|
|
|
|
#include <ac/string.h>
|
|
|
|
#include <ac/socket.h>
|
1999-05-21 11:53:37 +08:00
|
|
|
#include <ac/time.h>
|
1998-10-25 09:41:42 +08:00
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
#include "slap.h"
|
|
|
|
#include "back-ldbm.h"
|
1998-09-21 04:22:46 +08:00
|
|
|
#include "proto-back-ldbm.h"
|
1998-08-09 08:43:13 +08:00
|
|
|
|
1999-05-19 12:00:58 +08:00
|
|
|
/* We need this function because of LDAP modrdn. If we do not
|
|
|
|
* add this there would be a bunch of code replication here
|
|
|
|
* and there and of course the likelihood of bugs increases.
|
|
|
|
* Juan C. Gomez (gomez@engr.sgi.com) 05/18/99
|
|
|
|
*/
|
1999-05-20 02:27:25 +08:00
|
|
|
int ldbm_modify_internal(
|
1998-08-09 08:43:13 +08:00
|
|
|
Operation *op,
|
2000-02-08 04:37:10 +08:00
|
|
|
Modifications *modlist,
|
2000-05-29 04:44:08 +08:00
|
|
|
Entry *e,
|
2001-06-06 08:23:56 +08:00
|
|
|
const char **text,
|
|
|
|
char *textbuf,
|
|
|
|
size_t textlen
|
1998-08-09 08:43:13 +08:00
|
|
|
)
|
|
|
|
{
|
2002-01-14 07:21:03 +08:00
|
|
|
int rc = LDAP_SUCCESS;
|
2000-02-15 04:57:34 +08:00
|
|
|
Modification *mod;
|
2000-02-08 04:37:10 +08:00
|
|
|
Modifications *ml;
|
1999-07-29 12:41:49 +08:00
|
|
|
Attribute *save_attrs;
|
2002-01-14 07:21:03 +08:00
|
|
|
Attribute *ap;
|
1998-08-09 08:43:13 +08:00
|
|
|
|
2001-01-18 01:01:19 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2003-03-30 17:03:54 +08:00
|
|
|
LDAP_LOG( BACK_LDBM, ENTRY, "ldbm_modify_internal: %s\n", e->e_name.bv_val, 0, 0 );
|
2001-01-18 01:01:19 +08:00
|
|
|
#else
|
2003-03-30 17:03:54 +08:00
|
|
|
Debug(LDAP_DEBUG_TRACE, "ldbm_modify_internal: %s\n", e->e_name.bv_val, 0, 0);
|
2001-01-18 01:01:19 +08:00
|
|
|
#endif
|
|
|
|
|
2000-05-29 06:38:21 +08:00
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
if ( !acl_check_modlist( op, e, modlist )) {
|
1999-12-08 12:37:59 +08:00
|
|
|
return LDAP_INSUFFICIENT_ACCESS;
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
|
|
|
|
1999-07-29 12:41:49 +08:00
|
|
|
save_attrs = e->e_attrs;
|
|
|
|
e->e_attrs = attrs_dup( e->e_attrs );
|
1999-05-19 12:00:58 +08:00
|
|
|
|
2000-02-16 02:57:07 +08:00
|
|
|
for ( ml = modlist; ml != NULL; ml = ml->sml_next ) {
|
|
|
|
mod = &ml->sml_mod;
|
1998-12-21 08:21:58 +08:00
|
|
|
|
2000-05-22 06:46:51 +08:00
|
|
|
switch ( mod->sm_op ) {
|
1998-08-09 08:43:13 +08:00
|
|
|
case LDAP_MOD_ADD:
|
2001-01-18 01:01:19 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG( BACK_LDBM, DETAIL1, "ldbm_modify_internal: add\n", 0, 0, 0);
|
2001-01-18 01:01:19 +08:00
|
|
|
#else
|
2000-05-29 06:38:21 +08:00
|
|
|
Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: add\n", 0, 0, 0);
|
2001-01-18 01:01:19 +08:00
|
|
|
#endif
|
|
|
|
|
2003-03-07 03:44:41 +08:00
|
|
|
rc = modify_add_values( e, mod, get_permissiveModify( op ),
|
|
|
|
text, textbuf, textlen );
|
2002-01-14 07:21:03 +08:00
|
|
|
if( rc != LDAP_SUCCESS ) {
|
2001-01-18 01:01:19 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG( BACK_LDBM, INFO,
|
|
|
|
"ldbm_modify_internal: failed %d (%s)\n", rc, *text, 0 );
|
2001-01-18 01:01:19 +08:00
|
|
|
#else
|
2000-05-29 07:51:39 +08:00
|
|
|
Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: %d %s\n",
|
2002-01-14 07:21:03 +08:00
|
|
|
rc, *text, 0);
|
2001-01-18 01:01:19 +08:00
|
|
|
#endif
|
2000-05-29 04:44:08 +08:00
|
|
|
}
|
1998-08-09 08:43:13 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LDAP_MOD_DELETE:
|
2001-01-18 01:01:19 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG( BACK_LDBM, DETAIL1, "ldbm_modify_internal: delete\n", 0,0,0);
|
2001-01-18 01:01:19 +08:00
|
|
|
#else
|
2000-05-29 06:38:21 +08:00
|
|
|
Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: delete\n", 0, 0, 0);
|
2001-01-18 01:01:19 +08:00
|
|
|
#endif
|
|
|
|
|
2003-03-07 03:44:41 +08:00
|
|
|
rc = modify_delete_values( e, mod, get_permissiveModify( op ),
|
|
|
|
text, textbuf, textlen );
|
2002-01-14 07:21:03 +08:00
|
|
|
assert( rc != LDAP_TYPE_OR_VALUE_EXISTS );
|
|
|
|
if( rc != LDAP_SUCCESS ) {
|
2001-01-18 01:01:19 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG( BACK_LDBM, INFO,
|
|
|
|
"ldbm_modify_internal: failed %d (%s)\n", rc, *text, 0 );
|
2001-01-18 01:01:19 +08:00
|
|
|
#else
|
2000-05-29 07:51:39 +08:00
|
|
|
Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: %d %s\n",
|
2002-01-14 07:21:03 +08:00
|
|
|
rc, *text, 0);
|
2001-01-18 01:01:19 +08:00
|
|
|
#endif
|
2000-05-29 04:44:08 +08:00
|
|
|
}
|
1998-08-09 08:43:13 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LDAP_MOD_REPLACE:
|
2001-01-18 01:01:19 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG( BACK_LDBM, DETAIL1, "ldbm_modify_internal: replace\n",0,0,0);
|
2001-01-18 01:01:19 +08:00
|
|
|
#else
|
2000-05-29 06:38:21 +08:00
|
|
|
Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: replace\n", 0, 0, 0);
|
2001-01-18 01:01:19 +08:00
|
|
|
#endif
|
|
|
|
|
2003-03-07 03:44:41 +08:00
|
|
|
rc = modify_replace_values( e, mod, get_permissiveModify( op ),
|
|
|
|
text, textbuf, textlen );
|
2002-01-14 07:21:03 +08:00
|
|
|
if( rc != LDAP_SUCCESS ) {
|
2003-08-08 00:42:40 +08:00
|
|
|
#ifdef NEW_LOGGING
|
|
|
|
LDAP_LOG( BACK_LDBM, INFO,
|
|
|
|
"ldbm_modify_internal: failed %d (%s)\n", rc, *text, 0 );
|
|
|
|
#else
|
|
|
|
Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: %d %s\n",
|
|
|
|
rc, *text, 0);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LDAP_MOD_INCREMENT:
|
|
|
|
#ifdef NEW_LOGGING
|
|
|
|
LDAP_LOG( BACK_LDBM, DETAIL1,
|
|
|
|
"ldbm_modify_internal: increment\n",0,0,0);
|
|
|
|
#else
|
|
|
|
Debug(LDAP_DEBUG_ARGS,
|
|
|
|
"ldbm_modify_internal: increment\n",0,0,0);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
rc = modify_increment_values( e, mod, get_permissiveModify( op ),
|
|
|
|
text, textbuf, textlen );
|
|
|
|
if( rc != LDAP_SUCCESS ) {
|
2001-01-18 01:01:19 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG( BACK_LDBM, INFO,
|
|
|
|
"ldbm_modify_internal: failed %d (%s)\n", rc, *text, 0 );
|
2001-01-18 01:01:19 +08:00
|
|
|
#else
|
2000-05-29 07:51:39 +08:00
|
|
|
Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: %d %s\n",
|
2002-01-14 07:21:03 +08:00
|
|
|
rc, *text, 0);
|
2001-01-18 01:01:19 +08:00
|
|
|
#endif
|
2000-05-29 04:44:08 +08:00
|
|
|
}
|
1998-08-09 08:43:13 +08:00
|
|
|
break;
|
1999-05-26 19:45:17 +08:00
|
|
|
|
2000-02-08 04:37:10 +08:00
|
|
|
case SLAP_MOD_SOFTADD:
|
2001-01-18 01:01:19 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG( BACK_LDBM, DETAIL1,
|
|
|
|
"ldbm_modify_internal: softadd\n", 0, 0, 0 );
|
2001-01-18 01:01:19 +08:00
|
|
|
#else
|
2000-05-29 06:38:21 +08:00
|
|
|
Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: softadd\n", 0, 0, 0);
|
2001-01-18 01:01:19 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Avoid problems in index_add_mods()
|
|
|
|
* We need to add index if necessary.
|
|
|
|
*/
|
|
|
|
mod->sm_op = LDAP_MOD_ADD;
|
2000-03-18 02:31:40 +08:00
|
|
|
|
2003-03-07 03:44:41 +08:00
|
|
|
rc = modify_add_values( e, mod, get_permissiveModify( op ),
|
|
|
|
text, textbuf, textlen );
|
2002-01-14 07:21:03 +08:00
|
|
|
if ( rc == LDAP_TYPE_OR_VALUE_EXISTS ) {
|
|
|
|
rc = LDAP_SUCCESS;
|
2001-01-18 01:01:19 +08:00
|
|
|
}
|
2000-05-29 04:44:08 +08:00
|
|
|
|
2002-01-14 07:21:03 +08:00
|
|
|
if( rc != LDAP_SUCCESS ) {
|
2001-01-18 01:01:19 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG( BACK_LDBM, INFO,
|
|
|
|
"ldbm_modify_internal: failed %d (%s)\n", rc, *text, 0 );
|
2001-01-18 01:01:19 +08:00
|
|
|
#else
|
2000-05-29 07:51:39 +08:00
|
|
|
Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: %d %s\n",
|
2002-01-14 07:21:03 +08:00
|
|
|
rc, *text, 0);
|
2001-01-18 01:01:19 +08:00
|
|
|
#endif
|
2000-05-29 04:44:08 +08:00
|
|
|
}
|
2001-01-18 01:01:19 +08:00
|
|
|
break;
|
2000-05-29 04:44:08 +08:00
|
|
|
|
|
|
|
default:
|
2001-01-18 01:01:19 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG( BACK_LDBM, ERR,
|
|
|
|
"ldbm_modify_internal: invalid op %d\n", mod->sm_op, 0, 0 );
|
2001-01-18 01:01:19 +08:00
|
|
|
#else
|
2000-05-29 06:38:21 +08:00
|
|
|
Debug(LDAP_DEBUG_ANY, "ldbm_modify_internal: invalid op %d\n",
|
|
|
|
mod->sm_op, 0, 0);
|
2001-01-18 01:01:19 +08:00
|
|
|
#endif
|
|
|
|
|
2002-01-14 07:21:03 +08:00
|
|
|
rc = LDAP_OTHER;
|
2001-01-18 01:01:19 +08:00
|
|
|
*text = "Invalid modify operation";
|
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG( BACK_LDBM, INFO,
|
|
|
|
"ldbm_modify_internal: %d (%s)\n", rc, *text, 0 );
|
2001-01-18 01:01:19 +08:00
|
|
|
#else
|
2000-05-29 07:51:39 +08:00
|
|
|
Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: %d %s\n",
|
2002-01-14 07:21:03 +08:00
|
|
|
rc, *text, 0);
|
2001-01-18 01:01:19 +08:00
|
|
|
#endif
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
|
|
|
|
2002-01-14 07:21:03 +08:00
|
|
|
if ( rc != LDAP_SUCCESS ) {
|
|
|
|
goto exit;
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
|
|
|
|
2002-01-19 12:51:42 +08:00
|
|
|
/* If objectClass was modified, reset the flags */
|
|
|
|
if ( mod->sm_desc == slap_schema.si_ad_objectClass ) {
|
|
|
|
e->e_ocflags = 0;
|
|
|
|
}
|
|
|
|
|
2002-01-14 07:21:03 +08:00
|
|
|
/* check if modified attribute was indexed */
|
2003-03-30 17:03:54 +08:00
|
|
|
rc = index_is_indexed( op->o_bd, mod->sm_desc );
|
2002-01-14 07:21:03 +08:00
|
|
|
if ( rc == LDAP_SUCCESS ) {
|
|
|
|
ap = attr_find( save_attrs, mod->sm_desc );
|
|
|
|
if ( ap ) ap->a_flags |= SLAP_ATTR_IXDEL;
|
|
|
|
|
|
|
|
ap = attr_find( e->e_attrs, mod->sm_desc );
|
|
|
|
if ( ap ) ap->a_flags |= SLAP_ATTR_IXADD;
|
|
|
|
}
|
1999-07-29 12:41:49 +08:00
|
|
|
}
|
|
|
|
|
1998-09-21 04:22:46 +08:00
|
|
|
/* check that the entry still obeys the schema */
|
2003-03-30 17:03:54 +08:00
|
|
|
rc = entry_schema_check( op->o_bd, e, save_attrs, text, textbuf, textlen );
|
2003-03-07 03:44:41 +08:00
|
|
|
|
2000-04-25 21:07:14 +08:00
|
|
|
if ( rc != LDAP_SUCCESS ) {
|
2001-01-18 01:01:19 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG( BACK_LDBM, ERR,
|
|
|
|
"ldbm_modify_internal: entry failed schema check: %s\n",
|
|
|
|
*text, 0, 0 );
|
2001-01-18 01:01:19 +08:00
|
|
|
#else
|
2000-04-25 21:07:14 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY, "entry failed schema check: %s\n",
|
2000-05-29 04:44:08 +08:00
|
|
|
*text, 0, 0 );
|
2001-01-18 01:01:19 +08:00
|
|
|
#endif
|
|
|
|
|
2002-01-14 07:21:03 +08:00
|
|
|
goto exit;
|
1998-09-21 04:22:46 +08:00
|
|
|
}
|
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
/* check for abandon */
|
2002-04-11 16:03:40 +08:00
|
|
|
if ( op->o_abandon ) {
|
2002-01-14 07:21:03 +08:00
|
|
|
rc = SLAPD_ABANDON;
|
|
|
|
goto exit;
|
|
|
|
}
|
1998-08-09 08:43:13 +08:00
|
|
|
|
2002-01-14 07:21:03 +08:00
|
|
|
/* update the indices of the modified attributes */
|
2000-03-18 02:22:16 +08:00
|
|
|
|
2002-01-14 07:21:03 +08:00
|
|
|
/* start with deleting the old index entries */
|
|
|
|
for ( ap = save_attrs; ap != NULL; ap = ap->a_next ) {
|
|
|
|
if ( ap->a_flags & SLAP_ATTR_IXDEL ) {
|
2003-04-11 09:29:28 +08:00
|
|
|
rc = index_values( op, ap->a_desc,
|
2003-03-24 09:56:56 +08:00
|
|
|
ap->a_nvals,
|
2003-03-17 08:10:43 +08:00
|
|
|
e->e_id, SLAP_INDEX_DELETE_OP );
|
2002-01-14 07:21:03 +08:00
|
|
|
if ( rc != LDAP_SUCCESS ) {
|
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG( BACK_LDBM, ERR,
|
|
|
|
"ldbm_modify_internal: Attribute index delete failure\n",
|
|
|
|
0, 0, 0 );
|
2002-01-14 07:21:03 +08:00
|
|
|
#else
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"Attribute index delete failure",
|
|
|
|
0, 0, 0 );
|
|
|
|
#endif
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
ap->a_flags &= ~SLAP_ATTR_IXDEL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add the new index entries */
|
|
|
|
for ( ap = e->e_attrs; ap != NULL; ap = ap->a_next ) {
|
|
|
|
if ( ap->a_flags & SLAP_ATTR_IXADD ) {
|
2003-04-11 09:29:28 +08:00
|
|
|
rc = index_values( op, ap->a_desc,
|
2003-03-24 09:56:56 +08:00
|
|
|
ap->a_nvals,
|
2003-03-17 08:10:43 +08:00
|
|
|
e->e_id, SLAP_INDEX_ADD_OP );
|
2002-01-14 07:21:03 +08:00
|
|
|
if ( rc != LDAP_SUCCESS ) {
|
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG( BACK_LDBM, ERR,
|
|
|
|
"ldbm_modify_internal: Attribute index add failure\n",
|
|
|
|
0, 0, 0 );
|
2002-01-14 07:21:03 +08:00
|
|
|
#else
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"Attribute index add failure",
|
|
|
|
0, 0, 0 );
|
|
|
|
#endif
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
ap->a_flags &= ~SLAP_ATTR_IXADD;
|
|
|
|
}
|
|
|
|
}
|
1999-07-29 12:41:49 +08:00
|
|
|
|
2002-01-14 07:21:03 +08:00
|
|
|
exit:
|
|
|
|
if ( rc == LDAP_SUCCESS ) {
|
|
|
|
attrs_free( save_attrs );
|
|
|
|
} else {
|
|
|
|
for ( ap = save_attrs; ap; ap = ap->a_next ) {
|
|
|
|
ap->a_flags = 0;
|
|
|
|
}
|
|
|
|
attrs_free( e->e_attrs );
|
|
|
|
e->e_attrs = save_attrs;
|
|
|
|
}
|
2000-03-18 02:22:16 +08:00
|
|
|
|
2002-01-14 07:21:03 +08:00
|
|
|
return rc;
|
1999-07-29 12:41:49 +08:00
|
|
|
}
|
1999-05-19 12:00:58 +08:00
|
|
|
|
|
|
|
int
|
|
|
|
ldbm_back_modify(
|
|
|
|
Operation *op,
|
2003-03-30 17:03:54 +08:00
|
|
|
SlapReply *rs )
|
1999-05-19 12:00:58 +08:00
|
|
|
{
|
2003-03-30 17:03:54 +08:00
|
|
|
struct ldbminfo *li = (struct ldbminfo *) op->o_bd->be_private;
|
1999-07-16 10:45:46 +08:00
|
|
|
Entry *matched;
|
1999-05-19 12:00:58 +08:00
|
|
|
Entry *e;
|
1999-07-16 10:45:46 +08:00
|
|
|
int manageDSAit = get_manageDSAit( op );
|
2001-06-06 08:23:56 +08:00
|
|
|
char textbuf[SLAP_TEXT_BUFLEN];
|
|
|
|
size_t textlen = sizeof textbuf;
|
1999-05-19 12:00:58 +08:00
|
|
|
|
2001-01-18 01:01:19 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG( BACK_LDBM, ENTRY, "ldbm_back_modify: enter\n", 0, 0, 0);
|
2001-01-18 01:01:19 +08:00
|
|
|
#else
|
1999-05-19 12:00:58 +08:00
|
|
|
Debug(LDAP_DEBUG_ARGS, "ldbm_back_modify:\n", 0, 0, 0);
|
2001-01-18 01:01:19 +08:00
|
|
|
#endif
|
|
|
|
|
2002-01-30 01:58:36 +08:00
|
|
|
/* grab giant lock for writing */
|
|
|
|
ldap_pvt_thread_rdwr_wlock(&li->li_giant_rwlock);
|
1999-05-19 12:00:58 +08:00
|
|
|
|
|
|
|
/* acquire and lock entry */
|
2003-07-15 08:55:58 +08:00
|
|
|
e = dn2entry_w( op->o_bd, &op->o_req_ndn, &matched );
|
|
|
|
|
|
|
|
#ifdef LDAP_SYNCREPL /* FIXME: dn2entry() should return non-glue entry */
|
|
|
|
if (( e == NULL ) || ( !manageDSAit && e && is_entry_glue( e ))) {
|
|
|
|
#else
|
|
|
|
if ( e == NULL ) {
|
|
|
|
#endif
|
1999-05-19 12:00:58 +08:00
|
|
|
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 )
|
1999-07-16 10:45:46 +08:00
|
|
|
: NULL;
|
|
|
|
cache_return_entry_r( &li->li_cache, matched );
|
|
|
|
} else {
|
2003-07-15 08:55:58 +08:00
|
|
|
#ifdef LDAP_SYNCREPL
|
|
|
|
BerVarray deref = op->o_bd->syncinfo ?
|
|
|
|
op->o_bd->syncinfo->provideruri_bv : default_referral;
|
|
|
|
#else
|
|
|
|
BerVarray deref = default_referral;
|
|
|
|
#endif
|
|
|
|
rs->sr_ref = referral_rewrite( deref, NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
|
1999-05-19 12:00:58 +08:00
|
|
|
}
|
1999-07-16 10:45:46 +08:00
|
|
|
|
2002-01-30 01:58:36 +08:00
|
|
|
ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock);
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = LDAP_REFERRAL;
|
|
|
|
send_ldap_result( op, rs );
|
1999-07-16 10:45:46 +08:00
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
if ( rs->sr_ref ) ber_bvarray_free( rs->sr_ref );
|
|
|
|
free( (char *)rs->sr_matched );
|
1999-07-16 10:45:46 +08:00
|
|
|
|
2003-07-15 08:55:58 +08:00
|
|
|
#ifdef LDAP_SYNCREPL
|
|
|
|
return rs->sr_err;
|
|
|
|
#else
|
1999-05-19 12:00:58 +08:00
|
|
|
return( -1 );
|
2003-07-15 08:55:58 +08:00
|
|
|
#endif
|
1999-05-19 12:00:58 +08:00
|
|
|
}
|
|
|
|
|
2003-03-07 03:44:41 +08:00
|
|
|
if ( !manageDSAit && is_entry_referral( e ) )
|
|
|
|
{
|
1999-07-16 10:45:46 +08:00
|
|
|
/* parent is a referral, don't allow add */
|
|
|
|
/* parent is an alias, don't allow add */
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_ref = get_entry_referrals( op, e );
|
1999-07-16 10:45:46 +08:00
|
|
|
|
2001-01-18 01:01:19 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG( BACK_LDBM, INFO,
|
2003-03-30 17:03:54 +08:00
|
|
|
"ldbm_back_modify: entry (%s) is referral\n", op->o_req_ndn.bv_val, 0, 0 );
|
2001-01-18 01:01:19 +08:00
|
|
|
#else
|
1999-07-16 10:45:46 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0,
|
|
|
|
0, 0 );
|
2001-01-18 01:01:19 +08:00
|
|
|
#endif
|
|
|
|
|
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 );
|
1999-07-16 10:45:46 +08:00
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
if ( rs->sr_ref ) ber_bvarray_free( rs->sr_ref );
|
1999-07-16 10:45:46 +08:00
|
|
|
|
|
|
|
goto error_return;
|
|
|
|
}
|
|
|
|
|
1999-05-19 12:00:58 +08:00
|
|
|
/* Modify the entry */
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_err = ldbm_modify_internal( op, op->oq_modify.rs_modlist, e,
|
|
|
|
&rs->sr_text, textbuf, textlen );
|
1999-12-08 12:37:59 +08:00
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
if( rs->sr_err != LDAP_SUCCESS ) {
|
|
|
|
if( rs->sr_err != SLAPD_ABANDON ) {
|
|
|
|
send_ldap_result( op, rs );
|
1999-12-08 12:37:59 +08:00
|
|
|
}
|
|
|
|
|
1999-05-19 12:00:58 +08:00
|
|
|
goto error_return;
|
|
|
|
}
|
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
/* change the entry itself */
|
2003-03-30 17:03:54 +08:00
|
|
|
if ( id2entry_add( op->o_bd, e ) != 0 ) {
|
|
|
|
send_ldap_error( op, rs, LDAP_OTHER,
|
|
|
|
"id2entry failure" );
|
2003-07-15 08:55:58 +08:00
|
|
|
rs->sr_err = LDAP_OTHER;
|
1998-08-29 01:42:42 +08:00
|
|
|
goto error_return;
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
send_ldap_error( op, rs, LDAP_SUCCESS,
|
|
|
|
NULL );
|
1999-12-08 12:37:59 +08:00
|
|
|
|
1998-09-21 04:22:46 +08:00
|
|
|
cache_return_entry_w( &li->li_cache, e );
|
2002-01-30 01:58:36 +08:00
|
|
|
ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock);
|
2003-07-15 08:55:58 +08:00
|
|
|
|
|
|
|
return LDAP_SUCCESS;
|
1998-08-29 01:42:42 +08:00
|
|
|
|
|
|
|
error_return:;
|
1998-09-21 04:22:46 +08:00
|
|
|
cache_return_entry_w( &li->li_cache, e );
|
2002-01-30 01:58:36 +08:00
|
|
|
ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock);
|
2003-07-15 08:55:58 +08:00
|
|
|
#ifdef LDAP_SYNCREPL
|
|
|
|
return rs->sr_err;
|
|
|
|
#else
|
1998-08-29 01:42:42 +08:00
|
|
|
return( -1 );
|
2003-07-15 08:55:58 +08:00
|
|
|
#endif
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|