1998-08-21 14:33:42 +08:00
|
|
|
/* compare.c - ldbm backend compare routine */
|
|
|
|
|
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
|
|
|
|
|
|
|
|
1998-10-25 09:41:42 +08:00
|
|
|
#ifdef SLAPD_ACLGROUPS
|
1998-10-27 10:07:12 +08:00
|
|
|
/* return 0 IFF edn is a value in member attribute
|
1998-08-21 14:33:42 +08:00
|
|
|
* of entry with bdn 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(
|
|
|
|
Backend *be,
|
1998-12-30 11:35:23 +08:00
|
|
|
Entry *target,
|
1998-08-21 14:33:42 +08:00
|
|
|
char *bdn,
|
1998-10-27 10:07:12 +08:00
|
|
|
char *edn,
|
|
|
|
char *objectclassValue,
|
|
|
|
char *groupattrName
|
1998-08-21 14:33:42 +08:00
|
|
|
)
|
|
|
|
{
|
|
|
|
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
|
|
|
|
Entry *e;
|
1998-12-30 13:21:40 +08:00
|
|
|
char *tdn, *xdn;
|
1998-08-21 14:33:42 +08:00
|
|
|
char *matched;
|
|
|
|
Attribute *objectClass;
|
1998-10-24 10:33:17 +08:00
|
|
|
Attribute *member;
|
1998-08-21 14:33:42 +08:00
|
|
|
int rc;
|
|
|
|
|
1998-09-21 04:22:46 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE, "=> ldbm_back_group: bdn: %s\n", bdn, 0, 0 );
|
|
|
|
Debug( LDAP_DEBUG_TRACE, "=> ldbm_back_group: edn: %s\n", edn, 0, 0 );
|
1998-10-27 10:07:12 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE, "=> ldbm_back_group: objectClass: %s attrName: %s\n",
|
|
|
|
objectclassValue, groupattrName, 0 );
|
1998-08-21 14:33:42 +08:00
|
|
|
|
1998-12-30 11:35:23 +08:00
|
|
|
tdn = dn_normalize_case( ch_strdup( target->e_dn ) );
|
1998-12-30 13:21:40 +08:00
|
|
|
xdn = dn_normalize_case( ch_strdup( bdn ) );
|
|
|
|
Debug( LDAP_DEBUG_TRACE, "=> ldbm_back_group: tdn: %s\n", tdn, 0, 0 );
|
|
|
|
if (strcmp(tdn, xdn) == 0) {
|
1998-12-30 11:35:23 +08:00
|
|
|
/* we already have a LOCKED copy of the entry */
|
|
|
|
e = target;
|
|
|
|
Debug( LDAP_DEBUG_ARGS,
|
|
|
|
"=> ldbm_back_group: target is bdn: %s\n",
|
|
|
|
bdn, 0, 0 );
|
|
|
|
} else {
|
|
|
|
/* can we find bdn entry with reader lock */
|
|
|
|
if ((e = dn2entry_r(be, bdn, &matched )) == NULL) {
|
|
|
|
Debug( LDAP_DEBUG_TRACE,
|
|
|
|
"=> ldbm_back_group: cannot find bdn: %s matched: %s\n",
|
|
|
|
bdn, (matched ? matched : ""), 0 );
|
|
|
|
if (matched != NULL)
|
|
|
|
free(matched);
|
|
|
|
free(tdn);
|
1998-12-30 13:21:40 +08:00
|
|
|
free(xdn);
|
1998-12-30 11:35:23 +08:00
|
|
|
return( 1 );
|
|
|
|
}
|
|
|
|
Debug( LDAP_DEBUG_ARGS,
|
|
|
|
"=> ldbm_back_group: found bdn: %s\n",
|
|
|
|
bdn, 0, 0 );
|
1998-08-21 14:33:42 +08:00
|
|
|
}
|
1998-12-30 11:35:23 +08:00
|
|
|
free(tdn);
|
1998-12-30 13:21:40 +08:00
|
|
|
free(xdn);
|
1998-11-24 04:08:25 +08:00
|
|
|
|
1998-08-21 14:33:42 +08:00
|
|
|
|
1998-09-21 04:22:46 +08:00
|
|
|
/* check for deleted */
|
1998-08-21 14:33:42 +08:00
|
|
|
|
1998-10-24 10:33:17 +08:00
|
|
|
/* find it's objectClass and member attribute values
|
1998-08-21 14:33:42 +08:00
|
|
|
* make sure this is a group entry
|
1998-10-24 10:33:17 +08:00
|
|
|
* finally test if we can find edn in the member attribute value list *
|
1998-08-21 14:33:42 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
rc = 1;
|
|
|
|
if ((objectClass = attr_find(e->e_attrs, "objectclass")) == NULL) {
|
1998-09-21 04:22:46 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE, "<= ldbm_back_group: failed to find objectClass\n", 0, 0, 0 );
|
1998-08-21 14:33:42 +08:00
|
|
|
}
|
1998-10-27 10:07:12 +08:00
|
|
|
else if ((member = attr_find(e->e_attrs, groupattrName)) == NULL) {
|
|
|
|
Debug( LDAP_DEBUG_TRACE, "<= ldbm_back_group: failed to find %s\n", groupattrName, 0, 0 );
|
1998-08-21 14:33:42 +08:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
struct berval bvObjectClass;
|
1998-10-24 10:33:17 +08:00
|
|
|
struct berval bvMembers;
|
1998-08-21 14:33:42 +08:00
|
|
|
|
1998-10-27 10:07:12 +08:00
|
|
|
Debug( LDAP_DEBUG_ARGS, "<= ldbm_back_group: found objectClass and %s\n", groupattrName, 0, 0 );
|
1998-08-21 14:33:42 +08:00
|
|
|
|
1998-10-27 10:07:12 +08:00
|
|
|
bvObjectClass.bv_val = objectclassValue;
|
1998-08-21 14:33:42 +08:00
|
|
|
bvObjectClass.bv_len = strlen( bvObjectClass.bv_val );
|
1998-10-27 10:07:12 +08:00
|
|
|
|
1998-10-24 10:33:17 +08:00
|
|
|
bvMembers.bv_val = edn;
|
|
|
|
bvMembers.bv_len = strlen( edn );
|
1998-08-21 14:33:42 +08:00
|
|
|
|
|
|
|
if (value_find(objectClass->a_vals, &bvObjectClass, SYNTAX_CIS, 1) != 0) {
|
1998-10-24 10:33:17 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE,
|
1998-10-27 10:07:12 +08:00
|
|
|
"<= ldbm_back_group: failed to find %s in objectClass\n",
|
|
|
|
objectclassValue, 0, 0 );
|
1998-08-21 14:33:42 +08:00
|
|
|
}
|
1998-10-27 01:37:35 +08:00
|
|
|
else if (value_find(member->a_vals, &bvMembers, SYNTAX_CIS, 1) != 0) {
|
1998-10-27 10:07:12 +08:00
|
|
|
Debug( LDAP_DEBUG_ACL, "<= ldbm_back_group: %s not in %s: %s\n",
|
|
|
|
edn, bdn, groupattrName );
|
1998-08-21 14:33:42 +08:00
|
|
|
}
|
|
|
|
else {
|
1998-10-27 10:07:12 +08:00
|
|
|
Debug( LDAP_DEBUG_ACL, "<= ldbm_back_group: %s is in %s: %s\n",
|
|
|
|
edn, bdn, groupattrName );
|
1998-08-21 14:33:42 +08:00
|
|
|
rc = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-30 11:35:23 +08:00
|
|
|
if( target != e ) {
|
|
|
|
/* free entry and reader lock */
|
|
|
|
cache_return_entry_r( &li->li_cache, e );
|
|
|
|
}
|
1998-08-21 14:33:42 +08:00
|
|
|
Debug( LDAP_DEBUG_ARGS, "ldbm_back_group: rc: %d\n", rc, 0, 0 );
|
|
|
|
return(rc);
|
|
|
|
}
|
1998-10-27 10:07:12 +08:00
|
|
|
#endif /* SLAPD_ACLGROUPS */
|
1998-08-21 14:33:42 +08:00
|
|
|
|