From: Kurt Zeilenga Date: Sat, 24 Jul 1999 03:39:23 +0000 (+0000) Subject: Add support for LDAP_ALL_OPERATIONAL_ATTRIBUTES ("+") (based on X-Git-Tag: OPENLDAP_REL_ENG_2_BP~37 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a39cf6f93d38118375cabdf801391a5b08d81e13;p=openldap Add support for LDAP_ALL_OPERATIONAL_ATTRIBUTES ("+") (based on LDAPext discussions). Add attrs and attrsonly support to monitor/config info. Add rdn attributes to schema/monitor/config. Add extensibleObject objectclass to schema/monitor/config. Add top objectclass to rootdse/monitor/config. Remove opattrs option from send_search_entry(). --- diff --git a/include/ldap.h b/include/ldap.h index 6fbe9b1bed..70ab7318fe 100644 --- a/include/ldap.h +++ b/include/ldap.h @@ -72,6 +72,7 @@ LDAP_BEGIN_DECL #define LDAP_ROOT_DSE "" #define LDAP_NO_ATTRS "1.1" #define LDAP_ALL_USER_ATTRIBUTES "*" +#define LDAP_ALL_OPERATIONAL_ATTRIBUTES "+" /* * LDAP_OPTions defined by draft-ldapext-ldap-c-api-02 diff --git a/servers/slapd/back-bdb2/search.c b/servers/slapd/back-bdb2/search.c index 63d709475c..6fa45c895a 100644 --- a/servers/slapd/back-bdb2/search.c +++ b/servers/slapd/back-bdb2/search.c @@ -277,7 +277,7 @@ bdb2i_back_search_internal( if (e) { switch ( send_search_entry( be, conn, op, e, - attrs, attrsonly, 0, NULL ) ) { + attrs, attrsonly, NULL ) ) { case 0: /* entry sent ok */ nentries++; break; diff --git a/servers/slapd/back-ldap/search.c b/servers/slapd/back-ldap/search.c index f6054fa66e..3541c99046 100644 --- a/servers/slapd/back-ldap/search.c +++ b/servers/slapd/back-ldap/search.c @@ -160,7 +160,7 @@ ldap_send_entry( if (!attr->a_vals) attr->a_vals = &dummy; } - send_search_entry( be, lc->conn, op, &ent, attrs, attrsonly, 0, NULL ); + send_search_entry( be, lc->conn, op, &ent, attrs, attrsonly, NULL ); for (;ent.e_attrs;) { attr=ent.e_attrs; ent.e_attrs = attr->a_next; diff --git a/servers/slapd/back-ldbm/search.c b/servers/slapd/back-ldbm/search.c index dbbf761487..11171e4039 100644 --- a/servers/slapd/back-ldbm/search.c +++ b/servers/slapd/back-ldbm/search.c @@ -277,7 +277,7 @@ ldbm_back_search( if (e) { switch ( send_search_entry( be, conn, op, e, - attrs, attrsonly, 0, NULL ) ) { + attrs, attrsonly, NULL ) ) { case 0: /* entry sent ok */ nentries++; break; diff --git a/servers/slapd/back-passwd/search.c b/servers/slapd/back-passwd/search.c index 08c20b8900..c966890757 100644 --- a/servers/slapd/back-passwd/search.c +++ b/servers/slapd/back-passwd/search.c @@ -107,7 +107,7 @@ passwd_back_search( if ( test_filter( be, conn, op, e, filter ) == 0 ) { send_search_entry( be, conn, op, - e, attrs, attrsonly, 0, NULL ); + e, attrs, attrsonly, NULL ); sent++; } } @@ -145,7 +145,7 @@ passwd_back_search( } send_search_entry( be, conn, op, - e, attrs, attrsonly, 0, NULL ); + e, attrs, attrsonly, NULL ); sent++; } @@ -196,7 +196,7 @@ passwd_back_search( if ( test_filter( be, conn, op, e, filter ) == 0 ) { send_search_entry( be, conn, op, - e, attrs, attrsonly, 0, NULL ); + e, attrs, attrsonly, NULL ); sent++; } diff --git a/servers/slapd/back-perl/search.c b/servers/slapd/back-perl/search.c index 16648d658c..f3dfe1565b 100644 --- a/servers/slapd/back-perl/search.c +++ b/servers/slapd/back-perl/search.c @@ -87,7 +87,7 @@ perl_back_search( } else { send_search_entry( be, conn, op, - e, attrs, attrsonly, 0, NULL ); + e, attrs, attrsonly, NULL ); entry_free( e ); } diff --git a/servers/slapd/configinfo.c b/servers/slapd/configinfo.c index 5d45069fa9..565a606647 100644 --- a/servers/slapd/configinfo.c +++ b/servers/slapd/configinfo.c @@ -27,7 +27,11 @@ */ void -config_info( Connection *conn, Operation *op ) +config_info( + Connection *conn, + Operation *op, + char **attrs, + int attrsonly ) { Entry *e; char buf[BUFSIZ]; @@ -46,6 +50,20 @@ config_info( Connection *conn, Operation *op ) (void) dn_normalize_case( e->e_ndn ); e->e_private = NULL; + { + char *rdn = ch_strdup( SLAPD_CONFIG_DN ); + val.bv_val = strchr( rdn, '=' ); + + if( val.bv_val != NULL ) { + *val.bv_val = '\0'; + val.bv_len = strlen( ++val.bv_val ); + + attr_merge( e, rdn, vals ); + } + + free( rdn ); + } + for ( i = 0; i < nbackends; i++ ) { strcpy( buf, backends[i].be_type ); for ( j = 0; backends[i].be_suffix[j] != NULL; j++ ) { @@ -57,8 +75,16 @@ config_info( Connection *conn, Operation *op ) attr_merge( e, "database", vals ); } + val.bv_val = "top"; + val.bv_len = sizeof("top")-1; + attr_merge( e, "objectClass", vals ); + + val.bv_val = "extenisbleObject"; + val.bv_len = sizeof("extenisbleObject")-1; + attr_merge( e, "objectClass", vals ); + send_search_entry( &backends[0], conn, op, e, - NULL, 0, 1, NULL ); + attrs, attrsonly, NULL ); send_search_result( conn, op, LDAP_SUCCESS, NULL, NULL, NULL, NULL, 1 ); diff --git a/servers/slapd/monitor.c b/servers/slapd/monitor.c index 891cbab2b1..659be6e99b 100644 --- a/servers/slapd/monitor.c +++ b/servers/slapd/monitor.c @@ -24,7 +24,11 @@ #if defined( SLAPD_MONITOR_DN ) void -monitor_info( Connection *conn, Operation *op ) +monitor_info( + Connection *conn, + Operation *op, + char ** attrs, + int attrsonly ) { Entry *e; char buf[BUFSIZ]; @@ -50,6 +54,20 @@ monitor_info( Connection *conn, Operation *op ) (void) dn_normalize_case( e->e_ndn ); e->e_private = NULL; + { + char *rdn = ch_strdup( SLAPD_MONITOR_DN ); + val.bv_val = strchr( rdn, '=' ); + + if( val.bv_val != NULL ) { + *val.bv_val = '\0'; + val.bv_len = strlen( ++val.bv_val ); + + attr_merge( e, rdn, vals ); + } + + free( rdn ); + } + val.bv_val = (char *) Versionstr; if (( p = strchr( Versionstr, '\n' )) == NULL ) { val.bv_len = strlen( Versionstr ); @@ -246,8 +264,16 @@ monitor_info( Connection *conn, Operation *op ) attr_merge( e, "concurrency", vals ); #endif + val.bv_val = "top"; + val.bv_len = sizeof("top")-1; + attr_merge( e, "objectClass", vals ); + + val.bv_val = "extensibleObject"; + val.bv_len = sizeof("extensibleObject")-1; + attr_merge( e, "objectClass", vals ); + send_search_entry( &backends[0], conn, op, e, - NULL, 0, 1, NULL ); + attrs, attrsonly, NULL ); send_search_result( conn, op, LDAP_SUCCESS, NULL, NULL, NULL, NULL, 1 ); diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 78d0c8594d..adf380e809 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -241,7 +241,11 @@ extern char *supportedExtensions[]; extern char *supportedControls[]; extern char *supportedSASLMechanisms[]; -void monitor_info LDAP_P(( Connection *conn, Operation *op )); +void monitor_info LDAP_P(( + Connection *conn, + Operation *op, + char ** attrs, + int attrsonly )); /* * operation.c @@ -304,7 +308,7 @@ int send_search_reference LDAP_P(( int send_search_entry LDAP_P(( Backend *be, Connection *conn, Operation *op, - Entry *e, char **attrs, int attrsonly, int opattrs, + Entry *e, char **attrs, int attrsonly, LDAPControl **ctrls )); int str2result LDAP_P(( char *s, @@ -436,8 +440,17 @@ extern void slapd_remove LDAP_P((ber_socket_t s, int wake)); extern void slap_set_shutdown LDAP_P((int sig)); extern void slap_do_nothing LDAP_P((int sig)); -extern void config_info LDAP_P((Connection *conn, Operation *op)); -extern void root_dse_info LDAP_P((Connection *conn, Operation *op, char **attrs, int attrsonly)); +extern void config_info LDAP_P(( + Connection *conn, + Operation *op, + char ** attrs, + int attrsonly )); + +extern void root_dse_info LDAP_P(( + Connection *conn, + Operation *op, + char ** attrs, + int attrsonly )); extern int do_abandon LDAP_P((Connection *conn, Operation *op)); extern int do_add LDAP_P((Connection *conn, Operation *op)); diff --git a/servers/slapd/result.c b/servers/slapd/result.c index 4f2848e8de..061c6899c9 100644 --- a/servers/slapd/result.c +++ b/servers/slapd/result.c @@ -491,7 +491,6 @@ send_search_entry( Entry *e, char **attrs, int attrsonly, - int opattrs, LDAPControl **ctrls ) { @@ -500,7 +499,8 @@ send_search_entry( int i, rc=-1, bytes; AccessControl *acl; char *edn; - int allattrs; + int userattrs; + int opattrs; Debug( LDAP_DEBUG_TRACE, "=> send_search_entry: \"%s\"\n", e->e_dn, 0, 0 ); @@ -534,10 +534,14 @@ send_search_entry( goto error_return; } - /* check for special all user attributes ("*") attribute */ - allattrs = ( attrs == NULL ) ? 1 + /* check for special all user attributes ("*") type */ + userattrs = ( attrs == NULL ) ? 1 : charray_inlist( attrs, LDAP_ALL_USER_ATTRIBUTES ); + /* check for special all operational attributes ("+") type */ + opattrs = ( attrs == NULL ) ? 0 + : charray_inlist( attrs, LDAP_ALL_OPERATIONAL_ATTRIBUTES ); + for ( a = e->e_attrs; a != NULL; a = a->a_next ) { regmatch_t matches[MAXREMATCHES]; @@ -549,18 +553,16 @@ send_search_entry( } else { /* specific addrs requested */ - if ( allattrs ) { - /* user requested all user attributes */ - /* if operational, make sure it's in list */ - - if( oc_check_operational_attr( a->a_type ) - && !charray_inlist( attrs, a->a_type ) ) + if ( oc_check_operational_attr( a->a_type ) ) { + if( !opattrs && !charray_inlist( attrs, a->a_type ) ) + { + continue; + } + } else { + if (!userattrs && !charray_inlist( attrs, a->a_type ) ) { continue; } - - } else if ( !charray_inlist( attrs, a->a_type ) ) { - continue; } } @@ -611,6 +613,8 @@ send_search_entry( } #ifdef SLAPD_SCHEMA_DN + /* eventually will loop through generated operational attributes */ + /* only have subschemaSubentry implemented */ a = backend_subschemasubentry( be ); do { @@ -624,18 +628,16 @@ send_search_entry( } else { /* specific addrs requested */ - if ( allattrs ) { - /* user requested all user attributes */ - /* if operational, make sure it's in list */ - - if( oc_check_operational_attr( a->a_type ) - && !charray_inlist( attrs, a->a_type ) ) + if ( oc_check_operational_attr( a->a_type ) ) { + if( !opattrs && !charray_inlist( attrs, a->a_type ) ) + { + continue; + } + } else { + if (!userattrs && !charray_inlist( attrs, a->a_type ) ) { continue; } - - } else if ( !charray_inlist( attrs, a->a_type ) ) { - continue; } } @@ -738,7 +740,7 @@ send_search_reference( int rc; int bytes; - Debug( LDAP_DEBUG_TRACE, "=> send_search_entry (%s)\n", e->e_dn, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "=> send_search_reference (%s)\n", e->e_dn, 0, 0 ); if ( ! access_allowed( be, conn, op, e, "entry", NULL, ACL_READ ) ) @@ -806,7 +808,7 @@ send_search_reference( Statslog( LDAP_DEBUG_STATS2, "conn=%ld op=%ld ENTRY dn=\"%s\"\n", (long) conn->c_connid, (long) op->o_opid, e->e_dn, 0, 0 ); - Debug( LDAP_DEBUG_TRACE, "<= send_search_entry\n", 0, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "<= send_search_reference\n", 0, 0, 0 ); return 0; } diff --git a/servers/slapd/root_dse.c b/servers/slapd/root_dse.c index 9da603c89c..361f7bc4e3 100644 --- a/servers/slapd/root_dse.c +++ b/servers/slapd/root_dse.c @@ -98,8 +98,16 @@ root_dse_info( Connection *conn, Operation *op, char **attrs, int attrsonly ) attr_merge( e, "ref", default_referral ); } + val.bv_val = "top"; + val.bv_len = sizeof("top")-1; + attr_merge( e, "objectClass", vals ); + + val.bv_val = "extenisbleObject"; + val.bv_len = sizeof("extenisbleObject")-1; + attr_merge( e, "objectClass", vals ); + send_search_entry( &backends[0], conn, op, - e, attrs, attrsonly, 0, NULL ); + e, attrs, attrsonly, NULL ); send_search_result( conn, op, LDAP_SUCCESS, NULL, NULL, NULL, NULL, 1 ); diff --git a/servers/slapd/schema.c b/servers/slapd/schema.c index 8c5b5f7493..c7bafd9b8a 100644 --- a/servers/slapd/schema.c +++ b/servers/slapd/schema.c @@ -1120,15 +1120,19 @@ schema_info( Connection *conn, Operation *op, char **attrs, int attrsonly ) (void) dn_normalize_case( e->e_ndn ); e->e_private = NULL; - val.bv_val = ch_strdup( "top" ); - val.bv_len = strlen( val.bv_val ); - attr_merge( e, "objectClass", vals ); - ldap_memfree( val.bv_val ); + { + char *rdn = ch_strdup( SLAPD_SCHEMA_DN ); + val.bv_val = strchr( rdn, '=' ); - val.bv_val = ch_strdup( "subschema" ); - val.bv_len = strlen( val.bv_val ); - attr_merge( e, "objectClass", vals ); - ldap_memfree( val.bv_val ); + if( val.bv_val != NULL ) { + *val.bv_val = '\0'; + val.bv_len = strlen( ++val.bv_val ); + + attr_merge( e, rdn, vals ); + } + + free( rdn ); + } if ( syn_schema_info( e ) ) { /* Out of memory, do something about it */ @@ -1151,8 +1155,20 @@ schema_info( Connection *conn, Operation *op, char **attrs, int attrsonly ) return; } + val.bv_val = "top"; + val.bv_len = sizeof("top")-1; + attr_merge( e, "objectClass", vals ); + + val.bv_val = "subschema"; + val.bv_len = sizeof("subschema")-1; + attr_merge( e, "objectClass", vals ); + + val.bv_val = "extensibleObject"; + val.bv_len = sizeof("extensibleObject")-1; + attr_merge( e, "objectClass", vals ); + send_search_entry( &backends[0], conn, op, - e, attrs, attrsonly, 0, NULL ); + e, attrs, attrsonly, NULL ); send_search_result( conn, op, LDAP_SUCCESS, NULL, NULL, NULL, NULL, 1 ); diff --git a/servers/slapd/search.c b/servers/slapd/search.c index ef38c6a591..cc74378ba9 100644 --- a/servers/slapd/search.c +++ b/servers/slapd/search.c @@ -163,14 +163,14 @@ do_search( if ( scope == LDAP_SCOPE_BASE ) { #if defined( SLAPD_MONITOR_DN ) if ( strcmp( base, SLAPD_MONITOR_DN ) == 0 ) { - monitor_info( conn, op ); + monitor_info( conn, op, attrs, attrsonly ); goto return_results; } #endif #if defined( SLAPD_CONFIG_DN ) if ( strcmp( base, SLAPD_CONFIG_DN ) == 0 ) { - config_info( conn, op ); + config_info( conn, op, attrs, attrsonly ); goto return_results; } #endif diff --git a/servers/slapd/tools/mimic.c b/servers/slapd/tools/mimic.c index ea598b18c6..fba6ef6767 100644 --- a/servers/slapd/tools/mimic.c +++ b/servers/slapd/tools/mimic.c @@ -71,7 +71,6 @@ send_search_entry( Entry *e, char **attrs, int attrsonly, - int opattrs, LDAPControl **ctrls ) {