]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/limits.c
add logs; fix bug in group/dn selection logic
[openldap] / servers / slapd / limits.c
index 7507094432ee526e76b775590bffdeabb15d24eb..55fce61705ba50b7e2edeff4a980a3c487eaa723 100644 (file)
 
 #include "slap.h"
 
+static char *
+limits2str( unsigned i )
+{
+       switch ( i ) {
+       case SLAP_LIMITS_UNDEFINED:
+               return "UNDEFINED";
+
+       case SLAP_LIMITS_EXACT:
+               return "EXACT";
+                       
+       case SLAP_LIMITS_ONE:
+               return "ONELEVEL";      
+
+       case SLAP_LIMITS_SUBTREE:
+               return "SUBTREE";
+
+       case SLAP_LIMITS_CHILDREN:
+               return "CHILDREN";
+
+       case SLAP_LIMITS_REGEX:
+               return "REGEX";
+
+       case SLAP_LIMITS_ANONYMOUS:
+               return "ANONYMOUS";
+               
+       case SLAP_LIMITS_USERS:
+               return "USERS";
+               
+       case SLAP_LIMITS_ANY:
+               return "ANY";
+
+       default:
+               return "UNKNOWN";
+       }
+}
+
 int
 limits_get( 
        Operation               *op,
@@ -35,6 +71,16 @@ limits_get(
        assert( op );
        assert( limit );
 
+#ifdef NEW_LOGGING
+       LDAP_LOG( SLAPD, DETAIL1, "==> limits_get: conn=%lu op=%lu dn=\"%s\"\n",
+                       op->o_connid, op->o_opid,
+                       BER_BVISNULL( ndn ) ? "[anonymous]" : ndn->bv_val );
+#else
+       Debug( LDAP_DEBUG_TRACE, "==> limits_get: conn=%lu op=%lu dn=\"%s\"\n",
+                       op->o_connid, op->o_opid,
+                       BER_BVISNULL( ndn ) ? "[anonymous]" : ndn->bv_val );
+#endif
        /*
         * default values
         */
@@ -63,13 +109,35 @@ limits_get(
                                                lm[0]->lm_group_ad );
                                if ( rc == 0 ) {
                                        *limit = &lm[0]->lm_limits;
+#ifdef NEW_LOGGING
+                                       LDAP_LOG( SLAPD, DETAIL1, "<== limits_get: type=GROUP match=EXACT "
+                                                       "dn=\"%s\" oc=\"%s\" ad=\"%s\"\n",
+                                                       lm[0]->lm_pat.bv_val,
+                                                       lm[0]->lm_group_oc->soc_cname.bv_val,
+                                                       lm[0]->lm_group_ad->ad_cname.bv_val );
+#else
+                                       Debug( LDAP_DEBUG_TRACE, "<== limits_get: type=GROUP match=EXACT "
+                                                       "dn=\"%s\" oc=\"%s\" ad=\"%s\"\n",
+                                                       lm[0]->lm_pat.bv_val,
+                                                       lm[0]->lm_group_oc->soc_cname.bv_val,
+                                                       lm[0]->lm_group_ad->ad_cname.bv_val );
+
+#endif
                                        return( 0 );
                                }
-                       }
+                       } else {
                        
-                       if ( dn_match( &lm[0]->lm_pat, ndn ) ) {
-                               *limit = &lm[0]->lm_limits;
-                               return( 0 );
+                               if ( dn_match( &lm[0]->lm_pat, ndn ) ) {
+                                       *limit = &lm[0]->lm_limits;
+#ifdef NEW_LOGGING
+                                       LDAP_LOG( SLAPD, DETAIL1, "<== limits_get: type=DN match=EXACT dn=\"%s\"\n",
+                                                       lm[0]->lm_pat.bv_val, 0, 0 );
+#else
+                                       Debug( LDAP_DEBUG_TRACE, "<== limits_get: type=DN match=EXACT dn=\"%s\"\n",
+                                                       lm[0]->lm_pat.bv_val, 0, 0 );
+#endif
+                                       return( 0 );
+                               }
                        }
                        break;
 
@@ -119,6 +187,13 @@ limits_get(
                                }
 
                                *limit = &lm[0]->lm_limits;
+#ifdef NEW_LOGGING
+                               LDAP_LOG( SLAPD, DETAIL1, "<== limits_get: type=DN match=%s dn=\"%s\"\n",
+                                               limits2str( style ), lm[0]->lm_pat.bv_val, 0 );
+#else
+                               Debug( LDAP_DEBUG_TRACE, "<== limits_get: type=DN match=%s dn=\"%s\"\n",
+                                               limits2str( style ), lm[0]->lm_pat.bv_val, 0 );
+#endif
                                return( 0 );
                        }
 
@@ -133,12 +208,26 @@ limits_get(
                                                0, NULL, 0 ) == 0 )
                        {
                                *limit = &lm[0]->lm_limits;
+#ifdef NEW_LOGGING
+                               LDAP_LOG( SLAPD, DETAIL1, "<== limits_get: type=DN match=%s dn=\"%s\"\n",
+                                               limits2str( style ), lm[0]->lm_pat.bv_val, 0 );
+#else
+                               Debug( LDAP_DEBUG_TRACE, "<== limits_get: type=DN match=%s dn=\"%s\"\n",
+                                               limits2str( style ), lm[0]->lm_pat.bv_val, 0 );
+#endif
                                return( 0 );
                        }
                        break;
 
                case SLAP_LIMITS_ANONYMOUS:
                        if ( ndn->bv_len == 0 ) {
+#ifdef NEW_LOGGING
+                               LDAP_LOG( SLAPD, DETAIL1, "<== limits_get: type=DN match=%s\n",
+                                               limits2str( style ), 0, 0 );
+#else
+                               Debug( LDAP_DEBUG_TRACE, "<== limits_get: type=DN match=%s\n",
+                                               limits2str( style ), 0, 0 );
+#endif
                                *limit = &lm[0]->lm_limits;
                                return( 0 );
                        }
@@ -147,6 +236,13 @@ limits_get(
                case SLAP_LIMITS_USERS:
                        if ( ndn->bv_len != 0 ) {
                                *limit = &lm[0]->lm_limits;
+#ifdef NEW_LOGGING
+                               LDAP_LOG( SLAPD, DETAIL1, "<== limits_get: type=DN match=%s\n",
+                                               limits2str( style ), 0, 0 );
+#else
+                               Debug( LDAP_DEBUG_TRACE, "<== limits_get: type=DN match=%s\n",
+                                               limits2str( style ), 0, 0 );
+#endif
                                return( 0 );
                        }
                        break;