added new logging to back-meta

This commit is contained in:
Pierangelo Masarati 2001-05-13 23:44:22 +00:00
parent 076c3351e4
commit 0b4c7e0181
12 changed files with 239 additions and 36 deletions

View file

@ -91,6 +91,13 @@ meta_back_add(
LDAPMod **attrs;
char *mdn = NULL, *mapped;
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY, "meta_back_add: %s\n",
e->e_dn ));
#else /* !NEW_LOGGING */
Debug(LDAP_DEBUG_ARGS, "==> meta_back_add: %s\n", e->e_dn, 0, 0);
#endif /* !NEW_LOGGING */
/*
* get the current connection
*/
@ -109,15 +116,25 @@ meta_back_add(
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;
}

View file

@ -144,7 +144,6 @@ struct metainfo {
extern int
meta_back_do_single_bind(
Operation *op,
struct metainfo *li,
struct metaconn *lc,
const char *dn,

View file

@ -96,7 +96,7 @@ meta_back_bind(
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY,
"meta_back_bind: dn: %s.\n", dn ));
"meta_back_bind: dn: %s.\n", dn ));
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ARGS, "meta_back_bind: dn: %s.\n%s%s", dn, "", "" );
#endif /* !NEW_LOGGING */
@ -108,7 +108,8 @@ meta_back_bind(
if ( !lc ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_NOTICE,
"meta_back_bind: no target for dn %s.\n", dn ));
"meta_back_bind: no target for dn %s.\n",
dn ));
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ANY,
"meta_back_bind: no target for dn %s.\n%s%s",
@ -140,16 +141,20 @@ meta_back_bind(
*/
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_WARNING,
"==>meta_back_bind: more that one candidate is attempting to bind ...%s%s%s\n" ));
"==>meta_back_bind: more than one"
" candidate is attempting to bind"
" ...\n" ));
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ANY,
"==>meta_back_bind: more that one candidate is attempting to bind ...%s%s%s\n",
"", "", "" );
"==>meta_back_bind: more than one"
" candidate is attempting to bind"
" ...\n%s%s%s",
"", "", "" );
#endif /* !NEW_LOGGING */
}
lerr = meta_back_do_single_bind( op, li, lc, dn, ndn, cred,
lerr = meta_back_do_single_bind( li, lc, dn, ndn, cred,
method, i );
if ( lerr != LDAP_SUCCESS ) {
err = lerr;
@ -178,7 +183,6 @@ meta_back_bind(
*/
int
meta_back_do_single_bind(
Operation *op,
struct metainfo *li,
struct metaconn *lc,
const char *dn,
@ -200,19 +204,21 @@ meta_back_do_single_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( lc->conn, op, LDAP_UNWILLING_TO_PERFORM,
NULL, "Unwilling to perform",
NULL, NULL );
/* continues to next case */
return LDAP_UNWILLING_TO_PERFORM;
case REWRITE_REGEXEC_ERR:
return -1;
return LDAP_OPERATIONS_ERROR;
}
rc = ldap_bind_s( lc->conns[ candidate ]->ld, mdn,
@ -274,14 +280,20 @@ meta_back_dobind( struct metaconn *lc, Operation *op )
NULL, LDAP_AUTH_SIMPLE );
if ( rc != LDAP_SUCCESS ) {
/*
* This way, the first bind error would be fatal ...
*/
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_WARNING,
"meta_back_dobind: (anonymous)"
" bind as \"%s\" failed"
" with error \"%s\"\n",
lsc[ 0 ]->bound_dn,
ldap_err2string( rc ) ));
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ANY,
"==>meta_back_dobind: (anonymous) bind as \"%s\" failed"
" with error \"%s\"\n%s",
lsc[ 0 ]->bound_dn,
ldap_err2string( rc ), "" );
#endif /* !NEW_LOGGING */
/*
* null cred bind should always succeed
@ -334,11 +346,20 @@ meta_back_op_result( struct metaconn *lc, Operation *op )
send_ldap_result( lc->conn, op, err, match, msg,
NULL, NULL );
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_DEBUG_NOTICE,
"meta_back_op_result: target"
" <%d> sending msg \"%s\""
" (matched \"%s\")\n",
i, ( msg ? msg : "" ),
( match ? match : "" ) ));
#else /* !NEW_LOGGING */
Debug(LDAP_DEBUG_ANY,
"==> meta_back_op_result: target <%d> sending msg \"%s\" (matched \"%s\")\n",
i,
( msg ? msg : "" ),
( match ? match : "" ) );
#endif /* !NEW_LOGGING */
/* better test the pointers before freeing? */
if ( match ) {

View file

@ -124,17 +124,27 @@ meta_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;
}
@ -301,9 +311,15 @@ finish:
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, "" );
#endif /* !NEW_LOGGING */
break;
@ -311,15 +327,21 @@ finish:
send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM,
NULL, "Unwilling to perform",
NULL, NULL );
/* continue to the next case */
rc = -1;
goto cleanup;
case REWRITE_REGEXEC_ERR:
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
NULL, "Operations error",
NULL, NULL );
rc = -1;
break;
goto cleanup;
}
}
}
send_ldap_result( conn, op, rres, mmatch, err, NULL, NULL );
cleanup:
if ( match != NULL ) {
if ( mmatch != match ) {
free( mmatch );

View file

@ -251,10 +251,18 @@ meta_back_db_config(
ldap_free_urldesc( ludp );
#ifdef NEW_LOGGING
LDAP_LOG(( "config", LDAP_LEVEL_INFO,
"meta_back_db_config:"
" URI \"%s\", suffix \"%s\"\n",
li->targets[ i ]->uri,
li->targets[ i ]->suffix ));
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_CONFIG,
"==>meta_back_db_config: URI \"%s\", suffix \"%s\"%s\n",
"==>meta_back_db_config: URI \"%s\", suffix \"%s\"\n%s",
li->targets[ i ]->uri, li->targets[ i ]->suffix, "" );
#endif /* !NEW_LOGGING */
/* default target directive */
} else if ( strcasecmp( argv[ 0 ], "default-target" ) == 0 ) {
int i = li->ntargets-1;

View file

@ -292,9 +292,15 @@ init_one_conn(
if ( lsc->bound_dn == NULL ) {
lsc->bound_dn = ch_strdup( conn->c_cdn );
}
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
"[rw] bindDn: \"%s\" -> \"%s\"\n",
conn->c_cdn, lsc->bound_dn ));
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ARGS,
"rw> bindDn: \"%s\" -> \"%s\"\n%s",
conn->c_cdn, lsc->bound_dn, "" );
#endif /* !NEW_LOGGING */
break;
case REWRITE_REGEXEC_UNWILLING:
@ -393,11 +399,16 @@ meta_back_getconn(
return NULL;
}
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
"meta_back_getconn: got target %d"
" for ndn=\"%s\" from cache\n", i, ndn ));
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_CACHE,
"==>meta_back_getconn: got target %d for ndn=\"%s\" from cache\n%s",
i, ndn, "" );
#endif /* !NEW_LOGGING */
/*
* Clear all other candidates
*/
@ -477,9 +488,15 @@ meta_back_getconn(
ldap_pvt_thread_mutex_unlock( &li->conn_mutex );
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
"meta_back_getconn: conn %ld inserted\n",
lc->conn->c_connid ));
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_TRACE,
"=>meta_back_getconn: conn %ld inserted\n%s%s",
lc->conn->c_connid, "", "" );
#endif /* !NEW_LOGGING */
/*
* Err could be -1 in case a duplicate metaconn is inserted
@ -491,9 +508,15 @@ meta_back_getconn(
return NULL;
}
} else {
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
"meta_back_getconn: conn %ld fetched\n",
lc->conn->c_connid ));
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_TRACE,
"=>meta_back_getconn: conn %ld fetched\n%s%s",
lc->conn->c_connid, "", "" );
#endif /* !NEW_LOGGING */
}
return lc;

