From c9ec6b0cabf7c47ac9dbd9a74d4aba33934e6223 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Wed, 26 Mar 2003 11:52:59 +0000 Subject: [PATCH] Remove attribute.c, group.c from build --- servers/slapd/back-bdb/Makefile.in | 4 +- servers/slapd/back-bdb/attribute.c | 253 -------------------------- servers/slapd/back-bdb/group.c | 268 ---------------------------- servers/slapd/back-ldap/Makefile.in | 4 +- servers/slapd/back-ldap/attribute.c | 140 --------------- servers/slapd/back-ldap/group.c | 210 ---------------------- servers/slapd/back-ldbm/Makefile.in | 8 +- servers/slapd/back-ldbm/attribute.c | 201 --------------------- servers/slapd/back-ldbm/group.c | 231 ------------------------ 9 files changed, 8 insertions(+), 1311 deletions(-) delete mode 100644 servers/slapd/back-bdb/attribute.c delete mode 100644 servers/slapd/back-bdb/group.c delete mode 100644 servers/slapd/back-ldap/attribute.c delete mode 100644 servers/slapd/back-ldap/group.c delete mode 100644 servers/slapd/back-ldbm/attribute.c delete mode 100644 servers/slapd/back-ldbm/group.c diff --git a/servers/slapd/back-bdb/Makefile.in b/servers/slapd/back-bdb/Makefile.in index ccee12cdc3..6d85fd885a 100644 --- a/servers/slapd/back-bdb/Makefile.in +++ b/servers/slapd/back-bdb/Makefile.in @@ -2,12 +2,12 @@ SRCS = init.c tools.c config.c \ add.c bind.c compare.c delete.c modify.c modrdn.c search.c \ - extended.c passwd.c referral.c attribute.c group.c operational.c \ + extended.c passwd.c referral.c operational.c \ attr.c index.c key.c dbcache.c filterindex.c \ dn2entry.c dn2id.c error.c id2entry.c idl.c nextid.c cache.c psearch.c OBJS = init.lo tools.lo config.lo \ add.lo bind.lo compare.lo delete.lo modify.lo modrdn.lo search.lo \ - extended.lo passwd.lo referral.lo attribute.lo group.lo operational.lo \ + extended.lo passwd.lo referral.lo operational.lo \ attr.lo index.lo key.lo dbcache.lo filterindex.lo \ dn2entry.lo dn2id.lo error.lo id2entry.lo idl.lo nextid.lo cache.lo psearch.lo diff --git a/servers/slapd/back-bdb/attribute.c b/servers/slapd/back-bdb/attribute.c deleted file mode 100644 index 9ab9ec52d7..0000000000 --- a/servers/slapd/back-bdb/attribute.c +++ /dev/null @@ -1,253 +0,0 @@ -/* attribute.c - bdb backend acl attribute routine */ -/* $OpenLDAP$ */ -/* - * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved. - * COPYING RESTRICTIONS APPLY, see COPYRIGHT file - */ - -#include "portable.h" - -#include - -#include -#include - -#include "slap.h" -#include "back-bdb.h" -#include "proto-bdb.h" - -/* return LDAP_SUCCESS IFF we can retrieve the attributes - * of entry with e_ndn - */ -int -bdb_attribute( - Backend *be, - Connection *conn, - Operation *op, - Entry *target, - struct berval *entry_ndn, - AttributeDescription *entry_at, - BerVarray *vals ) -{ - struct bdb_info *bdb = (struct bdb_info *) be->be_private; - struct bdb_op_info *boi = NULL; - DB_TXN *txn = NULL; - Entry *e; - int i, j = 0, rc; - Attribute *attr; - BerVarray v; - const char *entry_at_name = entry_at->ad_cname.bv_val; - AccessControlState acl_state = ACL_STATE_INIT; - - u_int32_t locker = 0; - DB_LOCK lock; - int free_lock_id = 0; - -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, ARGS, - "bdb_attribute: gr ndn: \"%s\"\n", entry_ndn->bv_val, 0, 0 ); - LDAP_LOG( BACK_BDB, ARGS, - "bdb_attribute: at: \"%s\"\n", entry_at_name, 0, 0); - LDAP_LOG( BACK_BDB, ARGS, "bdb_attribute: tr ndn: \"%s\"\n", - target ? target->e_ndn : "", 0, 0 ); -#else - Debug( LDAP_DEBUG_ARGS, - "=> bdb_attribute: gr ndn: \"%s\"\n", - entry_ndn->bv_val, 0, 0 ); - Debug( LDAP_DEBUG_ARGS, - "=> bdb_attribute: at: \"%s\"\n", - entry_at_name, 0, 0 ); - - Debug( LDAP_DEBUG_ARGS, - "=> bdb_attribute: tr ndn: \"%s\"\n", - target ? target->e_ndn : "", 0, 0 ); -#endif - - if( op ) boi = (struct bdb_op_info *) op->o_private; - if( boi != NULL && be == boi->boi_bdb ) { - txn = boi->boi_txn; - locker = boi->boi_locker; - } - - if ( txn != NULL ) { - locker = TXN_ID ( txn ); - } else if ( !locker ) { - rc = LOCK_ID ( bdb->bi_dbenv, &locker ); - free_lock_id = 1; - switch(rc) { - case 0: - break; - default: - return LDAP_OTHER; - } - } - - if (target != NULL && dn_match(&target->e_nname, entry_ndn)) { - /* we already have a LOCKED copy of the entry */ - e = target; -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, DETAIL1, - "bdb_attribute: target is LOCKED (%s)\n", entry_ndn->bv_val, 0, 0 ); -#else - Debug( LDAP_DEBUG_ARGS, - "=> bdb_attribute: target is entry: \"%s\"\n", - entry_ndn->bv_val, 0, 0 ); -#endif - - } else { -dn2entry_retry: - /* can we find entry */ - rc = bdb_dn2entry_r( be, txn, entry_ndn, &e, NULL, 0, locker, &lock ); - switch( rc ) { - case DB_NOTFOUND: - case 0: - break; - case DB_LOCK_DEADLOCK: - case DB_LOCK_NOTGRANTED: - /* the txn must abort and retry */ - if ( txn ) { - boi->boi_err = rc; - return LDAP_BUSY; - } - ldap_pvt_thread_yield(); - goto dn2entry_retry; - default: - boi->boi_err = rc; - if ( free_lock_id ) { - LOCK_ID_FREE( bdb->bi_dbenv, locker ); - } - return (rc != LDAP_BUSY) ? LDAP_OTHER : LDAP_BUSY; - } - if (e == NULL) { -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, INFO, - "bdb_attribute: cannot find entry (%s)\n", - entry_ndn->bv_val, 0, 0 ); -#else - Debug( LDAP_DEBUG_ACL, - "=> bdb_attribute: cannot find entry: \"%s\"\n", - entry_ndn->bv_val, 0, 0 ); -#endif - if ( free_lock_id ) { - LOCK_ID_FREE( bdb->bi_dbenv, locker ); - } - return LDAP_NO_SUCH_OBJECT; - } - -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, DETAIL1, "bdb_attribute: found entry (%s)\n", - entry_ndn->bv_val, 0, 0 ); -#else - Debug( LDAP_DEBUG_ACL, - "=> bdb_attribute: found entry: \"%s\"\n", - entry_ndn->bv_val, 0, 0 ); -#endif - } - -#ifdef BDB_ALIASES - /* find attribute values */ - if( is_entry_alias( e ) ) { -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, INFO, - "bdb_attribute: entry (%s) is an alias\n", e->e_dn, 0, 0 ); -#else - Debug( LDAP_DEBUG_ACL, - "<= bdb_attribute: 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 - LDAP_LOG( BACK_BDB, INFO, - "bdb_attribute: entry (%s) is a referral.\n", e->e_dn, 0, 0); -#else - Debug( LDAP_DEBUG_ACL, - "<= bdb_attribute: entry is a referral\n", 0, 0, 0 ); -#endif - rc = LDAP_REFERRAL; - goto return_results; - } - - if ((attr = attr_find(e->e_attrs, entry_at)) == NULL) { -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, INFO, - "bdb_attribute: failed to find %s.\n", entry_at_name, 0, 0 ); -#else - Debug( LDAP_DEBUG_ACL, - "<= bdb_attribute: failed to find %s\n", - entry_at_name, 0, 0 ); -#endif - rc = LDAP_NO_SUCH_ATTRIBUTE; - goto return_results; - } - - if (conn != NULL && op != NULL - && access_allowed( be, conn, op, e, entry_at, NULL, - ACL_AUTH, &acl_state ) == 0 ) - { - rc = LDAP_INSUFFICIENT_ACCESS; - goto return_results; - } - - for ( i = 0; attr->a_vals[i].bv_val != NULL; i++ ) { - /* count them */ - } - - v = (BerVarray) ch_malloc( sizeof(struct berval) * (i+1) ); - - for ( i=0, j=0; attr->a_vals[i].bv_val != NULL; i++ ) { - if( conn != NULL - && op != NULL - && access_allowed(be, conn, op, e, entry_at, -#ifdef SLAP_NVALUES - &attr->a_nvals[i], -#else - &attr->a_vals[i], -#endif - ACL_AUTH, &acl_state ) == 0) - { - continue; - } - -#ifdef SLAP_NVALUES - ber_dupbv( &v[j], &attr->a_nvals[i] ); -#else - ber_dupbv( &v[j], &attr->a_vals[i] ); -#endif - - if( v[j].bv_val != NULL ) j++; - } - - if( j == 0 ) { - ch_free( v ); - *vals = NULL; - rc = LDAP_INSUFFICIENT_ACCESS; - } else { - v[j].bv_val = NULL; - v[j].bv_len = 0; - *vals = v; - rc = LDAP_SUCCESS; - } - -return_results: - if( target != e ) { - /* free entry */ - bdb_cache_return_entry_r(bdb->bi_dbenv, &bdb->bi_cache, e, &lock); - } - - if ( free_lock_id ) { - LOCK_ID_FREE( bdb->bi_dbenv, locker ); - } - -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, ENTRY, "bdb_attribute: rc=%d nvals=%d.\n", rc, j, 0 ); -#else - Debug( LDAP_DEBUG_TRACE, - "bdb_attribute: rc=%d nvals=%d\n", - rc, j, 0 ); -#endif - return(rc); -} diff --git a/servers/slapd/back-bdb/group.c b/servers/slapd/back-bdb/group.c deleted file mode 100644 index 9bd5d9c57d..0000000000 --- a/servers/slapd/back-bdb/group.c +++ /dev/null @@ -1,268 +0,0 @@ -/* group.c - bdb backend acl group routine */ -/* $OpenLDAP$ */ -/* - * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved. - * COPYING RESTRICTIONS APPLY, see COPYRIGHT file - */ - -#include "portable.h" - -#include - -#include -#include - -#include "slap.h" -#include "back-bdb.h" -#include "proto-bdb.h" - - -/* return 0 IFF op_dn is a value in member attribute - * of entry with gr_dn AND that entry has an objectClass - * value of groupOfNames - */ -int -bdb_group( - Backend *be, - Connection *conn, - Operation *op, - Entry *target, - struct berval *gr_ndn, - struct berval *op_ndn, - ObjectClass *group_oc, - AttributeDescription *group_at ) -{ - struct bdb_info *bdb = (struct bdb_info *) be->be_private; - struct bdb_op_info *boi = NULL; - DB_TXN *txn = NULL; - Entry *e; - int rc = 1; - Attribute *attr; - - const char *group_oc_name = NULL; - const char *group_at_name = group_at->ad_cname.bv_val; - - u_int32_t locker = 0; - DB_LOCK lock; - int free_lock_id = 0; - - 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; - } - -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, ENTRY, - "bdb_group: check (%s) member of (%s), oc %s\n", - op_ndn->bv_val, gr_ndn->bv_val, group_oc_name ); -#else - Debug( LDAP_DEBUG_ARGS, - "=> bdb_group: group ndn: \"%s\"\n", - gr_ndn->bv_val, 0, 0 ); - - Debug( LDAP_DEBUG_ARGS, - "=> bdb_group: op ndn: \"%s\"\n", - op_ndn->bv_val, 0, 0 ); - - Debug( LDAP_DEBUG_ARGS, - "=> bdb_group: oc: \"%s\" at: \"%s\"\n", - group_oc_name, group_at_name, 0 ); - - Debug( LDAP_DEBUG_ARGS, - "=> bdb_group: tr ndn: \"%s\"\n", - target ? target->e_ndn : "", 0, 0 ); -#endif - - if( op ) boi = (struct bdb_op_info *) op->o_private; - if( boi != NULL && be == boi->boi_bdb ) { - txn = boi->boi_txn; - locker = boi->boi_locker; - } - - if ( txn ) { - locker = TXN_ID( txn ); - } else if ( !locker ) { - rc = LOCK_ID ( bdb->bi_dbenv, &locker ); - free_lock_id = 1; - switch(rc) { - case 0: - break; - default: - return 1; - } - } - - if ( target != NULL && dn_match( &target->e_nname, gr_ndn )) { - /* we already have a LOCKED copy of the entry */ - e = target; -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, DETAIL1, - "bdb_group: target is group (%s)\n", gr_ndn->bv_val, 0, 0 ); -#else - Debug( LDAP_DEBUG_ARGS, - "=> bdb_group: target is group: \"%s\"\n", - gr_ndn->bv_val, 0, 0 ); -#endif - } else { -dn2entry_retry: - /* can we find group entry */ - rc = bdb_dn2entry_r( be, txn, gr_ndn, &e, NULL, 0, locker, &lock ); - if( rc ) { - boi->boi_err = rc; - if ( rc == DB_LOCK_DEADLOCK || rc == DB_LOCK_NOTGRANTED ) { - if ( txn ) { - /* must let owning txn abort, but our result - * is still inconclusive, so don't let it - * get cached. - */ - op->o_do_not_cache = 1; - return( 1 ); - } - ldap_pvt_thread_yield(); - goto dn2entry_retry; - } - if ( free_lock_id ) { - LOCK_ID_FREE ( bdb->bi_dbenv, locker ); - } - return( 1 ); - } - if (e == NULL) { -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, DETAIL1, - "bdb_group: cannot find group (%s)\n", gr_ndn->bv_val, 0, 0 ); -#else - Debug( LDAP_DEBUG_ACL, - "=> bdb_group: cannot find group: \"%s\"\n", - gr_ndn->bv_val, 0, 0 ); -#endif - if ( free_lock_id ) { - LOCK_ID_FREE ( bdb->bi_dbenv, locker ); - } - return( 1 ); - } -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, DETAIL1, - "bdb_group: found group (%s)\n", gr_ndn->bv_val, 0, 0 ); -#else - Debug( LDAP_DEBUG_ACL, - "=> bdb_group: found group: \"%s\"\n", - gr_ndn->bv_val, 0, 0 ); -#endif - } - - /* 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 - */ - rc = 1; - -#ifdef BDB_ALIASES - if( is_entry_alias( e ) ) { -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, INFO, - "bdb_group: group (%s) is an alias\n", gr_ndn->bv_val, 0, 0); -#else - Debug( LDAP_DEBUG_ACL, - "<= bdb_group: group is an alias\n", 0, 0, 0 ); -#endif - goto return_results; - } -#endif - - if( is_entry_referral( e ) ) { -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, INFO, - "bdb_group: group (%s) is a referral.\n", gr_ndn->bv_val, 0, 0 ); -#else - Debug( LDAP_DEBUG_ACL, - "<= bdb_group: group is a referral\n", 0, 0, 0 ); -#endif - goto return_results; - } - - if( !is_entry_objectclass( e, group_oc, 0 ) ) { -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, ERR, - "bdb_group: failed to find %s in objectClass.\n", - group_oc_name, 0, 0 ); -#else - Debug( LDAP_DEBUG_ACL, - "<= bdb_group: failed to find %s in objectClass\n", - group_oc_name, 0, 0 ); -#endif - goto return_results; - } - - if ((attr = attr_find(e->e_attrs, group_at)) == NULL) { -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, INFO, - "bdb_group: failed to find %s\n", group_at_name, 0, 0 ); -#else - Debug( LDAP_DEBUG_ACL, - "<= bdb_group: failed to find %s\n", - group_at_name, 0, 0 ); -#endif - goto return_results; - } - -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, ENTRY, - "bdb_group: found objectClass %s and %s\n", - group_oc_name, group_at_name, 0 ); -#else - Debug( LDAP_DEBUG_ACL, - "<= bdb_group: found objectClass %s and %s\n", - group_oc_name, group_at_name, 0 ); -#endif - -#ifdef SLAP_NVALUES - if( value_find_ex( group_at, SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH - | SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH, - attr->a_nvals, op_ndn ) != LDAP_SUCCESS ) -#else - if( value_find_ex( group_at, 0, attr->a_vals, op_ndn ) != LDAP_SUCCESS ) -#endif - { -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, DETAIL1, - "bdb_group: \"%s\" not in \"%s\": %s\n", - op_ndn->bv_val, gr_ndn->bv_val, group_at_name ); -#else - Debug( LDAP_DEBUG_ACL, - "<= bdb_group: \"%s\" not in \"%s\": %s\n", - op_ndn->bv_val, gr_ndn->bv_val, group_at_name ); -#endif - goto return_results; - } - -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, DETAIL1, "bdb_group: %s is in %s: %s\n", - op_ndn->bv_val, gr_ndn->bv_val, group_at_name ); -#else - Debug( LDAP_DEBUG_ACL, - "<= bdb_group: \"%s\" is in \"%s\": %s\n", - op_ndn->bv_val, gr_ndn->bv_val, group_at_name ); -#endif - - rc = 0; - -return_results: - if( target != e ) { - /* free entry */ - bdb_cache_return_entry_r( bdb->bi_dbenv, &bdb->bi_cache, e, &lock ); - } - - if ( free_lock_id ) { - LOCK_ID_FREE ( bdb->bi_dbenv, locker ); - } - -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, ENTRY, "bdb_group: rc=%d\n", rc, 0, 0 ); -#else - Debug( LDAP_DEBUG_TRACE, "bdb_group: rc=%d\n", rc, 0, 0 ); -#endif - - return(rc); -} - diff --git a/servers/slapd/back-ldap/Makefile.in b/servers/slapd/back-ldap/Makefile.in index 7122f6e80b..1445edad4f 100644 --- a/servers/slapd/back-ldap/Makefile.in +++ b/servers/slapd/back-ldap/Makefile.in @@ -1,10 +1,10 @@ # $OpenLDAP$ SRCS = init.c config.c search.c bind.c unbind.c add.c compare.c \ - delete.c modify.c modrdn.c group.c attribute.c \ + delete.c modify.c modrdn.c \ suffixmassage.c map.c extended.c OBJS = init.lo config.lo search.lo bind.lo unbind.lo add.lo compare.lo \ - delete.lo modify.lo modrdn.lo group.lo attribute.lo \ + delete.lo modify.lo modrdn.lo \ suffixmassage.lo map.lo extended.lo LDAP_INCDIR= ../../../include diff --git a/servers/slapd/back-ldap/attribute.c b/servers/slapd/back-ldap/attribute.c deleted file mode 100644 index 8b572024b6..0000000000 --- a/servers/slapd/back-ldap/attribute.c +++ /dev/null @@ -1,140 +0,0 @@ -/* group.c - ldap backend acl group routine */ -/* $OpenLDAP$ */ -/* - * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved. - * COPYING RESTRICTIONS APPLY, see COPYRIGHT file - */ - -#include "portable.h" - -#include - -#include -#include - -#include "slap.h" -#include "back-ldap.h" - - -/* return 0 IFF we can retrieve the attributes - * of entry with ndn - */ -int -ldap_back_attribute( - Backend *be, - Connection *conn, - Operation *op, - Entry *target, - struct berval *ndn, - AttributeDescription *entry_at, - BerVarray *vals -) -{ - struct ldapinfo *li = (struct ldapinfo *) be->be_private; - struct ldapconn *lc; - int rc = 1, i, j, count, is_oc; - Attribute *attr = NULL; - BerVarray abv, v; - struct berval mapped = { 0, NULL }; - char **vs = NULL; - LDAPMessage *result = NULL, *e = NULL; - char *gattr[2]; - - *vals = NULL; - if (target != NULL && dn_match( &target->e_nname, ndn )) { - /* we already have a copy of the entry */ - /* attribute and objectclass mapping has already been done */ - if ((attr = attr_find(target->e_attrs, entry_at)) == NULL) - return(1); - - for ( count = 0; attr->a_vals[count].bv_val != NULL; count++ ) { } - v = (BerVarray) ch_calloc( (count + 1), sizeof(struct berval) ); - if (v != NULL) { - for ( j = 0, abv = attr->a_vals; --count >= 0; abv++ ) { - if ( abv->bv_len > 0 ) { - ber_dupbv( &v[j], abv ); - if( v[j].bv_val == NULL ) - break; - } - } - v[j].bv_val = NULL; - *vals = v; - return 0; - } - - } - ldap_back_map(&li->at_map, &entry_at->ad_cname, &mapped, BACKLDAP_MAP); - if (mapped.bv_val == NULL || mapped.bv_val[0] == '\0') { - return 1; - } - - /* Tell getconn this is a privileged op */ - is_oc = op->o_do_not_cache; - op->o_do_not_cache = 1; - lc = ldap_back_getconn(li, conn, op); - if ( !lc || !ldap_back_dobind(li, lc, NULL, op) ) { - op->o_do_not_cache = is_oc; - return 1; - } - op->o_do_not_cache = is_oc; - - gattr[0] = mapped.bv_val; - gattr[1] = NULL; - if (ldap_search_ext_s(lc->ld, ndn->bv_val, LDAP_SCOPE_BASE, "(objectclass=*)", - gattr, 0, NULL, NULL, LDAP_NO_LIMIT, - LDAP_NO_LIMIT, &result) != LDAP_SUCCESS) - { - goto cleanup; - } - - if ((e = ldap_first_entry(lc->ld, result)) == NULL) { - goto cleanup; - } - - vs = ldap_get_values(lc->ld, e, mapped.bv_val); - if (vs == NULL) { - goto cleanup; - } - - for ( count = 0; vs[count] != NULL; count++ ) { } - v = (BerVarray) ch_calloc( (count + 1), sizeof(struct berval) ); - if (v == NULL) { - goto cleanup; - } - - is_oc = (strcasecmp("objectclass", mapped.bv_val) == 0); - for ( i = 0, j = 0; i < count; i++) { - ber_str2bv(vs[i], 0, 0, &v[j] ); - if (!is_oc) { - if( v[j].bv_val == NULL ) - ch_free(vs[i]); - else - j++; - } else { - ldap_back_map(&li->oc_map, &v[j], &mapped, - BACKLDAP_REMAP); - if (mapped.bv_val && mapped.bv_val[0] != '\0') { - ber_dupbv( &v[j], &mapped ); - if (v[j].bv_val) - j++; - } - ch_free(vs[i]); - } - } - v[j].bv_val = NULL; - *vals = v; - rc = 0; - ch_free(vs); - vs = NULL; - -cleanup: - if (vs) { - ldap_value_free(vs); - } - if (result) { - ldap_msgfree(result); - } - - return(rc); -} - diff --git a/servers/slapd/back-ldap/group.c b/servers/slapd/back-ldap/group.c deleted file mode 100644 index 199ead103a..0000000000 --- a/servers/slapd/back-ldap/group.c +++ /dev/null @@ -1,210 +0,0 @@ -/* group.c - ldap backend acl group routine */ -/* $OpenLDAP$ */ -/* - * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved. - * COPYING RESTRICTIONS APPLY, see COPYRIGHT file - */ - -#include "portable.h" - -#include - -#include -#include - -#include "slap.h" -#include "back-ldap.h" -#include "lutil.h" - -/* return 0 IFF op_dn is a value in group_at (member) attribute - * of entry with gr_dn AND that entry has an objectClass - * value of group_oc (groupOfNames) - */ -int -ldap_back_group( - Backend *be, - Connection *conn, - Operation *op, - Entry *target, - struct berval *gr_ndn, - struct berval *op_ndn, - ObjectClass *group_oc, - AttributeDescription* group_at -) -{ - struct ldapinfo *li = (struct ldapinfo *) be->be_private; - struct ldapconn *lc; - int rc = 1, oc; - Attribute *attr; - - LDAPMessage *result; - char *gattr[2]; - char *filter = NULL, *ptr; - struct berval mop_ndn = { 0, NULL }, mgr_ndn = { 0, NULL }; - - AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass; - struct berval group_oc_name = {0, NULL}; - struct berval group_at_name = group_at->ad_cname; - - if( group_oc->soc_names && group_oc->soc_names[0] ) { - group_oc_name.bv_val = group_oc->soc_names[0]; - } else { - group_oc_name.bv_val = group_oc->soc_oid; - } - if (group_oc_name.bv_val) - group_oc_name.bv_len = strlen(group_oc_name.bv_val); - - if (target != NULL && dn_match( &target->e_nname, gr_ndn ) ) { - /* we already have a copy of the entry */ - /* attribute and objectclass mapping has already been done */ - - /* - * first we need to check if the objectClass attribute - * has been retieved; otherwise we need to repeat the search - */ - attr = attr_find( target->e_attrs, ad_objectClass ); - if ( attr != NULL ) { - - /* - * Now we can check for the group objectClass value - */ - if( !is_entry_objectclass( target, group_oc, 0 ) ) { - return(1); - } - - /* - * This part has been reworked: the group attr compare - * fails only if the attribute is PRESENT but the value - * is NOT PRESENT; if the attribute is NOT PRESENT, the - * search must be repeated as well. - * This may happen if a search for an entry has already - * been performed (target is not null) but the group - * attribute has not been required - */ - if ((attr = attr_find(target->e_attrs, group_at)) != NULL) { - if( value_find_ex( group_at, SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH, - attr->a_vals, op_ndn ) != LDAP_SUCCESS ) - return(1); - return(0); - } /* else: repeat the search */ - } /* else: repeat the search */ - } /* else: do the search */ - - /* - * Rewrite the op ndn if needed - */ -#ifdef ENABLE_REWRITE - switch ( rewrite_session( li->rwinfo, "bindDn", - op_ndn->bv_val, conn, &mop_ndn.bv_val ) ) { - case REWRITE_REGEXEC_OK: - if ( mop_ndn.bv_val == NULL ) { - mop_ndn = *op_ndn; - } -#ifdef NEW_LOGGING - LDAP_LOG( BACK_LDAP, DETAIL1, - "[rw] bindDn (op ndn in group): \"%s\" -> \"%s\"\n", - op_ndn->bv_val, mop_ndn.bv_val, 0 ); -#else /* !NEW_LOGGING */ - Debug( LDAP_DEBUG_ARGS, - "rw> bindDn (op ndn in group): \"%s\" -> \"%s\"\n%s", - op_ndn->bv_val, mop_ndn.bv_val, "" ); -#endif /* !NEW_LOGGING */ - break; - - case REWRITE_REGEXEC_UNWILLING: - - case REWRITE_REGEXEC_ERR: - goto cleanup; - } - - /* - * Rewrite the gr ndn if needed - */ - switch ( rewrite_session( li->rwinfo, "searchBase", - gr_ndn->bv_val, conn, &mgr_ndn.bv_val ) ) { - case REWRITE_REGEXEC_OK: - if ( mgr_ndn.bv_val == NULL ) { - mgr_ndn = *gr_ndn; - } -#ifdef NEW_LOGGING - LDAP_LOG( BACK_LDAP, DETAIL1, - "[rw] searchBase (gr ndn in group): \"%s\" -> \"%s\"\n%s", - gr_ndn->bv_val, mgr_ndn.bv_val, "" ); -#else /* !NEW_LOGGING */ - Debug( LDAP_DEBUG_ARGS, - "rw> searchBase (gr ndn in group):" - " \"%s\" -> \"%s\"\n%s", - gr_ndn->bv_val, mgr_ndn.bv_val, "" ); -#endif /* !NEW_LOGGING */ - break; - - case REWRITE_REGEXEC_UNWILLING: - - case REWRITE_REGEXEC_ERR: - goto cleanup; - } -#else /* !ENABLE_REWRITE */ - ldap_back_dn_massage( li, op_ndn, &mop_ndn, 1, 1 ); - if ( mop_ndn.bv_val == NULL ) { - goto cleanup; - } - ldap_back_dn_massage( li, gr_ndn, &mgr_ndn, 1, 1 ); - if ( mgr_ndn.bv_val == NULL ) { - goto cleanup; - } -#endif /* !ENABLE_REWRITE */ - - ldap_back_map(&li->oc_map, &group_oc_name, &group_oc_name, - BACKLDAP_MAP); - if (group_oc_name.bv_val == NULL || group_oc_name.bv_val[0] == '\0') - goto cleanup; - ldap_back_map(&li->at_map, &group_at_name, &group_at_name, - BACKLDAP_MAP); - if (group_at_name.bv_val == NULL || group_at_name.bv_val[0] == '\0') - goto cleanup; - - filter = ch_malloc(sizeof("(&(objectclass=)(=))") - + group_oc_name.bv_len - + group_at_name.bv_len - + mop_ndn.bv_len + 1); - if (filter == NULL) - goto cleanup; - - /* Tell getconn this is a privileged op */ - oc = op->o_do_not_cache; - op->o_do_not_cache = 1; - lc = ldap_back_getconn(li, conn, op); - if ( !lc || !ldap_back_dobind( li, lc, NULL, op ) ) { - op->o_do_not_cache = oc; - goto cleanup; - } - op->o_do_not_cache = oc; - - ptr = lutil_strcopy(filter, "(&(objectclass="); - ptr = lutil_strcopy(ptr, group_oc_name.bv_val); - ptr = lutil_strcopy(ptr, ")("); - ptr = lutil_strcopy(ptr, group_at_name.bv_val); - ptr = lutil_strcopy(ptr, "="); - ptr = lutil_strcopy(ptr, mop_ndn.bv_val); - strcpy(ptr, "))"); - - gattr[0] = "objectclass"; - gattr[1] = NULL; - if (ldap_search_ext_s(lc->ld, mgr_ndn.bv_val, LDAP_SCOPE_BASE, filter, - gattr, 0, NULL, NULL, LDAP_NO_LIMIT, - LDAP_NO_LIMIT, &result) == LDAP_SUCCESS) { - if (ldap_first_entry(lc->ld, result) != NULL) - rc = 0; - ldap_msgfree(result); - } - -cleanup:; - ch_free(filter); - if ( mop_ndn.bv_val != op_ndn->bv_val ) { - free( mop_ndn.bv_val ); - } - if ( mgr_ndn.bv_val != gr_ndn->bv_val ) { - free( mgr_ndn.bv_val ); - } - return(rc); -} diff --git a/servers/slapd/back-ldbm/Makefile.in b/servers/slapd/back-ldbm/Makefile.in index 9a078dec78..9d6d9e5a09 100644 --- a/servers/slapd/back-ldbm/Makefile.in +++ b/servers/slapd/back-ldbm/Makefile.in @@ -2,16 +2,16 @@ SRCS = idl.c add.c search.c cache.c dbcache.c dn2id.c entry.c \ id2entry.c index.c id2children.c nextid.c \ - compare.c group.c modify.c modrdn.c delete.c init.c \ + compare.c modify.c modrdn.c delete.c init.c \ config.c bind.c attr.c filterindex.c close.c \ alias.c tools.c key.c extended.c passwd.c sasl.c \ - referral.c attribute.c operational.c + referral.c operational.c OBJS = idl.lo add.lo search.lo cache.lo dbcache.lo dn2id.lo entry.lo \ id2entry.lo index.lo id2children.lo nextid.lo \ - compare.lo group.lo modify.lo modrdn.lo delete.lo init.lo \ + compare.lo modify.lo modrdn.lo delete.lo init.lo \ config.lo bind.lo attr.lo filterindex.lo close.lo \ alias.lo tools.lo key.lo extended.lo passwd.lo sasl.lo \ - referral.lo attribute.lo operational.lo $(@BUILD_LDBM@_OBJS) + referral.lo operational.lo $(@BUILD_LDBM@_OBJS) LDAP_INCDIR= ../../../include LDAP_LIBDIR= ../../../libraries diff --git a/servers/slapd/back-ldbm/attribute.c b/servers/slapd/back-ldbm/attribute.c deleted file mode 100644 index 3246f47a53..0000000000 --- a/servers/slapd/back-ldbm/attribute.c +++ /dev/null @@ -1,201 +0,0 @@ -/* attribute.c - ldbm backend acl attribute routine */ -/* $OpenLDAP$ */ -/* - * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved. - * COPYING RESTRICTIONS APPLY, see COPYRIGHT file - */ - -#include "portable.h" - -#include - -#include -#include - -#include "slap.h" -#include "back-ldbm.h" -#include "proto-back-ldbm.h" - -/* return LDAP_SUCCESS IFF we can retrieve the attributes - * of entry with e_ndn - */ -int -ldbm_back_attribute( - Backend *be, - Connection *conn, - Operation *op, - Entry *target, - struct berval *entry_ndn, - AttributeDescription *entry_at, - BerVarray *vals ) -{ - struct ldbminfo *li = (struct ldbminfo *) be->be_private; - Entry *e; - int rc; - Attribute *attr; - BerVarray v; - const char *entry_at_name = entry_at->ad_cname.bv_val; - struct berval *iv, *jv; - AccessControlState acl_state = ACL_STATE_INIT; - int nvals = 0; - -#ifdef NEW_LOGGING - LDAP_LOG( BACK_LDBM, ARGS, - "ldbm_back_attribute: gr dn: \"%s\"\n", entry_ndn->bv_val, 0, 0 ); - LDAP_LOG( BACK_LDBM, ARGS, - "ldbm_back_attribute: at: \"%s\"\n", entry_at_name, 0, 0); - LDAP_LOG( BACK_LDBM, ARGS, "ldbm_back_attribute: tr dn: \"%s\"\n", - target ? target->e_ndn : "", 0, 0 ); -#else - Debug( LDAP_DEBUG_ARGS, - "=> ldbm_back_attribute: gr dn: \"%s\"\n", - entry_ndn->bv_val, 0, 0 ); - Debug( LDAP_DEBUG_ARGS, - "=> ldbm_back_attribute: at: \"%s\"\n", - entry_at_name, 0, 0 ); - - Debug( LDAP_DEBUG_ARGS, - "=> ldbm_back_attribute: tr dn: \"%s\"\n", - target ? target->e_ndn : "", 0, 0 ); -#endif - - if (target != NULL && dn_match( &target->e_nname, entry_ndn) ) { - /* we already have a LOCKED copy of the entry */ - e = target; -#ifdef NEW_LOGGING - LDAP_LOG( BACK_LDBM, DETAIL1, - "ldbm_back_attribute: target is LOCKED (%s)\n", - entry_ndn->bv_val, 0, 0); -#else - Debug( LDAP_DEBUG_ARGS, - "=> ldbm_back_attribute: target is entry: \"%s\"\n", - entry_ndn->bv_val, 0, 0 ); -#endif - - - } else { - /* can we find entry with reader lock */ - if ((e = dn2entry_r(be, entry_ndn, NULL )) == NULL) { -#ifdef NEW_LOGGING - LDAP_LOG( BACK_LDBM, INFO, - "ldbm_back_attribute: cannot find entry (%s)\n", - entry_ndn->bv_val, 0, 0 ); -#else - Debug( LDAP_DEBUG_ACL, - "=> ldbm_back_attribute: cannot find entry: \"%s\"\n", - entry_ndn->bv_val, 0, 0 ); -#endif - - return LDAP_NO_SUCH_OBJECT; - } - -#ifdef NEW_LOGGING - LDAP_LOG( BACK_LDBM, DETAIL1, - "ldbm_back_attribute: found entry (%s)\n", entry_ndn->bv_val, 0, 0); -#else - Debug( LDAP_DEBUG_ACL, - "=> ldbm_back_attribute: found entry: \"%s\"\n", - entry_ndn->bv_val, 0, 0 ); -#endif - - } - - /* find attribute values */ - - if( is_entry_alias( e ) ) { -#ifdef NEW_LOGGING - LDAP_LOG( BACK_LDBM, INFO, - "ldbm_back_attribute: entry (%s) is an alias\n", e->e_dn, 0, 0 ); -#else - Debug( LDAP_DEBUG_ACL, - "<= ldbm_back_attribute: entry is an alias\n", 0, 0, 0 ); -#endif - - rc = LDAP_ALIAS_PROBLEM; - goto return_results; - } - - if( is_entry_referral( e ) ) { -#ifdef NEW_LOGGING - LDAP_LOG( BACK_LDBM, INFO, - "ldbm_back_attribute: entry (%s) is a referral.\n", e->e_dn, 0, 0 ); -#else - Debug( LDAP_DEBUG_ACL, - "<= ldbm_back_attribute: entry is an referral\n", 0, 0, 0 ); -#endif - - rc = LDAP_REFERRAL; - goto return_results; - } - - if ((attr = attr_find(e->e_attrs, entry_at)) == NULL) { -#ifdef NEW_LOGGING - LDAP_LOG( BACK_LDBM, INFO, - "ldbm_back_attribute: failed to find %s.\n", entry_at_name, 0, 0 ); -#else - Debug( LDAP_DEBUG_ACL, - "<= ldbm_back_attribute: failed to find %s\n", - entry_at_name, 0, 0 ); -#endif - - rc = LDAP_NO_SUCH_ATTRIBUTE; - goto return_results; - } - - if (conn != NULL && op != NULL - && access_allowed( be, conn, op, e, entry_at, NULL, - ACL_AUTH, &acl_state ) == 0) - { - rc = LDAP_INSUFFICIENT_ACCESS; - goto return_results; - } - - for ( iv = attr->a_vals; iv->bv_val != NULL; iv++ ) { - /* count them */ - } - - v = (BerVarray) ch_malloc( sizeof(struct berval) * ((iv - attr->a_vals)+1) ); - - for ( iv=attr->a_vals, jv=v; iv->bv_val; iv++ ) { - if( conn != NULL - && op != NULL - && access_allowed( be, conn, op, e, entry_at, - iv, ACL_AUTH, &acl_state ) == 0) - { - continue; - } - ber_dupbv( jv, iv ); - - if( jv->bv_val != NULL ) jv++; - } - - nvals = jv - v; - - if( jv == v ) { - ch_free( v ); - *vals = NULL; - rc = LDAP_INSUFFICIENT_ACCESS; - } else { - jv->bv_val = NULL; - *vals = v; - rc = LDAP_SUCCESS; - } - -return_results: - if( target != e ) { - /* free entry and reader lock */ - cache_return_entry_r( &li->li_cache, e ); - } - -#ifdef NEW_LOGGING - LDAP_LOG( BACK_LDBM, ENTRY, - "ldbm_back_attribute: rc=%d nvals=%d.\n", rc, nvals, 0 ); -#else - Debug( LDAP_DEBUG_TRACE, - "ldbm_back_attribute: rc=%d nvals=%d\n", - rc, nvals, 0 ); -#endif - - return(rc); -} - diff --git a/servers/slapd/back-ldbm/group.c b/servers/slapd/back-ldbm/group.c deleted file mode 100644 index cfd28f73d0..0000000000 --- a/servers/slapd/back-ldbm/group.c +++ /dev/null @@ -1,231 +0,0 @@ -/* group.c - ldbm backend acl group routine */ -/* $OpenLDAP$ */ -/* - * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved. - * COPYING RESTRICTIONS APPLY, see COPYRIGHT file - */ - -#include "portable.h" - -#include - -#include -#include - -#include "slap.h" -#include "back-ldbm.h" -#include "proto-back-ldbm.h" - - -/* return 0 IFF op_dn is a value in member attribute - * of entry with gr_dn AND that entry has an objectClass - * value of groupOfNames - */ -int -ldbm_back_group( - Backend *be, - Connection *conn, - Operation *op, - Entry *target, - struct berval *gr_ndn, - struct berval *op_ndn, - ObjectClass *group_oc, - AttributeDescription *group_at -) -{ - struct ldbminfo *li = (struct ldbminfo *) be->be_private; - Entry *e; - int rc = 1; - Attribute *attr; - - const char *group_oc_name = NULL; - const char *group_at_name = group_at->ad_cname.bv_val; - - 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; - } - -#ifdef NEW_LOGGING - LDAP_LOG( BACK_LDBM, ENTRY, - "ldbm_back_group: check (%s) member of (%s), oc %s\n", - op_ndn->bv_val, gr_ndn->bv_val, group_oc_name ); -#else - Debug( LDAP_DEBUG_ARGS, - "=> ldbm_back_group: gr dn: \"%s\"\n", - gr_ndn->bv_val, 0, 0 ); - - Debug( LDAP_DEBUG_ARGS, - "=> ldbm_back_group: op dn: \"%s\"\n", - op_ndn->bv_val, 0, 0 ); - Debug( LDAP_DEBUG_ARGS, - "=> ldbm_back_group: oc: \"%s\" at: \"%s\"\n", - group_oc_name, group_at_name, 0 ); - - Debug( LDAP_DEBUG_ARGS, - "=> ldbm_back_group: tr dn: \"%s\"\n", - target->e_ndn, 0, 0 ); -#endif - - if (dn_match(&target->e_nname, gr_ndn)) { - /* we already have a LOCKED copy of the entry */ - e = target; -#ifdef NEW_LOGGING - LDAP_LOG( BACK_LDBM, DETAIL1, - "ldbm_back_group: target is group (%s)\n", gr_ndn->bv_val, 0, 0 ); -#else - Debug( LDAP_DEBUG_ARGS, - "=> ldbm_back_group: target is group: \"%s\"\n", - gr_ndn->bv_val, 0, 0 ); -#endif - - - } else { - /* can we find group entry with reader lock */ - if ((e = dn2entry_r(be, gr_ndn, NULL )) == NULL) { -#ifdef NEW_LOGGING - LDAP_LOG( BACK_LDBM, DETAIL1, - "ldbm_back_group: cannot find group (%s)\n", - gr_ndn->bv_val, 0, 0 ); -#else - Debug( LDAP_DEBUG_ACL, - "=> ldbm_back_group: cannot find group: \"%s\"\n", - gr_ndn->bv_val, 0, 0 ); -#endif - - return( 1 ); - } - -#ifdef NEW_LOGGING - LDAP_LOG( BACK_LDBM, DETAIL1, - "ldbm_back_group: found group (%s)\n", gr_ndn->bv_val, 0, 0 ); -#else - Debug( LDAP_DEBUG_ACL, - "=> ldbm_back_group: found group: \"%s\"\n", - gr_ndn->bv_val, 0, 0 ); -#endif - - } - - /* 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 * - */ - - rc = 1; - - - if( is_entry_alias( e ) ) { -#ifdef NEW_LOGGING - LDAP_LOG( BACK_LDBM, INFO, - "ldbm_back_group: group (%s) is an alias\n", gr_ndn->bv_val, 0, 0 ); -#else - Debug( LDAP_DEBUG_ACL, - "<= ldbm_back_group: group is an alias\n", 0, 0, 0 ); -#endif - - goto return_results; - } - - if( is_entry_referral( e ) ) { -#ifdef NEW_LOGGING - LDAP_LOG( BACK_LDBM, INFO, - "ldbm_back_group: group (%s) is a referral.\n", gr_ndn->bv_val,0,0); -#else - Debug( LDAP_DEBUG_ACL, - "<= ldbm_back_group: group is an referral\n", 0, 0, 0 ); -#endif - - goto return_results; - } - - if( !is_entry_objectclass( e, group_oc, 0 ) ) { -#ifdef NEW_LOGGING - LDAP_LOG( BACK_LDBM, ERR, - "ldbm_back_group: failed to find %s in objectClass.\n", - group_oc_name, 0, 0 ); -#else - Debug( LDAP_DEBUG_ACL, - "<= ldbm_back_group: failed to find %s in objectClass\n", - group_oc_name, 0, 0 ); -#endif - - goto return_results; - } - - if ((attr = attr_find(e->e_attrs, group_at)) == NULL) { -#ifdef NEW_LOGGING - LDAP_LOG( BACK_LDBM, INFO, - "ldbm_back_group: failed to find %s\n", group_at_name, 0, 0 ); -#else - Debug( LDAP_DEBUG_ACL, - "<= ldbm_back_group: failed to find %s\n", - group_at_name, 0, 0 ); -#endif - - goto return_results; - } - -#ifdef NEW_LOGGING - LDAP_LOG( BACK_LDBM, ENTRY, - "ldbm_back_group: found objectClass %s and %s\n", - group_oc_name, group_at_name, 0 ); -#else - Debug( LDAP_DEBUG_ACL, - "<= ldbm_back_group: found objectClass %s and %s\n", - group_oc_name, group_at_name, 0 ); -#endif - - -#ifdef SLAP_NVALUES - if( value_find_ex( group_at, - SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH - | SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH, - attr->a_nvals, op_ndn ) != LDAP_SUCCESS ) -#else - if( value_find_ex( group_at, 0, attr->a_vals, op_ndn ) != LDAP_SUCCESS ) -#endif - { -#ifdef NEW_LOGGING - LDAP_LOG( BACK_LDBM, DETAIL1, - "ldbm_back_group: \"%s\" not in \"%s\": %s\n", - op_ndn->bv_val, gr_ndn->bv_val, group_at_name ); -#else - Debug( LDAP_DEBUG_ACL, - "<= ldbm_back_group: \"%s\" not in \"%s\": %s\n", - op_ndn->bv_val, gr_ndn->bv_val, group_at_name ); -#endif - - goto return_results; - } - - -#ifdef NEW_LOGGING - LDAP_LOG( BACK_LDBM, DETAIL1, - "ldbm_back_group: %s is in %s: %s\n", - op_ndn->bv_val, gr_ndn->bv_val, group_at_name ); -#else - Debug( LDAP_DEBUG_ACL, - "<= ldbm_back_group: \"%s\" is in \"%s\": %s\n", - op_ndn->bv_val, gr_ndn->bv_val, group_at_name ); -#endif - - - rc = 0; - -return_results: - if( target != e ) { - /* free entry and reader lock */ - cache_return_entry_r( &li->li_cache, e ); - } - -#ifdef NEW_LOGGING - LDAP_LOG( BACK_LDBM, ENTRY, "ldbm_back_group: rc=%d\n", rc, 0, 0 ); -#else - Debug( LDAP_DEBUG_TRACE, "ldbm_back_group: rc=%d\n", rc, 0, 0 ); -#endif - - return(rc); -} - -- 2.39.5