From 8067107ed208da22ff1aaa2993eb548819cac737 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Thu, 10 Jan 2002 09:54:14 +0000 Subject: [PATCH] Added an_oc to AttributeName for caching ObjectClass lookups. Added error checking to str2anlist; if the attr name doesn't match any attribute or objectclass the offending attr name is displayed. --- servers/slapd/aclparse.c | 6 ++++++ servers/slapd/ad.c | 16 +++++++++++++++- servers/slapd/search.c | 1 + servers/slapd/slap.h | 1 + 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/servers/slapd/aclparse.c b/servers/slapd/aclparse.c index 23fe7c099e..d93f34ce0c 100644 --- a/servers/slapd/aclparse.c +++ b/servers/slapd/aclparse.c @@ -204,6 +204,12 @@ parse_acl( } else if ( strncasecmp( left, "attr", 4 ) == 0 ) { a->acl_attrs = str2anlist( a->acl_attrs, right, "," ); + if ( a->acl_attrs == NULL ) { + fprintf( stderr, + "%s: line %d: unknown attr \"%s\" in to clause\n", + fname, lineno, right ); + acl_usage(); + } } else { fprintf( stderr, "%s: line %d: expecting got \"%s\"\n", diff --git a/servers/slapd/ad.c b/servers/slapd/ad.c index d865d5301d..c674401b79 100644 --- a/servers/slapd/ad.c +++ b/servers/slapd/ad.c @@ -301,7 +301,11 @@ int ad_inlist( * EXTENSION: see if requested description is an object class * if so, return attributes which the class requires/allows */ - oc = oc_bvfind( &attrs->an_name ); + oc = attrs->an_oc; + if( oc == NULL ) { + oc = oc_bvfind( &attrs->an_name ); + attrs->an_oc = oc; + } if( oc != NULL ) { if ( oc == slap_schema.si_oc_extensibleObject ) { /* extensibleObject allows the return of anything */ @@ -461,8 +465,18 @@ str2anlist( AttributeName *an, const char *in, const char *brkstr ) s = ldap_pvt_strtok( NULL, brkstr, &lasts ) ) { anew->an_desc = NULL; + anew->an_oc = NULL; ber_str2bv(s, 0, 1, &anew->an_name); slap_bv2ad(&anew->an_name, &anew->an_desc, &text); + if ( !anew->an_desc ) { + anew->an_oc = oc_bvfind( &anew->an_name ); + if ( !anew->an_oc ) { + free( an ); + /* overwrites input string on error! */ + strcpy( in, s ); + return NULL; + } + } anew++; } anew->an_name.bv_val = NULL; diff --git a/servers/slapd/search.c b/servers/slapd/search.c index 6213d10d8b..68e5f521b9 100644 --- a/servers/slapd/search.c +++ b/servers/slapd/search.c @@ -166,6 +166,7 @@ do_search( } for ( i=0; iad_lang.bv_len != 0 ) -- 2.39.5