From: Pierangelo Masarati Date: Wed, 16 May 2001 22:55:44 +0000 (+0000) Subject: added new log; minor cleanup of rewrite stuff X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~1405 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=395cc1d7bb959d8ea7cf663929a332d4af99195e;p=openldap added new log; minor cleanup of rewrite stuff --- diff --git a/servers/slapd/back-ldap/add.c b/servers/slapd/back-ldap/add.c index cccc79e2ba..32fc5bb910 100644 --- a/servers/slapd/back-ldap/add.c +++ b/servers/slapd/back-ldap/add.c @@ -60,6 +60,13 @@ ldap_back_add( LDAPMod **attrs; char *mdn = NULL, *mapped; +#ifdef NEW_LOGGING + LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY, "ldap_back_add: %s\n", + e->e_dn )); +#else /* !NEW_LOGGING */ + Debug(LDAP_DEBUG_ARGS, "==> ldap_back_add: %s\n", e->e_dn, 0, 0); +#endif /* !NEW_LOGGING */ + lc = ldap_back_getconn(li, conn, op); if ( !lc || !ldap_back_dobind( lc, op ) ) { return( -1 ); @@ -71,18 +78,27 @@ ldap_back_add( #ifdef ENABLE_REWRITE switch (rewrite_session( li->rwinfo, "addDn", e->e_dn, conn, &mdn )) { case REWRITE_REGEXEC_OK: - if ( mdn == NULL ) { + if ( mdn == NULL ) { mdn = e->e_dn; } +#ifdef NEW_LOGGING + LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, + "[rw] addDn: \"%s\" -> \"%s\"\n", + e->e_dn, mdn )); +#else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ARGS, "rw> addDn: \"%s\" -> \"%s\"\n%s", e->e_dn, mdn, "" ); +#endif /* !NEW_LOGGING */ break; case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL, "Unwilling to perform", NULL, NULL ); + return( -1 ); case REWRITE_REGEXEC_ERR: + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, "Operations error", NULL, NULL ); return( -1 ); } #else /* !ENABLE_REWRITE */ @@ -180,11 +196,18 @@ ldap_dnattr_rewrite( /* no substitution */ continue; } +#ifdef NEW_LOGGING + LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, + "[rw] bindDn (in add of dn-valued" + " attr): \"%s\" -> \"%s\"\n", + a_vals[ j ]->bv_val, mattr )); +#else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ARGS, "rw> bindDn (in add of dn-valued attr):" " \"%s\" -> \"%s\"\n%s", a_vals[ j ]->bv_val, mattr, "" ); - +#endif /* !NEW_LOGGING */ + free( a_vals[ j ]->bv_val ); a_vals[ j ]->bv_val = mattr; a_vals[ j ]->bv_len = strlen( mattr ); diff --git a/servers/slapd/back-ldap/bind.c b/servers/slapd/back-ldap/bind.c index 0a6c7aed00..3f584d43fa 100644 --- a/servers/slapd/back-ldap/bind.c +++ b/servers/slapd/back-ldap/bind.c @@ -83,15 +83,23 @@ ldap_back_bind( if ( mdn == NULL ) { mdn = ( char * )dn; } +#ifdef NEW_LOGGING + LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, + "[rw] bindDn: \"%s\" -> \"%s\"\n", dn, mdn )); +#else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ARGS, "rw> bindDn: \"%s\" -> \"%s\"\n%s", dn, mdn, "" ); +#endif /* !NEW_LOGGING */ break; case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL, "Unwilling to perform", NULL, NULL ); + return( -1 ); case REWRITE_REGEXEC_ERR: + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, "Operations error", NULL, NULL ); return( -1 ); } #else /* !ENABLE_REWRITE */ @@ -239,11 +247,19 @@ ldap_back_getconn(struct ldapinfo *li, Connection *conn, Operation *op) lc->bound_dn = ch_strdup( lc->conn->c_cdn ); } +#ifdef NEW_LOGGING + LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, + "[rw] bindDn: \"%s\" ->" + " \"%s\"\n%s", + lc->conn->c_cdn, + lc->bound_dn )); +#else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ARGS, "rw> bindDn: \"%s\" ->" - " \"%s\"\n%s", + " \"%s\"\n%s", lc->conn->c_cdn, lc->bound_dn, "" ); +#endif /* !NEW_LOGGING */ break; case REWRITE_REGEXEC_UNWILLING: @@ -251,8 +267,13 @@ ldap_back_getconn(struct ldapinfo *li, Connection *conn, Operation *op) LDAP_UNWILLING_TO_PERFORM, NULL, "Unwilling to perform", NULL, NULL ); + return( NULL ); case REWRITE_REGEXEC_ERR: + send_ldap_result( conn, op, + LDAP_OPERATIONS_ERROR, + NULL, "Operations error", + NULL, NULL ); return( NULL ); } #else /* !ENABLE_REWRITE */ @@ -275,9 +296,15 @@ ldap_back_getconn(struct ldapinfo *li, Connection *conn, Operation *op) ldap_pvt_thread_mutex_unlock( &li->conn_mutex ); +#ifdef NEW_LOGGING + LDAP_LOG(( "backend", LDAP_LEVEL_INFO, + "ldap_back_getconn: conn %ld inserted\n", + lc->conn->c_connid )); +#else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_TRACE, - "=>ldap_back_getconn: conn %ld inserted%s%s\n", + "=>ldap_back_getconn: conn %ld inserted\n%s%s", lc->conn->c_connid, "", "" ); +#endif /* !NEW_LOGGING */ /* Err could be -1 in case a duplicate ldapconn is inserted */ if ( err != 0 ) { @@ -287,9 +314,15 @@ ldap_back_getconn(struct ldapinfo *li, Connection *conn, Operation *op) return( NULL ); } } else { +#ifdef NEW_LOGGING + LDAP_LOG(( "backend", LDAP_LEVEL_INFO, + "ldap_back_getconn: conn %ld inserted\n", + lc->conn->c_connid )); +#else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_TRACE, "=>ldap_back_getconn: conn %ld fetched%s%s\n", lc->conn->c_connid, "", "" ); +#endif /* !NEW_LOGGING */ } return( lc ); diff --git a/servers/slapd/back-ldap/compare.c b/servers/slapd/back-ldap/compare.c index 99bd397243..23d65f9e56 100644 --- a/servers/slapd/back-ldap/compare.c +++ b/servers/slapd/back-ldap/compare.c @@ -73,15 +73,24 @@ ldap_back_compare( if ( mdn == NULL ) { mdn = ( char * )dn; } +#ifdef NEW_LOGGING + LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, + "[rw] compareDn: \"%s\" -> \"%s\"\n", + dn, mdn )); +#else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ARGS, "rw> compareDn: \"%s\" -> \"%s\"\n%s", dn, mdn, "" ); +#endif /* !NEW_LOGGING */ break; case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL, "Unwilling to perform", NULL, NULL ); + return( -1 ); case REWRITE_REGEXEC_ERR: + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, "Operations error", NULL, NULL ); return( -1 ); } #else /* !ENABLE_REWRITE */ diff --git a/servers/slapd/back-ldap/delete.c b/servers/slapd/back-ldap/delete.c index ef1d947518..cd00c5469f 100644 --- a/servers/slapd/back-ldap/delete.c +++ b/servers/slapd/back-ldap/delete.c @@ -74,15 +74,23 @@ ldap_back_delete( if ( mdn == NULL ) { mdn = ( char * )dn; } - Debug( LDAP_DEBUG_ARGS, "rw> deleteDn: \"%s\" -> \"%s\"\n%s", - dn, mdn, "" ); - break; +#ifdef NEW_LOGGING + LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, + "[rw] deleteDn: \"%s\" -> \"%s\"\n", dn, mdn )); +#else /* !NEW_LOGGING */ + Debug( LDAP_DEBUG_ARGS, "rw> deleteDn: \"%s\" -> \"%s\"\n%s", + dn, mdn, "" ); +#endif /* !NEW_LOGGING */ + break; case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL, "Unwilling to perform", NULL, NULL ); + return( -1 ); case REWRITE_REGEXEC_ERR: + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, "Operations error", NULL, NULL ); return( -1 ); } #else /* !ENABLE_REWRITE */ diff --git a/servers/slapd/back-ldap/group.c b/servers/slapd/back-ldap/group.c index 800b873e8d..4c33926bc2 100644 --- a/servers/slapd/back-ldap/group.c +++ b/servers/slapd/back-ldap/group.c @@ -100,9 +100,15 @@ ldap_back_group( if ( mop_ndn == NULL ) { mop_ndn = ( char * )op_ndn; } +#ifdef NEW_LOGGING + LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, + "[rw] bindDn (op ndn in group):" + " \"%s\" -> \"%s\"\n", op_ndn, mop_ndn )); +#else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ARGS, "rw> bindDn (op ndn in group): \"%s\" -> \"%s\"\n%s", op_ndn, mop_ndn, "" ); +#endif /* !NEW_LOGGING */ break; case REWRITE_REGEXEC_UNWILLING: @@ -120,10 +126,16 @@ ldap_back_group( if ( mgr_ndn == NULL ) { mgr_ndn = ( char * )gr_ndn; } +#ifdef NEW_LOGGING + LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, + "[rw] searchBase (gr ndn in group):" + " \"%s\" -> \"%s\"\n%s", gr_ndn, mgr_ndn )); +#else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ARGS, "rw> searchBase (gr ndn in group):" " \"%s\" -> \"%s\"\n%s", gr_ndn, mgr_ndn, "" ); +#endif /* !NEW_LOGGING */ break; case REWRITE_REGEXEC_UNWILLING: diff --git a/servers/slapd/back-ldap/modify.c b/servers/slapd/back-ldap/modify.c index 269ebf4591..0b986db4c3 100644 --- a/servers/slapd/back-ldap/modify.c +++ b/servers/slapd/back-ldap/modify.c @@ -77,15 +77,23 @@ ldap_back_modify( if ( mdn == NULL ) { mdn = ( char * )dn; } - Debug( LDAP_DEBUG_ARGS, "rw> modifyDN: \"%s\" -> \"%s\"\n%s", +#ifdef NEW_LOGGING + LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, + "[rw] modifyDn: \"%s\" -> \"%s\"\n", dn, mdn )); +#else /* !NEW_LOGGING */ + Debug( LDAP_DEBUG_ARGS, "rw> modifyDn: \"%s\" -> \"%s\"\n%s", dn, mdn, "" ); +#endif /* !NEW_LOGGING */ break; case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL, "Unwilling to perform", NULL, NULL ); + return( -1 ); case REWRITE_REGEXEC_ERR: + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, "Operations error", NULL, NULL ); return( -1 ); } #else /* !ENABLE_REWRITE */ diff --git a/servers/slapd/back-ldap/modrdn.c b/servers/slapd/back-ldap/modrdn.c index 74c2922ce8..72d2543ab8 100644 --- a/servers/slapd/back-ldap/modrdn.c +++ b/servers/slapd/back-ldap/modrdn.c @@ -81,17 +81,28 @@ ldap_back_modrdn( if ( mnewSuperior == NULL ) { mnewSuperior = ( char * )newSuperior; } +#ifdef NEW_LOGGING + LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, + "[rw] newSuperiorDn:" + " \"%s\" -> \"%s\"\n", + newSuperior, mnewSuperior )); +#else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ARGS, "rw> newSuperiorDn:" " \"%s\" -> \"%s\"\n%s", newSuperior, mnewSuperior, "" ); +#endif /* !NEW_LOGGING */ break; case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL, "Unwilling to perform", NULL, NULL ); + return( -1 ); case REWRITE_REGEXEC_ERR: + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, "Operations error", + NULL, NULL ); return( -1 ); } #else /* !ENABLE_REWRITE */ @@ -112,15 +123,23 @@ ldap_back_modrdn( if ( mdn == NULL ) { mdn = ( char * )dn; } +#ifdef NEW_LOGGING + LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, + "[rw] modrDn: \"%s\" -> \"%s\"\n", dn, mdn )); +#else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ARGS, "rw> modrDn: \"%s\" -> \"%s\"\n%s", dn, mdn, "" ); +#endif /* !NEW_LOGGING */ break; case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL, "Unwilling to perform", NULL, NULL ); + return( -1 ); case REWRITE_REGEXEC_ERR: + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, "Operations error", NULL, NULL ); return( -1 ); } #else /* !ENABLE_REWRITE */ diff --git a/servers/slapd/back-ldap/search.c b/servers/slapd/back-ldap/search.c index 1b0e3a20ee..a0097d5c7f 100644 --- a/servers/slapd/back-ldap/search.c +++ b/servers/slapd/back-ldap/search.c @@ -103,15 +103,25 @@ ldap_back_search( if ( mbase == NULL ) { mbase = ( char * )base; } +#ifdef NEW_LOGGING + LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, + "[rw] searchBase: \"%s\" -> \"%s\"\n%", + base, mbase )); +#else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ARGS, "rw> searchBase: \"%s\" -> \"%s\"\n%s", base, mbase, "" ); +#endif /* !NEW_LOGGING */ break; case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL, "Unwilling to perform", NULL, NULL ); + rc = -1; + goto finish; case REWRITE_REGEXEC_ERR: + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, "Operations error", NULL, NULL ); rc = -1; goto finish; } @@ -128,9 +138,15 @@ ldap_back_search( } mfilter = ( char * )filterstr; } +#ifdef NEW_LOGGING + LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, + "[rw] searchFilter: \"%s\" -> \"%s\"\n", + filterstr, mfilter )); +#else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ARGS, "rw> searchFilter: \"%s\" -> \"%s\"\n%s", filterstr, mfilter, "" ); +#endif /* !NEW_LOGGING */ break; case REWRITE_REGEXEC_UNWILLING: @@ -226,9 +242,16 @@ fail: if ( mmatch == NULL ) { mmatch = ( char * )match; } +#ifdef NEW_LOGGING + LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, + "[rw] matchedDn:" + " \"%s\" -> \"%s\"\n", + match, mmatch )); +#else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ARGS, "rw> matchedDn:" - " \"%s\" -> \"%s\"\n%s", - match, mmatch, "" ); + " \"%s\" -> \"%s\"\n%s", + match, mmatch, "" ); +#endif /* !NEW_LOGGING */ break; case REWRITE_REGEXEC_UNWILLING: @@ -325,8 +348,14 @@ ldap_send_entry( if ( ent.e_dn == NULL ) { ent.e_dn = dn; } else { +#ifdef NEW_LOGGING + LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, + "[rw] searchResult: \"%s\"" + " -> \"%s\"\n", dn, ent.e_dn )); +#else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ARGS, "rw> searchResult: \"%s\"" " -> \"%s\"\n%s", dn, ent.e_dn, "" ); +#endif /* !NEW_LOGGING */ free( dn ); dn = NULL; } @@ -414,10 +443,20 @@ ldap_send_entry( if ( newval == NULL ) { break; } +#ifdef NEW_LOGGING + LDAP_LOG(( "backend", + LDAP_LEVEL_DETAIL1, + "[rw] searchResult on" + " attr=%s:" + " \"%s\" -> \"%s\"\n", + attr->a_desc->ad_type->sat_cname, + bv->bv_val, newval )); +#else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ARGS, "rw> searchResult on attr=%s: \"%s\" -> \"%s\"\n", attr->a_desc->ad_type->sat_cname, bv->bv_val, newval ); +#endif /* !NEW_LOGGING */ free( bv->bv_val ); bv->bv_val = newval; diff --git a/servers/slapd/back-ldap/unbind.c b/servers/slapd/back-ldap/unbind.c index 49b2f3ef19..eb8db9608b 100644 --- a/servers/slapd/back-ldap/unbind.c +++ b/servers/slapd/back-ldap/unbind.c @@ -54,10 +54,15 @@ ldap_back_conn_destroy( struct ldapinfo *li = (struct ldapinfo *) be->be_private; struct ldapconn *lc, lc_curr; +#ifdef NEW_LOGGING + LDAP_LOG(( "backend", LDAP_LEVEL_INFO, + "ldap_back_conn_destroy: fetching conn %d\n", + conn->c_connid )); +#else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_TRACE, "=>ldap_back_conn_destroy: fetching conn %d\n", conn->c_connid, 0, 0 ); - +#endif /* !NEW_LOGGING */ lc_curr.conn = conn;