1999-02-02 01:37:43 +08:00
|
|
|
/* group.c - ldbm backend acl group 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-21 14:33:42 +08:00
|
|
|
|
1998-10-25 09:41:42 +08:00
|
|
|
#include "portable.h"
|
|
|
|
|
1998-08-21 14:33:42 +08:00
|
|
|
#include <stdio.h>
|
1998-10-25 09:41:42 +08:00
|
|
|
|
|
|
|
#include <ac/socket.h>
|
|
|
|
#include <ac/string.h>
|
|
|
|
|
1998-08-21 14:33:42 +08:00
|
|
|
#include "slap.h"
|
|
|
|
#include "back-ldbm.h"
|
1998-09-21 04:22:46 +08:00
|
|
|
#include "proto-back-ldbm.h"
|
1998-08-21 14:33:42 +08:00
|
|
|
|
|
|
|
|
1999-01-19 13:10:50 +08:00
|
|
|
/* return 0 IFF op_dn is a value in member attribute
|
|
|
|
* of entry with gr_dn AND that entry has an objectClass
|
1998-10-24 10:33:17 +08:00
|
|
|
* value of groupOfNames
|
1998-08-21 14:33:42 +08:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
ldbm_back_group(
|
1999-01-19 13:10:50 +08:00
|
|
|
Backend *be,
|
2000-09-29 13:25:44 +08:00
|
|
|
Connection *conn,
|
|
|
|
Operation *op,
|
1998-12-30 11:35:23 +08:00
|
|
|
Entry *target,
|
2001-12-27 07:43:28 +08:00
|
|
|
struct berval *gr_ndn,
|
|
|
|
struct berval *op_ndn,
|
2000-05-29 00:36:34 +08:00
|
|
|
ObjectClass *group_oc,
|
2000-02-15 04:57:34 +08:00
|
|
|
AttributeDescription *group_at
|
1998-08-21 14:33:42 +08:00
|
|
|
)
|
|
|
|
{
|
1999-07-16 10:45:46 +08:00
|
|
|
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
|
2001-01-18 01:01:19 +08:00
|
|
|
Entry *e;
|
|
|
|
int rc = 1;
|
1999-07-16 10:45:46 +08:00
|
|
|
Attribute *attr;
|
|
|
|
|
2000-05-29 00:36:34 +08:00
|
|
|
const char *group_oc_name = NULL;
|
2001-10-22 21:23:05 +08:00
|
|
|
const char *group_at_name = group_at->ad_cname.bv_val;
|
2000-05-29 00:36:34 +08:00
|
|
|
|
|
|
|
if( group_oc->soc_names && group_oc->soc_names[0] ) {
|
|
|
|
group_oc_name = group_oc->soc_names[0];
|
|
|
|
} else {
|
|
|
|
group_oc_name = group_oc->soc_oid;
|
|
|
|
}
|
2000-01-29 04:01:00 +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,
|
2001-12-27 07:43:28 +08:00
|
|
|
"ldbm_back_group: check (%s) member of (%s), oc %s\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
op_ndn->bv_val, gr_ndn->bv_val, group_oc_name );
|
2001-01-18 01:01:19 +08:00
|
|
|
#else
|
1999-07-16 10:45:46 +08:00
|
|
|
Debug( LDAP_DEBUG_ARGS,
|
1999-01-19 13:10:50 +08:00
|
|
|
"=> ldbm_back_group: gr dn: \"%s\"\n",
|
2001-12-27 07:43:28 +08:00
|
|
|
gr_ndn->bv_val, 0, 0 );
|
2001-01-18 01:01:19 +08:00
|
|
|
|
1999-07-16 10:45:46 +08:00
|
|
|
Debug( LDAP_DEBUG_ARGS,
|
1999-01-19 13:10:50 +08:00
|
|
|
"=> ldbm_back_group: op dn: \"%s\"\n",
|
2001-12-27 07:43:28 +08:00
|
|
|
op_ndn->bv_val, 0, 0 );
|
1999-07-16 10:45:46 +08:00
|
|
|
Debug( LDAP_DEBUG_ARGS,
|
2000-05-29 00:36:34 +08:00
|
|
|
"=> ldbm_back_group: oc: \"%s\" at: \"%s\"\n",
|
|
|
|
group_oc_name, group_at_name, 0 );
|
1999-01-19 13:10:50 +08:00
|
|
|
|
1999-07-16 10:45:46 +08:00
|
|
|
Debug( LDAP_DEBUG_ARGS,
|
1999-01-19 13:10:50 +08:00
|
|
|
"=> ldbm_back_group: tr dn: \"%s\"\n",
|
|
|
|
target->e_ndn, 0, 0 );
|
2001-01-18 01:01:19 +08:00
|
|
|
#endif
|
1999-01-19 13:10:50 +08:00
|
|
|
|
2002-01-16 20:15:27 +08:00
|
|
|
if (dn_match(&target->e_nname, gr_ndn)) {
|
1998-12-30 11:35:23 +08:00
|
|
|
/* we already have a LOCKED copy of the entry */
|
|
|
|
e = target;
|
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_back_group: target is group (%s)\n", gr_ndn->bv_val, 0, 0 );
|
2001-01-18 01:01:19 +08:00
|
|
|
#else
|
|
|
|
Debug( LDAP_DEBUG_ARGS,
|
1999-01-19 13:10:50 +08:00
|
|
|
"=> ldbm_back_group: target is group: \"%s\"\n",
|
2001-12-27 07:43:28 +08:00
|
|
|
gr_ndn->bv_val, 0, 0 );
|
2001-01-18 01:01:19 +08:00
|
|
|
#endif
|
|
|
|
|
1999-07-16 10:45:46 +08:00
|
|
|
|
1998-12-30 11:35:23 +08:00
|
|
|
} else {
|
1999-01-19 13:10:50 +08:00
|
|
|
/* can we find group entry with reader lock */
|
2002-01-01 21:31:20 +08:00
|
|
|
if ((e = dn2entry_r(be, gr_ndn, NULL )) == NULL) {
|
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_back_group: cannot find group (%s)\n",
|
|
|
|
gr_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_ACL,
|
|
|
|
"=> ldbm_back_group: cannot find group: \"%s\"\n",
|
2001-12-27 07:43:28 +08:00
|
|
|
gr_ndn->bv_val, 0, 0 );
|
2001-01-18 01:01:19 +08:00
|
|
|
#endif
|
|
|
|
|
1998-12-30 11:35:23 +08:00
|
|
|
return( 1 );
|
|
|
|
}
|
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, DETAIL1,
|
|
|
|
"ldbm_back_group: found group (%s)\n", gr_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_ACL,
|
1999-01-19 13:10:50 +08:00
|
|
|
"=> ldbm_back_group: found group: \"%s\"\n",
|
2001-12-27 07:43:28 +08:00
|
|
|
gr_ndn->bv_val, 0, 0 );
|
2001-01-18 01:01:19 +08:00
|
|
|
#endif
|
|
|
|
|
1999-07-16 10:45:46 +08:00
|
|
|
}
|
1998-11-24 04:08:25 +08:00
|
|
|
|
1999-07-16 10:45:46 +08:00
|
|
|
/* find it's objectClass and member attribute values
|
|
|
|
* make sure this is a group entry
|
|
|
|
* finally test if we can find op_dn in the member attribute value list *
|
|
|
|
*/
|
2001-01-18 01:01:19 +08:00
|
|
|
|
1999-07-16 10:45:46 +08:00
|
|
|
rc = 1;
|
2001-01-18 01:01:19 +08:00
|
|
|
|
2000-06-06 10:11:27 +08:00
|
|
|
|
|
|
|
if( is_entry_alias( e ) ) {
|
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_back_group: group (%s) is an alias\n", gr_ndn->bv_val, 0, 0 );
|
2001-01-18 01:01:19 +08:00
|
|
|
#else
|
2000-06-06 10:11:27 +08:00
|
|
|
Debug( LDAP_DEBUG_ACL,
|
|
|
|
"<= ldbm_back_group: group is an alias\n", 0, 0, 0 );
|
2001-01-18 01:01:19 +08:00
|
|
|
#endif
|
|
|
|
|
2000-06-06 10:11:27 +08:00
|
|
|
goto return_results;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( is_entry_referral( e ) ) {
|
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_back_group: group (%s) is a referral.\n", gr_ndn->bv_val,0,0);
|
2001-01-18 01:01:19 +08:00
|
|
|
#else
|
2000-06-06 10:11:27 +08:00
|
|
|
Debug( LDAP_DEBUG_ACL,
|
|
|
|
"<= ldbm_back_group: group is an referral\n", 0, 0, 0 );
|
2001-01-18 01:01:19 +08:00
|
|
|
#endif
|
|
|
|
|
2000-06-06 10:11:27 +08:00
|
|
|
goto return_results;
|
|
|
|
}
|
|
|
|
|
2002-01-19 10:58:00 +08:00
|
|
|
if( !is_entry_objectclass( e, group_oc, 0 ) ) {
|
2001-01-18 01:01:19 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG( BACK_LDBM, ERR,
|
2001-12-27 07:43:28 +08:00
|
|
|
"ldbm_back_group: failed to find %s in objectClass.\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
group_oc_name, 0, 0 );
|
2001-01-18 01:01:19 +08:00
|
|
|
#else
|
2000-06-06 10:11:27 +08:00
|
|
|
Debug( LDAP_DEBUG_ACL,
|
|
|
|
"<= ldbm_back_group: failed to find %s in objectClass\n",
|
|
|
|
group_oc_name, 0, 0 );
|
2001-01-18 01:01:19 +08:00
|
|
|
#endif
|
|
|
|
|
2000-06-06 10:11:27 +08:00
|
|
|
goto return_results;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((attr = attr_find(e->e_attrs, group_at)) == NULL) {
|
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_back_group: failed to find %s\n", group_at_name, 0, 0 );
|
2001-01-18 01:01:19 +08:00
|
|
|
#else
|
2000-06-06 10:11:27 +08:00
|
|
|
Debug( LDAP_DEBUG_ACL,
|
|
|
|
"<= ldbm_back_group: failed to find %s\n",
|
|
|
|
group_at_name, 0, 0 );
|
2001-01-18 01:01:19 +08:00
|
|
|
#endif
|
|
|
|
|
2000-06-06 10:11:27 +08:00
|
|
|
goto return_results;
|
|
|
|
}
|
|
|
|
|
2001-01-18 01:01:19 +08:00
|
|
|
#ifdef NEW_LOGGING
|
2002-07-12 04:33:24 +08:00
|
|
|
LDAP_LOG( BACK_LDBM, ENTRY,
|
2001-01-18 01:01:19 +08:00
|
|
|
"ldbm_back_group: found objectClass %s and %s\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
group_oc_name, group_at_name, 0 );
|
2001-01-18 01:01:19 +08:00
|
|
|
#else
|
2000-06-06 10:11:27 +08:00
|
|
|
Debug( LDAP_DEBUG_ACL,
|
|
|
|
"<= ldbm_back_group: found objectClass %s and %s\n",
|
|
|
|
group_oc_name, group_at_name, 0 );
|
2001-01-18 01:01:19 +08:00
|
|
|
#endif
|
|
|
|
|
2000-06-06 10:11:27 +08:00
|
|
|
|
2002-12-05 02:19:46 +08:00
|
|
|
if( value_find_ex( group_at, SLAP_MR_VALUE_NORMALIZED_MATCH,
|
|
|
|
attr->a_vals, op_ndn ) != 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, DETAIL1,
|
2001-12-27 07:43:28 +08:00
|
|
|
"ldbm_back_group: \"%s\" not in \"%s\": %s\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
op_ndn->bv_val, gr_ndn->bv_val, group_at_name );
|
2001-01-18 01:01:19 +08:00
|
|
|
#else
|
2000-06-06 10:11:27 +08:00
|
|
|
Debug( LDAP_DEBUG_ACL,
|
|
|
|
"<= ldbm_back_group: \"%s\" not in \"%s\": %s\n",
|
2001-12-27 07:43:28 +08:00
|
|
|
op_ndn->bv_val, gr_ndn->bv_val, group_at_name );
|
2001-01-18 01:01:19 +08:00
|
|
|
#endif
|
|
|
|
|
2000-06-06 10:11:27 +08:00
|
|
|
goto return_results;
|
|
|
|
}
|
|
|
|
|
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, DETAIL1,
|
2001-12-27 07:43:28 +08:00
|
|
|
"ldbm_back_group: %s is in %s: %s\n",
|
2002-07-12 04:33:24 +08:00
|
|
|
op_ndn->bv_val, gr_ndn->bv_val, group_at_name );
|
2001-01-18 01:01:19 +08:00
|
|
|
#else
|
1999-07-16 10:45:46 +08:00
|
|
|
Debug( LDAP_DEBUG_ACL,
|
|
|
|
"<= ldbm_back_group: \"%s\" is in \"%s\": %s\n",
|
2001-12-27 07:43:28 +08:00
|
|
|
op_ndn->bv_val, gr_ndn->bv_val, group_at_name );
|
2001-01-18 01:01:19 +08:00
|
|
|
#endif
|
|
|
|
|
1999-07-16 10:45:46 +08:00
|
|
|
|
|
|
|
rc = 0;
|
1998-08-21 14:33:42 +08:00
|
|
|
|
1999-07-16 10:45:46 +08:00
|
|
|
return_results:
|
1998-12-30 11:35:23 +08:00
|
|
|
if( target != e ) {
|
|
|
|
/* free entry and reader lock */
|
2001-01-18 01:01:19 +08:00
|
|
|
cache_return_entry_r( &li->li_cache, e );
|
1998-12-30 11:35:23 +08:00
|
|
|
}
|
1999-01-19 13:10:50 +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_group: rc=%d\n", rc, 0, 0 );
|
2001-01-18 01:01:19 +08:00
|
|
|
#else
|
1999-07-16 10:45:46 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE, "ldbm_back_group: rc=%d\n", rc, 0, 0 );
|
2001-01-18 01:01:19 +08:00
|
|
|
#endif
|
|
|
|
|
1999-01-19 13:10:50 +08:00
|
|
|
return(rc);
|
1998-08-21 14:33:42 +08:00
|
|
|
}
|
|
|
|
|