]> git.sur5r.net Git - openldap/commitdiff
Added an_oc to AttributeName for caching ObjectClass lookups.
authorHoward Chu <hyc@openldap.org>
Thu, 10 Jan 2002 09:54:14 +0000 (09:54 +0000)
committerHoward Chu <hyc@openldap.org>
Thu, 10 Jan 2002 09:54:14 +0000 (09:54 +0000)
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
servers/slapd/ad.c
servers/slapd/search.c
servers/slapd/slap.h

index 23fe7c099e203432cd34de30f2f4aef8052ee14d..d93f34ce0c25a25343cb83b78fd671e91f9bd2f9 100644 (file)
@@ -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 <what> got \"%s\"\n",
index d865d5301d30897521aaadae499396c1904ec5f1..c674401b79366b8876fa979b7af8c9d73ef71361 100644 (file)
@@ -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;
index 6213d10d8b755ef9ee9d2f1fc0f8f888f3878833..68e5f521b9ca4999e550745582f6a15a6137104b 100644 (file)
@@ -166,6 +166,7 @@ do_search(
        }
        for ( i=0; i<siz; i++ ) {
                an[i].an_desc = NULL;
+               an[i].an_oc = NULL;
                slap_bv2ad(&an[i].an_name, &an[i].an_desc, &text);
        }
 
index 201dd82fe9c5fa38aa347a8c650abae54dd9a615..ba66ff390330a781c6b9bfb38bf24e88c78d1dff 100644 (file)
@@ -497,6 +497,7 @@ typedef struct slap_attr_desc {
 typedef struct slap_attr_name {
        struct berval an_name;
        AttributeDescription *an_desc;
+       ObjectClass *an_oc;
 } AttributeName;
 
 #define slap_ad_is_lang(ad)            ( (ad)->ad_lang.bv_len != 0 )