]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/ad.c
ITS#7305 add slapi_[get|free]_client_ip()
[openldap] / servers / slapd / ad.c
index c881612799f6492f5782efa83204fb7df14e71ed..2a083cf0070b913535b47d0939b17b2bb2485892 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2009 The OpenLDAP Foundation.
+ * Copyright 1998-2012 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -74,9 +74,11 @@ static int option_count = 1;
 
 static int msad_range_hack = 0;
 
+static int ad_count;
+
 static Attr_option *ad_find_option_definition( const char *opt, int optlen );
 
-static int ad_keystring(
+int ad_keystring(
        struct berval *bv )
 {
        ber_len_t i;
@@ -382,6 +384,9 @@ done:;
                d2->ad_flags = desc.ad_flags;
                d2->ad_cname.bv_len = desc.ad_type->sat_cname.bv_len;
                d2->ad_tags.bv_len = desc.ad_tags.bv_len;
+               ldap_pvt_thread_mutex_lock( &ad_index_mutex );
+               d2->ad_index = ++ad_count;
+               ldap_pvt_thread_mutex_unlock( &ad_index_mutex );
 
                if (dlen == 0) {
                        d2->ad_cname.bv_val = d2->ad_type->sat_cname.bv_val;
@@ -594,29 +599,33 @@ int ad_inlist(
                 * else if requested description is !objectClass, return
                 * attributes which the class does not require/allow
                 */
-               oc = attrs->an_oc;
-               if( oc == NULL && attrs->an_name.bv_val ) {
-                       switch( attrs->an_name.bv_val[0] ) {
-                       case '@': /* @objectClass */
-                       case '+': /* +objectClass (deprecated) */
-                       case '!': { /* exclude */
-                                       struct berval ocname;
-                                       ocname.bv_len = attrs->an_name.bv_len - 1;
-                                       ocname.bv_val = &attrs->an_name.bv_val[1];
-                                       oc = oc_bvfind( &ocname );
-                                       attrs->an_oc_exclude = 0;
-                                       if ( oc && attrs->an_name.bv_val[0] == '!' ) {
-                                               attrs->an_oc_exclude = 1;
-                                       }
-                               } break;
+               if ( !( attrs->an_flags & SLAP_AN_OCINITED )) {
+                       if( attrs->an_name.bv_val ) {
+                               switch( attrs->an_name.bv_val[0] ) {
+                               case '@': /* @objectClass */
+                               case '+': /* +objectClass (deprecated) */
+                               case '!': { /* exclude */
+                                               struct berval ocname;
+                                               ocname.bv_len = attrs->an_name.bv_len - 1;
+                                               ocname.bv_val = &attrs->an_name.bv_val[1];
+                                               oc = oc_bvfind( &ocname );
+                                               if ( oc && attrs->an_name.bv_val[0] == '!' ) {
+                                                       attrs->an_flags |= SLAP_AN_OCEXCLUDE;
+                                               } else {
+                                                       attrs->an_flags &= ~SLAP_AN_OCEXCLUDE;
+                                               }
+                                       } break;
 
-                       default: /* old (deprecated) way */
-                               oc = oc_bvfind( &attrs->an_name );
+                               default: /* old (deprecated) way */
+                                       oc = oc_bvfind( &attrs->an_name );
+                               }
+                               attrs->an_oc = oc;
                        }
-                       attrs->an_oc = oc;
+                       attrs->an_flags |= SLAP_AN_OCINITED;
                }
+               oc = attrs->an_oc;
                if( oc != NULL ) {
-                       if ( attrs->an_oc_exclude ) {
+                       if ( attrs->an_flags & SLAP_AN_OCEXCLUDE ) {
                                if ( oc == slap_schema.si_oc_extensibleObject ) {
                                        /* extensibleObject allows the return of anything */
                                        return 0;
@@ -766,6 +775,7 @@ int slap_bv2undef_ad(
 
                /* shouldn't we protect this for concurrency? */
                desc->ad_type = at;
+               desc->ad_index = 0;
                ldap_pvt_thread_mutex_lock( &ad_undef_mutex );
                desc->ad_next = desc->ad_type->sat_ad;
                desc->ad_type->sat_ad = desc;
@@ -932,7 +942,7 @@ str2anlist( AttributeName *an, char *in, const char *brkstr )
 
                anew->an_desc = NULL;
                anew->an_oc = NULL;
-               anew->an_oc_exclude = 0;
+               anew->an_flags = 0;
                ber_str2bv(s, 0, 1, &anew->an_name);
                slap_bv2ad(&anew->an_name, &anew->an_desc, &text);
                if ( !anew->an_desc ) {
@@ -959,7 +969,7 @@ str2anlist( AttributeName *an, char *in, const char *brkstr )
                                        }
 
                                        if ( anew->an_name.bv_val[0] == '!' ) {
-                                               anew->an_oc_exclude = 1;
+                                               anew->an_flags |= SLAP_AN_OCEXCLUDE;
                                        }
                                } break;
 
@@ -971,6 +981,7 @@ str2anlist( AttributeName *an, char *in, const char *brkstr )
                                }
                        }
                }
+               anew->an_flags |= SLAP_AN_OCINITED;
                anew++;
        }