1999-04-13 14:15:03 +08:00
|
|
|
/* entry.c - ldbm backend entry_release routine */
|
1999-09-09 03:06:24 +08:00
|
|
|
/* $OpenLDAP$ */
|
2003-11-29 05:08:20 +08:00
|
|
|
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
|
|
|
*
|
2004-01-02 03:15:16 +08:00
|
|
|
* Copyright 1998-2004 The OpenLDAP Foundation.
|
2003-11-29 05:08:20 +08:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted only as authorized by the OpenLDAP
|
|
|
|
* Public License.
|
|
|
|
*
|
|
|
|
* A copy of this license is available in the file LICENSE in the
|
|
|
|
* top-level directory of the distribution or, alternatively, at
|
|
|
|
* <http://www.OpenLDAP.org/license.html>.
|
1999-08-07 07:07:46 +08:00
|
|
|
*/
|
1999-04-13 14:15:03 +08:00
|
|
|
|
|
|
|
#include "portable.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <ac/socket.h>
|
|
|
|
#include <ac/string.h>
|
|
|
|
|
|
|
|
#include "slap.h"
|
|
|
|
#include "back-ldbm.h"
|
|
|
|
#include "proto-back-ldbm.h"
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
ldbm_back_entry_release_rw(
|
2000-09-30 12:13:30 +08:00
|
|
|
Operation *op,
|
1999-04-13 14:15:03 +08:00
|
|
|
Entry *e,
|
|
|
|
int rw
|
|
|
|
)
|
|
|
|
{
|
2003-03-30 17:03:54 +08:00
|
|
|
struct ldbminfo *li = (struct ldbminfo *) op->o_bd->be_private;
|
1999-04-13 14:15:03 +08:00
|
|
|
|
2001-12-06 20:28:49 +08:00
|
|
|
if ( slapMode == SLAP_SERVER_MODE ) {
|
|
|
|
/* free entry and reader or writer lock */
|
|
|
|
cache_return_entry_rw( &li->li_cache, e, rw );
|
2003-03-30 13:33:42 +08:00
|
|
|
/* only do_add calls here with a write lock.
|
|
|
|
* get_entry doesn't obtain the giant lock, because its
|
|
|
|
* caller has already obtained it.
|
|
|
|
*/
|
2002-01-30 03:43:17 +08:00
|
|
|
if( rw ) {
|
|
|
|
ldap_pvt_thread_rdwr_wunlock( &li->li_giant_rwlock );
|
2003-03-30 13:33:42 +08:00
|
|
|
}
|
|
|
|
#if 0
|
|
|
|
else {
|
2002-01-30 03:43:17 +08:00
|
|
|
ldap_pvt_thread_rdwr_runlock( &li->li_giant_rwlock );
|
|
|
|
}
|
2003-03-30 13:33:42 +08:00
|
|
|
#endif
|
2002-01-30 01:58:36 +08:00
|
|
|
|
2001-12-06 20:28:49 +08:00
|
|
|
} else {
|
2004-04-14 00:49:12 +08:00
|
|
|
if ( e->e_private ) {
|
|
|
|
free( e->e_private );
|
|
|
|
e->e_private = NULL;
|
|
|
|
}
|
2001-12-06 20:28:49 +08:00
|
|
|
entry_free( e );
|
|
|
|
}
|
1999-04-13 14:15:03 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2003-03-26 19:50:03 +08:00
|
|
|
|
|
|
|
/* return LDAP_SUCCESS IFF we can retrieve the specified entry.
|
|
|
|
*/
|
|
|
|
int ldbm_back_entry_get(
|
|
|
|
Operation *op,
|
|
|
|
struct berval *ndn,
|
|
|
|
ObjectClass *oc,
|
|
|
|
AttributeDescription *at,
|
|
|
|
int rw,
|
|
|
|
Entry **ent )
|
|
|
|
{
|
2003-03-30 17:03:54 +08:00
|
|
|
struct ldbminfo *li = (struct ldbminfo *) op->o_bd->be_private;
|
2003-03-26 19:50:03 +08:00
|
|
|
Entry *e;
|
|
|
|
int rc;
|
2003-09-20 15:48:57 +08:00
|
|
|
const char *at_name = at ? at->ad_cname.bv_val : "(null)";
|
2003-03-26 19:50:03 +08:00
|
|
|
|
|
|
|
#ifdef NEW_LOGGING
|
2003-07-15 08:55:58 +08:00
|
|
|
LDAP_LOG( BACK_LDBM, ARGS,
|
2003-03-26 19:50:03 +08:00
|
|
|
"ldbm_back_entry_get: ndn: \"%s\"\n", ndn->bv_val, 0, 0 );
|
2003-07-15 08:55:58 +08:00
|
|
|
LDAP_LOG( BACK_LDBM, ARGS,
|
2003-03-26 19:50:03 +08:00
|
|
|
"ldbm_back_entry_get: oc: \"%s\", at: \"%s\"\n",
|
|
|
|
oc ? oc->soc_cname.bv_val : "(null)", at_name, 0);
|
|
|
|
#else
|
|
|
|
Debug( LDAP_DEBUG_ARGS,
|
|
|
|
"=> ldbm_back_entry_get: ndn: \"%s\"\n", ndn->bv_val, 0, 0 );
|
|
|
|
Debug( LDAP_DEBUG_ARGS,
|
|
|
|
"=> ldbm_back_entry_get: oc: \"%s\", at: \"%s\"\n",
|
|
|
|
oc ? oc->soc_cname.bv_val : "(null)", at_name, 0);
|
|
|
|
#endif
|
|
|
|
|
2003-03-30 13:33:42 +08:00
|
|
|
/* don't grab the giant lock - our caller has already gotten it. */
|
|
|
|
|
2003-03-26 19:50:03 +08:00
|
|
|
/* can we find entry */
|
2003-03-30 17:03:54 +08:00
|
|
|
e = dn2entry_rw( op->o_bd, ndn, NULL, rw );
|
2003-03-26 19:50:03 +08:00
|
|
|
if (e == NULL) {
|
|
|
|
#ifdef NEW_LOGGING
|
2003-07-15 08:55:58 +08:00
|
|
|
LDAP_LOG( BACK_LDBM, INFO,
|
2003-03-26 19:50:03 +08:00
|
|
|
"ldbm_back_entry_get: cannot find entry (%s)\n",
|
|
|
|
ndn->bv_val, 0, 0 );
|
|
|
|
#else
|
|
|
|
Debug( LDAP_DEBUG_ACL,
|
|
|
|
"=> ldbm_back_entry_get: cannot find entry: \"%s\"\n",
|
|
|
|
ndn->bv_val, 0, 0 );
|
|
|
|
#endif
|
|
|
|
return LDAP_NO_SUCH_OBJECT;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef NEW_LOGGING
|
2003-07-15 08:55:58 +08:00
|
|
|
LDAP_LOG( BACK_LDBM, DETAIL1, "ldbm_back_entry_get: found entry (%s)\n",
|
2003-03-26 19:50:03 +08:00
|
|
|
ndn->bv_val, 0, 0 );
|
|
|
|
#else
|
|
|
|
Debug( LDAP_DEBUG_ACL,
|
|
|
|
"=> ldbm_back_entry_get: found entry: \"%s\"\n",
|
|
|
|
ndn->bv_val, 0, 0 );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef BDB_ALIASES
|
|
|
|
/* find attribute values */
|
|
|
|
if( is_entry_alias( e ) ) {
|
|
|
|
#ifdef NEW_LOGGING
|
2003-07-15 08:55:58 +08:00
|
|
|
LDAP_LOG( BACK_LDBM, INFO,
|
2003-03-26 19:50:03 +08:00
|
|
|
"ldbm_back_entry_get: entry (%s) is an alias\n", e->e_name.bv_val, 0, 0 );
|
|
|
|
#else
|
|
|
|
Debug( LDAP_DEBUG_ACL,
|
|
|
|
"<= ldbm_back_entry_get: entry is an alias\n", 0, 0, 0 );
|
|
|
|
#endif
|
|
|
|
rc = LDAP_ALIAS_PROBLEM;
|
|
|
|
goto return_results;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if( is_entry_referral( e ) ) {
|
|
|
|
#ifdef NEW_LOGGING
|
2003-07-15 08:55:58 +08:00
|
|
|
LDAP_LOG( BACK_LDBM, INFO,
|
2003-03-26 19:50:03 +08:00
|
|
|
"ldbm_back_entry_get: entry (%s) is a referral.\n", e->e_name.bv_val, 0, 0);
|
|
|
|
#else
|
|
|
|
Debug( LDAP_DEBUG_ACL,
|
|
|
|
"<= ldbm_back_entry_get: entry is a referral\n", 0, 0, 0 );
|
|
|
|
#endif
|
|
|
|
rc = LDAP_REFERRAL;
|
|
|
|
goto return_results;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( oc && !is_entry_objectclass( e, oc, 0 )) {
|
|
|
|
#ifdef NEW_LOGGING
|
2003-07-15 08:55:58 +08:00
|
|
|
LDAP_LOG( BACK_LDBM, INFO,
|
2003-03-26 19:50:03 +08:00
|
|
|
"ldbm_back_entry_get: failed to find objectClass.\n", 0, 0, 0 );
|
|
|
|
#else
|
|
|
|
Debug( LDAP_DEBUG_ACL,
|
|
|
|
"<= ldbm_back_entry_get: failed to find objectClass\n",
|
|
|
|
0, 0, 0 );
|
|
|
|
#endif
|
|
|
|
rc = LDAP_NO_SUCH_ATTRIBUTE;
|
|
|
|
goto return_results;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = LDAP_SUCCESS;
|
|
|
|
|
|
|
|
return_results:
|
|
|
|
if( rc != LDAP_SUCCESS ) {
|
|
|
|
/* free entry */
|
|
|
|
cache_return_entry_rw(&li->li_cache, e, rw);
|
|
|
|
} else {
|
|
|
|
*ent = e;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef NEW_LOGGING
|
2003-07-15 08:55:58 +08:00
|
|
|
LDAP_LOG( BACK_LDBM, ENTRY, "ldbm_back_entry_get: rc=%d\n", rc, 0, 0 );
|
2003-03-26 19:50:03 +08:00
|
|
|
#else
|
|
|
|
Debug( LDAP_DEBUG_TRACE,
|
|
|
|
"ldbm_back_entry_get: rc=%d\n",
|
|
|
|
rc, 0, 0 );
|
|
|
|
#endif
|
|
|
|
return(rc);
|
|
|
|
}
|