added new log; minor cleanup of rewrite stuff

This commit is contained in:
Pierangelo Masarati 2001-05-16 22:55:44 +00:00
parent a76935fe00
commit 395cc1d7bb
9 changed files with 167 additions and 11 deletions

View File

@ -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 );

View File

@ -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 );

View File

@ -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 */

View File

@ -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 */

View File

@ -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:

View File

@ -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 */

View File

@ -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 */

View File

@ -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;

View File

@ -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;