View file

@ -105,16 +105,25 @@ meta_back_delete(
if ( mdn == NULL ) {
mdn = ( char * )dn;
}
#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:
return( -1 );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
NULL, "Operations error", NULL, NULL );
return -1;
}
ldap_delete_s( lc->conns[ candidate ]->ld, mdn );

View file

@ -167,10 +167,17 @@ meta_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:
@ -190,10 +197,17 @@ meta_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",
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:

View file

@ -108,16 +108,25 @@ meta_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:
return( -1 );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
NULL, "Operations error", NULL, NULL );
return -1;
}
for ( i = 0, ml = modlist; ml; i++ ,ml = ml->sml_next )

View file

@ -137,18 +137,29 @@ meta_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:
return( -1 );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
NULL, "Operations error",
NULL, NULL );
return -1;
}
}
@ -161,16 +172,25 @@ meta_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:
return( -1 );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
NULL, "Operations error", NULL, NULL );
return -1;
}
ldap_rename2_s( lc->conns[ candidate ]->ld, mdn, newrdn,
@ -185,3 +205,4 @@ meta_back_modrdn(
return meta_back_op_result( lc, op );
}

View file

@ -217,17 +217,27 @@ meta_back_search(
if ( mbase == NULL ) {
mbase = realbase;
}
#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 );
/* continue to the next case */
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;
}
@ -245,9 +255,15 @@ meta_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:
@ -375,9 +391,16 @@ meta_back_search(
ldap_get_option( lsc[ 0 ]->ld,
LDAP_OPT_MATCHED_DN, &match );
Debug( LDAP_DEBUG_ARGS,
"meta_back_search=> [%d] match=\"%s\" err=\"%s\"\n",
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_ERR,
"meta_back_search [%d]"
" match=\"%s\" err=\"%s\"\n",
i, match, err ));
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ANY,
"=>meta_back_search [%d] match=\"%s\" err=\"%s\"\n",
i, match, err );
#endif /* !NEW_LOGGING */
last = i;
rc = 0;
@ -425,9 +448,15 @@ meta_back_search(
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, "" );
#endif /* !NEW_LOGGING */
break;
case REWRITE_REGEXEC_UNWILLING:
@ -501,8 +530,15 @@ meta_send_entry(
if ( ent.e_dn == NULL ) {
ent.e_dn = dn;
} else {
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
"[rw] searchResult[%d]:"
" \"%s\" -> \"%s\"\n",
target, dn, ent.e_dn ));
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ARGS, "rw> searchResult[%d]: \"%s\""
" -> \"%s\"\n", target, dn, ent.e_dn );
#endif /* !NEW_LOGGING */
free( dn );
dn = NULL;
}
@ -594,18 +630,30 @@ meta_send_entry(
char *newval;
switch ( rewrite_session( li->targets[ target ]->rwinfo,
"searchResult", bv->bv_val,
"searchResult",
bv->bv_val,
lc->conn, &newval )) {
case REWRITE_REGEXEC_OK:
/* left as is */
if ( newval == NULL ) {
break;
}
Debug( LDAP_DEBUG_ARGS,
"rw> searchResult on attr=%s: \"%s\" -> \"%s\"\n",
attr->a_desc->ad_type->sat_cname,
#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;
bv->bv_len = strlen( newval );

View file

@ -84,9 +84,15 @@ meta_back_conn_destroy(
struct metainfo *li = ( struct metainfo * )be->be_private;
struct metaconn *lc, lc_curr;
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY,
"meta_back_conn_destroy: fetching conn %ld\n",
conn->c_connid ));
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_TRACE,
"=>meta_back_conn_destroy: fetching conn %ld\n%s%s",
conn->c_connid, "", "" );
#endif /* !NEW_LOGGING */
lc_curr.conn = conn;
@ -98,9 +104,15 @@ meta_back_conn_destroy(
if ( lc ) {
int i;
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
"meta_back_conn_destroy: destroying conn %ld\n",
lc->conn->c_connid ));
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_TRACE,
"=>meta_back_conn_destroy: destroying conn %ld\n%s%s",
lc->conn->c_connid, "", "" );
#endif /* !NEW_LOGGING */
/*
* Cleanup rewrite session