From dd48690eaad250c6dfc13e81bd25c51227c33b3a Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Sat, 17 Apr 2004 18:12:37 +0000 Subject: [PATCH] add logs; fix bug in group/dn selection logic --- servers/slapd/limits.c | 104 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 100 insertions(+), 4 deletions(-) diff --git a/servers/slapd/limits.c b/servers/slapd/limits.c index 7507094432..55fce61705 100644 --- a/servers/slapd/limits.c +++ b/servers/slapd/limits.c @@ -23,6 +23,42 @@ #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; -- 2.39.5