From: Pierangelo Masarati Date: Sat, 22 Dec 2001 11:50:16 +0000 (+0000) Subject: added backend-side support for on-the-fly operational attributes; added hasSubordinat... X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~581 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e36bde9180fef61727da449f283438145398df50;p=openldap added backend-side support for on-the-fly operational attributes; added hasSubordinates to schema and back-ldbm --- diff --git a/servers/slapd/back-ldbm/Makefile.in b/servers/slapd/back-ldbm/Makefile.in index 45c280d38f..14e1b8bec9 100644 --- a/servers/slapd/back-ldbm/Makefile.in +++ b/servers/slapd/back-ldbm/Makefile.in @@ -5,13 +5,13 @@ SRCS = idl.c add.c search.c cache.c dbcache.c dn2id.c entry.c \ compare.c group.c modify.c modrdn.c delete.c init.c \ config.c bind.c attr.c filterindex.c unbind.c close.c \ alias.c tools.c key.c extended.c passwd.c sasl.c \ - referral.c attribute.c + referral.c attribute.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 abandon.lo \ compare.lo group.lo modify.lo modrdn.lo delete.lo init.lo \ config.lo bind.lo attr.lo filterindex.lo unbind.lo close.lo \ alias.lo tools.lo key.lo extended.lo passwd.lo sasl.lo \ - referral.lo attribute.lo + referral.lo attribute.lo operational.lo LDAP_INCDIR= ../../../include LDAP_LIBDIR= ../../../libraries diff --git a/servers/slapd/back-ldbm/external.h b/servers/slapd/back-ldbm/external.h index 76a3771f05..243b1bc1ea 100644 --- a/servers/slapd/back-ldbm/external.h +++ b/servers/slapd/back-ldbm/external.h @@ -88,6 +88,12 @@ extern int ldbm_back_attribute LDAP_P(( BackendDB *bd, AttributeDescription* entry_at, struct berval ***vals)); +extern int ldbm_back_operational LDAP_P((BackendDB *bd, + Connection *conn, Operation *op, + Entry *e, + char **attrs, + int opattrs, + Attribute **a )); /* hooks for slap tools */ extern int ldbm_tool_entry_open LDAP_P(( BackendDB *be, int mode )); diff --git a/servers/slapd/back-ldbm/init.c b/servers/slapd/back-ldbm/init.c index bba57e967d..ff836b9cb9 100644 --- a/servers/slapd/back-ldbm/init.c +++ b/servers/slapd/back-ldbm/init.c @@ -69,6 +69,7 @@ ldbm_back_initialize( bi->bi_acl_group = ldbm_back_group; bi->bi_acl_attribute = ldbm_back_attribute; bi->bi_chk_referrals = ldbm_back_referrals; + bi->bi_operational = ldbm_back_operational; /* * hooks for slap tools diff --git a/servers/slapd/back-ldbm/operational.c b/servers/slapd/back-ldbm/operational.c new file mode 100644 index 0000000000..81fe0efb1e --- /dev/null +++ b/servers/slapd/back-ldbm/operational.c @@ -0,0 +1,54 @@ +/* operational.c - ldbm backend operational attributes function */ +/* + * Copyright 1998-2001 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" + +/* + * sets the supported operational attributes (if required) + */ + +int +ldbm_back_operational( + BackendDB *be, + Connection *conn, + Operation *op, + Entry *e, + char **attrs, + int opattrs, + Attribute **a ) +{ + Attribute **aa = a; + + assert( e ); + + if ( opattrs || ad_inlist( slap_schema.si_ad_hasSubordinates, attrs ) ) { + int hs; + + hs = has_children( be, e ); + + *aa = ch_malloc( sizeof( Attribute ) ); + (*aa)->a_desc = slap_schema.si_ad_hasSubordinates; + + (*aa)->a_vals = ch_malloc( 2 * sizeof( struct berval * ) ); + (*aa)->a_vals[0] = ber_bvstrdup( hs ? "TRUE" : "FALSE" ); + (*aa)->a_vals[1] = NULL; + + (*aa)->a_next = NULL; + aa = &(*aa)->a_next; + } + + return 0; +} + diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index 6054ff89e2..8b1469ef38 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -1087,9 +1087,11 @@ Attribute *backend_operational( Backend *be, Connection *conn, Operation *op, - Entry *e ) + Entry *e, + char **attrs, + int opattrs ) { - Attribute *a = NULL; + Attribute *a = NULL, **ap = &a; #ifdef SLAPD_SCHEMA_DN a = ch_malloc( sizeof( Attribute ) ); @@ -1101,7 +1103,19 @@ Attribute *backend_operational( a->a_vals[1] = NULL; a->a_next = NULL; + ap = &a->a_next; #endif + /* + * If operational attributes (allegedly) are required, + * and the backend supports specific operational attributes, + * add them to the attribute list + */ + if ( ( opattrs || attrs ) && be->be_operational != NULL ) { + ( void )be->be_operational( be, conn, op, e, + attrs, opattrs, ap ); + } + return a; } + diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 20762b2811..f25c69e769 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -210,7 +210,9 @@ LDAP_SLAPD_F (Attribute *) backend_operational( BackendDB *, Connection *conn, Operation *op, - Entry * ); + Entry *e, + char **attrs, + int opattrs ); /* diff --git a/servers/slapd/result.c b/servers/slapd/result.c index 48638cad56..e9b066a5e6 100644 --- a/servers/slapd/result.c +++ b/servers/slapd/result.c @@ -839,7 +839,7 @@ send_search_entry( /* eventually will loop through generated operational attributes */ /* only have subschemaSubentry implemented */ - aa = backend_operational( be, conn, op, e ); + aa = backend_operational( be, conn, op, e, attrs, opattrs ); for (a = aa ; a != NULL; a = a->a_next ) { AttributeDescription *desc = a->a_desc; diff --git a/servers/slapd/schema/core.schema b/servers/slapd/schema/core.schema index d0b0ceede1..3801c48b6a 100644 --- a/servers/slapd/schema/core.schema +++ b/servers/slapd/schema/core.schema @@ -51,6 +51,12 @@ attributetype ( 2.5.18.4 NAME 'modifiersName' SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation ) +attributetype ( 2.5.18.9 NAME 'hasSubordinates' + DESC 'X.501: entry has children' + EQUALITY booleanMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 + SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation ) + attributetype ( 2.5.18.10 NAME 'subschemaSubentry' DESC 'RFC2252: name of controlling subschema entry' EQUALITY distinguishedNameMatch diff --git a/servers/slapd/schema_prep.c b/servers/slapd/schema_prep.c index f713d5e18e..34412ba580 100644 --- a/servers/slapd/schema_prep.c +++ b/servers/slapd/schema_prep.c @@ -165,6 +165,8 @@ struct slap_schema_ad_map { offsetof(struct slap_internal_schema, si_ad_modifiersName) }, { "modifyTimestamp", NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_modifyTimestamp) }, + { "hasSubordinates", NULL, NULL, NULL, + offsetof(struct slap_internal_schema, si_ad_hasSubordinates) }, { "subschemaSubentry", NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_subschemaSubentry) }, diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 1987230afe..d883542bea 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -483,6 +483,7 @@ struct slap_internal_schema { AttributeDescription *si_ad_createTimestamp; AttributeDescription *si_ad_modifiersName; AttributeDescription *si_ad_modifyTimestamp; + AttributeDescription *si_ad_hasSubordinates; AttributeDescription *si_ad_subschemaSubentry; /* root DSE attribute descriptions */ @@ -918,6 +919,7 @@ struct slap_backend_db { #define be_chk_referrals bd_info->bi_chk_referrals #define be_group bd_info->bi_acl_group #define be_attribute bd_info->bi_acl_attribute +#define be_operational bd_info->bi_operational #define be_controls bd_info->bi_controls @@ -1139,6 +1141,10 @@ struct slap_backend_info { AttributeDescription *entry_at, struct berval ***vals )); + int (*bi_operational) LDAP_P((Backend *bd, + struct slap_conn *c, struct slap_op *o, + Entry *e, char **attrs, int opattrs, Attribute **a )); + int (*bi_connection_init) LDAP_P((BackendDB *bd, struct slap_conn *c)); int (*bi_connection_destroy) LDAP_P((BackendDB *bd,