diff --git a/servers/slapd/abandon.c b/servers/slapd/abandon.c index b092d124f338f2c1d2713d7a0fe672af46949edd..80ea94be0ce51671969174d2d19c419d889fc7dd 100644 --- a/servers/slapd/abandon.c +++ b/servers/slapd/abandon.c @@ -35,8 +35,7 @@ do_abandon( int rc; #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, "conn: %d do_abandon\n", - conn->c_connid)); + LDAP_LOG( OPERATION, ENTRY, "conn: %d do_abandon\n", conn->c_connid, 0, 0); #else Debug( LDAP_DEBUG_TRACE, "do_abandon\n", 0, 0, 0 ); #endif @@ -49,9 +48,8 @@ do_abandon( if ( ber_scanf( op->o_ber, "i", &id ) == LBER_ERROR ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "conn: %d do_abandon: ber_scanf failed\n", - conn->c_connid )); + LDAP_LOG( OPERATION, ERR, + "conn: %d do_abandon: ber_scanf failed\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_abandon: ber_scanf failed\n", 0, 0 ,0 ); #endif @@ -66,16 +64,17 @@ do_abandon( } #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ARGS, - "do_abandon: conn: %d id=%ld\n", conn->c_connid, (long) id )); + LDAP_LOG( OPERATION, ARGS, "do_abandon: conn: %d id=%ld\n", + conn->c_connid, (long) id, 0 ); #else Debug( LDAP_DEBUG_ARGS, "do_abandon: id=%ld\n", (long) id, 0 ,0 ); #endif if( id <= 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "do_abandon: conn: %d bad msgid %ld\n", conn->c_connid, (long) id )); + LDAP_LOG( OPERATION, ERR, + "do_abandon: conn: %d bad msgid %ld\n", + conn->c_connid, (long) id, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_abandon: bad msgid %ld\n", (long) id, 0, 0 ); @@ -109,9 +108,9 @@ done: ldap_pvt_thread_mutex_unlock( &conn->c_mutex ); #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, + LDAP_LOG( OPERATION, ENTRY, "do_abandon: conn: %d op=%ld %sfound\n", - conn->c_connid, (long)id, o ? "" : "not " )); + conn->c_connid, (long)id, o ? "" : "not " ); #else Debug( LDAP_DEBUG_TRACE, "do_abandon: op=%ld %sfound\n", (long) id, o ? "" : "not ", 0 ); diff --git a/servers/slapd/acl.c b/servers/slapd/acl.c index 2318cbffd508eebd7ba923c6b51f691271f395ce..c99695b603b77e75b45a06e2502c8fdd02837a4f 100644 --- a/servers/slapd/acl.c +++ b/servers/slapd/acl.c @@ -19,7 +19,6 @@ #define ACL_BUF_SIZE 1024 /* use most appropriate size */ - /* * speed up compares */ @@ -122,6 +121,7 @@ access_allowed( int ret = 1; int count; AccessControl *a; + #ifdef LDAP_DEBUG char accessmaskbuf[ACCESSMASK_MAXLEN]; #endif @@ -152,9 +152,9 @@ access_allowed( } #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_ENTRY, - "access_allowed: conn %lu %s access to \"%s\" \"%s\" requested\n", - conn ? conn->c_connid : -1, access2str( access ), e->e_dn, attr )); + LDAP_LOG( ACL, ENTRY, + "access_allowed: %s access to \"%s\" \"%s\" requested\n", + access2str( access ), e->e_dn, attr ); #else Debug( LDAP_DEBUG_ACL, "=> access_allowed: %s access to \"%s\" \"%s\" requested\n", @@ -172,9 +172,9 @@ access_allowed( /* grant database root access */ if ( be != NULL && be_isroot( be, &op->o_ndn ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_INFO, - "access_allowed: conn %lu root access granted\n", - conn->c_connid)); + LDAP_LOG( ACL, INFO, + "access_allowed: conn %lu root access granted\n", + conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ACL, "<= root access granted\n", @@ -193,9 +193,9 @@ access_allowed( && desc != slap_schema.si_ad_children ) { #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1, - "access_allowed: conn %lu NoUserMod Operational attribute: %s access granted\n", - conn->c_connid, attr )); + LDAP_LOG( ACL, DETAIL1, + "access_allowed: conn %lu NoUserMod Operational attribute: %s " + "access granted\n", conn->c_connid, attr , 0 ); #else Debug( LDAP_DEBUG_ACL, "NoUserMod Operational attribute:" " %s access granted\n", @@ -207,10 +207,11 @@ access_allowed( /* use backend default access if no backend acls */ if( be != NULL && be->be_acl == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1, - "access_allowed: conn %lu backend default %s access %s to \"%s\"\n", - conn->c_connid, access2str( access ), - be->be_dfltaccess >= access ? "granted" : "denied", op->o_dn.bv_val )); + LDAP_LOG( ACL, DETAIL1, + "access_allowed: backend default %s access %s to \"%s\"\n", + access2str( access ), + be->be_dfltaccess >= access ? "granted" : "denied", + op->o_dn.bv_val ); #else Debug( LDAP_DEBUG_ACL, "=> access_allowed: backend default %s access %s to \"%s\"\n", @@ -225,10 +226,11 @@ access_allowed( /* use global default access if no global acls */ } else if ( be == NULL && global_acl == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1, - "access_allowed: conn %lu global default %s access %s to \"%s\"\n", - conn->c_connid, access2str( access ), - global_default_access >= access ? "granted" : "denied", op->o_dn.bv_val )); + LDAP_LOG( ACL, DETAIL1, + "access_allowed: global default %s access %s to \"%s\"\n", + access2str( access ), + global_default_access >= access ? "granted" : "denied", + op->o_dn.bv_val ); #else Debug( LDAP_DEBUG_ACL, "=> access_allowed: global default %s access %s to \"%s\"\n", @@ -267,10 +269,9 @@ access_allowed( for (i = 0; i < MAXREMATCHES && matches[i].rm_so > 0; i++) { #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1, - "access_allowed: conn %lu match[%d]: %d %d ", - conn->c_connid, i, - (int)matches[i].rm_so, (int)matches[i].rm_eo )); + LDAP_LOG( ACL, DETAIL1, + "access_allowed: match[%d]: %d %d ", + i, (int)matches[i].rm_so, (int)matches[i].rm_eo ); #else Debug( LDAP_DEBUG_ACL, "=> match[%d]: %d %d ", i, (int)matches[i].rm_so, (int)matches[i].rm_eo ); @@ -282,7 +283,7 @@ access_allowed( } } #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_ARGS, "\n" )); + LDAP_LOG( ACL, ARGS, "\n" , 0, 0, 0 ); #else Debug( LDAP_DEBUG_ARGS, "\n", 0, 0, 0 ); #endif @@ -301,9 +302,9 @@ vd_access: if ( ACL_IS_INVALID( mask ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1, - "access_allowed: conn %lu \"%s\" (%s) invalid!\n", - conn->c_connid, e->e_dn, attr )); + LDAP_LOG( ACL, DETAIL1, + "access_allowed: conn %lu \"%s\" (%s) invalid!\n", + conn->c_connid, e->e_dn, attr ); #else Debug( LDAP_DEBUG_ACL, "=> access_allowed: \"%s\" (%s) invalid!\n", @@ -313,9 +314,8 @@ vd_access: } else if ( control == ACL_BREAK ) { #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1, - "access_allowed: conn %lu no more rules\n", - conn->c_connid )); + LDAP_LOG( ACL, DETAIL1, + "access_allowed: conn %lu no more rules\n", conn->c_connid, 0,0 ); #else Debug( LDAP_DEBUG_ACL, "=> access_allowed: no more rules\n", 0, 0, 0); @@ -325,12 +325,10 @@ vd_access: } #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_ENTRY, - "access_allowed: conn %lu %s access %s by %s\n", - conn->c_connid, - access2str( access ), - ACL_GRANT( mask, access ) ? "granted" : "denied", - accessmask2str( mask, accessmaskbuf ) )); + LDAP_LOG( ACL, ENTRY, + "access_allowed: %s access %s by %s\n", + access2str( access ), ACL_GRANT( mask, access ) ? "granted" : "denied", + accessmask2str( mask, accessmaskbuf ) ); #else Debug( LDAP_DEBUG_ACL, "=> access_allowed: %s access %s by %s\n", @@ -398,9 +396,10 @@ acl_get( if ( a->acl_dn_pat.bv_len || ( a->acl_dn_style != ACL_STYLE_REGEX )) { if ( a->acl_dn_style == ACL_STYLE_REGEX ) { #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1, - "acl_get: dnpat [%d] %s nsub: %d\n", - *count, a->acl_dn_pat.bv_val, (int) a->acl_dn_re.re_nsub )); + LDAP_LOG( ACL, DETAIL1, + "acl_get: dnpat [%d] %s nsub: %d\n", + *count, a->acl_dn_pat.bv_val, + (int) a->acl_dn_re.re_nsub ); #else Debug( LDAP_DEBUG_ACL, "=> dnpat: [%d] %s nsub: %d\n", *count, a->acl_dn_pat.bv_val, (int) a->acl_dn_re.re_nsub ); @@ -410,9 +409,8 @@ acl_get( } else { #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1, - "acl_get: dn [%d] %s\n", - *count, a->acl_dn_pat.bv_val )); + LDAP_LOG( ACL, DETAIL1, "acl_get: dn [%d] %s\n", + *count, a->acl_dn_pat.bv_val, 0 ); #else Debug( LDAP_DEBUG_ACL, "=> dn: [%d] %s\n", *count, a->acl_dn_pat.bv_val, 0 ); @@ -455,9 +453,8 @@ acl_get( } #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1, - "acl_get: [%d] matched\n", - *count )); + LDAP_LOG( ACL, DETAIL1, + "acl_get: [%d] matched\n", *count, 0, 0 ); #else Debug( LDAP_DEBUG_ACL, "=> acl_get: [%d] matched\n", *count, 0, 0 ); @@ -472,9 +469,8 @@ acl_get( } #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1, - "acl_get: [%d] check attr %s\n", - *count, attr )); + LDAP_LOG( ACL, DETAIL1, + "acl_get: [%d] check attr %s\n", *count, attr ,0 ); #else Debug( LDAP_DEBUG_ACL, "=> acl_get: [%d] check attr %s\n", *count, attr, 0); @@ -483,9 +479,8 @@ acl_get( ad_inlist( desc, a->acl_attrs ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1, - "acl_get: [%d] acl %s attr: %s\n", - *count, e->e_dn, attr )); + LDAP_LOG( ACL, DETAIL1, + "acl_get: [%d] acl %s attr: %s\n", *count, e->e_dn, attr ); #else Debug( LDAP_DEBUG_ACL, "<= acl_get: [%d] acl %s attr: %s\n", @@ -497,8 +492,7 @@ acl_get( } #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_ENTRY, - "acl_get: done.\n" )); + LDAP_LOG( ACL, RESULTS, "acl_get: done.\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ACL, "<= acl_get: done.\n", 0, 0, 0 ); #endif @@ -559,15 +553,14 @@ acl_mask( assert( attr != NULL ); #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_ENTRY, - "acl_mask: conn %lu access to entry \"%s\", attr \"%s\" requested\n", - conn->c_connid, e->e_dn, attr )); - - LDAP_LOG(( "acl", LDAP_LEVEL_ARGS, - " to %s by \"%s\", (%s) \n", - val ? "value" : "all values", - op->o_ndn.bv_val ? op->o_ndn.bv_val : "", - accessmask2str( *mask, accessmaskbuf ) )); + LDAP_LOG( ACL, ENTRY, + "acl_mask: conn %lu access to entry \"%s\", attr \"%s\" requested\n", + conn->c_connid, e->e_dn, attr ); + + LDAP_LOG( ACL, ARGS, + " to %s by \"%s\", (%s) \n", val ? "value" : "all values", + op->o_ndn.bv_val ? op->o_ndn.bv_val : "", + accessmask2str( *mask, accessmaskbuf ) ); #else Debug( LDAP_DEBUG_ACL, "=> acl_mask: access to entry \"%s\", attr \"%s\" requested\n", @@ -599,9 +592,9 @@ acl_mask( /* AND <who> clauses */ if ( b->a_dn_pat.bv_len != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1, - "acl_mask: conn %lu check a_dn_pat: %s\n", - conn->c_connid, b->a_dn_pat.bv_val )); + LDAP_LOG( ACL, DETAIL1, + "acl_mask: conn %lu check a_dn_pat: %s\n", + conn->c_connid, b->a_dn_pat.bv_val ,0 ); #else Debug( LDAP_DEBUG_ACL, "<= check a_dn_pat: %s\n", b->a_dn_pat.bv_val, 0, 0); @@ -723,9 +716,9 @@ dn_match_cleanup:; if ( b->a_sockurl_pat.bv_len ) { #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1, + LDAP_LOG( ACL, DETAIL1, "acl_mask: conn %lu check a_sockurl_pat: %s\n", - conn->c_connid, b->a_sockurl_pat.bv_val )); + conn->c_connid, b->a_sockurl_pat.bv_val , 0 ); #else Debug( LDAP_DEBUG_ACL, "<= check a_sockurl_pat: %s\n", b->a_sockurl_pat.bv_val, 0, 0 ); @@ -747,9 +740,9 @@ dn_match_cleanup:; if ( b->a_domain_pat.bv_len ) { #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1, + LDAP_LOG( ACL, DETAIL1, "acl_mask: conn %lu check a_domain_pat: %s\n", - conn->c_connid, b->a_domain_pat.bv_val )); + conn->c_connid, b->a_domain_pat.bv_val , 0 ); #else Debug( LDAP_DEBUG_ACL, "<= check a_domain_pat: %s\n", b->a_domain_pat.bv_val, 0, 0 ); @@ -801,9 +794,9 @@ dn_match_cleanup:; if ( b->a_peername_pat.bv_len ) { #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1, + LDAP_LOG( ACL, DETAIL1, "acl_mask: conn %lu check a_perrname_path: %s\n", - conn->c_connid, b->a_peername_pat.bv_val )); + conn->c_connid, b->a_peername_pat.bv_val , 0 ); #else Debug( LDAP_DEBUG_ACL, "<= check a_peername_path: %s\n", b->a_peername_pat.bv_val, 0, 0 ); @@ -824,9 +817,9 @@ dn_match_cleanup:; if ( b->a_sockname_pat.bv_len ) { #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1, + LDAP_LOG( ACL, DETAIL1, "acl_mask: conn %lu check a_sockname_path: %s\n", - conn->c_connid, b->a_sockname_pat.bv_val )); + conn->c_connid, b->a_sockname_pat.bv_val , 0 ); #else Debug( LDAP_DEBUG_ACL, "<= check a_sockname_path: %s\n", b->a_sockname_pat.bv_val, 0, 0 ); @@ -859,9 +852,9 @@ dn_match_cleanup:; } #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1, + LDAP_LOG( ACL, DETAIL1, "acl_mask: conn %lu check a_dn_pat: %s\n", - conn->c_connid, attr )); + conn->c_connid, attr , 0 ); #else Debug( LDAP_DEBUG_ACL, "<= check a_dn_at: %s\n", attr, 0, 0); @@ -970,9 +963,9 @@ dn_match_cleanup:; if ( b->a_authz.sai_ssf ) { #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1, - "acl_mask: conn %lu check a_authz.sai_ssf: ACL %u > OP %u\n", - conn->c_connid, b->a_authz.sai_ssf, op->o_ssf )); + LDAP_LOG( ACL, DETAIL1, + "acl_mask: conn %lu check a_authz.sai_ssf: ACL %u > OP %u\n", + conn->c_connid, b->a_authz.sai_ssf, op->o_ssf ); #else Debug( LDAP_DEBUG_ACL, "<= check a_authz.sai_ssf: ACL %u > OP %u\n", b->a_authz.sai_ssf, op->o_ssf, 0 ); @@ -984,9 +977,11 @@ dn_match_cleanup:; if ( b->a_authz.sai_transport_ssf ) { #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1, - "acl_mask: conn %lu check a_authz.sai_transport_ssf: ACL %u > OP %u\n", - conn->c_connid, b->a_authz.sai_transport_ssf, op->o_transport_ssf )); + LDAP_LOG( ACL, DETAIL1, + "acl_mask: conn %lu check a_authz.sai_transport_ssf: " + "ACL %u > OP %u\n", + conn->c_connid, b->a_authz.sai_transport_ssf, + op->o_transport_ssf ); #else Debug( LDAP_DEBUG_ACL, "<= check a_authz.sai_transport_ssf: ACL %u > OP %u\n", @@ -999,9 +994,10 @@ dn_match_cleanup:; if ( b->a_authz.sai_tls_ssf ) { #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1, - "acl_mask: conn %lu check a_authz.sai_tls_ssf: ACL %u > OP %u\n", - conn->c_connid, b->a_authz.sai_tls_ssf, op->o_tls_ssf )); + LDAP_LOG( ACL, DETAIL1, + "acl_mask: conn %lu check a_authz.sai_tls_ssf: ACL %u > " + "OP %u\n", + conn->c_connid, b->a_authz.sai_tls_ssf, op->o_tls_ssf ); #else Debug( LDAP_DEBUG_ACL, "<= check a_authz.sai_tls_ssf: ACL %u > OP %u\n", @@ -1014,9 +1010,10 @@ dn_match_cleanup:; if ( b->a_authz.sai_sasl_ssf ) { #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1, - "acl_mask: conn %lu check a_authz.sai_sasl_ssf: ACL %u > OP %u\n", - conn->c_connid, b->a_authz.sai_sasl_ssf, op->o_sasl_ssf )); + LDAP_LOG( ACL, DETAIL1, + "acl_mask: conn %lu check a_authz.sai_sasl_ssf: " + "ACL %u > OP %u\n", + conn->c_connid, b->a_authz.sai_sasl_ssf, op->o_sasl_ssf ); #else Debug( LDAP_DEBUG_ACL, "<= check a_authz.sai_sasl_ssf: ACL %u > OP %u\n", @@ -1109,11 +1106,11 @@ dn_match_cleanup:; } #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_RESULTS, - "acl_mask: conn %lu [%d] applying %s (%s)\n", - conn->c_connid, i, accessmask2str( modmask, accessmaskbuf), + LDAP_LOG( ACL, RESULTS, + "acl_mask: [%d] applying %s (%s)\n", + i, accessmask2str( modmask, accessmaskbuf), b->a_type == ACL_CONTINUE ? "continue" : b->a_type == ACL_BREAK - ? "break" : "stop" )); + ? "break" : "stop" ); #else Debug( LDAP_DEBUG_ACL, "<= acl_mask: [%d] applying %s (%s)\n", @@ -1147,9 +1144,9 @@ dn_match_cleanup:; } #ifdef NEW_LOGGING - LDAP_LOG(( "aci", LDAP_LEVEL_DETAIL1, + LDAP_LOG( ACL, DETAIL1, "acl_mask: conn %lu [%d] mask: %s\n", - conn->c_connid, i, accessmask2str( *mask, accessmaskbuf) )); + conn->c_connid, i, accessmask2str( *mask, accessmaskbuf) ); #else Debug( LDAP_DEBUG_ACL, "<= acl_mask: [%d] mask: %s\n", @@ -1171,9 +1168,9 @@ dn_match_cleanup:; ACL_INIT(*mask); #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_RESULTS, + LDAP_LOG( ACL, RESULTS, "acl_mask: conn %lu no more <who> clauses, returning %d (stop)\n", - conn->c_connid, accessmask2str( *mask, accessmaskbuf) )); + conn->c_connid, accessmask2str( *mask, accessmaskbuf) , 0 ); #else Debug( LDAP_DEBUG_ACL, "<= acl_mask: no more <who> clauses, returning %s (stop)\n", @@ -1205,9 +1202,9 @@ acl_check_modlist( /* short circuit root database access */ if ( be_isroot( be, &op->o_ndn ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1, + LDAP_LOG( ACL, DETAIL1, "acl_check_modlist: conn %lu access granted to root user\n", - conn->c_connid )); + conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ACL, "<= acl_access_allowed: granted to database root\n", @@ -1219,10 +1216,11 @@ acl_check_modlist( /* use backend default access if no backend acls */ if( be != NULL && be->be_acl == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "aci", LDAP_LEVEL_DETAIL1, - "acl_check_modlist: conn %lu backend default %s access %s to \"%s\"\n", - conn->c_connid, access2str( ACL_WRITE ), - be->be_dfltaccess >= ACL_WRITE ? "granted" : "denied", op->o_dn.bv_val )); + LDAP_LOG( ACL, DETAIL1, + "acl_check_modlist: backend default %s access %s to \"%s\"\n", + access2str( ACL_WRITE ), + be->be_dfltaccess >= ACL_WRITE ? "granted" : "denied", + op->o_dn.bv_val ); #else Debug( LDAP_DEBUG_ACL, "=> access_allowed: backend default %s access %s to \"%s\"\n", @@ -1236,10 +1234,11 @@ acl_check_modlist( /* use global default access if no global acls */ } else if ( be == NULL && global_acl == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "aci", LDAP_LEVEL_DETAIL1, - "acl_check_modlist: conn %lu global default %s access %s to \"%s\"\n", - conn->c_connid, access2str( ACL_WRITE ), - global_default_access >= ACL_WRITE ? "granted" : "denied", op->o_dn )); + LDAP_LOG( ACL, DETAIL1, + "acl_check_modlist: global default %s access %s to \"%s\"\n", + access2str( ACL_WRITE ), + global_default_access >= ACL_WRITE ? "granted" : "denied", + op->o_dn ); #else Debug( LDAP_DEBUG_ACL, "=> access_allowed: global default %s access %s to \"%s\"\n", @@ -1261,9 +1260,9 @@ acl_check_modlist( */ if ( is_at_no_user_mod( mlist->sml_desc->ad_type ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "aci", LDAP_LEVEL_DETAIL1, + LDAP_LOG( ACL, DETAIL1, "acl_check_modlist: conn %lu no-user-mod %s: modify access granted\n", - conn->c_connid, mlist->sml_desc->ad_cname.bv_val )); + conn->c_connid, mlist->sml_desc->ad_cname.bv_val , 0 ); #else Debug( LDAP_DEBUG_ACL, "acl: no-user-mod %s:" " modify access granted\n", @@ -1825,7 +1824,8 @@ string_expand( flag = 0; for ( dp = bv->bv_val, sp = pat->bv_val; size < bv->bv_len && - sp < pat->bv_val + pat->bv_len ; sp++) { + sp < pat->bv_val + pat->bv_len ; sp++ ) + { /* did we previously see a $ */ if ( flag ) { if ( flag == 1 && *sp == '$' ) { @@ -1833,7 +1833,7 @@ string_expand( size++; flag = 0; - } else if ( flag == 1 && *sp == '{') { + } else if ( flag == 1 && *sp == '{' /*'}'*/) { flag = 2; } else if ( *sp >= '0' && *sp <= '9' ) { @@ -1844,13 +1844,13 @@ string_expand( n = *sp - '0'; if ( flag == 2 ) { - for ( sp++; *sp != '\0' && *sp != /* { */ '}'; sp++ ) { + for ( sp++; *sp != '\0' && *sp != /*'{'*/ '}'; sp++ ) { if ( *sp >= '0' && *sp <= '9' ) { n = 10*n + ( *sp - '0' ); } } - if ( *sp != /* { */ '}' ) { + if ( *sp != /*'{'*/ '}' ) { /* error */ } } @@ -1889,10 +1889,9 @@ string_expand( bv->bv_len = size; #ifdef NEW_LOGGING - LDAP_LOG(( "aci", LDAP_LEVEL_DETAIL1, - "string_expand: pattern = %.*s\n", (int)pat->bv_len, pat->bv_val )); - LDAP_LOG(( "aci", LDAP_LEVEL_DETAIL1, - "string_expand: expanded = %s\n", bv->bv_val )); + LDAP_LOG( ACL, DETAIL1, + "string_expand: pattern = %.*s\n", (int)pat->bv_len, pat->bv_val, 0 ); + LDAP_LOG( ACL, DETAIL1, "string_expand: expanded = %s\n", bv->bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "=> string_expand: pattern: %.*s\n", (int)pat->bv_len, pat->bv_val, 0 ); Debug( LDAP_DEBUG_TRACE, "=> string_expand: expanded: %s\n", bv->bv_val, 0, 0 ); @@ -1908,7 +1907,7 @@ regex_matches( ) { regex_t re; - char newbuf[512]; + char newbuf[ACL_BUF_SIZE]; struct berval bv; int rc; @@ -1919,13 +1918,13 @@ regex_matches( string_expand(&bv, pat, buf, matches); if (( rc = regcomp(&re, newbuf, REG_EXTENDED|REG_ICASE))) { - char error[512]; + char error[ACL_BUF_SIZE]; regerror(rc, &re, error, sizeof(error)); #ifdef NEW_LOGGING - LDAP_LOG(( "aci", LDAP_LEVEL_ERR, + LDAP_LOG( ACL, ERR, "regex_matches: compile( \"%s\", \"%s\") failed %s\n", - pat->bv_val, str, error )); + pat->bv_val, str, error ); #else Debug( LDAP_DEBUG_TRACE, "compile( \"%s\", \"%s\") failed %s\n", @@ -1938,11 +1937,9 @@ regex_matches( regfree( &re ); #ifdef NEW_LOGGING - LDAP_LOG(( "aci", LDAP_LEVEL_DETAIL2, - "regex_matches: string: %s\n", str )); - LDAP_LOG(( "aci", LDAP_LEVEL_DETAIL2, - "regex_matches: rc: %d %s\n", - rc, rc ? "matches" : "no matches" )); + LDAP_LOG( ACL, DETAIL2, "regex_matches: string: %s\n", str, 0, 0 ); + LDAP_LOG( ACL, DETAIL2, "regex_matches: rc: %d %s\n", + rc, rc ? "matches" : "no matches", 0 ); #else Debug( LDAP_DEBUG_TRACE, "=> regex_matches: string: %s\n", str, 0, 0 ); diff --git a/servers/slapd/aclparse.c b/servers/slapd/aclparse.c index 02703af4706bfa0f80dd51d884936b0a7a77f6db..51f0a0c1c3578712fda496e2b608caba4f4ad506 100644 --- a/servers/slapd/aclparse.c +++ b/servers/slapd/aclparse.c @@ -201,8 +201,7 @@ parse_acl( } if ( strcasecmp( left, "filter" ) == 0 ) { - if ( (a->acl_filter = str2filter( - right )) == NULL ) { + if ( (a->acl_filter = str2filter( right )) == NULL ) { fprintf( stderr, "%s: line %d: bad filter \"%s\" in to clause\n", fname, lineno, right ); @@ -227,7 +226,7 @@ parse_acl( } if ( a->acl_dn_pat.bv_len != 0 && - strcmp(a->acl_dn_pat.bv_val, "*") == 0) + strcmp(a->acl_dn_pat.bv_val, "*") == 0 ) { free( a->acl_dn_pat.bv_val ); a->acl_dn_pat.bv_val = NULL; @@ -1107,24 +1106,24 @@ accessmask2str( slap_mask_t mask, char *buf ) if ( ACL_IS_LEVEL( mask ) ) { if ( ACL_LVL_IS_NONE(mask) ) { - ptr = slap_strcopy( ptr, "none" ); + ptr = lutil_strcopy( ptr, "none" ); } else if ( ACL_LVL_IS_AUTH(mask) ) { - ptr = slap_strcopy( ptr, "auth" ); + ptr = lutil_strcopy( ptr, "auth" ); } else if ( ACL_LVL_IS_COMPARE(mask) ) { - ptr = slap_strcopy( ptr, "compare" ); + ptr = lutil_strcopy( ptr, "compare" ); } else if ( ACL_LVL_IS_SEARCH(mask) ) { - ptr = slap_strcopy( ptr, "search" ); + ptr = lutil_strcopy( ptr, "search" ); } else if ( ACL_LVL_IS_READ(mask) ) { - ptr = slap_strcopy( ptr, "read" ); + ptr = lutil_strcopy( ptr, "read" ); } else if ( ACL_LVL_IS_WRITE(mask) ) { - ptr = slap_strcopy( ptr, "write" ); + ptr = lutil_strcopy( ptr, "write" ); } else { - ptr = slap_strcopy( ptr, "unknown" ); + ptr = lutil_strcopy( ptr, "unknown" ); } *ptr++ = '('; diff --git a/servers/slapd/add.c b/servers/slapd/add.c index 48411f3b9908f69031daf99e51cca56aa3940f4f..b43e78105212e139b353cecd8cec865f62203463 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -50,8 +50,7 @@ do_add( Connection *conn, Operation *op ) int manageDSAit; #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, - "do_add: conn %d enter\n", conn->c_connid )); + LDAP_LOG( OPERATION, ENTRY, "do_add: conn %d enter\n", conn->c_connid,0,0 ); #else Debug( LDAP_DEBUG_TRACE, "do_add\n", 0, 0, 0 ); #endif @@ -70,8 +69,8 @@ do_add( Connection *conn, Operation *op ) /* get the name */ if ( ber_scanf( ber, "{m", /*}*/ &dn ) == LBER_ERROR ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "do_add: conn %d ber_scanf failed\n", conn->c_connid )); + LDAP_LOG( OPERATION, ERR, + "do_add: conn %d ber_scanf failed\n", conn->c_connid,0,0 ); #else Debug( LDAP_DEBUG_ANY, "do_add: ber_scanf failed\n", 0, 0, 0 ); #endif @@ -86,9 +85,8 @@ do_add( Connection *conn, Operation *op ) if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "do_add: conn %d invalid dn (%s)\n", conn->c_connid, - dn.bv_val )); + LDAP_LOG( OPERATION, ERR, + "do_add: conn %d invalid dn (%s)\n", conn->c_connid, dn.bv_val, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_add: invalid dn (%s)\n", dn.bv_val, 0, 0 ); #endif @@ -98,8 +96,8 @@ do_add( Connection *conn, Operation *op ) } #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ARGS, - "do_add: conn %d dn (%s)\n", conn->c_connid, e->e_dn )); + LDAP_LOG( OPERATION, ARGS, + "do_add: conn %d dn (%s)\n", conn->c_connid, e->e_dn, 0 ); #else Debug( LDAP_DEBUG_ARGS, "do_add: dn (%s)\n", e->e_dn, 0, 0 ); #endif @@ -115,8 +113,8 @@ do_add( Connection *conn, Operation *op ) if ( rtag == LBER_ERROR ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "do_add: conn %d decoding error \n", conn->c_connid )); + LDAP_LOG( OPERATION, ERR, + "do_add: conn %d decoding error \n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_add: decoding error\n", 0, 0, 0 ); #endif @@ -128,9 +126,9 @@ do_add( Connection *conn, Operation *op ) if ( tmp.sml_bvalues == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + LDAP_LOG( OPERATION, INFO, "do_add: conn %d no values for type %s\n", - conn->c_connid, tmp.sml_type.bv_val )); + conn->c_connid, tmp.sml_type.bv_val, 0 ); #else Debug( LDAP_DEBUG_ANY, "no values for type %s\n", tmp.sml_type.bv_val, 0, 0 ); @@ -153,8 +151,8 @@ do_add( Connection *conn, Operation *op ) if ( ber_scanf( ber, /*{*/ "}") == LBER_ERROR ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "do_add: conn %d ber_scanf failed\n", conn->c_connid )); + LDAP_LOG( OPERATION, ERR, + "do_add: conn %d ber_scanf failed\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_add: ber_scanf failed\n", 0, 0, 0 ); #endif @@ -166,8 +164,8 @@ do_add( Connection *conn, Operation *op ) if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, - "do_add: conn %d get_ctrls failed\n", conn->c_connid )); + LDAP_LOG( OPERATION, INFO, + "do_add: conn %d get_ctrls failed\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_add: get_ctrls failed\n", 0, 0, 0 ); #endif @@ -309,8 +307,8 @@ do_add( Connection *conn, Operation *op ) } } else { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, - "do_add: conn %d no backend support\n", conn->c_connid )); + LDAP_LOG( OPERATION, INFO, + "do_add: conn %d no backend support\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ARGS, " do_add: no backend support\n", 0, 0, 0 ); #endif diff --git a/servers/slapd/ava.c b/servers/slapd/ava.c index c521993c54bf3b9c66c667357e96ec052b9b444d..e0fdd8bb2e8decf242ae5c381d37f9d9d83996f9 100644 --- a/servers/slapd/ava.c +++ b/servers/slapd/ava.c @@ -44,8 +44,7 @@ get_ava( if( rtag == LBER_ERROR ) { #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ERR, - "get_ava: ber_scanf failure\n" )); + LDAP_LOG( FILTER, ERR, "get_ava: ber_scanf failure\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, " get_ava ber_scanf\n", 0, 0, 0 ); #endif diff --git a/servers/slapd/back-bdb/add.c b/servers/slapd/back-bdb/add.c index 98fa9b85665a0c0e60fbc89325a5879ce13856ac..983ddd9dba9c5c56ab6d25c083c8f70a85c7885c 100644 --- a/servers/slapd/back-bdb/add.c +++ b/servers/slapd/back-bdb/add.c @@ -41,7 +41,7 @@ bdb_add( #endif #ifdef NEW_LOGGING - LDAP_LOG (( "add", LDAP_LEVEL_ARGS, "==> bdb_add: %s\n", e->e_dn )); + LDAP_LOG ( OPERATION, ARGS, "==> bdb_add: %s\n", e->e_dn, 0, 0 ); #else Debug(LDAP_DEBUG_ARGS, "==> bdb_add: %s\n", e->e_dn, 0, 0); #endif @@ -50,7 +50,8 @@ bdb_add( rc = entry_schema_check( be, e, NULL, &text, textbuf, textlen ); if ( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG (( "add", LDAP_LEVEL_ERR, "bdb_add: entry failed schema check: %s (%d)\n", text, rc )); + LDAP_LOG ( OPERATION, ERR, + "bdb_add: entry failed schema check: %s (%d)\n", text, rc, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_add: entry failed schema check: %s (%d)\n", @@ -70,7 +71,8 @@ bdb_add( rc = bdb_next_id( be, NULL, &e->e_id ); if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "add", LDAP_LEVEL_ERR, "bdb_add: next_id failed (%d)\n", rc )); + LDAP_LOG ( OPERATION, ERR, + "bdb_add: next_id failed (%d)\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_add: next_id failed (%d)\n", @@ -100,7 +102,8 @@ retry: /* transaction retry */ text = NULL; if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "add", LDAP_LEVEL_ERR, "bdb_add: txn_begin failed: %s (%d)\n", db_strerror(rc), rc )); + LDAP_LOG ( OPERATION, ERR, + "bdb_add: txn_begin failed: %s (%d)\n", db_strerror(rc), rc, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_add: txn_begin failed: %s (%d)\n", @@ -182,7 +185,8 @@ retry: /* transaction retry */ } #ifdef NEW_LOGGING - LDAP_LOG (( "add", LDAP_LEVEL_DETAIL1, "bdb_add: parent does not exist\n" )); + LDAP_LOG ( OPERATION, DETAIL1, + "bdb_add: parent does not exist\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_add: parent does not exist\n", 0, 0, 0 ); @@ -211,7 +215,8 @@ retry: /* transaction retry */ if ( ! rc ) { #ifdef NEW_LOGGING - LDAP_LOG (( "add", LDAP_LEVEL_DETAIL1, "bdb_add: no write access to parent\n" )); + LDAP_LOG ( OPERATION, DETAIL1, + "bdb_add: no write access to parent\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_add: no write access to parent\n", 0, 0, 0 ); @@ -225,7 +230,8 @@ retry: /* transaction retry */ if ( is_entry_subentry( p ) ) { /* parent is a subentry, don't allow add */ #ifdef NEW_LOGGING - LDAP_LOG (( "add", LDAP_LEVEL_DETAIL1, "bdb_add: parent is subentry\n" )); + LDAP_LOG ( OPERATION, DETAIL1, + "bdb_add: parent is subentry\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_add: parent is subentry\n", 0, 0, 0 ); @@ -239,7 +245,8 @@ retry: /* transaction retry */ if ( is_entry_alias( p ) ) { /* parent is an alias, don't allow add */ #ifdef NEW_LOGGING - LDAP_LOG (( "add", LDAP_LEVEL_DETAIL1, "bdb_add: parent is alias\n" )); + LDAP_LOG ( OPERATION, DETAIL1, + "bdb_add: parent is alias\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_add: parent is alias\n", 0, 0, 0 ); @@ -256,7 +263,8 @@ retry: /* transaction retry */ BerVarray refs = get_entry_referrals( be, conn, op, p ); #ifdef NEW_LOGGING - LDAP_LOG (( "add", LDAP_LEVEL_DETAIL1, "bdb_add: parent is referral\n" )); + LDAP_LOG ( OPERATION, DETAIL1, + "bdb_add: parent is referral\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_add: parent is referral\n", 0, 0, 0 ); @@ -305,7 +313,8 @@ retry: /* transaction retry */ if ( ! rc ) { #ifdef NEW_LOGGING - LDAP_LOG (( "add", LDAP_LEVEL_DETAIL1, "bdb_add: no write access to parent\n" )); + LDAP_LOG ( OPERATION, DETAIL1, + "bdb_add: no write access to parent\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_add: no write access to parent\n", @@ -318,7 +327,8 @@ retry: /* transaction retry */ } else { #ifdef NEW_LOGGING - LDAP_LOG (( "add", LDAP_LEVEL_DETAIL1, "bdb_add: %s denied\n", pdn.bv_len == 0 ? "suffix" : "entry at root" )); + LDAP_LOG ( OPERATION, DETAIL1, "bdb_add: %s denied\n", + pdn.bv_len == 0 ? "suffix" : "entry at root", 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_add: %s denied\n", pdn.bv_len == 0 ? "suffix" : "entry at root", @@ -332,7 +342,8 @@ retry: /* transaction retry */ #ifdef BDB_SUBENTRIES if( subentry ) { #ifdef NEW_LOGGING - LDAP_LOG (( "add", LDAP_LEVEL_DETAIL1, "bdb_add: no parent, cannot add subentry\n" )); + LDAP_LOG ( OPERATION, DETAIL1, + "bdb_add: no parent, cannot add subentry\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_add: no parent, cannot add subentry\n", @@ -358,7 +369,8 @@ retry: /* transaction retry */ rc = bdb_dn2id_add( be, ltid, &pdn, e ); if ( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "add", LDAP_LEVEL_ERR, "bdb_add: dn2id_add failed: %s (%d)\n", db_strerror(rc), rc )); + LDAP_LOG ( OPERATION, ERR, + "bdb_add: dn2id_add failed: %s (%d)\n", db_strerror(rc), rc, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_add: dn2id_add failed: %s (%d)\n", db_strerror(rc), rc, 0 ); @@ -381,7 +393,7 @@ retry: /* transaction retry */ rc = bdb_id2entry_add( be, ltid, e ); if ( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "add", LDAP_LEVEL_ERR, "bdb_add: id2entry_add failed\n" )); + LDAP_LOG ( OPERATION, ERR, "bdb_add: id2entry_add failed\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_add: id2entry_add failed\n", 0, 0, 0 ); @@ -401,7 +413,8 @@ retry: /* transaction retry */ rc = bdb_index_entry_add( be, ltid, e, e->e_attrs ); if ( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG (( "add", LDAP_LEVEL_ERR, "bdb_add: index_entry_add failed\n" )); + LDAP_LOG ( OPERATION, ERR, + "bdb_add: index_entry_add failed\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_add: index_entry_add failed\n", 0, 0, 0 ); @@ -471,7 +484,9 @@ retry: /* transaction retry */ if (rc == LDAP_SUCCESS) { #ifdef NEW_LOGGING - LDAP_LOG (( "add", LDAP_LEVEL_RESULTS, "bdb_add: added%s id=%08lx dn=\"%s\"\n", op->o_noop ? " (no-op)" : "", e->e_id, e->e_dn )); + LDAP_LOG ( OPERATION, RESULTS, + "bdb_add: added%s id=%08lx dn=\"%s\"\n", + op->o_noop ? " (no-op)" : "", e->e_id, e->e_dn ); #else Debug(LDAP_DEBUG_TRACE, "bdb_add: added%s id=%08lx dn=\"%s\"\n", op->o_noop ? " (no-op)" : "", e->e_id, e->e_dn ); @@ -481,7 +496,8 @@ retry: /* transaction retry */ } else { #ifdef NEW_LOGGING - LDAP_LOG (( "add", LDAP_LEVEL_ERR, "bdb_add: %s : %s (%d)\n", text, db_strerror(rc), rc )); + LDAP_LOG ( OPERATION, ERR, + "bdb_add: %s : %s (%d)\n", text, db_strerror(rc), rc ); #else Debug( LDAP_DEBUG_TRACE, "bdb_add: %s : %s (%d)\n", text, db_strerror(rc), rc ); diff --git a/servers/slapd/back-bdb/attr.c b/servers/slapd/back-bdb/attr.c index c05cfc393390b46624cc01f5b3531c55d89ef096..b60f82c8dedb33932c0a708859016aa4bdb86804 100644 --- a/servers/slapd/back-bdb/attr.c +++ b/servers/slapd/back-bdb/attr.c @@ -181,9 +181,9 @@ bdb_attr_index_config( } #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, + LDAP_LOG( BACK_BDB, DETAIL1, "attr_index_config: index %s 0x%04lx\n", - ad->ad_cname.bv_val, mask )); + ad->ad_cname.bv_val, mask, 0 ); #else Debug( LDAP_DEBUG_CONFIG, "index %s 0x%04lx\n", ad->ad_cname.bv_val, mask, 0 ); diff --git a/servers/slapd/back-bdb/attribute.c b/servers/slapd/back-bdb/attribute.c index 1277f0256104f9addae957f37ed24829b19ed65a..b41177b4e74fdb4750091ca0a8c567b27646af43 100644 --- a/servers/slapd/back-bdb/attribute.c +++ b/servers/slapd/back-bdb/attribute.c @@ -43,13 +43,12 @@ bdb_attribute( DB_LOCK lock; #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_ARGS, - "bdb_attribute: gr dn: \"%s\"\n", entry_ndn->bv_val )); - LDAP_LOG(( "backend", LDAP_LEVEL_ARGS, - "bdb_attribute: at: \"%s\"\n", entry_at_name)); - LDAP_LOG(( "backend", LDAP_LEVEL_ARGS, - "bdb_attribute: tr dn: \"%s\"\n", - target ? target->e_ndn : "" )); + LDAP_LOG( BACK_BDB, ARGS, + "bdb_attribute: gr dn: \"%s\"\n", entry_ndn->bv_val, 0, 0 ); + LDAP_LOG( BACK_BDB, ARGS, + "bdb_attribute: at: \"%s\"\n", entry_at_name, 0, 0); + LDAP_LOG( BACK_BDB, ARGS, "bdb_attribute: tr dn: \"%s\"\n", + target ? target->e_ndn : "", 0, 0 ); #else Debug( LDAP_DEBUG_ARGS, "=> bdb_attribute: gr dn: \"%s\"\n", @@ -77,9 +76,8 @@ bdb_attribute( /* we already have a LOCKED copy of the entry */ e = target; #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "bdb_attribute: target is LOCKED (%s)\n", - entry_ndn->bv_val )); + LDAP_LOG( BACK_BDB, DETAIL1, + "bdb_attribute: target is LOCKED (%s)\n", entry_ndn->bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_ARGS, "=> bdb_attribute: target is entry: \"%s\"\n", @@ -109,9 +107,9 @@ dn2entry_retry: } if (e == NULL) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "bdb_attribute: cannot find entry (%s)\n", - entry_ndn->bv_val )); + LDAP_LOG( BACK_BDB, INFO, + "bdb_attribute: cannot find entry (%s)\n", + entry_ndn->bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_ACL, "=> bdb_attribute: cannot find entry: \"%s\"\n", @@ -124,9 +122,8 @@ dn2entry_retry: } #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "bdb_attribute: found entry (%s)\n", - entry_ndn->bv_val )); + LDAP_LOG( BACK_BDB, DETAIL1, "bdb_attribute: found entry (%s)\n", + entry_ndn->bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_ACL, "=> bdb_attribute: found entry: \"%s\"\n", @@ -138,8 +135,8 @@ dn2entry_retry: /* find attribute values */ if( is_entry_alias( e ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "bdb_attribute: entry (%s) is an alias\n", e->e_dn )); + LDAP_LOG( BACK_BDB, INFO, + "bdb_attribute: entry (%s) is an alias\n", e->e_dn, 0, 0 ); #else Debug( LDAP_DEBUG_ACL, "<= bdb_attribute: entry is an alias\n", 0, 0, 0 ); @@ -151,8 +148,8 @@ dn2entry_retry: if( is_entry_referral( e ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "bdb_attribute: entry (%s) is a referral.\n", e->e_dn )); + LDAP_LOG( BACK_BDB, INFO, + "bdb_attribute: entry (%s) is a referral.\n", e->e_dn, 0, 0); #else Debug( LDAP_DEBUG_ACL, "<= bdb_attribute: entry is a referral\n", 0, 0, 0 ); @@ -171,8 +168,8 @@ dn2entry_retry: if ((attr = attr_find(e->e_attrs, entry_at)) == NULL) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "bdb_attribute: failed to find %s.\n", entry_at_name )); + LDAP_LOG( BACK_BDB, INFO, + "bdb_attribute: failed to find %s.\n", entry_at_name, 0, 0 ); #else Debug( LDAP_DEBUG_ACL, "<= bdb_attribute: failed to find %s\n", @@ -231,9 +228,7 @@ return_results: } #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY, - "bdb_attribute: rc=%d nvals=%d.\n", - rc, j )); + LDAP_LOG( BACK_BDB, ENTRY, "bdb_attribute: rc=%d nvals=%d.\n", rc, j, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_attribute: rc=%d nvals=%d\n", diff --git a/servers/slapd/back-bdb/bind.c b/servers/slapd/back-bdb/bind.c index be64c5b6a8c90ca587a63b51cbf81943868bf619..ebd4880642383e15872e3fc971ed94ef295cfc55 100644 --- a/servers/slapd/back-bdb/bind.c +++ b/servers/slapd/back-bdb/bind.c @@ -44,7 +44,7 @@ bdb_bind( DB_LOCK lock; #ifdef NEW_LOGGING - LDAP_LOG (( "bind", LDAP_LEVEL_ARGS, "==> bdb_bind: dn: %s\n", dn->bv_val )); + LDAP_LOG ( OPERATION, ARGS, "==> bdb_bind: dn: %s\n", dn->bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_ARGS, "==> bdb_bind: dn: %s\n", dn->bv_val, 0, 0); #endif @@ -134,7 +134,8 @@ dn2entry_retry: if ( is_entry_subentry( e ) ) { /* entry is an subentry, don't allow bind */ #ifdef NEW_LOGGING - LDAP_LOG (( "bind", LDAP_LEVEL_DETAIL1, "bdb_bind: entry is subentry\n" )); + LDAP_LOG ( OPERATION, DETAIL1, + "bdb_bind: entry is subentry\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "entry is subentry\n", 0, 0, 0 ); @@ -151,7 +152,7 @@ dn2entry_retry: if ( is_entry_alias( e ) ) { /* entry is an alias, don't allow bind */ #ifdef NEW_LOGGING - LDAP_LOG (( "bind", LDAP_LEVEL_DETAIL1, "bdb_bind: entry is alias\n" )); + LDAP_LOG ( OPERATION, DETAIL1, "bdb_bind: entry is alias\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "entry is alias\n", 0, 0, 0 ); @@ -170,7 +171,8 @@ dn2entry_retry: conn, op, e ); #ifdef NEW_LOGGING - LDAP_LOG (( "bind", LDAP_LEVEL_DETAIL1, "bdb_bind: entry is referral\n" )); + LDAP_LOG ( OPERATION, DETAIL1, + "bdb_bind: entry is referral\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0, 0, 0 ); diff --git a/servers/slapd/back-bdb/cache.c b/servers/slapd/back-bdb/cache.c index 18854548fed61a6764105066e3f1d7348f53a697..8f20bcee6ff0f1b9559a3a91b98d3d7f815cc12d 100644 --- a/servers/slapd/back-bdb/cache.c +++ b/servers/slapd/back-bdb/cache.c @@ -49,9 +49,9 @@ static int bdb_cache_entry_rdwr_lock(Entry *e, int rw) { #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_ENTRY, - "bdb_cache_entry_rdwr_lock: %s lock on ID %ld\n", - rw ? "w" : "r", e->e_id )); + LDAP_LOG( CACHE, ENTRY, + "bdb_cache_entry_rdwr_lock: %s lock on ID %ld\n", + rw ? "w" : "r", e->e_id, 0 ); #else Debug( LDAP_DEBUG_ARGS, "entry_rdwr_%slock: ID: %ld\n", rw ? "w" : "r", e->e_id, 0); @@ -67,9 +67,9 @@ static int bdb_cache_entry_rdwr_trylock(Entry *e, int rw) { #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_ENTRY, - "bdb_cache_entry_rdwr_trylock: try %s lock on ID: %ld.\n", - rw ? "w" : "r", e->e_id )); + LDAP_LOG( CACHE, ENTRY, + "bdb_cache_entry_rdwr_trylock: try %s lock on ID: %ld.\n", + rw ? "w" : "r", e->e_id, 0 ); #else Debug( LDAP_DEBUG_ARGS, "entry_rdwr_%strylock: ID: %ld\n", rw ? "w" : "r", e->e_id, 0); @@ -85,9 +85,9 @@ static int bdb_cache_entry_rdwr_unlock(Entry *e, int rw) { #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_ENTRY, - "bdb_cache_entry_rdwr_unlock: remove %s lock on ID %ld.\n", - rw ? "w" : "r", e->e_id )); + LDAP_LOG( CACHE, ENTRY, + "bdb_cache_entry_rdwr_unlock: remove %s lock on ID %ld.\n", + rw ? "w" : "r", e->e_id, 0 ); #else Debug( LDAP_DEBUG_ARGS, "entry_rdwr_%sunlock: ID: %ld\n", rw ? "w" : "r", e->e_id, 0); @@ -232,9 +232,9 @@ bdb_unlocked_cache_return_entry_rw( Cache *cache, Entry *e, int rw ) ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock ); #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1, + LDAP_LOG( CACHE, DETAIL1, "bdb_unlocked_cache_return_entry_rw: return (%ld):%s, refcnt=%d\n", - id, rw ? "w" : "r", refcnt )); + id, rw ? "w" : "r", refcnt ); #else Debug( LDAP_DEBUG_TRACE, "====> bdb_unlocked_cache_return_entry_%s( %ld ): created (%d)\n", @@ -248,9 +248,9 @@ bdb_unlocked_cache_return_entry_rw( Cache *cache, Entry *e, int rw ) ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock ); #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1, + LDAP_LOG( CACHE, DETAIL1, "bdb_unlocked_cache_return_entry_rw: %ld, delete pending (%d).\n", - id, refcnt )); + id, refcnt, 0 ); #else Debug( LDAP_DEBUG_TRACE, "====> bdb_unlocked_cache_return_entry_%s( %ld ): delete pending (%d)\n", @@ -267,9 +267,9 @@ bdb_unlocked_cache_return_entry_rw( Cache *cache, Entry *e, int rw ) ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock ); #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1, + LDAP_LOG( CACHE, DETAIL1, "bdb_unlocked_cache_return_entry_rw: (%ld): deleted (%d)\n", - id, refcnt )); + id, refcnt, 0 ); #else Debug( LDAP_DEBUG_TRACE, "====> bdb_unlocked_cache_return_entry_%s( %ld ): deleted (%d)\n", @@ -282,9 +282,9 @@ bdb_unlocked_cache_return_entry_rw( Cache *cache, Entry *e, int rw ) ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock ); #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1, + LDAP_LOG( CACHE, DETAIL1, "bdb_unlocked_cache_return_entry_rw: ID %ld:%s returned (%d)\n", - id, rw ? "w": "r", refcnt )); + id, rw ? "w": "r", refcnt ); #else Debug( LDAP_DEBUG_TRACE, "====> bdb_unlocked_cache_return_entry_%s( %ld ): returned (%d)\n", @@ -335,9 +335,9 @@ bdb_cache_return_entry_rw ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock ); #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1, + LDAP_LOG( CACHE, DETAIL1, "bdb_cache_return_entry_rw: return (%ld):%s, refcnt=%d\n", - id, rw ? "w" : "r", refcnt )); + id, rw ? "w" : "r", refcnt ); #else Debug( LDAP_DEBUG_TRACE, "====> bdb_cache_return_entry_%s( %ld ): created (%d)\n", @@ -351,9 +351,9 @@ bdb_cache_return_entry_rw ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock ); #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1, + LDAP_LOG( CACHE, DETAIL1, "bdb_cache_return_entry_rw: %ld, delete pending (%d).\n", - id, refcnt )); + id, refcnt, 0 ); #else Debug( LDAP_DEBUG_TRACE, "====> bdb_cache_return_entry_%s( %ld ): delete pending (%d)\n", @@ -370,9 +370,9 @@ bdb_cache_return_entry_rw ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock ); #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1, + LDAP_LOG( CACHE, DETAIL1, "bdb_cache_return_entry_rw: (%ld): deleted (%d)\n", - id, refcnt )); + id, refcnt, 0 ); #else Debug( LDAP_DEBUG_TRACE, "====> bdb_cache_return_entry_%s( %ld ): deleted (%d)\n", @@ -385,9 +385,9 @@ bdb_cache_return_entry_rw ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock ); #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1, + LDAP_LOG( CACHE, DETAIL1, "bdb_cache_return_entry_rw: ID %ld:%s returned (%d)\n", - id, rw ? "w": "r", refcnt )); + id, rw ? "w": "r", refcnt ); #else Debug( LDAP_DEBUG_TRACE, "====> bdb_cache_return_entry_%s( %ld ): returned (%d)\n", @@ -442,9 +442,9 @@ bdb_cache_add_entry_rw( Entry *ee; #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_ENTRY, - "bdb_cache_add_entry_rw: add (%s):%s to cache\n", - e->e_dn, rw ? "w" : "r" )); + LDAP_LOG( CACHE, ENTRY, + "bdb_cache_add_entry_rw: add (%s):%s to cache\n", + e->e_dn, rw ? "w" : "r", 0 ); #endif /* set cache write lock */ ldap_pvt_thread_rdwr_wlock( &cache->c_rwlock ); @@ -456,9 +456,9 @@ bdb_cache_add_entry_rw( ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock ); #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_ERR, - "bdb_cache_add_entry_rw: add (%s):%ld private init failed!\n", - e->e_dn, e->e_id )); + LDAP_LOG( CACHE, ERR, + "bdb_cache_add_entry_rw: add (%s):%ld private init failed!\n", + e->e_dn, e->e_id, 0 ); #else Debug( LDAP_DEBUG_ANY, "====> bdb_cache_add_entry( %ld ): \"%s\": private init failed!\n", @@ -476,9 +476,9 @@ bdb_cache_add_entry_rw( ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock ); #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1, - "bdb_cache_add_entry: (%s):%ld already in cache.\n", - e->e_dn, e->e_id )); + LDAP_LOG( CACHE, DETAIL1, + "bdb_cache_add_entry: (%s):%ld already in cache.\n", + e->e_dn, e->e_id, 0 ); #else Debug( LDAP_DEBUG_TRACE, "====> bdb_cache_add_entry( %ld ): \"%s\": already in dn cache\n", @@ -495,9 +495,9 @@ bdb_cache_add_entry_rw( (AVL_CMP) entry_id_cmp, avl_dup_error ) != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1, - "bdb_cache_add_entry: (%s):%ls already in cache.\n", - e->e_dn, e->e_id )); + LDAP_LOG( CACHE, DETAIL1, + "bdb_cache_add_entry: (%s):%ls already in cache.\n", + e->e_dn, e->e_id, 0 ); #else Debug( LDAP_DEBUG_ANY, "====> bdb_cache_add_entry( %ld ): \"%s\": already in id cache\n", @@ -509,9 +509,9 @@ bdb_cache_add_entry_rw( (AVL_CMP) entry_dn_cmp ) == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_INFO, - "bdb_cache_add_entry: can't delete (%s) from cache.\n", - e->e_dn )); + LDAP_LOG( CACHE, INFO, + "bdb_cache_add_entry: can't delete (%s) from cache.\n", + e->e_dn, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "====> can't delete from dn cache\n", 0, 0, 0 ); @@ -535,8 +535,9 @@ bdb_cache_add_entry_rw( if ( avl_delete( &cache->c_idtree, (caddr_t) e, (AVL_CMP) entry_id_cmp ) == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_INFO, - "bdb_cache_add_entry: can't delete (%s) from cache.\n", e->e_dn )); + LDAP_LOG( CACHE, INFO, + "bdb_cache_add_entry: can't delete (%s) from cache.\n", + e->e_dn, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "====> can't delete from id cache\n", 0, 0, 0 ); #endif @@ -544,8 +545,9 @@ bdb_cache_add_entry_rw( if ( avl_delete( &cache->c_dntree, (caddr_t) e, (AVL_CMP) entry_dn_cmp ) == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_INFO, - "bdb_cache_add_entry: can't delete (%s) from cache.\n", e->e_dn )); + LDAP_LOG( CACHE, INFO, + "bdb_cache_add_entry: can't delete (%s) from cache.\n", + e->e_dn, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "====> can't delete from dn cache\n", 0, 0, 0 ); #endif @@ -633,9 +635,9 @@ bdb_cache_update_entry( (AVL_CMP) entry_dn_cmp, avl_dup_error ) != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1, - "bdb_cache_update_entry: (%s):%ld already in dn cache\n", - e->e_dn, e->e_id )); + LDAP_LOG( CACHE, DETAIL1, + "bdb_cache_update_entry: (%s):%ld already in dn cache\n", + e->e_dn, e->e_id, 0 ); #else Debug( LDAP_DEBUG_TRACE, "====> bdb_cache_update_entry( %ld ): \"%s\": already in dn cache\n", @@ -652,9 +654,9 @@ bdb_cache_update_entry( (AVL_CMP) entry_id_cmp, avl_dup_error ) != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1, - "bdb_cache_update_entry: (%s)%ld already in id cache\n", - e->e_dn, e->e_id )); + LDAP_LOG( CACHE, DETAIL1, + "bdb_cache_update_entry: (%s)%ld already in id cache\n", + e->e_dn, e->e_id, 0 ); #else Debug( LDAP_DEBUG_ANY, "====> bdb_cache_update_entry( %ld ): \"%s\": already in id cache\n", @@ -666,9 +668,9 @@ bdb_cache_update_entry( (AVL_CMP) entry_dn_cmp ) == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_INFO, - "bdb_cache_update_entry: can't delete (%s)%ld from dn cache.\n", - e->e_dn, e->e_id )); + LDAP_LOG( CACHE, INFO, + "bdb_cache_update_entry: can't delete (%s)%ld from dn cache.\n", + e->e_dn, e->e_id, 0 ); #else Debug( LDAP_DEBUG_ANY, "====> can't delete from dn cache\n", 0, 0, 0 ); @@ -778,9 +780,9 @@ try_again: ldap_pvt_thread_rdwr_runlock( &cache->c_rwlock ); #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_INFO, - "bdb_cache_find_entry_dn2id: (%s) %ld not ready: %d\n", - ndn->bv_val, id, state )); + LDAP_LOG( CACHE, INFO, + "bdb_cache_find_entry_dn2id: (%s) %ld not ready: %d\n", + ndn->bv_val, id, state ); #else Debug(LDAP_DEBUG_TRACE, "====> bdb_cache_find_entry_dn2id(\"%s\"): %ld (not ready) %d\n", @@ -806,9 +808,9 @@ try_again: ldap_pvt_thread_mutex_unlock( &cache->lru_mutex ); #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1, - "bdb_cache_find_entry_dn2id: (%s): %ld %d tries\n", - ndn->bv_val, id, count )); + LDAP_LOG( CACHE, DETAIL1, + "bdb_cache_find_entry_dn2id: (%s): %ld %d tries\n", + ndn->bv_val, id, count ); #else Debug(LDAP_DEBUG_TRACE, "====> bdb_cache_find_entry_dn2id(\"%s\"): %ld (%d tries)\n", @@ -874,9 +876,9 @@ try_again: ldap_pvt_thread_rdwr_runlock( &cache->c_rwlock ); #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_INFO, - "bdb_cache_find_entry_id: (%ld)->%ld not ready (%d).\n", - id, ep_id, state )); + LDAP_LOG( CACHE, INFO, + "bdb_cache_find_entry_id: (%ld)->%ld not ready (%d).\n", + id, ep_id, state ); #else Debug(LDAP_DEBUG_TRACE, @@ -905,9 +907,9 @@ try_again: ldap_pvt_thread_rdwr_runlock( &cache->c_rwlock ); #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_INFO, - "bdb_cache_find_entry_id: %ld -> %ld (busy) %d.\n", - id, ep_id, state )); + LDAP_LOG( CACHE, INFO, + "bdb_cache_find_entry_id: %ld -> %ld (busy) %d.\n", + id, ep_id, state ); #else Debug(LDAP_DEBUG_TRACE, "====> bdb_cache_find_entry_id( %ld ): %ld (busy) %d\n", @@ -935,9 +937,9 @@ try_again: ldap_pvt_thread_mutex_unlock( &cache->lru_mutex ); #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1, - "bdb_cache_find_entry_id: %ld -> %s found %d tries.\n", - ep_id, ep->e_dn, count )); + LDAP_LOG( CACHE, DETAIL1, + "bdb_cache_find_entry_id: %ld -> %s found %d tries.\n", + ep_id, ep->e_dn, count ); #else Debug(LDAP_DEBUG_TRACE, "====> bdb_cache_find_entry_id( %ld ) \"%s\" (found) (%d tries)\n", @@ -979,8 +981,8 @@ bdb_cache_delete_entry( assert( e->e_private ); #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_ENTRY, - "bdb_cache_delete_entry: delete %ld.\n", e->e_id )); + LDAP_LOG( CACHE, ENTRY, + "bdb_cache_delete_entry: delete %ld.\n", e->e_id, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "====> bdb_cache_delete_entry( %ld )\n", e->e_id, 0, 0 ); @@ -1047,8 +1049,7 @@ bdb_cache_release_all( Cache *cache ) ldap_pvt_thread_mutex_lock( &cache->lru_mutex ); #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_ENTRY, - "bdb_cache_release_all: enter\n" )); + LDAP_LOG( CACHE, ENTRY, "bdb_cache_release_all: enter\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "====> bdb_cache_release_all\n", 0, 0, 0 ); #endif @@ -1067,8 +1068,8 @@ bdb_cache_release_all( Cache *cache ) if ( cache->c_cursize ) { #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_INFO, - "bdb_cache_release_all: Entry cache could not be emptied.\n" )); + LDAP_LOG( CACHE, INFO, + "bdb_cache_release_all: Entry cache could not be emptied.\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "Entry-cache could not be emptied\n", 0, 0, 0 ); #endif diff --git a/servers/slapd/back-bdb/compare.c b/servers/slapd/back-bdb/compare.c index ac799bb62777791701da86b2cd90c090a076f781..25c8cf4f9554480bd81db6913ce5238dda08b2ba 100644 --- a/servers/slapd/back-bdb/compare.c +++ b/servers/slapd/back-bdb/compare.c @@ -88,7 +88,8 @@ dn2entry_retry: conn, op, e ); #ifdef NEW_LOGGING - LDAP_LOG (( "compare", LDAP_LEVEL_DETAIL1,"bdb_compare: entry is referral\n" )); + LDAP_LOG ( OPERATION, DETAIL1, + "bdb_compare: entry is referral\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0, 0, 0 ); diff --git a/servers/slapd/back-bdb/dbcache.c b/servers/slapd/back-bdb/dbcache.c index 85ed700fbba42bed33ffe66a739e4ad5c323f394..68efe9aad4b977a75807bbf050943257f318960e 100644 --- a/servers/slapd/back-bdb/dbcache.c +++ b/servers/slapd/back-bdb/dbcache.c @@ -87,7 +87,9 @@ bdb_db_cache( rc = db_create( &db->bdi_db, bdb->bi_dbenv, 0 ); if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "dbcache", LDAP_LEVEL_ERR, "bdb_db_cache: db_create(%s) failed: %s (%d)\n", bdb->bi_dbenv_home, db_strerror(rc), rc )); + LDAP_LOG ( CACHE, ERR, + "bdb_db_cache: db_create(%s) failed: %s (%d)\n", + bdb->bi_dbenv_home, db_strerror(rc), rc ); #else Debug( LDAP_DEBUG_ANY, "bdb_db_cache: db_create(%s) failed: %s (%d)\n", @@ -116,7 +118,9 @@ bdb_db_cache( if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "dbcache", LDAP_LEVEL_ERR, "bdb_db_cache: db_open(%s) failed: %s (%d)\n", name, db_strerror(rc), rc )); + LDAP_LOG ( CACHE, ERR, + "bdb_db_cache: db_open(%s) failed: %s (%d)\n", + name, db_strerror(rc), rc ); #else Debug( LDAP_DEBUG_ANY, "bdb_db_cache: db_open(%s) failed: %s (%d)\n", diff --git a/servers/slapd/back-bdb/delete.c b/servers/slapd/back-bdb/delete.c index 8c26e9a08054771297a633e2cfe9b428ed46f2b7..c15662b15d8b494a1c48e5c8b4a00618f71e51c4 100644 --- a/servers/slapd/back-bdb/delete.c +++ b/servers/slapd/back-bdb/delete.c @@ -42,8 +42,7 @@ bdb_delete( #endif #ifdef NEW_LOGGING - LDAP_LOG (( "delete", LDAP_LEVEL_ARGS, "==> bdb_delete: %s\n", - dn->bv_val )); + LDAP_LOG ( OPERATION, ARGS, "==> bdb_delete: %s\n", dn->bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_ARGS, "==> bdb_delete: %s\n", dn->bv_val, 0, 0 ); @@ -55,8 +54,8 @@ retry: /* transaction retry */ bdb_unlocked_cache_return_entry_w(&bdb->bi_cache, e); } #ifdef NEW_LOGGING - LDAP_LOG (( "delete", LDAP_LEVEL_DETAIL1, - "==> bdb_delete: retrying...\n" )); + LDAP_LOG ( OPERATION, DETAIL1, + "==> bdb_delete: retrying...\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "==> bdb_delete: retrying...\n", 0, 0, 0 ); @@ -78,9 +77,9 @@ retry: /* transaction retry */ text = NULL; if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "delete", LDAP_LEVEL_ERR, + LDAP_LOG ( OPERATION, ERR, "==> bdb_delete: txn_begin failed: %s (%d)\n", - db_strerror(rc), rc )); + db_strerror(rc), rc, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_delete: txn_begin failed: %s (%d)\n", @@ -136,8 +135,8 @@ retry: /* transaction retry */ if( p == NULL) { #ifdef NEW_LOGGING - LDAP_LOG (( "delete", LDAP_LEVEL_DETAIL1, - "<=- bdb_delete: parent does not exist\n" )); + LDAP_LOG ( OPERATION, DETAIL1, + "<=- bdb_delete: parent does not exist\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<=- bdb_delete: parent does not exist\n", @@ -163,8 +162,8 @@ retry: /* transaction retry */ if ( !rc ) { #ifdef NEW_LOGGING - LDAP_LOG (( "delete", LDAP_LEVEL_DETAIL1, - "<=- bdb_delete: no access to parent\n" )); + LDAP_LOG ( OPERATION, DETAIL1, + "<=- bdb_delete: no access to parent\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<=- bdb_delete: no access to parent\n", @@ -194,8 +193,8 @@ retry: /* transaction retry */ if ( !rc ) { #ifdef NEW_LOGGING - LDAP_LOG (( "delete", LDAP_LEVEL_DETAIL1, - "<=- bdb_delete: no access to parent\n" )); + LDAP_LOG ( OPERATION, DETAIL1, + "<=- bdb_delete: no access to parent\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<=- bdb_delete: no access " @@ -207,8 +206,8 @@ retry: /* transaction retry */ } else { #ifdef NEW_LOGGING - LDAP_LOG (( "delete", LDAP_LEVEL_DETAIL1, - "<=- bdb_delete: no parent and not root\n" )); + LDAP_LOG ( OPERATION, DETAIL1, + "<=- bdb_delete: no parent and not root\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<=- bdb_delete: no parent " @@ -254,9 +253,8 @@ retry: /* transaction retry */ BerVarray refs; #ifdef NEW_LOGGING - LDAP_LOG (( "delete", LDAP_LEVEL_ARGS, - "<=- bdb_delete: no such object %s\n", - dn->bv_val )); + LDAP_LOG ( OPERATION, ARGS, + "<=- bdb_delete: no such object %s\n", dn->bv_val, 0, 0); #else Debug( LDAP_DEBUG_ARGS, "<=- bdb_delete: no such object %s\n", @@ -292,8 +290,8 @@ retry: /* transaction retry */ conn, op, e ); #ifdef NEW_LOGGING - LDAP_LOG (( "delete", LDAP_LEVEL_DETAIL1, - "<=- bdb_delete: entry is referral\n" )); + LDAP_LOG ( OPERATION, DETAIL1, + "<=- bdb_delete: entry is referral\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_delete: entry is referral\n", @@ -317,9 +315,8 @@ retry: /* transaction retry */ goto retry; case 0: #ifdef NEW_LOGGING - LDAP_LOG (( "delete", LDAP_LEVEL_DETAIL1, - "<=- bdb_delete: non-leaf %s\n", - dn->bv_val )); + LDAP_LOG ( OPERATION, DETAIL1, + "<=- bdb_delete: non-leaf %s\n", dn->bv_val, 0, 0 ); #else Debug(LDAP_DEBUG_ARGS, "<=- bdb_delete: non-leaf %s\n", @@ -330,9 +327,9 @@ retry: /* transaction retry */ break; default: #ifdef NEW_LOGGING - LDAP_LOG (( "delete", LDAP_LEVEL_ERR, + LDAP_LOG ( OPERATION, ERR, "<=- bdb_delete: has_children failed %s (%d)\n", - db_strerror(rc), rc )); + db_strerror(rc), rc, 0 ); #else Debug(LDAP_DEBUG_ARGS, "<=- bdb_delete: has_children failed: %s (%d)\n", @@ -355,9 +352,8 @@ retry: /* transaction retry */ rc = LDAP_OTHER; } #ifdef NEW_LOGGING - LDAP_LOG (( "delete", LDAP_LEVEL_ERR, - "<=- bdb_delete: dn2id failed %s (%d)\n", - db_strerror(rc), rc )); + LDAP_LOG ( OPERATION, ERR, + "<=- bdb_delete: dn2id failed %s (%d)\n", db_strerror(rc), rc, 0 ); #else Debug(LDAP_DEBUG_ARGS, "<=- bdb_delete: dn2id failed: %s (%d)\n", @@ -378,9 +374,9 @@ retry: /* transaction retry */ rc = LDAP_OTHER; } #ifdef NEW_LOGGING - LDAP_LOG (( "delete", LDAP_LEVEL_ERR, - "<=- bdb_delete: id2entry failed: %s (%d)\n", - db_strerror(rc), rc )); + LDAP_LOG ( OPERATION, ERR, + "<=- bdb_delete: id2entry failed: %s (%d)\n", + db_strerror(rc), rc, 0 ); #else Debug(LDAP_DEBUG_ARGS, "<=- bdb_delete: id2entry failed: %s (%d)\n", @@ -401,8 +397,8 @@ retry: /* transaction retry */ rc = LDAP_OTHER; } #ifdef NEW_LOGGING - LDAP_LOG (( "delete", LDAP_LEVEL_ERR, - "<=- bdb_delete: entry index delete failed!\n" )); + LDAP_LOG ( OPERATION, ERR, + "<=- bdb_delete: entry index delete failed!\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "entry index delete failed!\n", 0, 0, 0 ); @@ -429,10 +425,9 @@ retry: /* transaction retry */ if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "delete", LDAP_LEVEL_ERR, + LDAP_LOG ( OPERATION, ERR, "bdb_delete: txn_%s failed: %s (%d)\n", - op->o_noop ? "abort (no-op)" : "commit", - db_strerror(rc), rc )); + op->o_noop ? "abort (no-op)" : "commit", db_strerror(rc), rc ); #else Debug( LDAP_DEBUG_TRACE, "bdb_delete: txn_%s failed: %s (%d)\n", @@ -444,10 +439,9 @@ retry: /* transaction retry */ } else { #ifdef NEW_LOGGING - LDAP_LOG (( "delete", LDAP_LEVEL_RESULTS, + LDAP_LOG ( OPERATION, RESULTS, "bdb_delete: deleted%s id=%08lx db=\"%s\"\n", - op->o_noop ? " (no-op)" : "", - e->e_id, e->e_dn )); + op->o_noop ? " (no-op)" : "", e->e_id, e->e_dn ); #else Debug( LDAP_DEBUG_TRACE, "bdb_delete: deleted%s id=%08lx dn=\"%s\"\n", diff --git a/servers/slapd/back-bdb/dn2entry.c b/servers/slapd/back-bdb/dn2entry.c index 497514113050e57a51ed8ceefc2739dff0c994da..c2817e23b22104671732c539b0c06adff54c940b 100644 --- a/servers/slapd/back-bdb/dn2entry.c +++ b/servers/slapd/back-bdb/dn2entry.c @@ -12,6 +12,7 @@ #include "back-bdb.h" + /* * dn2entry - look up dn in the cache/indexes and return the corresponding * entry. @@ -33,8 +34,7 @@ bdb_dn2entry_rw( ID id, id2 = 0; #ifdef NEW_LOGGING - LDAP_LOG (( "db2entry", LDAP_LEVEL_ARGS, "bdb_dn2entry_rw(\"%s\")\n", - dn->bv_val )); + LDAP_LOG ( CACHE, ARGS, "bdb_dn2entry_rw(\"%s\")\n", dn->bv_val, 0, 0 ); #else Debug(LDAP_DEBUG_TRACE, "bdb_dn2entry_rw(\"%s\")\n", dn->bv_val, 0, 0 ); diff --git a/servers/slapd/back-bdb/dn2id.c b/servers/slapd/back-bdb/dn2id.c index ea63172b6aa7f11d0a9b3197908f3116c66d53a5..4e8d02cd60aab4b6439f1344fdb8379d78de9ad8 100644 --- a/servers/slapd/back-bdb/dn2id.c +++ b/servers/slapd/back-bdb/dn2id.c @@ -29,8 +29,8 @@ bdb_dn2id_add( struct berval ptr, pdn; #ifdef NEW_LOGGING - LDAP_LOG (( "db2id", LDAP_LEVEL_ARGS, "bdb_dn2id_add( \"%s\", 0x%08lx )\n", - e->e_ndn, (long) e->e_id )); + LDAP_LOG ( INDEX, ARGS, "bdb_dn2id_add( \"%s\", 0x%08lx )\n", + e->e_ndn, (long) e->e_id, 0 ); #else Debug( LDAP_DEBUG_TRACE, "=> bdb_dn2id_add( \"%s\", 0x%08lx )\n", e->e_ndn, (long) e->e_id, 0 ); @@ -57,9 +57,8 @@ bdb_dn2id_add( rc = db->put( db, txn, &key, &data, DB_NOOVERWRITE ); if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "db2id", LDAP_LEVEL_ERR, - "bdb_dn2id_add: put failed: %s %d\n", - db_strerror(rc), rc )); + LDAP_LOG ( INDEX, ERR, "bdb_dn2id_add: put failed: %s %d\n", + db_strerror(rc), rc, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_dn2id_add: put failed: %s %d\n", db_strerror(rc), rc, 0 ); @@ -72,9 +71,9 @@ bdb_dn2id_add( rc = bdb_idl_insert_key( be, db, txn, &key, e->e_id ); if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "db2id", LDAP_LEVEL_ERR, - "=> bdb_dn2id_add: subtree (%s) insert failed: %d\n", - ptr.bv_val, rc )); + LDAP_LOG ( INDEX, ERR, + "=> bdb_dn2id_add: subtree (%s) insert failed: %d\n", + ptr.bv_val, rc, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_dn2id_add: subtree (%s) insert failed: %d\n", @@ -95,9 +94,9 @@ bdb_dn2id_add( if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "db2id", LDAP_LEVEL_ERR, + LDAP_LOG ( INDEX, ERR, "=> bdb_dn2id_add: parent (%s) insert failed: %d\n", - ptr.bv_val, rc )); + ptr.bv_val, rc, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_dn2id_add: parent (%s) insert failed: %d\n", @@ -114,9 +113,9 @@ bdb_dn2id_add( if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "db2id", LDAP_LEVEL_ERR, + LDAP_LOG ( INDEX, ERR, "=> bdb_dn2id_add: subtree (%s) insert failed: %d\n", - ptr.bv_val, rc )); + ptr.bv_val, rc, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_dn2id_add: subtree (%s) insert failed: %d\n", @@ -135,8 +134,7 @@ bdb_dn2id_add( done: ch_free( buf ); #ifdef NEW_LOGGING - LDAP_LOG (( "db2id", LDAP_LEVEL_RESULTS, - "<= bdb_dn2id_add: %d\n", rc )); + LDAP_LOG ( INDEX, RESULTS, "<= bdb_dn2id_add: %d\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= bdb_dn2id_add: %d\n", rc, 0, 0 ); #endif @@ -158,9 +156,8 @@ bdb_dn2id_delete( struct berval pdn, ptr; #ifdef NEW_LOGGING - LDAP_LOG (( "db2id", LDAP_LEVEL_ARGS, - "=> bdb_dn2id_delete ( \"%s\", 0x08lx )\n", - e->e_ndn, e->e_id )); + LDAP_LOG ( INDEX, ARGS, + "=> bdb_dn2id_delete ( \"%s\", 0x%08lx )\n", e->e_ndn, e->e_id, 0); #else Debug( LDAP_DEBUG_TRACE, "=> bdb_dn2id_delete( \"%s\", 0x%08lx )\n", e->e_ndn, e->e_id, 0 ); @@ -181,9 +178,9 @@ bdb_dn2id_delete( rc = db->del( db, txn, &key, 0 ); if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "db2id", LDAP_LEVEL_ERR, + LDAP_LOG ( INDEX, ERR, "=> bdb_dn2id_delete: delete failed: %s %d\n", - db_strerror(rc), rc )); + db_strerror(rc), rc, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_dn2id_delete: delete failed: %s %d\n", db_strerror(rc), rc, 0 ); @@ -196,9 +193,9 @@ bdb_dn2id_delete( rc = db->del( db, txn, &key, 0 ); if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "db2id", LDAP_LEVEL_ERR, - "=> bdb_dn2id_delete: subtree (%s) delete failed: %d\n", - ptr.bv_val, rc )); + LDAP_LOG ( INDEX, ERR, + "=> bdb_dn2id_delete: subtree (%s) delete failed: %d\n", + ptr.bv_val, rc, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_dn2id_delete: subtree (%s) delete failed: %d\n", @@ -219,9 +216,9 @@ bdb_dn2id_delete( if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "db2id", LDAP_LEVEL_ERR, + LDAP_LOG ( INDEX, ERR, "=> bdb_dn2id_delete: parent (%s) delete failed: %d\n", - ptr.bv_val, rc )); + ptr.bv_val, rc, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_dn2id_delete: parent (%s) delete failed: %d\n", @@ -237,9 +234,9 @@ bdb_dn2id_delete( rc = bdb_idl_delete_key( be, db, txn, &key, e->e_id ); if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "db2id", LDAP_LEVEL_ERR, + LDAP_LOG ( INDEX, ERR, "=> bdb_dn2id_delete: subtree (%s) delete failed: %d\n", - ptr.bv_val, rc )); + ptr.bv_val, rc, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_dn2id_delete: subtree (%s) delete failed: %d\n", @@ -258,7 +255,7 @@ bdb_dn2id_delete( done: ch_free( buf ); #ifdef NEW_LOGGING - LDAP_LOG (( "db2id", LDAP_LEVEL_RESULTS, "<= bdb_dn2id_delete %d\n", rc )); + LDAP_LOG ( INDEX, RESULTS, "<= bdb_dn2id_delete %d\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= bdb_dn2id_delete %d\n", rc, 0, 0 ); #endif @@ -279,8 +276,7 @@ bdb_dn2id( DB *db = bdb->bi_dn2id->bdi_db; #ifdef NEW_LOGGING - LDAP_LOG (( "db2id", LDAP_LEVEL_ARGS, "=> bdb_dn2id( \"%s\" )\n", - dn->bv_val )); + LDAP_LOG ( INDEX, ARGS, "=> bdb_dn2id( \"%s\" )\n", dn->bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "=> bdb_dn2id( \"%s\" )\n", dn->bv_val, 0, 0 ); #endif @@ -309,17 +305,16 @@ bdb_dn2id( if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "db2id", LDAP_LEVEL_ERR, - "<= bdb_dn2id: get failed %s (%d)\n", - db_strerror(rc), rc )); + LDAP_LOG ( INDEX, ERR, "<= bdb_dn2id: get failed %s (%d)\n", + db_strerror(rc), rc, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= bdb_dn2id: get failed: %s (%d)\n", db_strerror( rc ), rc, 0 ); #endif } else { #ifdef NEW_LOGGING - LDAP_LOG (( "db2id", LDAP_LEVEL_RESULTS, - "<= bdb_dn2id: got id=0x%08lx\n", *id )); + LDAP_LOG ( INDEX, RESULTS, + "<= bdb_dn2id: got id=0x%08lx\n", *id, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= bdb_dn2id: got id=0x%08lx\n", *id, 0, 0 ); @@ -348,8 +343,8 @@ bdb_dn2id_matched( ID cached_id; #ifdef NEW_LOGGING - LDAP_LOG (( "db2id", LDAP_LEVEL_ARGS, - "=> bdb_dn2id_matched( \"%s\" )\n", in->bv_val )); + LDAP_LOG ( INDEX, ARGS, + "=> bdb_dn2id_matched( \"%s\" )\n", in->bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "=> bdb_dn2id_matched( \"%s\" )\n", in->bv_val, 0, 0 ); #endif @@ -395,8 +390,8 @@ bdb_dn2id_matched( dnParent( &dn, &pdn ); } else { #ifdef NEW_LOGGING - LDAP_LOG (( "db2id", LDAP_LEVEL_DETAIL1, - "<= bdb_dn2id_matched: no match\n" )); + LDAP_LOG ( INDEX, DETAIL1, + "<= bdb_dn2id_matched: no match\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= bdb_dn2id_matched: no match\n", @@ -412,10 +407,10 @@ bdb_dn2id_matched( } else if ( rc == 0 ) { if( data.size != sizeof( ID ) ) { #ifdef NEW_LOGGING - LDAP_LOG (( "db2id", LDAP_LEVEL_DETAIL1, + LDAP_LOG ( INDEX, DETAIL1, "<= bdb_dn2id_matched: get size mismatch:" "expected %ld, got %ld\n", - (long) sizeof(ID), (long) data.size )); + (long) sizeof(ID), (long) data.size, 0 ); #else Debug( LDAP_DEBUG_ANY, "<= bdb_dn2id_matched: get size mismatch: " @@ -429,9 +424,9 @@ bdb_dn2id_matched( } #ifdef NEW_LOGGING - LDAP_LOG (( "db2id", LDAP_LEVEL_DETAIL1, + LDAP_LOG ( INDEX, DETAIL1, "<= bdb_dn2id_matched: id=0x%08lx: %s %s\n", - (long) *id, *id2 == 0 ? "entry" : "matched", dn.bv_val )); + (long) *id, *id2 == 0 ? "entry" : "matched", dn.bv_val ); #else Debug( LDAP_DEBUG_TRACE, "<= bdb_dn2id_matched: id=0x%08lx: %s %s\n", @@ -441,9 +436,9 @@ bdb_dn2id_matched( } else { #ifdef NEW_LOGGING - LDAP_LOG (( "db2id", LDAP_LEVEL_ERR, + LDAP_LOG ( INDEX, ERR, "<= bdb_dn2id_matched: get failed: %s (%d)\n", - db_strerror(rc), rc )); + db_strerror(rc), rc, 0 ); #else Debug( LDAP_DEBUG_ANY, "<= bdb_dn2id_matched: get failed: %s (%d)\n", @@ -471,8 +466,8 @@ bdb_dn2id_children( ID id; #ifdef NEW_LOGGING - LDAP_LOG (( "db2id", LDAP_LEVEL_ARGS, - "=> bdb_dn2id_children( %s )\n", dn->bv_val )); + LDAP_LOG ( INDEX, ARGS, + "=> bdb_dn2id_children( %s )\n", dn->bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "=> bdb_dn2id_children( %s )\n", dn->bv_val, 0, 0 ); @@ -496,10 +491,10 @@ bdb_dn2id_children( free( key.data ); #ifdef NEW_LOGGING - LDAP_LOG (( "db2id", LDAP_LEVEL_DETAIL1, + LDAP_LOG ( INDEX, DETAIL1, "<= bdb_dn2id_children( %s ): %schildren (%d)\n", dn->bv_val, rc == 0 ? "" : ( rc == DB_NOTFOUND ? "no " : - db_strerror(rc)), rc )); + db_strerror(rc)), rc ); #else Debug( LDAP_DEBUG_TRACE, "<= bdb_dn2id_children( %s ): %schildren (%d)\n", dn->bv_val, @@ -523,8 +518,8 @@ bdb_dn2idl( DB *db = bdb->bi_dn2id->bdi_db; #ifdef NEW_LOGGING - LDAP_LOG (( "db2id", LDAP_LEVEL_ARGS, - "=> bdb_dn2ididl( \"%s\" )\n", dn->bv_val )); + LDAP_LOG ( INDEX, ARGS, + "=> bdb_dn2ididl( \"%s\" )\n", dn->bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "=> bdb_dn2idl( \"%s\" )\n", dn->bv_val, 0, 0 ); #endif @@ -547,9 +542,8 @@ bdb_dn2idl( if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "db2id", LDAP_LEVEL_ERR, - "<= bdb_dn2ididl: get failed: %s (%d)\n", - db_strerror(rc), rc )); + LDAP_LOG ( INDEX, ERR, + "<= bdb_dn2ididl: get failed: %s (%d)\n", db_strerror(rc), rc, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= bdb_dn2idl: get failed: %s (%d)\n", @@ -558,10 +552,10 @@ bdb_dn2idl( } else { #ifdef NEW_LOGGING - LDAP_LOG (( "db2id", LDAP_LEVEL_RESULTS, + LDAP_LOG ( INDEX, RESULTS, "<= bdb_dn2ididl: id=%ld first=%ld last=%ld\n", (long) ids[0], (long) BDB_IDL_FIRST( ids ), - (long) BDB_IDL_LAST( ids ) )); + (long) BDB_IDL_LAST( ids ) ); #else Debug( LDAP_DEBUG_TRACE, "<= bdb_dn2idl: id=%ld first=%ld last=%ld\n", @@ -799,9 +793,9 @@ int bdb_fix_dn( ptr = e->e_name.bv_val; nptr = e->e_nname.bv_val; for (n = o; n && n->i_parent; n=n->i_parent) { - ptr = slap_strcopy(ptr, n->i_rdn->rdn.bv_val); + ptr = lutil_strcopy(ptr, n->i_rdn->rdn.bv_val); *ptr++ = ','; - nptr = slap_strcopy(nptr, n->i_rdn->nrdn.bv_val); + nptr = lutil_strcopy(nptr, n->i_rdn->nrdn.bv_val); *nptr++ = ','; } ldap_pvt_thread_rdwr_runlock(&bdb->bi_tree_rdwr); diff --git a/servers/slapd/back-bdb/error.c b/servers/slapd/back-bdb/error.c index ba96309a390940ed192a23323aaa66ea22ac7cd7..c34b277df1316bdf3b19da4d4c4d09016fbfda2c 100644 --- a/servers/slapd/back-bdb/error.c +++ b/servers/slapd/back-bdb/error.c @@ -16,7 +16,7 @@ void bdb_errcall( const char *pfx, char * msg ) { #ifdef NEW_LOGGING - LDAP_LOG (( "error", LDAP_LEVEL_INFO, "bdb(%s): %s\n", pfx, msg )); + LDAP_LOG ( OPERATION, INFO, "bdb(%s): %s\n", pfx, msg, 0 ); #else Debug( LDAP_DEBUG_ANY, "bdb(%s): %s\n", pfx, msg, 0 ); #endif diff --git a/servers/slapd/back-bdb/filterindex.c b/servers/slapd/back-bdb/filterindex.c index a09bc1e3f4b578dcec590e8befcd484512c263a7..53289e7ffaf3ddf3356d583456b8853e933a1d68 100644 --- a/servers/slapd/back-bdb/filterindex.c +++ b/servers/slapd/back-bdb/filterindex.c @@ -52,7 +52,7 @@ bdb_filter_candidates( { int rc = -1; #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_ENTRY, "=> bdb_filter_candidates\n")); + LDAP_LOG ( INDEX, ENTRY, "=> bdb_filter_candidates\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "=> bdb_filter_candidates\n", 0, 0, 0 ); #endif @@ -60,7 +60,7 @@ bdb_filter_candidates( switch ( f->f_choice ) { case SLAPD_FILTER_DN_ONE: #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_ARGS, "=> bdb_filter_candidates: \tDN ONE\n")); + LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tDN ONE\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "\tDN ONE\n", 0, 0, 0 ); #endif @@ -73,7 +73,7 @@ bdb_filter_candidates( case SLAPD_FILTER_DN_SUBTREE: #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_ARGS, "=> bdb_filter_candidates: \tDN SUBTREE\n")); + LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tDN SUBTREE\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "\tDN SUBTREE\n", 0, 0, 0 ); #endif @@ -82,7 +82,7 @@ bdb_filter_candidates( case LDAP_FILTER_PRESENT: #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_ARGS, "=> bdb_filter_candidates: \tPRESENT\n")); + LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tPRESENT\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "\tPRESENT\n", 0, 0, 0 ); #endif @@ -91,7 +91,7 @@ bdb_filter_candidates( case LDAP_FILTER_EQUALITY: #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_ARGS, "=> bdb_filter_candidates: \tEQUALITY\n")); + LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tEQUALITY\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "\tEQUALITY\n", 0, 0, 0 ); #endif @@ -100,7 +100,7 @@ bdb_filter_candidates( case LDAP_FILTER_APPROX: #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_ARGS, "=> bdb_filter_candidates: \tAPPROX\n")); + LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tAPPROX\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "\tAPPROX\n", 0, 0, 0 ); #endif @@ -109,7 +109,7 @@ bdb_filter_candidates( case LDAP_FILTER_SUBSTRINGS: #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_ARGS, "=> bdb_filter_candidates: \tSUBSTRINGS\n")); + LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tSUBSTRINGS\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "\tSUBSTRINGS\n", 0, 0, 0 ); #endif @@ -119,7 +119,7 @@ bdb_filter_candidates( case LDAP_FILTER_GE: /* no GE index, use pres */ #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_ARGS, "=> bdb_filter_candidates: \tGE\n")); + LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tGE\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "\tGE\n", 0, 0, 0 ); #endif @@ -129,7 +129,7 @@ bdb_filter_candidates( case LDAP_FILTER_LE: /* no LE index, use pres */ #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_ARGS, "=> bdb_filter_candidates: \tLE\n")); + LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tLE\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "\tLE\n", 0, 0, 0 ); #endif @@ -139,7 +139,7 @@ bdb_filter_candidates( case LDAP_FILTER_NOT: /* no indexing to support NOT filters */ #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_ARGS, "=> bdb_filter_candidates: \tNOT\n")); + LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tNOT\n",0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "\tNOT\n", 0, 0, 0 ); #endif @@ -147,7 +147,7 @@ bdb_filter_candidates( case LDAP_FILTER_AND: #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_ARGS, "=> bdb_filter_candidates: \tAND\n")); + LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tAND\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "\tAND\n", 0, 0, 0 ); #endif @@ -157,7 +157,7 @@ bdb_filter_candidates( case LDAP_FILTER_OR: #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_ARGS, "=> bdb_filter_candidates: \tOR\n")); + LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tOR\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "\tOR\n", 0, 0, 0 ); #endif @@ -167,7 +167,7 @@ bdb_filter_candidates( default: #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_ARGS, "=> bdb_filter_candidates: \tUNKNOWN\n")); + LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tUNKNOWN\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "\tUNKNOWN %lu\n", (unsigned long) f->f_choice, 0, 0 ); @@ -175,7 +175,9 @@ bdb_filter_candidates( } #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_RESULTS, "=> bdb_filter_candidates: id=%ld first=%ld last=%ld\n", (long) ids[0], (long) BDB_IDL_FIRST( ids ), (long) BDB_IDL_LAST( ids ) )); + LDAP_LOG ( INDEX, RESULTS, + "=> bdb_filter_candidates: id=%ld first=%ld last=%ld\n", + (long)ids[0], (long)BDB_IDL_FIRST( ids ), (long) BDB_IDL_LAST( ids )); #else Debug( LDAP_DEBUG_FILTER, "<= bdb_filter_candidates: id=%ld first=%ld last=%ld\n", @@ -201,7 +203,7 @@ list_candidates( Filter *f; #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_ARGS, "=> bdb_list_candidates: 0x%x\n", ftype)); + LDAP_LOG ( INDEX, ARGS, "=> bdb_list_candidates: 0x%x\n", ftype, 0 , 0 ); #else Debug( LDAP_DEBUG_FILTER, "=> bdb_list_candidates 0x%x\n", ftype, 0, 0 ); #endif @@ -237,7 +239,10 @@ list_candidates( if( rc ) { #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_RESULTS, "<= bdb_list_candidates: id=%ld first=%ld last=%ld\n", (long) ids[0], (long) BDB_IDL_FIRST( ids ), (long) BDB_IDL_LAST( ids ) )); + LDAP_LOG ( INDEX, RESULTS, + "<= bdb_list_candidates: id=%ld first=%ld last=%ld\n", + (long) ids[0], (long) BDB_IDL_FIRST( ids ), + (long) BDB_IDL_LAST( ids ) ); #else Debug( LDAP_DEBUG_FILTER, "<= bdb_list_candidates: id=%ld first=%ld last=%ld\n", @@ -248,7 +253,7 @@ list_candidates( } else { #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_ARGS, "<= bdb_list_candidates: rc=%d\n", rc)); + LDAP_LOG ( INDEX, ARGS, "<= bdb_list_candidates: rc=%d\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "<= bdb_list_candidates: undefined rc=%d\n", @@ -272,7 +277,7 @@ presence_candidates( struct berval prefix = {0}; #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_ENTRY, "=> bdb_presence_candidates\n")); + LDAP_LOG ( INDEX, ENTRY, "=> bdb_presence_candidates\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "=> bdb_presence_candidates\n", 0, 0, 0 ); #endif @@ -287,7 +292,8 @@ presence_candidates( if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_RESULTS, "=> bdb_presence_candidates: index_parm returned=%d\n", rc )); + LDAP_LOG ( INDEX, RESULTS, + "=> bdb_presence_candidates: index_parm returned=%d\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= bdb_presence_candidates: index_param returned=%d\n", @@ -299,7 +305,8 @@ presence_candidates( if( db == NULL ) { /* not indexed */ #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_RESULTS, "<= bdb_presence_candidates: not indexed\n" )); + LDAP_LOG(INDEX, RESULTS, + "<= bdb_presence_candidates: not indexed\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= bdb_presence_candidates: not indexed\n", @@ -310,7 +317,8 @@ presence_candidates( if( prefix.bv_val == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_RESULTS, "<= bdb_presence_candidates: no prefix\n" )); + LDAP_LOG(INDEX, RESULTS, + "<= bdb_presence_candidates: no prefix\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= bdb_presence_candidates: no prefix\n", @@ -326,7 +334,8 @@ presence_candidates( rc = 0; } else if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_RESULTS, "<= bdb_presence_candidates: key read failed (%d)\n", rc )); + LDAP_LOG ( INDEX, RESULTS, + "<= bdb_presence_candidates: key read failed (%d)\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= bdb_presense_candidates: key read failed (%d)\n", @@ -336,7 +345,9 @@ presence_candidates( } #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_RESULTS, "<= bdb_presence_candidates: id=%ld first=%ld last=%ld\n", (long) ids[0], (long) BDB_IDL_FIRST( ids ), (long) BDB_IDL_LAST( ids ) )); + LDAP_LOG ( INDEX, RESULTS, + "<= bdb_presence_candidates: id=%ld first=%ld last=%ld\n", + (long)ids[0], (long)BDB_IDL_FIRST( ids ), (long)BDB_IDL_LAST( ids ) ); #else Debug(LDAP_DEBUG_TRACE, "<= bdb_presence_candidates: id=%ld first=%ld last=%ld\n", @@ -365,7 +376,7 @@ equality_candidates( MatchingRule *mr; #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_ENTRY, "=> equality_candidates\n")); + LDAP_LOG ( INDEX, ENTRY, "=> equality_candidates\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "=> bdb_equality_candidates\n", 0, 0, 0 ); #endif @@ -375,7 +386,8 @@ equality_candidates( if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_RESULTS, "=> bdb_equality_candidates: index_param failed (%d)\n", rc)); + LDAP_LOG ( INDEX, RESULTS, + "=> bdb_equality_candidates: index_param failed (%d)\n", rc, 0, 0); #else Debug( LDAP_DEBUG_ANY, "<= bdb_equality_candidates: index_param failed (%d)\n", @@ -386,7 +398,8 @@ equality_candidates( if ( db == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_RESULTS, "=> bdb_equality_candidates: not indexed\n")); + LDAP_LOG(INDEX, RESULTS, + "=> bdb_equality_candidates: not indexed\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "<= bdb_equality_candidates: not indexed\n", 0, 0, 0 ); @@ -414,7 +427,8 @@ equality_candidates( if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_RESULTS, "=> bdb_equality_candidates: MR filter failed (%d)\n", rc)); + LDAP_LOG ( INDEX, RESULTS, + "=> bdb_equality_candidates: MR filter failed (%d)\n", rc, 0, 0); #else Debug( LDAP_DEBUG_TRACE, "<= bdb_equality_candidates: MR filter failed (%d)\n", @@ -425,7 +439,8 @@ equality_candidates( if( keys == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_RESULTS, "=> bdb_equality_candidates: no keys\n")); + LDAP_LOG ( INDEX, RESULTS, + "=> bdb_equality_candidates: no keys\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= bdb_equality_candidates: no keys\n", @@ -442,7 +457,8 @@ equality_candidates( rc = 0; } else if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_RESULTS, "<= bdb_equality_candidates: key read failed (%d)\n", rc)); + LDAP_LOG ( INDEX, RESULTS, + "<= bdb_equality_candidates: key read failed (%d)\n", rc, 0, 0); #else Debug( LDAP_DEBUG_TRACE, "<= bdb_equality_candidates key read failed (%d)\n", @@ -453,7 +469,7 @@ equality_candidates( if( BDB_IDL_IS_ZERO( tmp ) ) { #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_RESULTS, "=> bdb_equality_candidates: NULL\n")); + LDAP_LOG ( INDEX, RESULTS, "=> bdb_equality_candidates: NULL\n", 0, 0, 0); #else Debug( LDAP_DEBUG_TRACE, "<= bdb_equality_candidates NULL\n", @@ -472,7 +488,10 @@ equality_candidates( ber_bvarray_free( keys ); #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_RESULTS, "<= bdb_equality_candidates: id=%ld first=%ld last=%ld\n", (long) ids[0], (long) BDB_IDL_FIRST( ids ), (long) BDB_IDL_LAST( ids ) )); + LDAP_LOG ( INDEX, RESULTS, + "<= bdb_equality_candidates: id=%ld first=%ld last=%ld\n", + (long) ids[0], (long) BDB_IDL_FIRST( ids ), + (long) BDB_IDL_LAST( ids ) ); #else Debug( LDAP_DEBUG_TRACE, "<= bdb_equality_candidates id=%ld, first=%ld, last=%ld\n", @@ -500,7 +519,7 @@ approx_candidates( MatchingRule *mr; #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_ENTRY, "=> bdb_approx_candidates\n")); + LDAP_LOG ( INDEX, ENTRY, "=> bdb_approx_candidates\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "=> bdb_approx_candidates\n", 0, 0, 0 ); #endif @@ -510,7 +529,8 @@ approx_candidates( if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_RESULTS, "<= bdb_approx_candidates: index_param failed (%d)\n", rc )); + LDAP_LOG ( INDEX, RESULTS, + "<= bdb_approx_candidates: index_param failed (%d)\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "<= bdb_approx_candidates: index_param failed (%d)\n", @@ -521,7 +541,8 @@ approx_candidates( if ( db == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_RESULTS, "<= bdb_approx_candidates: not indexed\n" )); + LDAP_LOG(INDEX, RESULTS, + "<= bdb_approx_candidates: not indexed\n",0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "<= bdb_approx_candidates: not indexed\n", 0, 0, 0 ); @@ -554,7 +575,8 @@ approx_candidates( if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_RESULTS, "<= bdb_approx_candidates: MR filter failed (%d)\n", rc )); + LDAP_LOG ( INDEX, RESULTS, + "<= bdb_approx_candidates: MR filter failed (%d)\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= bdb_approx_candidates: (%s) MR filter failed (%d)\n", @@ -565,7 +587,8 @@ approx_candidates( if( keys == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_RESULTS, "<= bdb_approx_candidates: no keys (%s)\n", prefix.bv_val )); + LDAP_LOG ( INDEX, RESULTS, + "<= bdb_approx_candidates: no keys (%s)\n", prefix.bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= bdb_approx_candidates: no keys (%s)\n", @@ -583,7 +606,8 @@ approx_candidates( break; } else if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_RESULTS, "<= bdb_approx_candidates: key read failed (%d)\n", rc )); + LDAP_LOG ( INDEX, RESULTS, + "<= bdb_approx_candidates: key read failed (%d)\n", rc, 0, 0); #else Debug( LDAP_DEBUG_TRACE, "<= bdb_approx_candidates key read failed (%d)\n", rc, 0, 0 ); @@ -593,7 +617,8 @@ approx_candidates( if( BDB_IDL_IS_ZERO( tmp ) ) { #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_RESULTS, "<= bdb_approx_candidates: NULL\n" )); + LDAP_LOG ( INDEX, RESULTS, + "<= bdb_approx_candidates: NULL\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= bdb_approx_candidates NULL\n", 0, 0, 0 ); @@ -611,7 +636,10 @@ approx_candidates( ber_bvarray_free( keys ); #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_RESULTS, "<= bdb_approx_candidates: id=%ld first=%ld last=%ld\n", (long) ids[0], (long) BDB_IDL_FIRST( ids ), (long) BDB_IDL_LAST( ids ) )); + LDAP_LOG ( INDEX, RESULTS, + "<= bdb_approx_candidates: id=%ld first=%ld last=%ld\n", + (long) ids[0], (long) BDB_IDL_FIRST( ids ), + (long) BDB_IDL_LAST( ids ) ); #else Debug( LDAP_DEBUG_TRACE, "<= bdb_approx_candidates %ld, first=%ld, last=%ld\n", (long) ids[0], @@ -637,7 +665,7 @@ substring_candidates( MatchingRule *mr; #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_ENTRY, "=> bdb_substring_candidates\n")); + LDAP_LOG ( INDEX, ENTRY, "=> bdb_substring_candidates\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "=> bdb_substring_candidates\n", 0, 0, 0 ); #endif @@ -647,7 +675,8 @@ substring_candidates( if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_RESULTS, "<= bdb_substring_candidates: index_param failed (%d)\n", rc )); + LDAP_LOG ( INDEX, RESULTS, + "<= bdb_substring_candidates: index_param failed (%d)\n", rc, 0, 0); #else Debug( LDAP_DEBUG_ANY, "<= bdb_substring_candidates: index_param failed (%d)\n", @@ -658,7 +687,8 @@ substring_candidates( if ( db == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_RESULTS, "<= bdb_substring_candidates: not indexed\n")); + LDAP_LOG ( INDEX, RESULTS, + "<= bdb_substring_candidates: not indexed\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "<= bdb_substring_candidates not indexed\n", @@ -688,7 +718,9 @@ substring_candidates( if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_RESULTS, "<= bdb_substring_candidates: (%s) MR filter failed (%d)\n", sub->sa_desc->ad_cname.bv_val, rc )); + LDAP_LOG ( INDEX, RESULTS, + "<= bdb_substring_candidates: (%s) MR filter failed (%d)\n", + sub->sa_desc->ad_cname.bv_val, rc, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= bdb_substring_candidates: (%s) MR filter failed (%d)\n", @@ -699,7 +731,9 @@ substring_candidates( if( keys == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_RESULTS, "<= bdb_substring_candidates: (%s) MR filter failed (%d)\n", mask, sub->sa_desc->ad_cname.bv_val )); + LDAP_LOG ( INDEX, RESULTS, + "<= bdb_substring_candidates: (%d) MR filter failed (%s)\n", + mask, sub->sa_desc->ad_cname.bv_val, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= bdb_substring_candidates: (0x%04lx) no keys (%s)\n", @@ -717,7 +751,8 @@ substring_candidates( break; } else if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_RESULTS, "<= bdb_substring_candidates: key read failed (%d)\n", rc)); + LDAP_LOG ( INDEX, RESULTS, + "<= bdb_substring_candidates: key read failed (%d)\n", rc, 0,0); #else Debug( LDAP_DEBUG_TRACE, "<= bdb_substring_candidates key read failed (%d)\n", rc, 0, 0 ); @@ -727,7 +762,8 @@ substring_candidates( if( BDB_IDL_IS_ZERO( tmp ) ) { #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_RESULTS, "<= bdb_substring_candidates: NULL \n" )); + LDAP_LOG ( INDEX, RESULTS, + "<= bdb_substring_candidates: NULL \n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= bdb_substring_candidates NULL\n", 0, 0, 0 ); @@ -745,7 +781,10 @@ substring_candidates( ber_bvarray_free( keys ); #ifdef NEW_LOGGING - LDAP_LOG (( "filterindex", LDAP_LEVEL_RESULTS, "<= bdb_substring_candidates: id=%ld first=%ld last=%ld\n", (long) ids[0], (long) BDB_IDL_FIRST( ids ), (long) BDB_IDL_LAST( ids ) )); + LDAP_LOG ( INDEX, RESULTS, + "<= bdb_substring_candidates: id=%ld first=%ld last=%ld\n", + (long) ids[0], (long) BDB_IDL_FIRST( ids ), + (long) BDB_IDL_LAST( ids ) ); #else Debug( LDAP_DEBUG_TRACE, "<= bdb_substring_candidates %ld, first=%ld, last=%ld\n", (long) ids[0], diff --git a/servers/slapd/back-bdb/group.c b/servers/slapd/back-bdb/group.c index 6c2cdf11330a3c7f9035248c16555a65ffa41101..59a33e94b387b6d93699bc98394b1fd4206fc281 100644 --- a/servers/slapd/back-bdb/group.c +++ b/servers/slapd/back-bdb/group.c @@ -54,9 +54,9 @@ bdb_group( } #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY, + LDAP_LOG( BACK_BDB, ENTRY, "bdb_group: check (%s) member of (%s), oc %s\n", - op_ndn->bv_val, gr_ndn->bv_val, group_oc_name )); + op_ndn->bv_val, gr_ndn->bv_val, group_oc_name ); #else Debug( LDAP_DEBUG_ARGS, "=> bdb_group: gr dn: \"%s\"\n", @@ -88,8 +88,8 @@ bdb_group( /* we already have a LOCKED copy of the entry */ e = target; #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "bdb_group: target is group (%s)\n", gr_ndn->bv_val )); + LDAP_LOG( BACK_BDB, DETAIL1, + "bdb_group: target is group (%s)\n", gr_ndn->bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_ARGS, "=> bdb_group: target is group: \"%s\"\n", @@ -112,9 +112,8 @@ dn2entry_retry: } if (e == NULL) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "bdb_group: cannot find group (%s)\n", - gr_ndn->bv_val )); + LDAP_LOG( BACK_BDB, DETAIL1, + "bdb_group: cannot find group (%s)\n", gr_ndn->bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_ACL, "=> bdb_group: cannot find group: \"%s\"\n", @@ -126,8 +125,8 @@ dn2entry_retry: return( 1 ); } #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "bdb_group: found group (%s)\n", gr_ndn->bv_val )); + LDAP_LOG( BACK_BDB, DETAIL1, + "bdb_group: found group (%s)\n", gr_ndn->bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_ACL, "=> bdb_group: found group: \"%s\"\n", @@ -144,8 +143,8 @@ dn2entry_retry: #ifdef BDB_ALIASES if( is_entry_alias( e ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "bdb_group: group (%s) is an alias\n", gr_ndn->bv_val )); + LDAP_LOG( BACK_BDB, INFO, + "bdb_group: group (%s) is an alias\n", gr_ndn->bv_val, 0, 0); #else Debug( LDAP_DEBUG_ACL, "<= bdb_group: group is an alias\n", 0, 0, 0 ); @@ -156,8 +155,8 @@ dn2entry_retry: if( is_entry_referral( e ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "bdb_group: group (%s) is a referral.\n", gr_ndn->bv_val )); + LDAP_LOG( BACK_BDB, INFO, + "bdb_group: group (%s) is a referral.\n", gr_ndn->bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_ACL, "<= bdb_group: group is a referral\n", 0, 0, 0 ); @@ -167,9 +166,9 @@ dn2entry_retry: if( !is_entry_objectclass( e, group_oc, 0 ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_ERR, - "bdb_group: failed to find %s in objectClass.\n", - group_oc_name )); + LDAP_LOG( BACK_BDB, ERR, + "bdb_group: failed to find %s in objectClass.\n", + group_oc_name, 0, 0 ); #else Debug( LDAP_DEBUG_ACL, "<= bdb_group: failed to find %s in objectClass\n", @@ -180,8 +179,8 @@ dn2entry_retry: if ((attr = attr_find(e->e_attrs, group_at)) == NULL) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "bdb_group: failed to find %s\n", group_at_name )); + LDAP_LOG( BACK_BDB, INFO, + "bdb_group: failed to find %s\n", group_at_name, 0, 0 ); #else Debug( LDAP_DEBUG_ACL, "<= bdb_group: failed to find %s\n", @@ -191,9 +190,9 @@ dn2entry_retry: } #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY, + LDAP_LOG( BACK_BDB, ENTRY, "bdb_group: found objectClass %s and %s\n", - group_oc_name, group_at_name )); + group_oc_name, group_at_name, 0 ); #else Debug( LDAP_DEBUG_ACL, "<= bdb_group: found objectClass %s and %s\n", @@ -202,9 +201,9 @@ dn2entry_retry: if( value_find( group_at, attr->a_vals, op_ndn ) != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, + LDAP_LOG( BACK_BDB, DETAIL1, "bdb_group: \"%s\" not in \"%s\": %s\n", - op_ndn->bv_val, gr_ndn->bv_val, group_at_name )); + op_ndn->bv_val, gr_ndn->bv_val, group_at_name ); #else Debug( LDAP_DEBUG_ACL, "<= bdb_group: \"%s\" not in \"%s\": %s\n", @@ -214,9 +213,8 @@ dn2entry_retry: } #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "bdb_group: %s is in %s: %s\n", - op_ndn->bv_val, gr_ndn->bv_val, group_at_name )); + LDAP_LOG( BACK_BDB, DETAIL1, "bdb_group: %s is in %s: %s\n", + op_ndn->bv_val, gr_ndn->bv_val, group_at_name ); #else Debug( LDAP_DEBUG_ACL, "<= bdb_group: \"%s\" is in \"%s\": %s\n", @@ -236,8 +234,7 @@ return_results: } #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY, - "bdb_group: rc=%d\n", rc )); + LDAP_LOG( BACK_BDB, ENTRY, "bdb_group: rc=%d\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_group: rc=%d\n", rc, 0, 0 ); #endif diff --git a/servers/slapd/back-bdb/idl.c b/servers/slapd/back-bdb/idl.c index 175faa0bbdc742db7766b81ceebd02d4016c5670..09f86a7ccffd1c8507975c940ef42af46d70de77 100644 --- a/servers/slapd/back-bdb/idl.c +++ b/servers/slapd/back-bdb/idl.c @@ -36,9 +36,9 @@ static void idl_dump( ID *ids ) { if( BDB_IDL_IS_RANGE( ids ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_INFO, "IDL: range (%ld - %ld)\n", + LDAP_LOG( INDEX, INFO, "IDL: range (%ld - %ld)\n", (long) BDB_IDL_RANGE_FIRST( ids ), - (long) BDB_IDL_RANGE_LAST( ids ) )); + (long) BDB_IDL_RANGE_LAST( ids ), 0 ); #else Debug( LDAP_DEBUG_ANY, "IDL: range ( %ld - %ld )\n", @@ -49,8 +49,7 @@ static void idl_dump( ID *ids ) } else { ID i; #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_INFO, "IDL: size %ld", - (long) ids[0] )); + LDAP_LOG( INDEX, INFO, "IDL: size %ld", (long) ids[0], 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "IDL: size %ld", (long) ids[0], 0, 0 ); #endif @@ -60,7 +59,7 @@ static void idl_dump( ID *ids ) Debug( LDAP_DEBUG_ANY, "\n", 0, 0, 0 ); } #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_INFO, "%02lx",(long)ids[i] )); + LDAP_LOG( INDEX, INFO, "%02lx",(long)ids[i], 0, 0 ); #else Debug( LDAP_DEBUG_ANY, " %02lx", (long) ids[i], 0, 0 ); #endif @@ -139,8 +138,7 @@ int bdb_idl_insert( ID *ids, ID id ) #if IDL_DEBUG > 1 #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_DETAIL1, "insert: %04lx at %d\n", - (long) id, x )); + LDAP_LOG( INDEX, DETAIL1, "insert: %04lx at %d\n", (long) id, x, 0 ); #else Debug( LDAP_DEBUG_ANY, "insert: %04lx at %d\n", (long) id, x, 0 ); idl_dump( ids ); @@ -193,8 +191,7 @@ static int idl_delete( ID *ids, ID id ) #if IDL_DEBUG > 1 #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_DETAIL1, "delete: %04lx at %d\n", - (long) id, x )); + LDAP_LOG( INDEX, DETAIL1, "delete: %04lx at %d\n", (long) id, x, 0 ); #else Debug( LDAP_DEBUG_ANY, "delete: %04lx at %d\n", (long) id, x, 0 ); idl_dump( ids ); @@ -267,7 +264,9 @@ bdb_idl_fetch_key( rc = db->cursor( db, tid, &cursor, bdb->bi_db_opflags ); if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_fetch_key: cursor failed: %s (%d)\n", db_strerror(rc), rc )); + LDAP_LOG( INDEX, ERR, + "bdb_idl_fetch_key: cursor failed: %s (%d)\n", + db_strerror(rc), rc, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_idl_fetch_key: " "cursor failed: %s (%d)\n", db_strerror(rc), rc, 0 ); @@ -296,7 +295,10 @@ bdb_idl_fetch_key( if (ids[1] == 0) { if (ids[0] != BDB_IDL_RANGE_SIZE) { #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "=> bdb_idl_fetch_key: range size mismatch: expected %ld, got %ld\n", BDB_IDL_RANGE_SIZE, ids[0] )); + LDAP_LOG( INDEX, ERR, + "=> bdb_idl_fetch_key: range size mismatch: " + "expected %ld, got %ld\n", + BDB_IDL_RANGE_SIZE, ids[0], 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_idl_fetch_key: " "range size mismatch: expected %d, got %ld\n", @@ -312,7 +314,9 @@ bdb_idl_fetch_key( rc2 = cursor->c_close( cursor ); if (rc2) { #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_fetch_key: close failed: %s (%d)\n", db_strerror(rc2), rc2 )); + LDAP_LOG( INDEX, ERR, + "bdb_idl_fetch_key: close failed: %s (%d)\n", + db_strerror(rc2), rc2, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_idl_fetch_key: " "close failed: %s (%d)\n", db_strerror(rc2), rc2, 0 ); @@ -333,7 +337,9 @@ bdb_idl_fetch_key( } else if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_fetch_key: get failed: %s (%d)\n", db_strerror(rc), rc )); + LDAP_LOG( INDEX, ERR, + "bdb_idl_fetch_key: get failed: %s (%d)\n", + db_strerror(rc), rc, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_idl_fetch_key: " "get failed: %s (%d)\n", @@ -344,7 +350,9 @@ bdb_idl_fetch_key( } else if ( data.size == 0 || data.size % sizeof( ID ) ) { /* size not multiple of ID size */ #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_fetch_key: odd size: expected %ld multiple, got %ld\n", (long) sizeof( ID ), (long) data.size )); + LDAP_LOG( INDEX, ERR, + "bdb_idl_fetch_key: odd size: expected %ld multiple, got %ld\n", + (long) sizeof( ID ), (long) data.size, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_idl_fetch_key: " "odd size: expected %ld multiple, got %ld\n", @@ -355,7 +363,9 @@ bdb_idl_fetch_key( } else if ( data.size != BDB_IDL_SIZEOF(ids) ) { /* size mismatch */ #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_fetch_key: get size mismatch: expected %ld, got %ld\n", (long) ((1 + ids[0]) * sizeof( ID )), (long) data.size )); + LDAP_LOG( INDEX, ERR, + "bdb_idl_fetch_key: get size mismatch: expected %ld, got %ld\n", + (long) ((1 + ids[0]) * sizeof( ID )), (long) data.size, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_idl_fetch_key: " "get size mismatch: expected %ld, got %ld\n", @@ -385,7 +395,8 @@ bdb_idl_insert_key( #if 0 /* for printable keys only */ #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_ARGS, "bdb_idl_insert_key: %s %ld\n", (char *)key->data, (long) id )); + LDAP_LOG( INDEX, ARGS, "bdb_idl_insert_key: %s %ld\n", + (char *)key->data, (long) id, 0 ); #else Debug( LDAP_DEBUG_ARGS, "=> bdb_idl_insert_key: %s %ld\n", @@ -409,7 +420,9 @@ bdb_idl_insert_key( rc = db->cursor( db, tid, &cursor, bdb->bi_db_opflags ); if ( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_insert_key: cursor failed: %s (%d)\n", db_strerror(rc), rc )); + LDAP_LOG( INDEX, ERR, + "bdb_idl_insert_key: cursor failed: %s (%d)\n", + db_strerror(rc), rc, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_idl_insert_key: " "cursor failed: %s (%d)\n", db_strerror(rc), rc, 0 ); @@ -433,13 +446,31 @@ bdb_idl_insert_key( } if ( count >= BDB_IDL_DB_SIZE ) { /* No room, convert to a range */ + DBT key2 = *key; + + key2.dlen = key2.ulen; + key2.flags |= DB_DBT_PARTIAL; + lo = tmp; data.data = &hi; - rc = cursor->c_get( cursor, key, &data, DB_LAST ); - if ( rc != 0 ) { - err = "c_get last"; + rc = cursor->c_get( cursor, &key2, &data, DB_NEXT_NODUP ); + if ( rc != 0 && rc != DB_NOTFOUND ) { + err = "c_get next_nodup"; goto fail; } + if ( rc == DB_NOTFOUND ) { + rc = cursor->c_get( cursor, key, &data, DB_LAST ); + if ( rc != 0 ) { + err = "c_get last"; + goto fail; + } + } else { + rc = cursor->c_get( cursor, key, &data, DB_PREV ); + if ( rc != 0 ) { + err = "c_get prev"; + goto fail; + } + } if ( id < lo ) lo = id; else if ( id > hi ) @@ -518,7 +549,9 @@ put1: data.data = &id; /* initial c_get failed, nothing was done */ fail: #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_insert_key: %s failed: %s (%d)\n", err, db_strerror(rc), rc )); + LDAP_LOG( INDEX, ERR, + "bdb_idl_insert_key: %s failed: %s (%d)\n", + err, db_strerror(rc), rc ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_idl_insert_key: " "%s failed: %s (%d)\n", err, db_strerror(rc), rc ); @@ -543,7 +576,8 @@ fail: } else if ( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_insert_key: get failed: %s (%d)\n", db_strerror(rc), rc )); + LDAP_LOG( INDEX, ERR, "bdb_idl_insert_key: get failed: %s (%d)\n", + db_strerror(rc), rc, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_idl_insert_key: " "get failed: %s (%d)\n", @@ -554,7 +588,9 @@ fail: } else if ( data.size == 0 || data.size % sizeof( ID ) ) { /* size not multiple of ID size */ #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_insert_key: odd size: expected %ld multiple, got %ld\n", (long) sizeof( ID ), (long) data.size )); + LDAP_LOG( INDEX, ERR, + "bdb_idl_insert_key: odd size: expected %ld multiple, got %ld\n", + (long) sizeof( ID ), (long) data.size, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_idl_insert_key: " "odd size: expected %ld multiple, got %ld\n", @@ -565,7 +601,9 @@ fail: } else if ( data.size != BDB_IDL_SIZEOF(ids) ) { /* size mismatch */ #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_insert_key: odd size: expected %ld multiple, got %ld\n", (long) ((1 + ids[0]) * sizeof( ID )), (long) data.size )); + LDAP_LOG( INDEX, ERR, + "bdb_idl_insert_key: odd size: expected %ld multiple, got %ld\n", + (long) ((1 + ids[0]) * sizeof( ID )), (long) data.size, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_idl_insert_key: " "get size mismatch: expected %ld, got %ld\n", @@ -587,7 +625,7 @@ fail: if( rc == -1 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_DETAIL1, "bdb_idl_insert_key: dup\n" )); + LDAP_LOG( INDEX, DETAIL1, "bdb_idl_insert_key: dup\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "=> bdb_idl_insert_key: dup\n", 0, 0, 0 ); @@ -596,7 +634,8 @@ fail: } if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_insert_key: insert failed: (%d)\n", rc )); + LDAP_LOG( INDEX, ERR, + "bdb_idl_insert_key: insert failed: (%d)\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_idl_insert_key: " "bdb_idl_insert failed (%d)\n", @@ -616,7 +655,9 @@ fail: if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_insert_key: put failed: (%d)\n", db_strerror(rc), rc )); + LDAP_LOG( INDEX, ERR, + "bdb_idl_insert_key: put failed: %s (%d)\n", + db_strerror(rc), rc, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_idl_insert_key: " "put failed: %s (%d)\n", @@ -644,7 +685,8 @@ bdb_idl_delete_key( #if 0 /* for printable keys only */ #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_ARGS, "bdb_idl_delete_key: %s %ld\n", (char *)key->data, (long) id )); + LDAP_LOG( INDEX, ARGS, "bdb_idl_delete_key: %s %ld\n", + (char *)key->data, (long) id, 0 ); #else Debug( LDAP_DEBUG_ARGS, "=> bdb_idl_delete_key: %s %ld\n", @@ -669,7 +711,9 @@ bdb_idl_delete_key( rc = db->cursor( db, tid, &cursor, bdb->bi_db_opflags ); if ( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_delete_key: cursor failed: %s (%d)\n", db_strerror(rc), rc )); + LDAP_LOG( INDEX, ERR, + "bdb_idl_delete_key: cursor failed: %s (%d)\n", + db_strerror(rc), rc, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_idl_delete_key: " "cursor failed: %s (%d)\n", db_strerror(rc), rc, 0 ); @@ -752,7 +796,9 @@ bdb_idl_delete_key( /* initial c_get failed, nothing was done */ fail: #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_delete_key: %s failed: %s (%d)\n", err, db_strerror(rc), rc )); + LDAP_LOG( INDEX, ERR, + "bdb_idl_delete_key: %s failed: %s (%d)\n", + err, db_strerror(rc), rc ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_idl_delete_key: " "%s failed: %s (%d)\n", err, db_strerror(rc), rc ); @@ -772,7 +818,8 @@ fail: if ( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_delete_key: get failed: %s (%d)\n", db_strerror(rc), rc )); + LDAP_LOG( INDEX, ERR, "bdb_idl_delete_key: get failed: %s (%d)\n", + db_strerror(rc), rc, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_idl_delete_key: " "get failed: %s (%d)\n", @@ -783,7 +830,9 @@ fail: } else if ( data.size == 0 || data.size % sizeof( ID ) ) { /* size not multiple of ID size */ #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_delete_key: odd size: expected: %ld multiple, got %ld\n", (long) sizeof( ID ), (long) data.size )); + LDAP_LOG( INDEX, ERR, + "bdb_idl_delete_key: odd size: expected: %ld multiple, got %ld\n", + (long) sizeof( ID ), (long) data.size, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_idl_delete_key: " "odd size: expected %ld multiple, got %ld\n", @@ -797,7 +846,9 @@ fail: } else if ( data.size != (1 + ids[0]) * sizeof( ID ) ) { /* size mismatch */ #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_delete_key: get size mismatch: expected: %ld, got %ld\n", (long) ((1 + ids[0]) * sizeof( ID )), (long) data.size )); + LDAP_LOG( INDEX, ERR, + "bdb_idl_delete_key: get size mismatch: expected: %ld, got %ld\n", + (long) ((1 + ids[0]) * sizeof( ID )), (long) data.size, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_idl_delete_key: " "get size mismatch: expected %ld, got %ld\n", @@ -810,7 +861,8 @@ fail: if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_delete_key: delete failed: (%d)\n", rc )); + LDAP_LOG( INDEX, ERR, + "bdb_idl_delete_key: delete failed: (%d)\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_idl_delete_key: " "idl_delete failed (%d)\n", @@ -824,7 +876,9 @@ fail: rc = db->del( db, tid, key, 0 ); if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_delete_key: delete failed: %s (%d)\n", db_strerror(rc), rc )); + LDAP_LOG( INDEX, ERR, + "bdb_idl_delete_key: delete failed: %s (%d)\n", + db_strerror(rc), rc, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_idl_delete_key: " "delete failed: %s (%d)\n", @@ -844,7 +898,8 @@ fail: if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_delete_key: put failed: %s (%d)\n", db_strerror(rc), rc )); + LDAP_LOG( INDEX, ERR, "bdb_idl_delete_key: put failed: %s (%d)\n", + db_strerror(rc), rc, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_idl_delete_key: put failed: %s (%d)\n", diff --git a/servers/slapd/back-bdb/index.c b/servers/slapd/back-bdb/index.c new file mode 100644 index 0000000000000000000000000000000000000000..907b0589026509316ede79c6f40a47abab878b09 --- /dev/null +++ b/servers/slapd/back-bdb/index.c @@ -0,0 +1,384 @@ +/* index.c - routines for dealing with attribute indexes */ +/* $OpenLDAP$ */ +/* + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ + +#include "portable.h" + +#include <stdio.h> + +#include <ac/string.h> +#include <ac/socket.h> + +#include "slap.h" +#include "back-bdb.h" +#include "lutil_hash.h" + +static char presence_keyval[LUTIL_HASH_BYTES] = {0,0,0,1}; +static struct berval presence_key = {LUTIL_HASH_BYTES, presence_keyval}; + +static slap_mask_t index_mask( + Backend *be, + AttributeDescription *desc, + char **dbname, + struct berval *atname ) +{ + AttributeType *at; + slap_mask_t mask = 0; + + bdb_attr_mask( be->be_private, desc, &mask ); + + if( mask ) { + *atname = desc->ad_cname; + *dbname = desc->ad_cname.bv_val; + return mask; + } + + /* If there is a language tag, did we ever index the base + * type? If so, check for mask, otherwise it's not there. + */ + if( slap_ad_is_lang( desc ) && desc != desc->ad_type->sat_ad ) { + /* has language tag */ + bdb_attr_mask( be->be_private, desc->ad_type->sat_ad, &mask ); + + if ( mask && ( mask ^ SLAP_INDEX_NOLANG ) ) { + *atname = desc->ad_type->sat_cname; + *dbname = desc->ad_type->sat_cname.bv_val; + return mask; + } + } + + /* see if supertype defined mask for its subtypes */ + for( at = desc->ad_type; at != NULL ; at = at->sat_sup ) { + /* If no AD, we've never indexed this type */ + if ( !at->sat_ad ) continue; + + bdb_attr_mask( be->be_private, at->sat_ad, &mask ); + + if ( mask && ( mask ^ SLAP_INDEX_NOSUBTYPES ) ) { + *atname = at->sat_cname; + *dbname = at->sat_cname.bv_val; + return mask; + } + } + + return 0; +} + +int bdb_index_is_indexed( + Backend *be, + AttributeDescription *desc ) +{ + slap_mask_t mask; + char *dbname; + struct berval prefix; + + mask = index_mask( be, desc, &dbname, &prefix ); + + if( mask == 0 ) { + return LDAP_INAPPROPRIATE_MATCHING; + } + + return LDAP_SUCCESS; +} + +int bdb_index_param( + Backend *be, + AttributeDescription *desc, + int ftype, + DB **dbp, + slap_mask_t *maskp, + struct berval *prefixp ) +{ + int rc; + slap_mask_t mask; + DB *db; + char *dbname; + + mask = index_mask( be, desc, &dbname, prefixp ); + + if( mask == 0 ) { + return LDAP_INAPPROPRIATE_MATCHING; + } + + rc = bdb_db_cache( be, dbname, &db ); + + if( rc != LDAP_SUCCESS ) { + return rc; + } + + switch( ftype ) { + case LDAP_FILTER_PRESENT: + if( IS_SLAP_INDEX( mask, SLAP_INDEX_PRESENT ) ) { + goto done; + } + break; + + case LDAP_FILTER_APPROX: + if( IS_SLAP_INDEX( mask, SLAP_INDEX_APPROX ) ) { + goto done; + } + /* fall thru */ + + case LDAP_FILTER_EQUALITY: + if( IS_SLAP_INDEX( mask, SLAP_INDEX_EQUALITY ) ) { + goto done; + } + break; + + case LDAP_FILTER_SUBSTRINGS: + if( IS_SLAP_INDEX( mask, SLAP_INDEX_SUBSTR ) ) { + goto done; + } + break; + + default: + return LDAP_OTHER; + } + + return LDAP_INAPPROPRIATE_MATCHING; + +done: + *dbp = db; + *maskp = mask; + return LDAP_SUCCESS; +} + +static int indexer( + Backend *be, + DB_TXN *txn, + char *dbname, + struct berval *atname, + BerVarray vals, + ID id, + int op, + slap_mask_t mask ) +{ + int rc, i; + const char *text; + DB *db; + AttributeDescription *ad = NULL; + struct berval *keys; + + assert( mask ); + + rc = bdb_db_cache( be, dbname, &db ); + + if ( rc != LDAP_SUCCESS ) { +#ifdef NEW_LOGGING + LDAP_LOG( INDEX, ERR, + "bdb_index_read: Could not open DB %s\n", dbname, 0, 0 ); +#else + Debug( LDAP_DEBUG_ANY, + "<= bdb_index_read NULL (could not open %s)\n", + dbname, 0, 0 ); +#endif + return LDAP_OTHER; + } + + rc = slap_bv2ad( atname, &ad, &text ); + if( rc != LDAP_SUCCESS ) return rc; + + if( IS_SLAP_INDEX( mask, SLAP_INDEX_PRESENT ) ) { + rc = bdb_key_change( be, db, txn, &presence_key, id, op ); + if( rc ) { + goto done; + } + } + + if( IS_SLAP_INDEX( mask, SLAP_INDEX_EQUALITY ) ) { + rc = ad->ad_type->sat_equality->smr_indexer( + LDAP_FILTER_EQUALITY, + mask, + ad->ad_type->sat_syntax, + ad->ad_type->sat_equality, + atname, vals, &keys ); + + if( rc == LDAP_SUCCESS && keys != NULL ) { + for( i=0; keys[i].bv_val != NULL; i++ ) { + rc = bdb_key_change( be, db, txn, &keys[i], id, op ); + if( rc ) { + ber_bvarray_free( keys ); + goto done; + } + } + ber_bvarray_free( keys ); + } + rc = LDAP_SUCCESS; + } + + if( IS_SLAP_INDEX( mask, SLAP_INDEX_APPROX ) ) { + rc = ad->ad_type->sat_approx->smr_indexer( + LDAP_FILTER_APPROX, + mask, + ad->ad_type->sat_syntax, + ad->ad_type->sat_approx, + atname, vals, &keys ); + + if( rc == LDAP_SUCCESS && keys != NULL ) { + for( i=0; keys[i].bv_val != NULL; i++ ) { + rc = bdb_key_change( be, db, txn, &keys[i], id, op ); + if( rc ) { + ber_bvarray_free( keys ); + goto done; + } + } + ber_bvarray_free( keys ); + } + + rc = LDAP_SUCCESS; + } + + if( IS_SLAP_INDEX( mask, SLAP_INDEX_SUBSTR ) ) { + rc = ad->ad_type->sat_substr->smr_indexer( + LDAP_FILTER_SUBSTRINGS, + mask, + ad->ad_type->sat_syntax, + ad->ad_type->sat_substr, + atname, vals, &keys ); + + if( rc == LDAP_SUCCESS && keys != NULL ) { + for( i=0; keys[i].bv_val != NULL; i++ ) { + bdb_key_change( be, db, txn, &keys[i], id, op ); + if( rc ) { + ber_bvarray_free( keys ); + goto done; + } + } + ber_bvarray_free( keys ); + } + + rc = LDAP_SUCCESS; + } + +done: + return rc; +} + +static int index_at_values( + Backend *be, + DB_TXN *txn, + AttributeType *type, + struct berval *lang, + BerVarray vals, + ID id, + int op ) +{ + int rc; + slap_mask_t mask = 0; + + if( type->sat_sup ) { + /* recurse */ + rc = index_at_values( be, txn, + type->sat_sup, lang, + vals, id, op ); + + if( rc ) return rc; + } + + /* If this type has no AD, we've never used it before */ + if( type->sat_ad ) { + bdb_attr_mask( be->be_private, type->sat_ad, &mask ); + } + + if( mask ) { + rc = indexer( be, txn, type->sat_cname.bv_val, + &type->sat_cname, + vals, id, op, + mask ); + + if( rc ) return rc; + } + + if( lang->bv_len ) { + AttributeDescription *desc; + + mask = 0; + + desc = ad_find_lang( type, lang ); + if( desc ) { + bdb_attr_mask( be->be_private, desc, &mask ); + } + + if( mask ) { + rc = indexer( be, txn, desc->ad_cname.bv_val, + &desc->ad_cname, + vals, id, op, + mask ); + + if( rc ) { + return rc; + } + } + } + + return LDAP_SUCCESS; +} + +int bdb_index_values( + Backend *be, + DB_TXN *txn, + AttributeDescription *desc, + BerVarray vals, + ID id, + int op ) +{ + int rc; + + rc = index_at_values( be, txn, + desc->ad_type, &desc->ad_lang, + vals, id, op ); + + return rc; +} + +int +bdb_index_entry( + Backend *be, + DB_TXN *txn, + int op, + Entry *e, + Attribute *ap ) +{ + int rc; + +#ifdef NEW_LOGGING + LDAP_LOG( INDEX, ENTRY, "index_entry: %s (%s) %ld\n", + op == SLAP_INDEX_ADD_OP ? "add" : "del", e->e_dn, (long) e->e_id ); +#else + Debug( LDAP_DEBUG_TRACE, "=> index_entry_%s( %ld, \"%s\" )\n", + op == SLAP_INDEX_ADD_OP ? "add" : "del", + (long) e->e_id, e->e_dn ); +#endif + + /* add each attribute to the indexes */ + for ( ; ap != NULL; ap = ap->a_next ) { + rc = bdb_index_values( be, txn, + ap->a_desc, ap->a_vals, e->e_id, op ); + + if( rc != LDAP_SUCCESS ) { +#ifdef NEW_LOGGING + LDAP_LOG( INDEX, ENTRY, + "index_entry: failure (%d)\n", rc, 0, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, + "<= index_entry_%s( %ld, \"%s\" ) failure\n", + op == SLAP_INDEX_ADD_OP ? "add" : "del", + (long) e->e_id, e->e_dn ); +#endif + return rc; + } + } + +#ifdef NEW_LOGGING + LDAP_LOG( INDEX, ENTRY, "index_entry: success\n", 0, 0, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, "<= index_entry_%s( %ld, \"%s\" ) success\n", + op == SLAP_INDEX_ADD_OP ? "add" : "del", + (long) e->e_id, e->e_dn ); +#endif + + return LDAP_SUCCESS; +} diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c index 8563b3ee83a88388177fda06395349a6d4c5835e..2a80970a46c48604c006ef59ea8523e5109a5e35 100644 --- a/servers/slapd/back-bdb/init.c +++ b/servers/slapd/back-bdb/init.c @@ -61,7 +61,7 @@ bdb_db_init( BackendDB *be ) struct bdb_info *bdb; #ifdef NEW_LOGGING - LDAP_LOG(( "init", LDAP_LEVEL_ENTRY, "bdb_db_init" )); + LDAP_LOG( BACK_BDB, ENTRY, "bdb_db_init", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "bdb_db_init: Initializing BDB database\n", @@ -126,7 +126,8 @@ static void *lock_detect_task( void *arg ) } #ifdef NEW_LOGGING - LDAP_LOG(( "init", LDAP_LEVEL_ERR, "bdb_db_init: aborted %d locks\n", aborted )); + LDAP_LOG( BACK_BDB, ERR, "bdb_db_init: aborted %d locks\n", + aborted, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "bdb_lock_detect: aborted %d locks\n", @@ -171,7 +172,8 @@ bdb_db_open( BackendDB *be ) u_int32_t flags; #ifdef NEW_LOGGING - LDAP_LOG(( "init", LDAP_LEVEL_ARGS, "bdb_db_open: %s\n", be->be_suffix[0].bv_val )); + LDAP_LOG( BACK_BDB, ARGS, + "bdb_db_open: %s\n", be->be_suffix[0].bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_ARGS, "bdb_db_open: %s\n", @@ -183,7 +185,9 @@ bdb_db_open( BackendDB *be ) rc = db_env_create( &bdb->bi_dbenv, 0 ); if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "init", LDAP_LEVEL_ERR, "bdb_db_open: db_env_create failed: %s (%d)\n", db_strerror(rc), rc )); + LDAP_LOG( BACK_BDB, ERR, + "bdb_db_open: db_env_create failed: %s (%d)\n", + db_strerror(rc), rc, 0 ); #else Debug( LDAP_DEBUG_ANY, "bdb_db_open: db_env_create failed: %s (%d)\n", @@ -193,7 +197,12 @@ bdb_db_open( BackendDB *be ) } flags = DB_INIT_MPOOL | DB_THREAD | DB_CREATE - | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_TXN | DB_RECOVER; + | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_TXN; + + /* Only slapd will do recovery, slap-tools won't. Otherwise + * running slapcat while slapd is active corrupts the db. + */ + if( !(slapMode & SLAP_TOOL_MODE) ) flags |= DB_RECOVER; bdb->bi_dbenv->set_errpfx( bdb->bi_dbenv, be->be_suffix[0].bv_val ); bdb->bi_dbenv->set_errcall( bdb->bi_dbenv, bdb_errcall ); @@ -212,7 +221,9 @@ bdb_db_open( BackendDB *be ) rc = bdb->bi_dbenv->set_tmp_dir( bdb->bi_dbenv, dir ); if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "init", LDAP_LEVEL_ERR, "bdb_db_open: set_tmp_dir(%s) failed: %s (%d)\n", dir, db_strerror(rc), rc )); + LDAP_LOG( BACK_BDB, ERR, + "bdb_db_open: set_tmp_dir(%s) failed: %s (%d)\n", + dir, db_strerror(rc), rc ); #else Debug( LDAP_DEBUG_ANY, "bdb_db_open: set_tmp_dir(%s) failed: %s (%d)\n", @@ -226,7 +237,9 @@ bdb_db_open( BackendDB *be ) rc = bdb->bi_dbenv->set_lg_dir( bdb->bi_dbenv, dir ); if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "init", LDAP_LEVEL_ERR, "bdb_db_open: set_lg_dir(%s) failed: %s (%d)\n", dir, db_strerror(rc), rc )); + LDAP_LOG( BACK_BDB, ERR, + "bdb_db_open: set_lg_dir(%s) failed: %s (%d)\n", + dir, db_strerror(rc), rc ); #else Debug( LDAP_DEBUG_ANY, "bdb_db_open: set_lg_dir(%s) failed: %s (%d)\n", @@ -240,7 +253,9 @@ bdb_db_open( BackendDB *be ) rc = bdb->bi_dbenv->set_data_dir( bdb->bi_dbenv, dir ); if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "init", LDAP_LEVEL_ERR, "bdb_db_open: set_data_dir(%s) failed: %s (%d)\n", dir, db_strerror(rc), rc )); + LDAP_LOG( BACK_BDB, ERR, + "bdb_db_open: set_data_dir(%s) failed: %s (%d)\n", + dir, db_strerror(rc), rc ); #else Debug( LDAP_DEBUG_ANY, "bdb_db_open: set_data_dir(%s) failed: %s (%d)\n", @@ -252,7 +267,8 @@ bdb_db_open( BackendDB *be ) #endif #ifdef NEW_LOGGING - LDAP_LOG(( "init", LDAP_LEVEL_DETAIL1, "bdb_db_open: dbenv_open %s\n", bdb->bi_dbenv_home )); + LDAP_LOG( BACK_BDB, DETAIL1, + "bdb_db_open: dbenv_open %s\n", bdb->bi_dbenv_home, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_db_open: dbenv_open(%s)\n", @@ -265,7 +281,9 @@ bdb_db_open( BackendDB *be ) bdb->bi_dbenv_mode ); if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "init", LDAP_LEVEL_ERR, "bdb_db_open: dbenv_open failed: %s (%d)\n", db_strerror(rc), rc )); + LDAP_LOG( BACK_BDB, ERR, + "bdb_db_open: dbenv_open failed: %s (%d)\n", + db_strerror(rc), rc, 0 ); #else Debug( LDAP_DEBUG_ANY, "bdb_db_open: dbenv_open failed: %s (%d)\n", @@ -279,7 +297,9 @@ bdb_db_open( BackendDB *be ) bdb->bi_dbenv_xflags, 1); if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "init", LDAP_LEVEL_ERR, "bdb_db_open: dbenv_set_flags failed: %s (%d)\n", db_strerror(rc), rc )); + LDAP_LOG( BACK_BDB, ERR, + "bdb_db_open: dbenv_set_flags failed: %s (%d)\n", + db_strerror(rc), rc, 0 ); #else Debug( LDAP_DEBUG_ANY, "bdb_db_open: dbenv_set_flags failed: %s (%d)\n", @@ -303,7 +323,9 @@ bdb_db_open( BackendDB *be ) rc = db_create( &db->bdi_db, bdb->bi_dbenv, 0 ); if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "init", LDAP_LEVEL_ERR, "bdb_db_open: db_create(%s) failed: %s (%d)\n", bdb->bi_dbenv_home, db_strerror(rc), rc )); + LDAP_LOG( BACK_BDB, ERR, + "bdb_db_open: db_create(%s) failed: %s (%d)\n", + bdb->bi_dbenv_home, db_strerror(rc), rc ); #else Debug( LDAP_DEBUG_ANY, "bdb_db_open: db_create(%s) failed: %s (%d)\n", @@ -340,7 +362,9 @@ bdb_db_open( BackendDB *be ) if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "init", LDAP_LEVEL_ERR, "bdb_db_open: db_create(%s) failed: %s (%d)\n", bdb->bi_dbenv_home, db_strerror(rc), rc )); + LDAP_LOG( BACK_BDB, ERR, + "bdb_db_open: db_create(%s) failed: %s (%d)\n", + bdb->bi_dbenv_home, db_strerror(rc), rc ); #else Debug( LDAP_DEBUG_ANY, "bdb_db_open: db_open(%s) failed: %s (%d)\n", @@ -360,7 +384,9 @@ bdb_db_open( BackendDB *be ) rc = bdb_last_id( be, NULL ); if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "init", LDAP_LEVEL_ERR, "bdb_db_open: last_id(%s) failed: %s (%d)\n", bdb->bi_dbenv_home, db_strerror(rc), rc )); + LDAP_LOG( BACK_BDB, ERR, + "bdb_db_open: last_id(%s) failed: %s (%d)\n", + bdb->bi_dbenv_home, db_strerror(rc), rc ); #else Debug( LDAP_DEBUG_ANY, "bdb_db_open: last_id(%s) failed: %s (%d)\n", @@ -419,7 +445,9 @@ bdb_db_destroy( BackendDB *be ) rc = TXN_CHECKPOINT( bdb->bi_dbenv, 0, 0, DB_FORCE ); if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "init", LDAP_LEVEL_ERR, "bdb_db_destroy: txn_checkpoint failed: %s (%d)\n", db_strerror(rc), rc )); + LDAP_LOG( BACK_BDB, ERR, + "bdb_db_destroy: txn_checkpoint failed: %s (%d)\n", + db_strerror(rc), rc, 0 ); #else Debug( LDAP_DEBUG_ANY, "bdb_db_destroy: txn_checkpoint failed: %s (%d)\n", @@ -433,7 +461,9 @@ bdb_db_destroy( BackendDB *be ) bdb->bi_dbenv = NULL; if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "init", LDAP_LEVEL_ERR, "bdb_db_destroy: close failed: %s (%d)\n", db_strerror(rc), rc )); + LDAP_LOG( BACK_BDB, ERR, + "bdb_db_destroy: close failed: %s (%d)\n", + db_strerror(rc), rc, 0 ); #else Debug( LDAP_DEBUG_ANY, "bdb_db_destroy: close failed: %s (%d)\n", @@ -490,7 +520,7 @@ bdb_initialize( /* initialize the underlying database system */ #ifdef NEW_LOGGING - LDAP_LOG(( "init", LDAP_LEVEL_ENTRY, "bdb_db_initialize\n" )); + LDAP_LOG( BACK_BDB, ENTRY, "bdb_db_initialize\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_open: initialize BDB backend\n", 0, 0, 0 ); @@ -505,7 +535,9 @@ bdb_initialize( patch < DB_VERSION_PATCH ) { #ifdef NEW_LOGGING - LDAP_LOG(( "init", LDAP_LEVEL_ERR, "bdb_db_initialize: version mismatch: \texpected: %s \tgot: %s\n", DB_VERSION_STRING, version )); + LDAP_LOG( BACK_BDB, ERR, + "bdb_db_initialize: version mismatch: " + "\texpected: %s \tgot: %s\n", DB_VERSION_STRING, version, 0 ); #else Debug( LDAP_DEBUG_ANY, "bdb_open: version mismatch\n" @@ -515,7 +547,8 @@ bdb_initialize( } #ifdef NEW_LOGGING - LDAP_LOG(( "init", LDAP_LEVEL_DETAIL1, "bdb_db_initialize: bdb_open: %s\n", version )); + LDAP_LOG( BACK_BDB, DETAIL1, + "bdb_db_initialize: bdb_open: %s\n", version, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "bdb_open: %s\n", version, 0, 0 ); diff --git a/servers/slapd/back-bdb/key.c b/servers/slapd/back-bdb/key.c index a6b490f101cac5f2d2dcdc9f9e50987a9020face..46371dc519125a00ceb0e0b604787f1bda7c1662 100644 --- a/servers/slapd/back-bdb/key.c +++ b/servers/slapd/back-bdb/key.c @@ -30,8 +30,7 @@ bdb_key_read( DBT key; #ifdef NEW_LOGGING - LDAP_LOG(( "index", LDAP_LEVEL_ENTRY, - "key_read: enter\n" )); + LDAP_LOG( INDEX, ENTRY, "key_read: enter\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "=> key_read\n", 0, 0, 0 ); #endif @@ -45,17 +44,15 @@ bdb_key_read( if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "index", LDAP_LEVEL_ERR, - "bdb_key_read: failed (%d)\n", - rc )); + LDAP_LOG( INDEX, ERR, "bdb_key_read: failed (%d)\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= bdb_index_read: failed (%d)\n", rc, 0, 0 ); #endif } else { #ifdef NEW_LOGGING - LDAP_LOG(( "index", LDAP_LEVEL_DETAIL1, - "bdb_key_read: %ld candidates\n", (long) BDB_IDL_N(ids) )); + LDAP_LOG( INDEX, DETAIL1, + "bdb_key_read: %ld candidates\n", (long)BDB_IDL_N(ids), 0, 0); #else Debug( LDAP_DEBUG_TRACE, "<= bdb_index_read %ld candidates\n", (long) BDB_IDL_N(ids), 0, 0 ); @@ -80,9 +77,8 @@ bdb_key_change( DBT key; #ifdef NEW_LOGGING - LDAP_LOG(( "index", LDAP_LEVEL_DETAIL1, - "key_change: %s ID %lx\n", - op == SLAP_INDEX_ADD_OP ? "Add" : "Delete", (long) id )); + LDAP_LOG( INDEX, ENTRY, "key_change: %s ID %lx\n", + op == SLAP_INDEX_ADD_OP ? "Add" : "Delete", (long) id, 0 ); #else Debug( LDAP_DEBUG_TRACE, "=> key_change(%s,%lx)\n", op == SLAP_INDEX_ADD_OP ? "ADD":"DELETE", (long) id, 0 ); @@ -103,8 +99,7 @@ bdb_key_change( } #ifdef NEW_LOGGING - LDAP_LOG(( "index", LDAP_LEVEL_RESULTS, - "key_change: return %d\n", rc )); + LDAP_LOG( INDEX, RESULTS, "key_change: return %d\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= key_change %d\n", rc, 0, 0 ); #endif diff --git a/servers/slapd/back-bdb/modify.c b/servers/slapd/back-bdb/modify.c index a6c80c3992387031425be0e5a378714532c7f43c..4f052e404ce7ad154f40c28389826ffcb1552116 100644 --- a/servers/slapd/back-bdb/modify.c +++ b/servers/slapd/back-bdb/modify.c @@ -32,7 +32,8 @@ int bdb_modify_internal( Attribute *ap; #ifdef NEW_LOGGING - LDAP_LOG (( "modify", LDAP_LEVEL_ENTRY,"bdb_modify_internal: 0x%08lx: %s\n", e->e_id, e->e_dn )); + LDAP_LOG ( OPERATION, ENTRY, "bdb_modify_internal: 0x%08lx: %s\n", + e->e_id, e->e_dn, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modify_internal: 0x%08lx: %s\n", e->e_id, e->e_dn, 0); @@ -51,14 +52,15 @@ int bdb_modify_internal( switch ( mod->sm_op ) { case LDAP_MOD_ADD: #ifdef NEW_LOGGING - LDAP_LOG (( "modify", LDAP_LEVEL_DETAIL1, "bdb_modify_internal: add\n" )); + LDAP_LOG ( OPERATION, DETAIL1, "bdb_modify_internal: add\n", 0,0,0); #else Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: add\n", 0, 0, 0); #endif err = modify_add_values( e, mod, text, textbuf, textlen ); if( err != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG (( "modify", LDAP_LEVEL_ERR, "bdb_modify_internal: %d %s\n", err, *text )); + LDAP_LOG ( OPERATION, ERR, + "bdb_modify_internal: %d %s\n", err, *text, 0 ); #else Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: %d %s\n", err, *text, 0); @@ -68,7 +70,8 @@ int bdb_modify_internal( case LDAP_MOD_DELETE: #ifdef NEW_LOGGING - LDAP_LOG (( "modify", LDAP_LEVEL_DETAIL1, "bdb_modify_internal: delete\n" )); + LDAP_LOG ( OPERATION, DETAIL1, + "bdb_modify_internal: delete\n", 0, 0, 0 ); #else Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: delete\n", 0, 0, 0); #endif @@ -76,7 +79,8 @@ int bdb_modify_internal( assert( err != LDAP_TYPE_OR_VALUE_EXISTS ); if( err != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG (( "modify", LDAP_LEVEL_ERR, "bdb_modify_internal: %d %s\n", err, *text )); + LDAP_LOG ( OPERATION, ERR, + "bdb_modify_internal: %d %s\n", err, *text, 0 ); #else Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: %d %s\n", err, *text, 0); @@ -86,14 +90,16 @@ int bdb_modify_internal( case LDAP_MOD_REPLACE: #ifdef NEW_LOGGING - LDAP_LOG (( "modify", LDAP_LEVEL_DETAIL1, "bdb_modify_internal: replace\n" )); + LDAP_LOG ( OPERATION, DETAIL1, + "bdb_modify_internal: replace\n", 0, 0, 0 ); #else Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: replace\n", 0, 0, 0); #endif err = modify_replace_values( e, mod, text, textbuf, textlen ); if( err != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG (( "modify", LDAP_LEVEL_ERR, "bdb_modify_internal: %d %s\n", err, *text )); + LDAP_LOG ( OPERATION, ERR, + "bdb_modify_internal: %d %s\n", err, *text, 0 ); #else Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: %d %s\n", err, *text, 0); @@ -103,7 +109,8 @@ int bdb_modify_internal( case SLAP_MOD_SOFTADD: #ifdef NEW_LOGGING - LDAP_LOG (( "modify", LDAP_LEVEL_DETAIL1, "bdb_modify_internal: softadd\n" )); + LDAP_LOG ( OPERATION, DETAIL1, + "bdb_modify_internal: softadd\n",0,0,0 ); #else Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: softadd\n", 0, 0, 0); #endif @@ -119,7 +126,8 @@ int bdb_modify_internal( if( err != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG (( "modify", LDAP_LEVEL_ERR, "bdb_modify_internal: %d %s\n", err, *text )); + LDAP_LOG ( OPERATION, ERR, + "bdb_modify_internal: %d %s\n", err, *text, 0 ); #else Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: %d %s\n", err, *text, 0); @@ -129,7 +137,8 @@ int bdb_modify_internal( default: #ifdef NEW_LOGGING - LDAP_LOG (( "modify", LDAP_LEVEL_ERR, "bdb_modify_internal: invalid op %d\n", mod->sm_op )); + LDAP_LOG ( OPERATION, ERR, + "bdb_modify_internal: invalid op %d\n", mod->sm_op, 0, 0 ); #else Debug(LDAP_DEBUG_ANY, "bdb_modify_internal: invalid op %d\n", mod->sm_op, 0, 0); @@ -137,7 +146,8 @@ int bdb_modify_internal( *text = "Invalid modify operation"; err = LDAP_OTHER; #ifdef NEW_LOGGING - LDAP_LOG (( "modify", LDAP_LEVEL_ERR, "bdb_modify_internal: %d %s\n", err, *text )); + LDAP_LOG ( OPERATION, ERR, + "bdb_modify_internal: %d %s\n", err, *text, 0 ); #else Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: %d %s\n", err, *text, 0); @@ -173,7 +183,9 @@ int bdb_modify_internal( attrs_free( e->e_attrs ); e->e_attrs = save_attrs; #ifdef NEW_LOGGING - LDAP_LOG (( "modify", LDAP_LEVEL_ERR, "bdb_modify_internal: entry failed schema check %s\n", *text )); + LDAP_LOG ( OPERATION, ERR, + "bdb_modify_internal: entry failed schema check %s\n", + *text, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "entry failed schema check: %s\n", *text, 0, 0 ); @@ -192,7 +204,9 @@ int bdb_modify_internal( attrs_free( e->e_attrs ); e->e_attrs = save_attrs; #ifdef NEW_LOGGING - LDAP_LOG (( "modify", LDAP_LEVEL_ERR, "bdb_modify_internal: attribute index delete failure\n" )); + LDAP_LOG ( OPERATION, ERR, + "bdb_modify_internal: attribute index delete failure\n", + 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "Attribute index delete failure", @@ -213,7 +227,9 @@ int bdb_modify_internal( attrs_free( e->e_attrs ); e->e_attrs = save_attrs; #ifdef NEW_LOGGING - LDAP_LOG (( "modify", LDAP_LEVEL_ERR, "bdb_modify_internal: attribute index add failure\n" )); + LDAP_LOG ( OPERATION, ERR, + "bdb_modify_internal: attribute index add failure\n", + 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "Attribute index add failure", @@ -253,7 +269,7 @@ bdb_modify( DB_LOCK lock; #ifdef NEW_LOGGING - LDAP_LOG (( "modify", LDAP_LEVEL_ENTRY, "bdb_modify: %s\n", dn->bv_val )); + LDAP_LOG ( OPERATION, ENTRY, "bdb_modify: %s\n", dn->bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_ARGS, "bdb_modify: %s\n", dn->bv_val, 0, 0 ); #endif @@ -265,7 +281,7 @@ retry: /* transaction retry */ bdb_unlocked_cache_return_entry_w(&bdb->bi_cache, e); } #ifdef NEW_LOGGING - LDAP_LOG (( "modify", LDAP_LEVEL_DETAIL1, "bdb_modify: retrying...\n" )); + LDAP_LOG ( OPERATION, DETAIL1, "bdb_modify: retrying...\n", 0, 0, 0 ); #else Debug(LDAP_DEBUG_TRACE, "bdb_modify: retrying...\n", 0, 0, 0); @@ -287,7 +303,8 @@ retry: /* transaction retry */ text = NULL; if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "modify", LDAP_LEVEL_DETAIL1, "bdb_modify: txn_begin failed: %s (%d)\n", db_strerror(rc), rc )); + LDAP_LOG ( OPERATION, DETAIL1, + "bdb_modify: txn_begin failed: %s (%d)\n", db_strerror(rc), rc, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modify: txn_begin failed: %s (%d)\n", @@ -310,7 +327,8 @@ retry: /* transaction retry */ if ( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "modify", LDAP_LEVEL_DETAIL1, "bdb_modify: dn2entry failed: (%d)\n", rc )); + LDAP_LOG ( OPERATION, DETAIL1, + "bdb_modify: dn2entry failed: (%d)\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modify: dn2entry failed (%d)\n", @@ -365,7 +383,7 @@ retry: /* transaction retry */ conn, op, e ); #ifdef NEW_LOGGING - LDAP_LOG (( "modify", LDAP_LEVEL_DETAIL1, "bdb_modify: entry is referral\n" )); + LDAP_LOG ( OPERATION, DETAIL1, "bdb_modify: entry is referral\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modify: entry is referral\n", @@ -385,7 +403,8 @@ retry: /* transaction retry */ if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG (( "modify", LDAP_LEVEL_ERR, "bdb_modify: modify failed (%d)\n", rc )); + LDAP_LOG ( OPERATION, ERR, + "bdb_modify: modify failed (%d)\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modify: modify failed (%d)\n", @@ -403,7 +422,8 @@ retry: /* transaction retry */ rc = bdb_id2entry_update( be, ltid, e ); if ( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "modify", LDAP_LEVEL_ERR, "bdb_modify: id2entry update failed (%d)\n", rc )); + LDAP_LOG ( OPERATION, ERR, + "bdb_modify: id2entry update failed (%d)\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modify: id2entry update failed (%d)\n", @@ -428,7 +448,9 @@ retry: /* transaction retry */ if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "modify", LDAP_LEVEL_ERR, "bdb_modify: txn_%s failed %s (%d)\n", op->o_noop ? "abort (no_op)" : "commit", db_strerror(rc), rc )); + LDAP_LOG ( OPERATION, ERR, + "bdb_modify: txn_%s failed %s (%d)\n", + op->o_noop ? "abort (no_op)" : "commit", db_strerror(rc), rc ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modify: txn_%s failed: %s (%d)\n", @@ -440,7 +462,9 @@ retry: /* transaction retry */ } else { #ifdef NEW_LOGGING - LDAP_LOG (( "modify", LDAP_LEVEL_DETAIL1, "bdb_modify: updated%s id=%08lx dn=\"%s\"\n", op->o_noop ? " (no_op)" : "", e->e_id, e->e_dn )); + LDAP_LOG ( OPERATION, DETAIL1, + "bdb_modify: updated%s id=%08lx dn=\"%s\"\n", + op->o_noop ? " (no_op)" : "", e->e_id, e->e_dn ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modify: updated%s id=%08lx dn=\"%s\"\n", diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c index 439fcc2b5de47df2dca37c46af60cc96ffe7398d..da4ab3ec95b9e11bda48e4c8a4166554c5d6b649 100644 --- a/servers/slapd/back-bdb/modrdn.c +++ b/servers/slapd/back-bdb/modrdn.c @@ -60,9 +60,8 @@ bdb_modrdn( DB_LOCK lock; #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_ENTRY, "==>bdb_modrdn(%s,%s,%s)\n", - dn->bv_val,newrdn->bv_val, - newSuperior ? newSuperior->bv_val : "NULL" )); + LDAP_LOG ( OPERATION, ENTRY, "==>bdb_modrdn(%s,%s,%s)\n", + dn->bv_val,newrdn->bv_val, newSuperior ? newSuperior->bv_val : "NULL" ); #else Debug( LDAP_DEBUG_TRACE, "==>bdb_modrdn(%s,%s,%s)\n", dn->bv_val, newrdn->bv_val, @@ -90,7 +89,7 @@ retry: /* transaction retry */ bdb_unlocked_cache_return_entry_r(&bdb->bi_cache, np); } #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: retrying...\n")); + LDAP_LOG ( OPERATION, DETAIL1, "==>bdb_modrdn: retrying...\n", 0, 0, 0); #else Debug( LDAP_DEBUG_TRACE, "==>bdb_modrdn: retrying...\n", 0, 0, 0 ); #endif @@ -111,7 +110,9 @@ retry: /* transaction retry */ text = NULL; if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "==>bdb_modrdn: txn_begin failed: %s (%d)\n", db_strerror(rc), rc )); + LDAP_LOG ( OPERATION, ERR, + "==>bdb_modrdn: txn_begin failed: %s (%d)\n", + db_strerror(rc), rc, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_delete: txn_begin failed: %s (%d)\n", @@ -181,7 +182,8 @@ retry: /* transaction retry */ conn, op, e ); #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: entry %s is referral \n", e->e_dn )); + LDAP_LOG ( OPERATION, DETAIL1, + "==>bdb_modrdn: entry %s is referral \n", e->e_dn, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: entry %s is referral\n", e->e_dn, 0, 0 ); @@ -224,7 +226,8 @@ retry: /* transaction retry */ if( p == NULL) { #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "==>bdb_modrdn: parent does not exist\n" )); + LDAP_LOG ( OPERATION, ERR, + "==>bdb_modrdn: parent does not exist\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: parent does not exist\n", 0, 0, 0); @@ -238,7 +241,8 @@ retry: /* transaction retry */ children, NULL, ACL_WRITE, NULL ) ) { #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "==>bdb_modrdn: no access to parent\n" )); + LDAP_LOG ( OPERATION, ERR, + "==>bdb_modrdn: no access to parent\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "no access to parent\n", 0, 0, 0 ); @@ -249,7 +253,8 @@ retry: /* transaction retry */ } #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: wr to children %s is OK\n", p_ndn.bv_val )); + LDAP_LOG ( OPERATION, DETAIL1, + "==>bdb_modrdn: wr to children %s is OK\n", p_ndn.bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: wr to children of entry %s OK\n", @@ -263,7 +268,8 @@ retry: /* transaction retry */ } #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: parent dn=%s\n", p_dn.bv_val )); + LDAP_LOG ( OPERATION, DETAIL1, + "==>bdb_modrdn: parent dn=%s\n", p_dn.bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: parent dn=%s\n", @@ -288,7 +294,8 @@ retry: /* transaction retry */ if ( ! rc ) { #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "==>bdb_modrdn: no access to parent\n" )); + LDAP_LOG ( OPERATION, ERR, + "==>bdb_modrdn: no access to parent\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "no access to parent\n", @@ -301,7 +308,9 @@ retry: /* transaction retry */ } #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: wr to children of entry \"\" OK\n", p_dn.bv_val )); + LDAP_LOG ( OPERATION, DETAIL1, + "==>bdb_modrdn: wr to children of entry \"%s\" OK\n", + p_dn.bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: wr to children of entry \"\" OK\n", @@ -312,7 +321,8 @@ retry: /* transaction retry */ p_dn.bv_len = 0; #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: parent dn=\"\" \n" )); + LDAP_LOG ( OPERATION, DETAIL1, + "==>bdb_modrdn: parent dn=\"\" \n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: parent dn=\"\"\n", @@ -321,7 +331,9 @@ retry: /* transaction retry */ } else { #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "==>bdb_modrdn: no parent, not root &\"\" is not suffix\n" )); + LDAP_LOG ( OPERATION, ERR, + "==>bdb_modrdn: no parent, not root &\"\" is not " + "suffix\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: no parent, not root " @@ -338,7 +350,9 @@ retry: /* transaction retry */ if ( newSuperior != NULL ) { #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: new parent \"%s\" requested...\n", newSuperior->bv_val )); + LDAP_LOG ( OPERATION, DETAIL1, + "==>bdb_modrdn: new parent \"%s\" requested...\n", + newSuperior->bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: new parent \"%s\" requested...\n", @@ -373,7 +387,9 @@ retry: /* transaction retry */ if( np == NULL) { #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: newSup(ndn=%s) not here!\n", np_ndn->bv_val )); + LDAP_LOG ( OPERATION, DETAIL1, + "==>bdb_modrdn: newSup(ndn=%s) not here!\n", + np_ndn->bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: newSup(ndn=%s) not here!\n", @@ -384,7 +400,9 @@ retry: /* transaction retry */ } #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: wr to new parent OK np=%p, id=%ld\n", np, (long) np->e_id )); + LDAP_LOG ( OPERATION, DETAIL1, + "==>bdb_modrdn: wr to new parent OK np=%p, id=%ld\n", + np, (long) np->e_id, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: wr to new parent OK np=%p, id=%ld\n", @@ -394,7 +412,8 @@ retry: /* transaction retry */ /* check newSuperior for "children" acl */ if ( !access_allowed( be, conn, op, np, children, NULL, ACL_WRITE, NULL ) ) { #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: no wr to newSup children\n" )); + LDAP_LOG ( OPERATION, DETAIL1, + "==>bdb_modrdn: no wr to newSup children\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: no wr to newSup children\n", @@ -408,7 +427,8 @@ retry: /* transaction retry */ if ( is_entry_alias( np ) ) { /* parent is an alias, don't allow add */ #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: entry is alias\n" )); + LDAP_LOG ( OPERATION, DETAIL1, + "==>bdb_modrdn: entry is alias\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: entry is alias\n", 0, 0, 0 ); @@ -422,7 +442,8 @@ retry: /* transaction retry */ if ( is_entry_referral( np ) ) { /* parent is a referral, don't allow add */ #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: entry is referral\n" )); + LDAP_LOG ( OPERATION, DETAIL1, + "==>bdb_modrdn: entry is referral\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: entry is referral\n", 0, 0, 0 ); @@ -454,7 +475,8 @@ retry: /* transaction retry */ if ( ! rc ) { #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "==>bdb_modrdn: no access to superior\n" )); + LDAP_LOG ( OPERATION, ERR, + "==>bdb_modrdn: no access to superior\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "no access to new superior\n", @@ -467,7 +489,8 @@ retry: /* transaction retry */ } #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "bdb_modrdn: wr to children entry \"\" OK\n" )); + LDAP_LOG ( OPERATION, DETAIL1, + "bdb_modrdn: wr to children entry \"\" OK\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: wr to children of entry \"\" OK\n", @@ -476,7 +499,9 @@ retry: /* transaction retry */ } else { #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "bdb_modrdn: new superior=\"\", not root & \"\" is not suffix\n" )); + LDAP_LOG ( OPERATION, ERR, + "bdb_modrdn: new superior=\"\", not root & \"\" " + "is not suffix\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: new superior=\"\", not root " @@ -489,7 +514,8 @@ retry: /* transaction retry */ } #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "bdb_modrdn: new superior=\"\"\n" )); + LDAP_LOG ( OPERATION, DETAIL1, + "bdb_modrdn: new superior=\"\"\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: new superior=\"\"\n", @@ -498,7 +524,8 @@ retry: /* transaction retry */ } #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "bdb_modrdn: wr to new parent's children OK\n" )); + LDAP_LOG ( OPERATION, DETAIL1, + "bdb_modrdn: wr to new parent's children OK\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: wr to new parent's children OK\n", @@ -514,7 +541,8 @@ retry: /* transaction retry */ dnNormalize2( NULL, &new_dn, &new_ndn ); #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_RESULTS, "bdb_modrdn: new ndn=%s\n", new_ndn.bv_val )); + LDAP_LOG ( OPERATION, RESULTS, + "bdb_modrdn: new ndn=%s\n", new_ndn.bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: new ndn=%s\n", new_ndn.bv_val, 0, 0 ); @@ -537,7 +565,8 @@ retry: /* transaction retry */ } #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "bdb_modrdn: new ndn=%s does not exist\n", new_ndn.bv_val )); + LDAP_LOG ( OPERATION, ERR, + "bdb_modrdn: new ndn=%s does not exist\n", new_ndn.bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: new ndn=%s does not exist\n", @@ -551,7 +580,9 @@ retry: /* transaction retry */ LDAP_DN_FORMAT_LDAP ) ) { #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "bdb_modrdn: can't figure out type(s)/values(s) of newrdn\n" )); + LDAP_LOG ( OPERATION, ERR, + "bdb_modrdn: can't figure out type(s)/values(s) of newrdn\n", + 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: can't figure out type(s)/values(s) " @@ -563,7 +594,9 @@ retry: /* transaction retry */ } #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_RESULTS, "bdb_modrdn: new_rdn_type=\"%s\", new_rdn_val=\"%s\"\n", new_rdn[0][0]->la_attr.bv_val, new_rdn[0][0]->la_value.bv_val )); + LDAP_LOG ( OPERATION, RESULTS, + "bdb_modrdn: new_rdn_type=\"%s\", new_rdn_val=\"%s\"\n", + new_rdn[0][0]->la_attr.bv_val, new_rdn[0][0]->la_value.bv_val, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: new_rdn_type=\"%s\", new_rdn_val=\"%s\"\n", @@ -574,7 +607,9 @@ retry: /* transaction retry */ LDAP_DN_FORMAT_LDAP ) ) { #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "bdb_modrdn: can't figure out type(s)/values(s) of old_rdn\n" )); + LDAP_LOG ( OPERATION, ERR, + "bdb_modrdn: can't figure out type(s)/values(s) of old_rdn\n", + 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_back_modrdn: can't figure out the old_rdn " @@ -591,7 +626,9 @@ retry: /* transaction retry */ ( const char ** )new_rdn_types ) != 0 ) { /* Not a big deal but we may say something */ #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "bdb_modrdn: old_rdn_type(s)=%s, new_rdn_type(s)=%s do not match\n", old_rdn_types[ 0 ], new_rdn_types[ 0 ] )); + LDAP_LOG ( OPERATION, ERR, + "bdb_modrdn: old_rdn_type(s)=%s, new_rdn_type(s)=%s do not match\n", + old_rdn_types[ 0 ], new_rdn_types[ 0 ], 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: old_rdn_type(s)=%s, new_rdn_type(s)=%s " @@ -611,7 +648,8 @@ retry: /* transaction retry */ if ( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "bdb_modrdn: %s: %s (new)\n", text, new_rdn[0][a_cnt]->la_attr.bv_val )); + LDAP_LOG ( OPERATION, ERR, "bdb_modrdn: %s: %s (new)\n", + text, new_rdn[0][a_cnt]->la_attr.bv_val, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: %s: %s (new)\n", @@ -624,7 +662,9 @@ retry: /* transaction retry */ if ( !access_allowed( be, conn, op, e, desc, &new_rdn[0][ a_cnt ]->la_value, ACL_WRITE, NULL ) ) { #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "bdb_modrdn: access to attr \"%s\" (new) not allowed\n", new_rdn[0][a_cnt]->la_attr.bv_val )); + LDAP_LOG ( OPERATION, ERR, + "bdb_modrdn: access to attr \"%s\" (new) not allowed\n", + new_rdn[0][a_cnt]->la_attr.bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: access to attr \"%s\" " @@ -652,7 +692,9 @@ retry: /* transaction retry */ /* Get value of old rdn */ if ( old_rdn == NULL) { #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "bdb_modrdn: can't figure out old RDN values(s) from old RDN\n" )); + LDAP_LOG ( OPERATION, ERR, + "bdb_modrdn: can't figure out old RDN values(s) " + "from old RDN\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: can't figure out old RDN value(s) " @@ -673,7 +715,8 @@ retry: /* transaction retry */ if ( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "bdb_modrdn: %s: %s (old)\n", text, old_rdn[0][d_cnt]->la_attr.bv_val )); + LDAP_LOG ( OPERATION, ERR, "bdb_modrdn: %s: %s (old)\n", + text, old_rdn[0][d_cnt]->la_attr.bv_val, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: %s: %s (old)\n", @@ -686,7 +729,9 @@ retry: /* transaction retry */ if ( !access_allowed( be, conn, op, e, desc, &old_rdn[0][d_cnt]->la_value, ACL_WRITE, NULL ) ) { #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "bdb_modrdn: access to attr \"%s\" (old) not allowed\n", old_rdn[0][d_cnt]->la_attr.bv_val )); + LDAP_LOG ( OPERATION, ERR, + "bdb_modrdn: access to attr \"%s\" (old) not allowed\n", + old_rdn[0][d_cnt]->la_attr.bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: access to attr \"%s\" " @@ -813,7 +858,9 @@ retry: /* transaction retry */ if( rc == LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_RESULTS, "bdb_modrdn: rdn modified%s id=%08lx dn=\"%s\"\n", op->o_noop ? " (no-op)" : "", e->e_id, e->e_dn )); + LDAP_LOG ( OPERATION, RESULTS, + "bdb_modrdn: rdn modified%s id=%08lx dn=\"%s\"\n", + op->o_noop ? " (no-op)" : "", e->e_id, e->e_dn ); #else Debug(LDAP_DEBUG_TRACE, "bdb_modrdn: rdn modified%s id=%08lx dn=\"%s\"\n", @@ -824,7 +871,8 @@ retry: /* transaction retry */ } else { #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_RESULTS, "bdb_modrdn: %s : %s (%d)\n", text, db_strerror(rc), rc )); + LDAP_LOG ( OPERATION, RESULTS, "bdb_modrdn: %s : %s (%d)\n", + text, db_strerror(rc), rc ); #else Debug( LDAP_DEBUG_TRACE, "bdb_add: %s : %s (%d)\n", text, db_strerror(rc), rc ); diff --git a/servers/slapd/back-bdb/nextid.c b/servers/slapd/back-bdb/nextid.c index f5d0e618b17508df03e4b6e47f82f37fcc9da5df..b9e4151b34aa715c2b2b1a72f9baff38f6591e5a 100644 --- a/servers/slapd/back-bdb/nextid.c +++ b/servers/slapd/back-bdb/nextid.c @@ -58,9 +58,8 @@ int bdb_last_id( BackendDB *be, DB_TXN *tid ) default: #ifdef NEW_LOGGING - LDAP_LOG (( "nextid", LDAP_LEVEL_ERR, - "bdb_last_id: get failed: %s (%d)\n", - db_strerror(rc), rc )); + LDAP_LOG ( INDEX, ERR, "bdb_last_id: get failed: %s (%d)\n", + db_strerror(rc), rc, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_last_id: get failed: %s (%d)\n", diff --git a/servers/slapd/back-bdb/operational.c b/servers/slapd/back-bdb/operational.c index 9cff5cb3fc42316eced86b2192872d310e0372f9..cfcf17cdb3d02ec46f62cdd2c1354923b7ffca93 100644 --- a/servers/slapd/back-bdb/operational.c +++ b/servers/slapd/back-bdb/operational.c @@ -33,7 +33,7 @@ bdb_operational( Attribute **aa = a; int rc; DB_TXN *ltid = NULL; - struct bdb_op_info opinfo; + struct bdb_op_info opinfo; assert( e ); @@ -50,8 +50,8 @@ retry: /* transaction retry */ } #endif #ifdef NEW_LOGGING - LDAP_LOG (( "operational", LDAP_LEVEL_DETAIL1, - "=> bdb_operational: retrying...\n" )); + LDAP_LOG ( OPERATION, DETAIL1, + "=> bdb_operational: retrying...\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "==> bdb_operational: retrying...\n", 0, 0, 0 ); @@ -70,9 +70,9 @@ retry: /* transaction retry */ rc = TXN_BEGIN( bdb->bi_dbenv, NULL, <id, bdb->bi_db_opflags ); if ( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "operational", LDAP_LEVEL_ERR, + LDAP_LOG ( OPERATION, ERR, "=> bdb_operational: txn_begin failed: %s (%d)\n", - db_strerror(rc), rc )); + db_strerror(rc), rc, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_operational: txn_begin failed: %s (%d)\n", @@ -104,9 +104,9 @@ retry: /* transaction retry */ default: #ifdef NEW_LOGGING - LDAP_LOG (( "operational", LDAP_LEVEL_ERR, + LDAP_LOG ( OPERATION, ERR, "=> bdb_operational: has_children failed: %s (%d)\n", - db_strerror(rc), rc )); + db_strerror(rc), rc, 0 ); #else Debug(LDAP_DEBUG_ARGS, "<=- bdb_operational: has_children failed: %s (%d)\n", diff --git a/servers/slapd/back-bdb/passwd.c b/servers/slapd/back-bdb/passwd.c index 25f0c654ed7513a2184c6684b29b49dc0af7abc9..17d54cacc5a733022e1a2d18e0d5cc17a4040e53 100644 --- a/servers/slapd/back-bdb/passwd.c +++ b/servers/slapd/back-bdb/passwd.c @@ -51,8 +51,8 @@ bdb_exop_passwd( &id, NULL, &new, text ); #ifdef NEW_LOGGING - LDAP_LOG (( "passwd", LDAP_LEVEL_ENTRY, "==>bdb_exop_passwd: \"%s\"\n", - id.bv_val ? id.bv_val : "" )); + LDAP_LOG ( ACL, ENTRY, + "==>bdb_exop_passwd: \"%s\"\n", id.bv_val ? id.bv_val : "", 0, 0 ); #else Debug( LDAP_DEBUG_ARGS, "==> bdb_exop_passwd: \"%s\"\n", id.bv_val ? id.bv_val : "", 0, 0 ); @@ -89,8 +89,8 @@ bdb_exop_passwd( } #ifdef NEW_LOGGING - LDAP_LOG (( "passwd", LDAP_LEVEL_DETAIL1, "bdb_exop_passwd: \"%s\"%s\"\n", - dn.bv_val, id.bv_len ? " (proxy)" : "" )); + LDAP_LOG ( ACL, DETAIL1, "bdb_exop_passwd: \"%s\"%s\"\n", + dn.bv_val, id.bv_len ? " (proxy)" : "", 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_exop_passwd: \"%s\"%s\n", dn.bv_val, id.bv_len ? " (proxy)" : "", 0 ); @@ -115,7 +115,7 @@ retry: /* transaction retry */ bdb_cache_return_entry_w(bdb->bi_dbenv, &bdb->bi_cache, e, &lock); } #ifdef NEW_LOGGING - LDAP_LOG (( "passwd", LDAP_LEVEL_DETAIL1, "bdb_exop_passwd: retrying...\n" )); + LDAP_LOG ( ACL, DETAIL1, "bdb_exop_passwd: retrying...\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_exop_passwd: retrying...\n", 0, 0, 0 ); #endif @@ -136,7 +136,9 @@ retry: /* transaction retry */ *text = NULL; if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "passwd", LDAP_LEVEL_ERR, "bdb_exop_passwd: txn_begin failed: %s (%d)\n", db_strerror(rc), rc )); + LDAP_LOG ( ACL, ERR, + "bdb_exop_passwd: txn_begin failed: %s (%d)\n", + db_strerror(rc), rc, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_exop_passwd: txn_begin failed: %s (%d)\n", diff --git a/servers/slapd/back-bdb/referral.c b/servers/slapd/back-bdb/referral.c index 4d60f68d0e83030029b78329c7c41b3424ea4b3f..07c85df4b360f08e9ecdb8430e91542cbb169ec7 100644 --- a/servers/slapd/back-bdb/referral.c +++ b/servers/slapd/back-bdb/referral.c @@ -66,9 +66,9 @@ dn2entry_retry: goto dn2entry_retry; default: #ifdef NEW_LOGGING - LDAP_LOG (( "referral", LDAP_LEVEL_ERR, - "bdb_referrals: dn2entry failed: %s (%d)\n", - db_strerror(rc), rc )); + LDAP_LOG ( OPERATION, ERR, + "bdb_referrals: dn2entry failed: %s (%d)\n", + db_strerror(rc), rc, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_referrals: dn2entry failed: %s (%d)\n", @@ -94,9 +94,9 @@ dn2entry_retry: matched_dn = ch_strdup( matched->e_dn ); #ifdef NEW_LOGGING - LDAP_LOG (( "referral", LDAP_LEVEL_DETAIL1, + LDAP_LOG ( OPERATION, DETAIL1, "bdb_referrals: op=%ld target=\"%s\" matched=\"%s\"\n", - (long) op->o_tag, dn->bv_val, matched_dn )); + (long) op->o_tag, dn->bv_val, matched_dn ); #else Debug( LDAP_DEBUG_TRACE, "bdb_referrals: op=%ld target=\"%s\" matched=\"%s\"\n", @@ -139,9 +139,9 @@ dn2entry_retry: refs, &e->e_name, dn, LDAP_SCOPE_DEFAULT ); #ifdef NEW_LOGGING - LDAP_LOG (( "referral", LDAP_LEVEL_DETAIL1, + LDAP_LOG ( OPERATION, DETAIL1, "bdb_referrals: op=%ld target=\"%s\" matched=\"%s\"\n", - (long) op->o_tag, dn->bv_val, e->e_dn )); + (long) op->o_tag, dn->bv_val, e->e_dn ); #else Debug( LDAP_DEBUG_TRACE, "bdb_referrals: op=%ld target=\"%s\" matched=\"%s\"\n", diff --git a/servers/slapd/back-bdb/search.c b/servers/slapd/back-bdb/search.c index a68e17fb646e90400b4058bb1f660c30aea5f04b..44076d7abeed248791f8c46787c854fbf38065b1 100644 --- a/servers/slapd/back-bdb/search.c +++ b/servers/slapd/back-bdb/search.c @@ -63,7 +63,7 @@ bdb_search( DB_LOCK lock; #ifdef NEW_LOGGING - LDAP_LOG (( "search", LDAP_LEVEL_ENTRY,"bdb_back_search\n")); + LDAP_LOG ( OPERATION, ENTRY, "bdb_back_search\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "=> bdb_back_search\n", 0, 0, 0); @@ -175,7 +175,8 @@ dn2entry_retry: } #ifdef NEW_LOGGING - LDAP_LOG (( "search", LDAP_LEVEL_RESULTS,"bdb_search: entry is referral\n")); + LDAP_LOG ( OPERATION, RESULTS, + "bdb_search: entry is referral\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_search: entry is referral\n", 0, 0, 0 ); @@ -288,7 +289,7 @@ dn2entry_retry: if ( candidates[0] == 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "search", LDAP_LEVEL_RESULTS,"bdb_search: no candidates\n")); + LDAP_LOG ( OPERATION, RESULTS, "bdb_search: no candidates\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_search: no candidates\n", 0, 0, 0 ); @@ -349,7 +350,8 @@ id2entry_retry: if( !BDB_IDL_IS_RANGE(candidates) ) { /* only complain for non-range IDLs */ #ifdef NEW_LOGGING - LDAP_LOG (( "search", LDAP_LEVEL_RESULTS,"bdb_search: candidate %ld not found\n", (long) id)); + LDAP_LOG ( OPERATION, RESULTS, + "bdb_search: candidate %ld not found\n", (long) id, 0, 0); #else Debug( LDAP_DEBUG_TRACE, "bdb_search: candidate %ld not found\n", @@ -411,7 +413,8 @@ id2entry_retry: } else if ( dnIsSuffix( &e->e_nname, &realbase ) ) { /* alias is within scope */ #ifdef NEW_LOGGING - LDAP_LOG (( "search", LDAP_LEVEL_RESULTS,"bdb_search: \"%s\" in subtree\n", e->edn)); + LDAP_LOG ( OPERATION, RESULTS, + "bdb_search: \"%s\" in subtree\n", e->edn, 0, 0); #else Debug( LDAP_DEBUG_TRACE, "bdb_search: \"%s\" in subtree\n", @@ -466,9 +469,9 @@ id2entry_retry: } else { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL2, + LDAP_LOG(OPERATION, DETAIL2, "bdb_search: candidate referral %ld scope not okay\n", - id )); + id, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_search: candidate referral %ld scope not okay\n", @@ -536,7 +539,8 @@ id2entry_retry: } } else { #ifdef NEW_LOGGING - LDAP_LOG (( "search", LDAP_LEVEL_RESULTS,"bdb_search: %ld scope not okay\n", (long) id)); + LDAP_LOG ( OPERATION, RESULTS, + "bdb_search: %ld scope not okay\n", (long) id, 0, 0); #else Debug( LDAP_DEBUG_TRACE, "bdb_search: %ld scope not okay\n", @@ -545,7 +549,8 @@ id2entry_retry: } } else { #ifdef NEW_LOGGING - LDAP_LOG (( "search", LDAP_LEVEL_RESULTS,"bdb_search: %ld does match filter\n", (long) id)); + LDAP_LOG ( OPERATION, RESULTS, + "bdb_search: %ld does match filter\n", (long) id, 0, 0); #else Debug( LDAP_DEBUG_TRACE, "bdb_search: %ld does match filter\n", @@ -589,7 +594,8 @@ static int base_candidate( ID *ids ) { #ifdef NEW_LOGGING - LDAP_LOG (( "search", LDAP_LEVEL_ENTRY,"base_candidate: base: \"%s\" (0x%08lx)\n", e->e_dn, (long) e->e_id)); + LDAP_LOG ( OPERATION, ENTRY, + "base_candidate: base: \"%s\" (0x%08lx)\n", e->e_dn, (long) e->e_id, 0); #else Debug(LDAP_DEBUG_ARGS, "base_candidates: base: \"%s\" (0x%08lx)\n", e->e_dn, (long) e->e_id, 0); @@ -669,7 +675,9 @@ static int search_candidates( */ #ifdef NEW_LOGGING - LDAP_LOG (( "search", LDAP_LEVEL_ENTRY,"search_candidates: base=\"%s\" (0x%08lx) scope=%d\n", e->e_dn, (long) e->e_id, scope)); + LDAP_LOG ( OPERATION, ENTRY, + "search_candidates: base=\"%s\" (0x%08lx) scope=%d\n", + e->e_dn, (long) e->e_id, scope); #else Debug(LDAP_DEBUG_TRACE, "search_candidates: base=\"%s\" (0x%08lx) scope=%d\n", @@ -741,7 +749,8 @@ static int search_candidates( if( rc ) { #ifdef NEW_LOGGING - LDAP_LOG (( "search", LDAP_LEVEL_DETAIL1,"bdb_search_candidates: failed (rc=%d)\n", rc)); + LDAP_LOG ( OPERATION, DETAIL1, + "bdb_search_candidates: failed (rc=%d)\n", rc, 0, 0 ); #else Debug(LDAP_DEBUG_TRACE, "bdb_search_candidates: failed (rc=%d)\n", @@ -750,7 +759,10 @@ static int search_candidates( } else { #ifdef NEW_LOGGING - LDAP_LOG (( "search", LDAP_LEVEL_DETAIL1,"bdb_search_candidates: id=%ld first=%ld last=%ld\n", (long) ids[0], (long) BDB_IDL_FIRST(ids), (long) BDB_IDL_LAST(ids))); + LDAP_LOG ( OPERATION, DETAIL1, + "bdb_search_candidates: id=%ld first=%ld last=%ld\n", + (long) ids[0], (long) BDB_IDL_FIRST(ids), + (long) BDB_IDL_LAST(ids)); #else Debug(LDAP_DEBUG_TRACE, "bdb_search_candidates: id=%ld first=%ld last=%ld\n", diff --git a/servers/slapd/back-bdb/tools.c b/servers/slapd/back-bdb/tools.c index 0203ef71068b7ede316b0f0bc60d540f3d00abc4..1056944ebd255be7170b73275a5ca7b9c41ac04c 100644 --- a/servers/slapd/back-bdb/tools.c +++ b/servers/slapd/back-bdb/tools.c @@ -126,9 +126,8 @@ ID bdb_tool_entry_put( assert( text->bv_val[0] == '\0' ); #ifdef NEW_LOGGING - LDAP_LOG (( "tools", LDAP_LEVEL_ARGS, - "=> bdb_tool_entry_put( %ld, \"%s\" )\n", - (long) e->e_id, e->e_dn )); + LDAP_LOG ( TOOLS, ARGS, "=> bdb_tool_entry_put( %ld, \"%s\" )\n", + (long) e->e_id, e->e_dn, 0 ); #else Debug( LDAP_DEBUG_TRACE, "=> bdb_tool_entry_put( %ld, \"%s\" )\n", (long) e->e_id, e->e_dn, 0 ); @@ -141,8 +140,7 @@ ID bdb_tool_entry_put( "txn_begin failed: %s (%d)", db_strerror(rc), rc ); #ifdef NEW_LOGGING - LDAP_LOG (( "tools", LDAP_LEVEL_ERR, - "=> bdb_tool_entry_put: %s\n", text->bv_val )); + LDAP_LOG ( TOOLS, ERR, "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_tool_entry_put: %s\n", @@ -157,8 +155,8 @@ ID bdb_tool_entry_put( "next_id failed: %s (%d)", db_strerror(rc), rc ); #ifdef NEW_LOGGING - LDAP_LOG (( "tools", LDAP_LEVEL_ERR, - "=> bdb_tool_entry_put: %s\n", text->bv_val )); + LDAP_LOG ( TOOLS, ERR, + "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 ); @@ -178,8 +176,8 @@ ID bdb_tool_entry_put( "dn2id_add failed: %s (%d)", db_strerror(rc), rc ); #ifdef NEW_LOGGING - LDAP_LOG (( "tools", LDAP_LEVEL_ERR, - "=> bdb_tool_entry_put: %s\n", text->bv_val )); + LDAP_LOG ( TOOLS, ERR, + "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 ); @@ -194,8 +192,8 @@ ID bdb_tool_entry_put( "id2entry_add failed: %s (%d)", db_strerror(rc), rc ); #ifdef NEW_LOGGING - LDAP_LOG (( "tools", LDAP_LEVEL_ERR, - "=> bdb_tool_entry_put: %s\n", text->bv_val )); + LDAP_LOG ( TOOLS, ERR, + "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 ); @@ -209,8 +207,8 @@ ID bdb_tool_entry_put( "index_entry_add failed: %s (%d)", db_strerror(rc), rc ); #ifdef NEW_LOGGING - LDAP_LOG (( "tools", LDAP_LEVEL_ERR, - "=> bdb_tool_entry_put: %s\n", text->bv_val )); + LDAP_LOG ( TOOLS, ERR, + "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 ); @@ -226,8 +224,8 @@ done: "txn_commit failed: %s (%d)", db_strerror(rc), rc ); #ifdef NEW_LOGGING - LDAP_LOG (( "tools", LDAP_LEVEL_ERR, - "=> bdb_tool_entry_put: %s\n", text->bv_val )); + LDAP_LOG ( TOOLS, ERR, + "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_tool_entry_put: %s\n", @@ -242,8 +240,8 @@ done: "txn_aborted! %s (%d)", db_strerror(rc), rc ); #ifdef NEW_LOGGING - LDAP_LOG (( "tools", LDAP_LEVEL_ERR, - "=> bdb_tool_entry_put: %s\n", text->bv_val )); + LDAP_LOG ( TOOLS, ERR, + "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_tool_entry_put: %s\n", @@ -266,8 +264,8 @@ int bdb_tool_entry_reindex( struct berval pdn; #ifdef NEW_LOGGING - LDAP_LOG (( "tools", LDAP_LEVEL_ARGS, - "=> bdb_tool_entry_reindex( %ld )\n", (long) id )); + LDAP_LOG ( TOOLS, ARGS, + "=> bdb_tool_entry_reindex( %ld )\n", (long) id, 0, 0 ); #else Debug( LDAP_DEBUG_ARGS, "=> bdb_tool_entry_reindex( %ld )\n", (long) id, 0, 0 ); @@ -277,9 +275,9 @@ int bdb_tool_entry_reindex( if( e == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG (( "tools", LDAP_LEVEL_DETAIL1, + LDAP_LOG ( TOOLS, DETAIL1, "bdb_tool_entry_reindex:: could not locate id=%ld\n", - (long) id )); + (long) id, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "bdb_tool_entry_reindex:: could not locate id=%ld\n", @@ -291,9 +289,9 @@ int bdb_tool_entry_reindex( rc = TXN_BEGIN( bi->bi_dbenv, NULL, &tid, bi->bi_db_opflags ); if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "tools", LDAP_LEVEL_ERR, + LDAP_LOG ( TOOLS, ERR, "=> bdb_tool_entry_reindex: txn_begin failed: %s (%d)\n", - db_strerror(rc), rc )); + db_strerror(rc), rc, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_tool_entry_reindex: txn_begin failed: %s (%d)\n", @@ -310,9 +308,8 @@ int bdb_tool_entry_reindex( */ #ifdef NEW_LOGGING - LDAP_LOG (( "tools", LDAP_LEVEL_ERR, - "=> bdb_tool_entry_reindex( %ld, \"%s\" )\n", - (long) id, e->e_dn )); + LDAP_LOG ( TOOLS, ERR, + "=> bdb_tool_entry_reindex( %ld, \"%s\" )\n", (long) id, e->e_dn, 0 ); #else Debug( LDAP_DEBUG_TRACE, "=> bdb_tool_entry_reindex( %ld, \"%s\" )\n", (long) id, e->e_dn, 0 ); @@ -327,9 +324,9 @@ int bdb_tool_entry_reindex( rc = bdb_dn2id_add( be, tid, &pdn, e ); if( rc != 0 && rc != DB_KEYEXIST ) { #ifdef NEW_LOGGING - LDAP_LOG (( "tools", LDAP_LEVEL_ERR, + LDAP_LOG ( TOOLS, ERR, "=> bdb_tool_entry_reindex: dn2id_add failed: %s (%d)\n", - db_strerror(rc), rc )); + db_strerror(rc), rc, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_tool_entry_reindex: dn2id_add failed: %s (%d)\n", @@ -345,9 +342,9 @@ done: rc = TXN_COMMIT( tid, 0 ); if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "tools", LDAP_LEVEL_ERR, + LDAP_LOG ( TOOLS, ERR, "=> bdb_tool_entry_reindex: txn_commit failed: %s (%d)\n", - db_strerror(rc), rc )); + db_strerror(rc), rc, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_tool_entry_reindex: txn_commit failed: %s (%d)\n", @@ -359,9 +356,9 @@ done: } else { TXN_ABORT( tid ); #ifdef NEW_LOGGING - LDAP_LOG (( "tools", LDAP_LEVEL_DETAIL1, + LDAP_LOG ( TOOLS, DETAIL1, "=> bdb_tool_entry_reindex: txn_aborted! %s (%d)\n", - db_strerror(rc), rc )); + db_strerror(rc), rc, 0 ); #else Debug( LDAP_DEBUG_ANY, "=> bdb_tool_entry_reindex: txn_aborted! %s (%d)\n", diff --git a/servers/slapd/back-ldap/add.c b/servers/slapd/back-ldap/add.c new file mode 100644 index 0000000000000000000000000000000000000000..b947441efb5721e68411cbe377d4eb3fa66ddd61 --- /dev/null +++ b/servers/slapd/back-ldap/add.c @@ -0,0 +1,239 @@ +/* add.c - ldap backend add function */ +/* $OpenLDAP$ */ +/* + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* This is an altered version */ +/* + * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com> + * + * Permission is granted to anyone to use this software for any purpose + * on any computer system, and to alter it and redistribute it, subject + * to the following restrictions: + * + * 1. The author is not responsible for the consequences of use of this + * software, no matter how awful, even if they arise from flaws in it. + * + * 2. The origin of this software must not be misrepresented, either by + * explicit claim or by omission. Since few users ever read sources, + * credits should appear in the documentation. + * + * 3. Altered versions must be plainly marked as such, and must not be + * misrepresented as being the original software. Since few users + * ever read sources, credits should appear in the documentation. + * + * 4. This notice may not be removed or altered. + * + * + * + * Copyright 2000, Pierangelo Masarati, All rights reserved. <ando@sys-net.it> + * + * This software is being modified by Pierangelo Masarati. + * The previously reported conditions apply to the modified code as well. + * Changes in the original code are highlighted where required. + * Credits for the original code go to the author, Howard Chu. + */ + +#include "portable.h" + +#include <stdio.h> + +#include <ac/string.h> +#include <ac/socket.h> + +#include "slap.h" +#include "back-ldap.h" + +int +ldap_back_add( + Backend *be, + Connection *conn, + Operation *op, + Entry *e +) +{ + struct ldapinfo *li = (struct ldapinfo *) be->be_private; + struct ldapconn *lc; + int i, j; + Attribute *a; + LDAPMod **attrs; + struct berval mapped; + struct berval mdn = { 0, NULL }; + +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDAP, ENTRY, "ldap_back_add: %s\n", e->e_dn, 0, 0 ); +#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 ); + } + + /* + * Rewrite the add dn, if needed + */ +#ifdef ENABLE_REWRITE + switch (rewrite_session( li->rwinfo, "addDn", e->e_dn, conn, + &mdn.bv_val )) { + case REWRITE_REGEXEC_OK: + if ( mdn.bv_val != NULL && mdn.bv_val[ 0 ] != '\0' ) { + mdn.bv_len = strlen( mdn.bv_val ); + } else { + mdn = e->e_name; + } +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDAP, DETAIL1, + "[rw] addDn: \"%s\" -> \"%s\"\n", e->e_dn, mdn.bv_val, 0 ); +#else /* !NEW_LOGGING */ + Debug( LDAP_DEBUG_ARGS, "rw> addDn: \"%s\" -> \"%s\"\n%s", + e->e_dn, mdn.bv_val, "" ); +#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 */ + ldap_back_dn_massage( li, &e->e_name, &mdn, 0, 1 ); +#endif /* !ENABLE_REWRITE */ + + /* Count number of attributes in entry */ + for (i = 1, a = e->e_attrs; a; i++, a = a->a_next) + ; + + /* Create array of LDAPMods for ldap_add() */ + attrs = (LDAPMod **)ch_malloc(sizeof(LDAPMod *)*i); + + for (i=0, a=e->e_attrs; a; a=a->a_next) { + /* + * lastmod should always be <off>, so that + * creation/modification operational attrs + * of the target directory are used, if available + */ +#if 0 + if ( !strcasecmp( a->a_desc->ad_cname.bv_val, + slap_schema.si_ad_creatorsName->ad_cname.bv_val ) + || !strcasecmp( a->a_desc->ad_cname.bv_val, + slap_schema.si_ad_createTimestamp->ad_cname.bv_val ) + || !strcasecmp( a->a_desc->ad_cname.bv_val, + slap_schema.si_ad_modifiersName->ad_cname.bv_val ) + || !strcasecmp( a->a_desc->ad_cname.bv_val, + slap_schema.si_ad_modifyTimestamp->ad_cname.bv_val ) + ) { + continue; + } +#endif + + ldap_back_map(&li->at_map, &a->a_desc->ad_cname, &mapped, 0); + if (mapped.bv_val == NULL) { + continue; + } + + attrs[i] = (LDAPMod *)ch_malloc(sizeof(LDAPMod)); + if (attrs[i] == NULL) { + continue; + } + + attrs[i]->mod_op = LDAP_MOD_BVALUES; + attrs[i]->mod_type = mapped.bv_val; + +#ifdef ENABLE_REWRITE + /* + * FIXME: dn-valued attrs should be rewritten + * to allow their use in ACLs at the back-ldap + * level. + */ + if ( strcmp( a->a_desc->ad_type->sat_syntax->ssyn_oid, + SLAPD_DN_SYNTAX ) == 0 ) { + ldap_dnattr_rewrite( li->rwinfo, a->a_vals, conn ); + } +#endif /* ENABLE_REWRITE */ + + for (j=0; a->a_vals[j].bv_val; j++); + attrs[i]->mod_vals.modv_bvals = ch_malloc((j+1)*sizeof(struct berval *)); + for (j=0; a->a_vals[j].bv_val; j++) + attrs[i]->mod_vals.modv_bvals[j] = &a->a_vals[j]; + attrs[i]->mod_vals.modv_bvals[j] = NULL; + i++; + } + attrs[i] = NULL; + + ldap_add_s(lc->ld, mdn.bv_val, attrs); + for (--i; i>= 0; --i) { + ch_free(attrs[i]->mod_vals.modv_bvals); + ch_free(attrs[i]); + } + ch_free(attrs); + if ( mdn.bv_val != e->e_dn ) { + free( mdn.bv_val ); + } + + return( ldap_back_op_result( lc, op ) ); +} + +#ifdef ENABLE_REWRITE +int +ldap_dnattr_rewrite( + struct rewrite_info *rwinfo, + BerVarray a_vals, + void *cookie +) +{ + char *mattr; + + for ( ; a_vals->bv_val != NULL; a_vals++ ) { + switch ( rewrite_session( rwinfo, "bindDn", a_vals->bv_val, + cookie, &mattr )) { + case REWRITE_REGEXEC_OK: + if ( mattr == NULL ) { + /* no substitution */ + continue; + } +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDAP, DETAIL1, + "[rw] bindDn (in add of dn-valued" + " attr): \"%s\" -> \"%s\"\n", a_vals->bv_val, mattr, 0 ); +#else /* !NEW_LOGGING */ + Debug( LDAP_DEBUG_ARGS, + "rw> bindDn (in add of dn-valued attr):" + " \"%s\" -> \"%s\"\n%s", + a_vals->bv_val, mattr, "" ); +#endif /* !NEW_LOGGING */ + + /* + * FIXME: replacing server-allocated memory + * (ch_malloc) with librewrite allocated memory + * (malloc) + */ + ch_free( a_vals->bv_val ); + a_vals->bv_val = mattr; + a_vals->bv_len = strlen( mattr ); + + break; + + case REWRITE_REGEXEC_UNWILLING: + + case REWRITE_REGEXEC_ERR: + /* + * FIXME: better give up, + * skip the attribute + * or leave it untouched? + */ + break; + } + } + + return 0; +} +#endif /* ENABLE_REWRITE */ + diff --git a/servers/slapd/back-ldap/bind.c b/servers/slapd/back-ldap/bind.c index c0e532930a884995f4ddb0b0b37b2248651037fd..32d432c285c7c39496210860701bfde1c6b64d3b 100644 --- a/servers/slapd/back-ldap/bind.c +++ b/servers/slapd/back-ldap/bind.c @@ -84,8 +84,8 @@ ldap_back_bind( mdn.bv_val = ( char * )dn->bv_val; } #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "[rw] bindDn: \"%s\" -> \"%s\"\n", dn->bv_val, mdn.bv_val )); + LDAP_LOG( BACK_LDAP, DETAIL1, + "[rw] bindDn: \"%s\" -> \"%s\"\n", dn->bv_val, mdn.bv_val, 0 ); #else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ARGS, "rw> bindDn: \"%s\" -> \"%s\"\n%s", dn->bv_val, mdn.bv_val, "" ); @@ -258,11 +258,11 @@ ldap_back_getconn(struct ldapinfo *li, Connection *conn, Operation *op) ber_dupbv( &lc->bound_dn, &lc->conn->c_dn ); } #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "[rw] bindDn: \"%s\" ->" + LDAP_LOG( BACK_LDAP, DETAIL1, + "[rw] bindDn: \"%s\" ->" " \"%s\"\n%s", - lc->conn->c_dn.bv_val, - lc->bound_dn.bv_val )); + lc->conn->c_dn.bv_val, + lc->bound_dn.bv_val, "" ); #else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ARGS, "rw> bindDn: \"%s\" ->" @@ -312,9 +312,8 @@ 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 )); + LDAP_LOG( BACK_LDAP, INFO, + "ldap_back_getconn: conn %ld inserted\n", lc->conn->c_connid, 0, 0); #else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_TRACE, "=>ldap_back_getconn: conn %ld inserted\n%s%s", @@ -330,9 +329,9 @@ ldap_back_getconn(struct ldapinfo *li, Connection *conn, Operation *op) } } else { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "ldap_back_getconn: conn %ld inserted\n", - lc->conn->c_connid )); + LDAP_LOG( BACK_LDAP, INFO, + "ldap_back_getconn: conn %ld inserted\n", + lc->conn->c_connid, 0, 0 ); #else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_TRACE, "=>ldap_back_getconn: conn %ld fetched%s%s\n", diff --git a/servers/slapd/back-ldap/compare.c b/servers/slapd/back-ldap/compare.c new file mode 100644 index 0000000000000000000000000000000000000000..d7d1f77f9de07d4cd44fcea86eab010de127061b --- /dev/null +++ b/servers/slapd/back-ldap/compare.c @@ -0,0 +1,118 @@ +/* compare.c - ldap backend compare function */ +/* $OpenLDAP$ */ +/* + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* This is an altered version */ +/* + * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com> + * + * Permission is granted to anyone to use this software for any purpose + * on any computer system, and to alter it and redistribute it, subject + * to the following restrictions: + * + * 1. The author is not responsible for the consequences of use of this + * software, no matter how awful, even if they arise from flaws in it. + * + * 2. The origin of this software must not be misrepresented, either by + * explicit claim or by omission. Since few users ever read sources, + * credits should appear in the documentation. + * + * 3. Altered versions must be plainly marked as such, and must not be + * misrepresented as being the original software. Since few users + * ever read sources, credits should appear in the documentation. + * + * 4. This notice may not be removed or altered. + * + * + * + * Copyright 2000, Pierangelo Masarati, All rights reserved. <ando@sys-net.it> + * + * This software is being modified by Pierangelo Masarati. + * The previously reported conditions apply to the modified code as well. + * Changes in the original code are highlighted where required. + * Credits for the original code go to the author, Howard Chu. + */ + +#include "portable.h" + +#include <stdio.h> + +#include <ac/string.h> +#include <ac/socket.h> + +#include "slap.h" +#include "back-ldap.h" + +int +ldap_back_compare( + Backend *be, + Connection *conn, + Operation *op, + struct berval *dn, + struct berval *ndn, + AttributeAssertion *ava +) +{ + struct ldapinfo *li = (struct ldapinfo *) be->be_private; + struct ldapconn *lc; + struct berval mapped_oc, mapped_at; + struct berval mdn = { 0, NULL }; + + lc = ldap_back_getconn(li, conn, op); + if (!lc || !ldap_back_dobind( lc, op ) ) { + return( -1 ); + } + + /* + * Rewrite the compare dn, if needed + */ +#ifdef ENABLE_REWRITE + switch ( rewrite_session( li->rwinfo, "compareDn", dn->bv_val, conn, &mdn.bv_val ) ) { + case REWRITE_REGEXEC_OK: + if ( mdn.bv_val == NULL ) { + mdn.bv_val = ( char * )dn->bv_val; + } +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDAP, DETAIL1, + "[rw] compareDn: \"%s\" -> \"%s\"\n", dn->bv_val, mdn.bv_val, 0 ); +#else /* !NEW_LOGGING */ + Debug( LDAP_DEBUG_ARGS, "rw> compareDn: \"%s\" -> \"%s\"\n%s", + dn->bv_val, mdn.bv_val, "" ); +#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 */ + ldap_back_dn_massage( li, dn, &mdn, 0, 1 ); + if ( mdn.bv_val == NULL ) { + return -1; + } +#endif /* !ENABLE_REWRITE */ + + ldap_back_map(&li->oc_map, &ava->aa_desc->ad_cname, &mapped_oc, 0); + if (mapped_oc.bv_val == NULL) + return( -1 ); + + ldap_back_map(&li->at_map, &ava->aa_value, &mapped_at, 0); + if (mapped_at.bv_val == NULL) + return( -1 ); + + ldap_compare_s( lc->ld, mdn.bv_val, mapped_oc.bv_val, mapped_at.bv_val ); + + if ( mdn.bv_val != dn->bv_val ) { + free( mdn.bv_val ); + } + + return( ldap_back_op_result( lc, op ) ); +} diff --git a/servers/slapd/back-ldap/config.c b/servers/slapd/back-ldap/config.c index a8e82ad0eacd6c612c246ca2760630c0d1bce8c8..f0ea612e8137575f1134c18bca2b534c610b0224 100644 --- a/servers/slapd/back-ldap/config.c +++ b/servers/slapd/back-ldap/config.c @@ -325,18 +325,18 @@ suffix_massage_regexize( const char *s ) res = ch_calloc( sizeof( char ), strlen( s ) + 4 + 4*i + 1 ); - ptr = slap_strcopy( res, "(.*)" ); + ptr = lutil_strcopy( res, "(.*)" ); for ( i = 0, p = s; ( r = strchr( p, ',' ) ) != NULL; p = r + 1 , i++ ) { - ptr = slap_strncopy( ptr, p, r - p + 1 ); - ptr = slap_strcopy( ptr, "[ ]?" ); + ptr = lutil_strncopy( ptr, p, r - p + 1 ); + ptr = lutil_strcopy( ptr, "[ ]?" ); if ( r[ 1 ] == ' ' ) { r++; } } - slap_strcopy( ptr, p ); + lutil_strcopy( ptr, p ); return res; } diff --git a/servers/slapd/back-ldap/delete.c b/servers/slapd/back-ldap/delete.c new file mode 100644 index 0000000000000000000000000000000000000000..115252ba313134607722366733c7663653701bd1 --- /dev/null +++ b/servers/slapd/back-ldap/delete.c @@ -0,0 +1,107 @@ +/* delete.c - ldap backend delete function */ +/* $OpenLDAP$ */ +/* + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* This is an altered version */ +/* + * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com> + * + * Permission is granted to anyone to use this software for any purpose + * on any computer system, and to alter it and redistribute it, subject + * to the following restrictions: + * + * 1. The author is not responsible for the consequences of use of this + * software, no matter how awful, even if they arise from flaws in it. + * + * 2. The origin of this software must not be misrepresented, either by + * explicit claim or by omission. Since few users ever read sources, + * credits should appear in the documentation. + * + * 3. Altered versions must be plainly marked as such, and must not be + * misrepresented as being the original software. Since few users + * ever read sources, credits should appear in the documentation. + * + * 4. This notice may not be removed or altered. + * + * + * + * Copyright 2000, Pierangelo Masarati, All rights reserved. <ando@sys-net.it> + * + * This software is being modified by Pierangelo Masarati. + * The previously reported conditions apply to the modified code as well. + * Changes in the original code are highlighted where required. + * Credits for the original code go to the author, Howard Chu. + */ + +#include "portable.h" + +#include <stdio.h> + +#include <ac/string.h> +#include <ac/socket.h> + +#include "slap.h" +#include "back-ldap.h" + +int +ldap_back_delete( + Backend *be, + Connection *conn, + Operation *op, + struct berval *dn, + struct berval *ndn +) +{ + struct ldapinfo *li = (struct ldapinfo *) be->be_private; + struct ldapconn *lc; + + struct berval mdn = { 0, NULL }; + + lc = ldap_back_getconn( li, conn, op ); + + if ( !lc || !ldap_back_dobind( lc, op ) ) { + return( -1 ); + } + + /* + * Rewrite the compare dn, if needed + */ +#ifdef ENABLE_REWRITE + switch ( rewrite_session( li->rwinfo, "deleteDn", dn->bv_val, conn, &mdn.bv_val ) ) { + case REWRITE_REGEXEC_OK: + if ( mdn.bv_val == NULL ) { + mdn.bv_val = ( char * )dn->bv_val; + } +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDAP, DETAIL1, + "[rw] deleteDn: \"%s\" -> \"%s\"\n", dn->bv_val, mdn.bv_val, 0 ); +#else /* !NEW_LOGGING */ + Debug( LDAP_DEBUG_ARGS, "rw> deleteDn: \"%s\" -> \"%s\"\n%s", + dn->bv_val, mdn.bv_val, "" ); +#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 */ + ldap_back_dn_massage( li, dn, &mdn, 0, 1 ); +#endif /* !ENABLE_REWRITE */ + + ldap_delete_s( lc->ld, mdn.bv_val ); + + if ( mdn.bv_val != dn->bv_val ) { + free( mdn.bv_val ); + } + + return( ldap_back_op_result( lc, op ) ); +} diff --git a/servers/slapd/back-ldap/group.c b/servers/slapd/back-ldap/group.c new file mode 100644 index 0000000000000000000000000000000000000000..16a2c5046ec62d5d3819425b46823ccdeb4bd961 --- /dev/null +++ b/servers/slapd/back-ldap/group.c @@ -0,0 +1,209 @@ +/* group.c - ldap backend acl group routine */ +/* $OpenLDAP$ */ +/* + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ + +#include "portable.h" + +#include <stdio.h> + +#include <ac/socket.h> +#include <ac/string.h> + +#include "slap.h" +#include "back-ldap.h" + + +/* return 0 IFF op_dn is a value in group_at (member) attribute + * of entry with gr_dn AND that entry has an objectClass + * value of group_oc (groupOfNames) + */ +int +ldap_back_group( + Backend *be, + Connection *conn, + Operation *op, + Entry *target, + struct berval *gr_ndn, + struct berval *op_ndn, + ObjectClass *group_oc, + AttributeDescription* group_at +) +{ + struct ldapinfo *li = (struct ldapinfo *) be->be_private; + int rc = 1; + Attribute *attr; + + LDAPMessage *result; + char *gattr[2]; + char *filter = NULL, *ptr; + LDAP *ld; + struct berval mop_ndn = { 0, NULL }, mgr_ndn = { 0, NULL }; + + AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass; + struct berval group_oc_name = {0, NULL}; + struct berval group_at_name = group_at->ad_cname; + + if( group_oc->soc_names && group_oc->soc_names[0] ) { + group_oc_name.bv_val = group_oc->soc_names[0]; + } else { + group_oc_name.bv_val = group_oc->soc_oid; + } + if (group_oc_name.bv_val) + group_oc_name.bv_len = strlen(group_oc_name.bv_val); + + if (target != NULL && dn_match( &target->e_nname, gr_ndn ) ) { + /* we already have a copy of the entry */ + /* attribute and objectclass mapping has already been done */ + + /* + * first we need to check if the objectClass attribute + * has been retieved; otherwise we need to repeat the search + */ + attr = attr_find( target->e_attrs, ad_objectClass ); + if ( attr != NULL ) { + + /* + * Now we can check for the group objectClass value + */ + if( !is_entry_objectclass( target, group_oc, 0 ) ) { + return(1); + } + + /* + * This part has been reworked: the group attr compare + * fails only if the attribute is PRESENT but the value + * is NOT PRESENT; if the attribute is NOT PRESENT, the + * search must be repeated as well. + * This may happen if a search for an entry has already + * been performed (target is not null) but the group + * attribute has not been required + */ + if ((attr = attr_find(target->e_attrs, group_at)) != NULL) { + if( value_find( group_at, attr->a_vals, op_ndn ) != LDAP_SUCCESS ) + return(1); + return(0); + } /* else: repeat the search */ + } /* else: repeat the search */ + } /* else: do the search */ + + /* + * Rewrite the op ndn if needed + */ +#ifdef ENABLE_REWRITE + switch ( rewrite_session( li->rwinfo, "bindDn", + op_ndn->bv_val, conn, &mop_ndn.bv_val ) ) { + case REWRITE_REGEXEC_OK: + if ( mop_ndn.bv_val == NULL ) { + mop_ndn = *op_ndn; + } +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDAP, DETAIL1, + "[rw] bindDn (op ndn in group): \"%s\" -> \"%s\"\n", + op_ndn->bv_val, mop_ndn.bv_val, 0 ); +#else /* !NEW_LOGGING */ + Debug( LDAP_DEBUG_ARGS, + "rw> bindDn (op ndn in group): \"%s\" -> \"%s\"\n%s", + op_ndn->bv_val, mop_ndn.bv_val, "" ); +#endif /* !NEW_LOGGING */ + break; + + case REWRITE_REGEXEC_UNWILLING: + + case REWRITE_REGEXEC_ERR: + goto cleanup; + } + + /* + * Rewrite the gr ndn if needed + */ + switch ( rewrite_session( li->rwinfo, "searchBase", + gr_ndn->bv_val, conn, &mgr_ndn.bv_val ) ) { + case REWRITE_REGEXEC_OK: + if ( mgr_ndn.bv_val == NULL ) { + mgr_ndn = *gr_ndn; + } +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDAP, DETAIL1, + "[rw] searchBase (gr ndn in group): \"%s\" -> \"%s\"\n%s", + gr_ndn->bv_val, mgr_ndn.bv_val, "" ); +#else /* !NEW_LOGGING */ + Debug( LDAP_DEBUG_ARGS, + "rw> searchBase (gr ndn in group):" + " \"%s\" -> \"%s\"\n%s", + gr_ndn->bv_val, mgr_ndn.bv_val, "" ); +#endif /* !NEW_LOGGING */ + break; + + case REWRITE_REGEXEC_UNWILLING: + + case REWRITE_REGEXEC_ERR: + goto cleanup; + } +#else /* !ENABLE_REWRITE */ + ldap_back_dn_massage( li, op_ndn, &mop_ndn, 1, 1 ); + if ( mop_ndn.bv_val == NULL ) { + goto cleanup; + } + ldap_back_dn_massage( li, gr_ndn, &mgr_ndn, 1, 1 ); + if ( mgr_ndn.bv_val == NULL ) { + goto cleanup; + } +#endif /* !ENABLE_REWRITE */ + + ldap_back_map(&li->oc_map, &group_oc_name, &group_oc_name, 0); + if (group_oc_name.bv_val == NULL) + goto cleanup; + ldap_back_map(&li->at_map, &group_at_name, &group_at_name, 0); + if (group_at_name.bv_val == NULL) + goto cleanup; + + filter = ch_malloc(sizeof("(&(objectclass=)(=))") + + group_oc_name.bv_len + + group_at_name.bv_len + + mop_ndn.bv_len + 1); + if (filter == NULL) + goto cleanup; + + if (ldap_initialize(&ld, li->url) != LDAP_SUCCESS) { + goto cleanup; + } + + if (ldap_bind_s(ld, li->binddn, li->bindpw, LDAP_AUTH_SIMPLE) + != LDAP_SUCCESS) { + goto cleanup; + } + + ptr = lutil_strcopy(filter, "(&(objectclass="); + ptr = lutil_strcopy(ptr, group_oc_name.bv_val); + ptr = lutil_strcopy(ptr, ")("); + ptr = lutil_strcopy(ptr, group_at_name.bv_val); + ptr = lutil_strcopy(ptr, "="); + ptr = lutil_strcopy(ptr, mop_ndn.bv_val); + strcpy(ptr, "))"); + + gattr[0] = "objectclass"; + gattr[1] = NULL; + if (ldap_search_ext_s(ld, mgr_ndn.bv_val, LDAP_SCOPE_BASE, filter, + gattr, 0, NULL, NULL, LDAP_NO_LIMIT, + LDAP_NO_LIMIT, &result) == LDAP_SUCCESS) { + if (ldap_first_entry(ld, result) != NULL) + rc = 0; + ldap_msgfree(result); + } + +cleanup:; + if ( ld != NULL ) { + ldap_unbind(ld); + } + ch_free(filter); + if ( mop_ndn.bv_val != op_ndn->bv_val ) { + free( mop_ndn.bv_val ); + } + if ( mgr_ndn.bv_val != gr_ndn->bv_val ) { + free( mgr_ndn.bv_val ); + } + return(rc); +} diff --git a/servers/slapd/back-ldap/modify.c b/servers/slapd/back-ldap/modify.c new file mode 100644 index 0000000000000000000000000000000000000000..8e19960fe76f5191ca50d01adc8aa179b1edf67e --- /dev/null +++ b/servers/slapd/back-ldap/modify.c @@ -0,0 +1,165 @@ +/* modify.c - ldap backend modify function */ +/* $OpenLDAP$ */ +/* + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* This is an altered version */ +/* + * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com> + * + * Permission is granted to anyone to use this software for any purpose + * on any computer system, and to alter it and redistribute it, subject + * to the following restrictions: + * + * 1. The author is not responsible for the consequences of use of this + * software, no matter how awful, even if they arise from flaws in it. + * + * 2. The origin of this software must not be misrepresented, either by + * explicit claim or by omission. Since few users ever read sources, + * credits should appear in the documentation. + * + * 3. Altered versions must be plainly marked as such, and must not be + * misrepresented as being the original software. Since few users + * ever read sources, credits should appear in the documentation. + * + * 4. This notice may not be removed or altered. + * + * + * + * Copyright 2000, Pierangelo Masarati, All rights reserved. <ando@sys-net.it> + * + * This software is being modified by Pierangelo Masarati. + * The previously reported conditions apply to the modified code as well. + * Changes in the original code are highlighted where required. + * Credits for the original code go to the author, Howard Chu. + */ + +#include "portable.h" + +#include <stdio.h> + +#include <ac/string.h> +#include <ac/socket.h> + +#include "slap.h" +#include "back-ldap.h" + +int +ldap_back_modify( + Backend *be, + Connection *conn, + Operation *op, + struct berval *dn, + struct berval *ndn, + Modifications *modlist +) +{ + struct ldapinfo *li = (struct ldapinfo *) be->be_private; + struct ldapconn *lc; + LDAPMod **modv = NULL; + LDAPMod *mods; + Modifications *ml; + int i, j; + struct berval mapped; + struct berval mdn = { 0, NULL }; + + lc = ldap_back_getconn(li, conn, op); + if ( !lc || !ldap_back_dobind( lc, op ) ) { + return( -1 ); + } + + /* + * Rewrite the modify dn, if needed + */ +#ifdef ENABLE_REWRITE + switch ( rewrite_session( li->rwinfo, "modifyDn", dn->bv_val, conn, &mdn.bv_val ) ) { + case REWRITE_REGEXEC_OK: + if ( mdn.bv_val == NULL ) { + mdn.bv_val = ( char * )dn->bv_val; + } +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDAP, DETAIL1, + "[rw] modifyDn: \"%s\" -> \"%s\"\n", dn->bv_val, mdn.bv_val, 0 ); +#else /* !NEW_LOGGING */ + Debug( LDAP_DEBUG_ARGS, "rw> modifyDn: \"%s\" -> \"%s\"\n%s", + dn->bv_val, mdn.bv_val, "" ); +#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 */ + ldap_back_dn_massage( li, dn, &mdn, 0, 1 ); +#endif /* !ENABLE_REWRITE */ + + for (i=0, ml=modlist; ml; i++,ml=ml->sml_next) + ; + + mods = (LDAPMod *)ch_malloc(i*sizeof(LDAPMod)); + if (mods == NULL) { + goto cleanup; + } + modv = (LDAPMod **)ch_malloc((i+1)*sizeof(LDAPMod *)); + if (modv == NULL) { + goto cleanup; + } + + for (i=0, ml=modlist; ml; ml=ml->sml_next) { + ldap_back_map(&li->at_map, &ml->sml_desc->ad_cname, &mapped, 0); + if (mapped.bv_val == NULL) { + continue; + } + + modv[i] = &mods[i]; + mods[i].mod_op = ml->sml_op | LDAP_MOD_BVALUES; + mods[i].mod_type = mapped.bv_val; + +#ifdef ENABLE_REWRITE + /* + * FIXME: dn-valued attrs should be rewritten + * to allow their use in ACLs at the back-ldap + * level. + */ + if ( strcmp( ml->sml_desc->ad_type->sat_syntax->ssyn_oid, + SLAPD_DN_SYNTAX ) == 0 ) { + ldap_dnattr_rewrite( li->rwinfo, + ml->sml_bvalues, conn ); + } +#endif /* ENABLE_REWRITE */ + + for (j = 0; ml->sml_bvalues[j].bv_val; j++); + mods[i].mod_bvalues = (struct berval **)ch_malloc((j+1) * + sizeof(struct berval *)); + for (j = 0; ml->sml_bvalues[j].bv_val; j++) + mods[i].mod_bvalues[j] = &ml->sml_bvalues[j]; + mods[i].mod_bvalues[j] = NULL; + i++; + } + modv[i] = 0; + + ldap_modify_s( lc->ld, mdn.bv_val, modv ); + +cleanup:; +#ifdef ENABLE_REWRITE + if ( mdn.bv_val != dn->bv_val ) { +#endif /* ENABLE_REWRITE */ + free( mdn.bv_val ); +#ifdef ENABLE_REWRITE + } +#endif /* ENABLE_REWRITE */ + for (i=0; modv[i]; i++) + ch_free(modv[i]->mod_bvalues); + ch_free(mods); + ch_free(modv); + return( ldap_back_op_result( lc, op )); +} + diff --git a/servers/slapd/back-ldap/modrdn.c b/servers/slapd/back-ldap/modrdn.c new file mode 100644 index 0000000000000000000000000000000000000000..5caf780e8cfe9aadfefce41347b9a35e890bfb84 --- /dev/null +++ b/servers/slapd/back-ldap/modrdn.c @@ -0,0 +1,160 @@ +/* modrdn.c - ldap backend modrdn function */ +/* $OpenLDAP$ */ +/* + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* This is an altered version */ +/* + * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com> + * + * Permission is granted to anyone to use this software for any purpose + * on any computer system, and to alter it and redistribute it, subject + * to the following restrictions: + * + * 1. The author is not responsible for the consequences of use of this + * software, no matter how awful, even if they arise from flaws in it. + * + * 2. The origin of this software must not be misrepresented, either by + * explicit claim or by omission. Since few users ever read sources, + * credits should appear in the documentation. + * + * 3. Altered versions must be plainly marked as such, and must not be + * misrepresented as being the original software. Since few users + * ever read sources, credits should appear in the documentation. + * + * 4. This notice may not be removed or altered. + * + * + * + * Copyright 2000, Pierangelo Masarati, All rights reserved. <ando@sys-net.it> + * + * This software is being modified by Pierangelo Masarati. + * The previously reported conditions apply to the modified code as well. + * Changes in the original code are highlighted where required. + * Credits for the original code go to the author, Howard Chu. + */ + +#include "portable.h" + +#include <stdio.h> + +#include <ac/socket.h> +#include <ac/string.h> + +#include "slap.h" +#include "back-ldap.h" + +int +ldap_back_modrdn( + Backend *be, + Connection *conn, + Operation *op, + struct berval *dn, + struct berval *ndn, + struct berval *newrdn, + struct berval *nnewrdn, + int deleteoldrdn, + struct berval *newSuperior, + struct berval *nnewSuperior +) +{ + struct ldapinfo *li = (struct ldapinfo *) be->be_private; + struct ldapconn *lc; + + struct berval mdn = { 0, NULL }, mnewSuperior = { 0, NULL }; + + lc = ldap_back_getconn( li, conn, op ); + if ( !lc || !ldap_back_dobind(lc, op) ) { + return( -1 ); + } + + if (newSuperior) { + int version = LDAP_VERSION3; + ldap_set_option( lc->ld, LDAP_OPT_PROTOCOL_VERSION, &version); + + /* + * Rewrite the new superior, if defined and required + */ +#ifdef ENABLE_REWRITE + switch ( rewrite_session( li->rwinfo, "newSuperiorDn", + newSuperior->bv_val, conn, &mnewSuperior.bv_val ) ) { + case REWRITE_REGEXEC_OK: + if ( mnewSuperior.bv_val == NULL ) { + mnewSuperior.bv_val = ( char * )newSuperior; + } +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDAP, DETAIL1, + "[rw] newSuperiorDn:" " \"%s\" -> \"%s\"\n", + newSuperior, mnewSuperior.bv_val, 0 ); +#else /* !NEW_LOGGING */ + Debug( LDAP_DEBUG_ARGS, "rw> newSuperiorDn:" + " \"%s\" -> \"%s\"\n%s", + newSuperior->bv_val, mnewSuperior.bv_val, "" ); +#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 */ + ldap_back_dn_massage( li, newSuperior, &mnewSuperior, 0, 1 ); + if ( mnewSuperior.bv_val == NULL ) { + return( -1 ); + } +#endif /* !ENABLE_REWRITE */ + } + +#ifdef ENABLE_REWRITE + /* + * Rewrite the modrdn dn, if required + */ + switch ( rewrite_session( li->rwinfo, "modrDn", dn->bv_val, conn, &mdn.bv_val ) ) { + case REWRITE_REGEXEC_OK: + if ( mdn.bv_val == NULL ) { + mdn.bv_val = ( char * )dn->bv_val; + } +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDAP, DETAIL1, + "[rw] modrDn: \"%s\" -> \"%s\"\n", dn->bv_val, mdn.bv_val, 0 ); +#else /* !NEW_LOGGING */ + Debug( LDAP_DEBUG_ARGS, "rw> modrDn: \"%s\" -> \"%s\"\n%s", + dn->bv_val, mdn.bv_val, "" ); +#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 */ + ldap_back_dn_massage( li, dn, &mdn, 0, 1 ); +#endif /* !ENABLE_REWRITE */ + + ldap_rename2_s( lc->ld, mdn.bv_val, newrdn->bv_val, mnewSuperior.bv_val, deleteoldrdn ); + + if ( mdn.bv_val != dn->bv_val ) { + free( mdn.bv_val ); + } + if ( mnewSuperior.bv_val != NULL + && mnewSuperior.bv_val != newSuperior->bv_val ) { + free( mnewSuperior.bv_val ); + } + + return( ldap_back_op_result( lc, op ) ); +} diff --git a/servers/slapd/back-ldap/search.c b/servers/slapd/back-ldap/search.c index 4f107a4f38f9cc23d401e755954522865753ee99..65d9b8110704f907ec4ba4839085682ffebdd2e4 100644 --- a/servers/slapd/back-ldap/search.c +++ b/servers/slapd/back-ldap/search.c @@ -153,9 +153,9 @@ ldap_back_search( mbase = *base; } #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "[rw] searchBase: \"%s\" -> \"%s\"\n%", - base->bv_val, mbase.bv_val )); + LDAP_LOG( BACK_LDAP, DETAIL1, + "[rw] searchBase: \"%s\" -> \"%s\"\n", + base->bv_val, mbase.bv_val, 0 ); #else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ARGS, "rw> searchBase: \"%s\" -> \"%s\"\n%s", base->bv_val, mbase.bv_val, "" ); @@ -191,9 +191,9 @@ ldap_back_search( } #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "[rw] searchFilter: \"%s\" -> \"%s\"\n", - filterstr->bv_val, mfilter.bv_val )); + LDAP_LOG( BACK_LDAP, DETAIL1, + "[rw] searchFilter: \"%s\" -> \"%s\"\n", + filterstr->bv_val, mfilter.bv_val, 0 ); #else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ARGS, "rw> searchFilter: \"%s\" -> \"%s\"\n%s", @@ -300,10 +300,8 @@ fail:; mmatch = ( char * )match; } #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "[rw] matchedDn:" - " \"%s\" -> \"%s\"\n", - match, mmatch )); + LDAP_LOG( BACK_LDAP, DETAIL1, + "[rw] matchedDn:" " \"%s\" -> \"%s\"\n", match, mmatch, 0 ); #else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ARGS, "rw> matchedDn:" " \"%s\" -> \"%s\"\n%s", @@ -389,9 +387,9 @@ ldap_send_entry( ent.e_name = bdn; } else { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "[rw] searchResult: \"%s\"" - " -> \"%s\"\n", bdn.bv_val, ent.e_dn )); + LDAP_LOG( BACK_LDAP, DETAIL1, + "[rw] searchResult: \"%s\"" " -> \"%s\"\n", + bdn.bv_val, ent.e_dn, 0 ); #else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ARGS, "rw> searchResult: \"%s\"" " -> \"%s\"\n%s", bdn.bv_val, ent.e_dn, "" ); @@ -428,9 +426,8 @@ ldap_send_entry( if (slap_bv2undef_ad(&mapped, &attr->a_desc, &text) != LDAP_SUCCESS) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "slap_bv2undef_ad(%s): " - "%s\n", mapped.bv_val, text )); + LDAP_LOG( BACK_LDAP, DETAIL1, + "slap_bv2undef_ad(%s): %s\n", mapped.bv_val, text, 0 ); #else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ANY, "slap_bv2undef_ad(%s): " @@ -506,14 +503,10 @@ ldap_send_entry( } newval.bv_len = strlen( newval.bv_val ); #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_val, - bv->bv_val, - newval.bv_val )); + LDAP_LOG( BACK_LDAP, DETAIL1, + "[rw] searchResult on attr=%s: \"%s\" -> \"%s\"\n", + attr->a_desc->ad_type->sat_cname.bv_val, + bv->bv_val, newval.bv_val ); #else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ARGS, "rw> searchResult on attr=%s: \"%s\" -> \"%s\"\n", diff --git a/servers/slapd/back-ldap/suffixmassage.c b/servers/slapd/back-ldap/suffixmassage.c index d24af0e275af0e3ca6b868cf1271e71d70894e0b..c392207b3a0f2ca242eb2ffd9d57f8373e1f20ad 100644 --- a/servers/slapd/back-ldap/suffixmassage.c +++ b/servers/slapd/back-ldap/suffixmassage.c @@ -99,9 +99,9 @@ ldap_back_dn_massage( strncpy( res->bv_val, dn->bv_val, diff ); strcpy( &res->bv_val[diff], li->suffix_massage[i+dst].bv_val ); #ifdef NEW_LOGGING - LDAP_LOG (( "suffixmassage", LDAP_LEVEL_ARGS, + LDAP_LOG ( BACK_LDAP, ARGS, "ldap_back_dn_massage: converted \"%s\" to \"%s\"\n", - dn->bv_val, res->bv_val )); + dn->bv_val, res->bv_val, 0 ); #else Debug( LDAP_DEBUG_ARGS, "ldap_back_dn_massage:" diff --git a/servers/slapd/back-ldap/unbind.c b/servers/slapd/back-ldap/unbind.c index a15452721a2dde7092f5269fa1e77d2da13cdd13..a5aa5f1f9245f117b8e9b1b9e73a2e7f301f0f93 100644 --- a/servers/slapd/back-ldap/unbind.c +++ b/servers/slapd/back-ldap/unbind.c @@ -55,9 +55,8 @@ ldap_back_conn_destroy( struct ldapconn *lc, lc_curr; #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "ldap_back_conn_destroy: fetching conn %ld\n", - conn->c_connid )); + LDAP_LOG( BACK_LDAP, INFO, + "ldap_back_conn_destroy: fetching conn %ld\n", conn->c_connid, 0, 0 ); #else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_TRACE, "=>ldap_back_conn_destroy: fetching conn %ld\n", @@ -72,9 +71,9 @@ ldap_back_conn_destroy( if (lc) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "ldap_back_conn_destroy: destroying conn %ld\n", - conn->c_connid )); + LDAP_LOG( BACK_LDAP, DETAIL1, + "ldap_back_conn_destroy: destroying conn %ld\n", + conn->c_connid, 0, 0 ); #else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_TRACE, "=>ldap_back_conn_destroy: destroying conn %ld\n", diff --git a/servers/slapd/back-ldbm/add.c b/servers/slapd/back-ldbm/add.c index 3dacd6da3dba445dece437a7eff58708971c2e65..64854753fa332688e76e1f087fa0721501d02c4d 100644 --- a/servers/slapd/back-ldbm/add.c +++ b/servers/slapd/back-ldbm/add.c @@ -1,16 +1,20 @@ /* add.c - ldap ldbm back-end add routine */ +/* $OpenLDAP$ */ +/* + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ + +#include "portable.h" #include <stdio.h> -#include <string.h> -#include <sys/types.h> -#include <sys/socket.h> + +#include <ac/socket.h> +#include <ac/string.h> + #include "slap.h" #include "back-ldbm.h" - -extern int global_schemacheck; -extern char *dn_parent(); -extern char *dn_normalize(); -extern Entry *dn2entry(); +#include "proto-back-ldbm.h" int ldbm_back_add( @@ -21,49 +25,48 @@ ldbm_back_add( ) { struct ldbminfo *li = (struct ldbminfo *) be->be_private; - char *matched; - char *dn = NULL, *pdn = NULL; - Entry *p; - - dn = dn_normalize( strdup( e->e_dn ) ); - matched = NULL; - if ( (p = dn2entry( be, dn, &matched )) != NULL ) { - cache_return_entry( &li->li_cache, p ); - entry_free( e ); - free( dn ); - send_ldap_result( conn, op, LDAP_ALREADY_EXISTS, "", "" ); - return( -1 ); - } - if ( matched != NULL ) { - free( matched ); - } - /* XXX race condition here til we cache_add_entry_lock below XXX */ + struct berval pdn; + Entry *p = NULL; + int rc; + ID id = NOID; + const char *text = NULL; + AttributeDescription *children = slap_schema.si_ad_children; + char textbuf[SLAP_TEXT_BUFLEN]; + size_t textlen = sizeof textbuf; - if ( global_schemacheck && oc_schema_check( e ) != 0 ) { - Debug( LDAP_DEBUG_TRACE, "entry failed schema check\n", 0, 0, - 0 ); - entry_free( e ); - free( dn ); - send_ldap_result( conn, op, LDAP_OBJECT_CLASS_VIOLATION, "", - "" ); +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ENTRY, "ldbm_back_add: %s\n", e->e_dn, 0, 0 ); +#else + Debug(LDAP_DEBUG_ARGS, "==> ldbm_back_add: %s\n", e->e_dn, 0, 0); +#endif + + /* grab giant lock for writing */ + ldap_pvt_thread_rdwr_wlock(&li->li_giant_rwlock); + + if ( ( rc = dn2id( be, &e->e_nname, &id ) ) || id != NOID ) { + /* if (rc) something bad happened to ldbm cache */ + ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock); + send_ldap_result( conn, op, + rc ? LDAP_OPERATIONS_ERROR : LDAP_ALREADY_EXISTS, + NULL, NULL, NULL, NULL ); return( -1 ); } - /* - * Try to add the entry to the cache, assign it a new dnid - * and mark it locked. This should only fail if the entry - * already exists. - */ + rc = entry_schema_check( be, e, NULL, &text, textbuf, textlen ); - e->e_id = next_id( be ); - if ( cache_add_entry_lock( &li->li_cache, e, ENTRY_STATE_CREATING ) - != 0 ) { - Debug( LDAP_DEBUG_ANY, "cache_add_entry_lock failed\n", 0, 0, - 0 ); - next_id_return( be, e->e_id ); - entry_free( e ); - free( dn ); - send_ldap_result( conn, op, LDAP_ALREADY_EXISTS, "", "" ); + if ( rc != LDAP_SUCCESS ) { + ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock); + +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ERR, + "ldbm_back_add: entry (%s) failed schema check.\n", e->e_dn, 0, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, "entry failed schema check: %s\n", + text, 0, 0 ); +#endif + + send_ldap_result( conn, op, rc, + NULL, text, NULL, NULL ); return( -1 ); } @@ -73,101 +76,311 @@ ldbm_back_add( * add the entry. */ - if ( (pdn = dn_parent( be, dn )) != NULL ) { - /* no parent */ - matched = NULL; - if ( (p = dn2entry( be, pdn, &matched )) == NULL ) { - send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT, - matched, "" ); + if ( be_issuffix( be, &e->e_nname ) ) { + pdn = slap_empty_bv; + } else { + dnParent( &e->e_nname, &pdn ); + } + + if( pdn.bv_len ) { + Entry *matched = NULL; + + /* get parent with writer lock */ + if ( (p = dn2entry_w( be, &pdn, &matched )) == NULL ) { + char *matched_dn = NULL; + BerVarray refs; + if ( matched != NULL ) { - free( matched ); + matched_dn = ch_strdup( matched->e_dn ); + refs = is_entry_referral( matched ) + ? get_entry_referrals( be, conn, op, matched ) + : NULL; + cache_return_entry_r( &li->li_cache, matched ); + + } else { + refs = referral_rewrite( default_referral, + NULL, &e->e_name, LDAP_SCOPE_DEFAULT ); } - Debug( LDAP_DEBUG_TRACE, "parent does not exist\n", 0, + + ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock); + +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ERR, + "ldbm_back_add: Parent of (%s) does not exist.\n", + e->e_dn, 0, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, "parent does not exist\n", + 0, 0, 0 ); +#endif + + send_ldap_result( conn, op, LDAP_REFERRAL, matched_dn, + refs == NULL ? "parent does not exist" : "parent is referral", + refs, NULL ); + + ber_bvarray_free( refs ); + free( matched_dn ); + + return -1; + } + + if ( ! access_allowed( be, conn, op, p, + children, NULL, ACL_WRITE, NULL ) ) + { + /* free parent and writer lock */ + cache_return_entry_w( &li->li_cache, p ); + ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock); + +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ERR, + "ldbm_back_add: No write access to parent (%s).\n", + e->e_dn, 0, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, "no write access to parent\n", 0, 0, 0 ); - goto error_return; +#endif + + send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS, + NULL, "no write access to parent", NULL, NULL ); + + return -1; } - if ( matched != NULL ) { - free( matched ); + + if ( is_entry_alias( p ) ) { + /* parent is an alias, don't allow add */ + + /* free parent and writer lock */ + cache_return_entry_w( &li->li_cache, p ); + ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock); + +#ifdef NEW_LOGGING + LDAP_LOG(BACK_LDBM, ERR, + "ldbm_back_add: Parent is an alias.\n", 0, 0, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, "parent is alias\n", 0, + 0, 0 ); +#endif + + + send_ldap_result( conn, op, LDAP_ALIAS_PROBLEM, + NULL, "parent is an alias", NULL, NULL ); + + return -1; } - if ( ! access_allowed( be, conn, op, p, "children", NULL, - op->o_dn, ACL_WRITE ) ) { - Debug( LDAP_DEBUG_TRACE, "no access to parent\n", 0, + if ( is_entry_referral( p ) ) { + /* parent is a referral, don't allow add */ + char *matched_dn = ch_strdup( p->e_dn ); + BerVarray refs = is_entry_referral( p ) + ? get_entry_referrals( be, conn, op, p ) + : NULL; + + /* free parent and writer lock */ + cache_return_entry_w( &li->li_cache, p ); + ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock); + +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ERR, + "ldbm_back_add: Parent is referral.\n", 0, 0, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, "parent is referral\n", 0, 0, 0 ); - send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS, - "", "" ); - goto error_return; +#endif + + send_ldap_result( conn, op, LDAP_REFERRAL, + matched_dn, NULL, refs, NULL ); + + ber_bvarray_free( refs ); + free( matched_dn ); + return -1; } + } else { - if ( ! be_isroot( be, op->o_dn ) ) { - Debug( LDAP_DEBUG_TRACE, "no parent & not root\n", 0, - 0, 0 ); - send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS, - "", "" ); - goto error_return; + if(pdn.bv_val != NULL) { + assert( *pdn.bv_val == '\0' ); + } + + /* no parent, must be adding entry to root */ + if ( !be_isroot( be, &op->o_ndn ) ) { + if ( be_issuffix( be, (struct berval *)&slap_empty_bv ) || be_isupdate( be, &op->o_ndn ) ) { + p = (Entry *)&slap_entry_root; + + rc = access_allowed( be, conn, op, p, + children, NULL, ACL_WRITE, NULL ); + p = NULL; + + if ( ! rc ) { + ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock); + +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ERR, + "ldbm_back_add: No write " + "access to parent (\"\").\n", 0, 0, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, + "no write access to parent\n", + 0, 0, 0 ); +#endif + + send_ldap_result( conn, op, + LDAP_INSUFFICIENT_ACCESS, + NULL, + "no write access to parent", + NULL, NULL ); + + return -1; + } + + } else { + ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock); + +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ERR, + "ldbm_back_add: %s add denied.\n", + pdn.bv_val == NULL ? "suffix" + : "entry at root", 0, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, "%s add denied\n", + pdn.bv_val == NULL ? "suffix" + : "entry at root", 0, 0 ); +#endif + + send_ldap_result( conn, op, + LDAP_INSUFFICIENT_ACCESS, + NULL, NULL, NULL, NULL ); + + return -1; + } } - p = NULL; } - /* - * add it to the id2children index for the parent - */ + if ( next_id( be, &e->e_id ) ) { + if( p != NULL) { + /* free parent and writer lock */ + cache_return_entry_w( &li->li_cache, p ); + } - if ( id2children_add( be, p, e ) != 0 ) { - Debug( LDAP_DEBUG_TRACE, "id2children_add failed\n", 0, - 0, 0 ); - send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", - "" ); - goto error_return; + ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock); + +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ERR, + "ldbm_back_add: next_id failed.\n", 0, 0, 0 ); +#else + Debug( LDAP_DEBUG_ANY, "ldbm_add: next_id failed\n", + 0, 0, 0 ); +#endif + + send_ldap_result( conn, op, LDAP_OTHER, + NULL, "next_id add failed", NULL, NULL ); + + return( -1 ); } /* - * Add the entry to the attribute indexes, then add it to - * the id2children index, dn2id index, and the id2entry index. + * Try to add the entry to the cache, assign it a new dnid. */ + rc = cache_add_entry_rw(&li->li_cache, e, CACHE_WRITE_LOCK); + + if ( rc != 0 ) { + if( p != NULL) { + /* free parent and writer lock */ + cache_return_entry_w( &li->li_cache, p ); + } + + ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock); + +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ERR, + "ldbm_back_add: cache_add_entry_lock failed.\n", 0, 0, 0 ); +#else + Debug( LDAP_DEBUG_ANY, "cache_add_entry_lock failed\n", 0, 0, + 0 ); +#endif + + send_ldap_result( conn, op, + rc > 0 ? LDAP_ALREADY_EXISTS : LDAP_OTHER, + NULL, rc > 0 ? NULL : "cache add failed", NULL, NULL ); + + return( -1 ); + } + + rc = -1; /* attribute indexes */ - if ( index_add_entry( be, e ) != 0 ) { - Debug( LDAP_DEBUG_TRACE, "index_add_entry failed\n", 0, + if ( index_entry_add( be, e, e->e_attrs ) != LDAP_SUCCESS ) { +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ERR, + "ldbm_back_add: index_entry_add failed.\n", 0, 0, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, "index_entry_add failed\n", 0, 0, 0 ); - send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" ); - goto error_return; +#endif + + send_ldap_result( conn, op, LDAP_OTHER, + NULL, "index generation failed", NULL, NULL ); + + goto return_results; } /* dn2id index */ - if ( dn2id_add( be, dn, e->e_id ) != 0 ) { + if ( dn2id_add( be, &e->e_nname, e->e_id ) != 0 ) { +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ERR, + "ldbm_back_add: dn2id_add failed.\n", 0, 0, 0 ); +#else Debug( LDAP_DEBUG_TRACE, "dn2id_add failed\n", 0, 0, 0 ); - send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" ); - goto error_return; +#endif + /* FIXME: delete attr indices? */ + + send_ldap_result( conn, op, LDAP_OTHER, + NULL, "DN index generation failed", NULL, NULL ); + + goto return_results; } /* id2entry index */ if ( id2entry_add( be, e ) != 0 ) { +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ERR, + "ldbm_back_add: id2entry_add failed.\n", 0, 0, 0 ); +#else Debug( LDAP_DEBUG_TRACE, "id2entry_add failed\n", 0, 0, 0 ); - (void) dn2id_delete( be, dn ); - send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" ); - goto error_return; +#endif + + /* FIXME: delete attr indices? */ + (void) dn2id_delete( be, &e->e_nname, e->e_id ); + + send_ldap_result( conn, op, LDAP_OTHER, + NULL, "entry store failed", NULL, NULL ); + + goto return_results; + } + + send_ldap_result( conn, op, LDAP_SUCCESS, + NULL, NULL, NULL, NULL ); + + /* marks the entry as committed, so it is added to the cache; + * otherwise it is removed from the cache, but not destroyed; + * it will be destroyed by the caller */ + rc = 0; + cache_entry_commit( e ); + +return_results:; + if (p != NULL) { + /* free parent and writer lock */ + cache_return_entry_w( &li->li_cache, p ); + } + + if ( rc ) { + /* + * in case of error, writer lock is freed + * and entry's private data is destroyed. + * otherwise, this is done when entry is released + */ + cache_return_entry_w( &li->li_cache, e ); + ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock); } - send_ldap_result( conn, op, LDAP_SUCCESS, "", "" ); - if ( dn != NULL ) - free( dn ); - if ( pdn != NULL ) - free( pdn ); - cache_set_state( &li->li_cache, e, 0 ); - cache_return_entry( &li->li_cache, e ); - return( 0 ); - -error_return:; - if ( dn != NULL ) - free( dn ); - if ( pdn != NULL ) - free( pdn ); - next_id_return( be, e->e_id ); - cache_delete_entry( &li->li_cache, e ); - cache_return_entry( &li->li_cache, e ); - - return( -1 ); + return( rc ); } diff --git a/servers/slapd/back-ldbm/attr.c b/servers/slapd/back-ldbm/attr.c index d0bb831c263337797c0f5ed1e8f2603c35664ec8..6bfa9824b4a12a096fe6e6b15697924b852d99be 100644 --- a/servers/slapd/back-ldbm/attr.c +++ b/servers/slapd/back-ldbm/attr.c @@ -1,165 +1,219 @@ /* attr.c - backend routines for dealing with attributes */ +/* $OpenLDAP$ */ +/* + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ + +#include "portable.h" #include <stdio.h> -#include <string.h> -#include <sys/types.h> -#include <sys/socket.h> + +#include <ac/socket.h> +#include <ac/string.h> + #include "slap.h" #include "back-ldbm.h" -extern char **str2charray(); +/* for the cache of attribute information (which are indexed, etc.) */ +typedef struct ldbm_attrinfo { + AttributeDescription *ai_desc; /* attribute description cn;lang-en */ + slap_mask_t ai_indexmask; /* how the attr is indexed */ +} AttrInfo; static int ainfo_type_cmp( - char *type, - struct attrinfo *a + AttributeDescription *desc, + AttrInfo *a ) { - return( strcasecmp( type, a->ai_type ) ); + return desc - a->ai_desc; } static int ainfo_cmp( - struct attrinfo *a, - struct attrinfo *b + AttrInfo *a, + AttrInfo *b ) { - return( strcasecmp( a->ai_type, b->ai_type ) ); -} - -/* - * Called when a duplicate "index" line is encountered. - * - * returns 1 => original from init code, indexmask updated - * 2 => original not from init code, warn the user - */ - -static int -ainfo_dup( - struct attrinfo *a, - struct attrinfo *b -) -{ - /* - * if the duplicate definition is because we initialized the attr, - * just add what came from the config file. otherwise, complain. - */ - if ( a->ai_indexmask & INDEX_FROMINIT ) { - a->ai_indexmask |= b->ai_indexmask; - - return( 1 ); - } - - return( 2 ); + return a->ai_desc - b->ai_desc; } void -attr_masks( +attr_mask( struct ldbminfo *li, - char *type, - int *indexmask, - int *syntaxmask -) + AttributeDescription *desc, + slap_mask_t *indexmask ) { - struct attrinfo *a; - - *indexmask = 0; - *syntaxmask = 0; - if ( (a = (struct attrinfo *) avl_find( li->li_attrs, type, - ainfo_type_cmp )) == NULL ) { - if ( (a = (struct attrinfo *) avl_find( li->li_attrs, "default", - ainfo_type_cmp )) == NULL ) { - return; - } - } - *indexmask = a->ai_indexmask; - if ( strcasecmp( a->ai_type, "default" ) == 0 ) { - *syntaxmask = attr_syntax( type ); - } else { - *syntaxmask = a->ai_syntaxmask; - } + AttrInfo *a; + + a = (AttrInfo *) avl_find( li->li_attrs, desc, + (AVL_CMP) ainfo_type_cmp ); + + *indexmask = a != NULL ? a->ai_indexmask : 0; } -void +int attr_index_config( struct ldbminfo *li, - char *fname, + const char *fname, int lineno, int argc, - char **argv, - int init -) + char **argv ) { - int i, j; - char **attrs, **indexes; - struct attrinfo *a; + int rc; + int i; + slap_mask_t mask; + char **attrs; + char **indexes = NULL; attrs = str2charray( argv[0], "," ); + + if( attrs == NULL ) { + fprintf( stderr, "%s: line %d: " + "no attributes specified: %s\n", + fname, lineno, argv[0] ); + return LDAP_PARAM_ERROR; + } + if ( argc > 1 ) { indexes = str2charray( argv[1], "," ); + + if( indexes == NULL ) { + fprintf( stderr, "%s: line %d: " + "no indexes specified: %s\n", + fname, lineno, argv[1] ); + return LDAP_PARAM_ERROR; + } } - for ( i = 0; attrs[i] != NULL; i++ ) { - a = (struct attrinfo *) ch_malloc( sizeof(struct attrinfo) ); - a->ai_type = strdup( attrs[i] ); - a->ai_syntaxmask = attr_syntax( a->ai_type ); - if ( argc == 1 ) { - a->ai_indexmask = (INDEX_PRESENCE | INDEX_EQUALITY | - INDEX_APPROX | INDEX_SUB); - } else { - a->ai_indexmask = 0; - for ( j = 0; indexes[j] != NULL; j++ ) { - if ( strncasecmp( indexes[j], "pres", 4 ) - == 0 ) { - a->ai_indexmask |= INDEX_PRESENCE; - } else if ( strncasecmp( indexes[j], "eq", 2 ) - == 0 ) { - a->ai_indexmask |= INDEX_EQUALITY; - } else if ( strncasecmp( indexes[j], "approx", - 6 ) == 0 ) { - a->ai_indexmask |= INDEX_APPROX; - } else if ( strncasecmp( indexes[j], "sub", 3 ) - == 0 ) { - a->ai_indexmask |= INDEX_SUB; - } else if ( strncasecmp( indexes[j], "none", 4 ) - == 0 ) { - if ( a->ai_indexmask != 0 ) { - fprintf( stderr, -"%s: line %d: index type \"none\" cannot be combined with other types\n", - fname, lineno ); - } - a->ai_indexmask = 0; - } else { - fprintf( stderr, - "%s: line %d: unknown index type \"%s\" (ignored)\n", - fname, lineno, indexes[j] ); - fprintf( stderr, - "valid index types are \"pres\", \"eq\", \"approx\", or \"sub\"\n" ); - } + + if( indexes == NULL ) { + mask = li->li_defaultmask; + + } else { + mask = 0; + + for ( i = 0; indexes[i] != NULL; i++ ) { + slap_mask_t index; + rc = slap_str2index( indexes[i], &index ); + + if( rc != LDAP_SUCCESS ) { + fprintf( stderr, "%s: line %d: " + "index type \"%s\" undefined\n", + fname, lineno, indexes[i] ); + return LDAP_PARAM_ERROR; } + + mask |= index; + } + } + + if( !mask ) { + fprintf( stderr, "%s: line %d: " + "no indexes selected\n", + fname, lineno ); + return LDAP_PARAM_ERROR; + } + + for ( i = 0; attrs[i] != NULL; i++ ) { + AttrInfo *a; + AttributeDescription *ad; + const char *text; + + if( strcasecmp( attrs[i], "default" ) == 0 ) { + li->li_defaultmask = mask; + continue; + } + + a = (AttrInfo *) ch_malloc( sizeof(AttrInfo) ); + + ad = NULL; + rc = slap_str2ad( attrs[i], &ad, &text ); + + if( rc != LDAP_SUCCESS ) { + fprintf( stderr, "%s: line %d: " + "index attribute \"%s\" undefined\n", + fname, lineno, attrs[i] ); + return rc; + } + + if( slap_ad_is_binary( ad ) ) { + fprintf( stderr, "%s: line %d: " + "index of attribute \"%s\" disallowed\n", + fname, lineno, attrs[i] ); + return LDAP_UNWILLING_TO_PERFORM; + } + + if( IS_SLAP_INDEX( mask, SLAP_INDEX_APPROX ) && !( + ( ad->ad_type->sat_approx + && ad->ad_type->sat_approx->smr_indexer + && ad->ad_type->sat_approx->smr_filter ) + && ( ad->ad_type->sat_equality + && ad->ad_type->sat_equality->smr_indexer + && ad->ad_type->sat_equality->smr_filter ) ) ) + { + fprintf( stderr, "%s: line %d: " + "approx index of attribute \"%s\" disallowed\n", + fname, lineno, attrs[i] ); + return LDAP_INAPPROPRIATE_MATCHING; + } + + if( IS_SLAP_INDEX( mask, SLAP_INDEX_EQUALITY ) && !( + ad->ad_type->sat_equality + && ad->ad_type->sat_equality->smr_indexer + && ad->ad_type->sat_equality->smr_filter ) ) + { + fprintf( stderr, "%s: line %d: " + "equality index of attribute \"%s\" disallowed\n", + fname, lineno, attrs[i] ); + return LDAP_INAPPROPRIATE_MATCHING; } - if ( init ) { - a->ai_indexmask |= INDEX_FROMINIT; + + if( IS_SLAP_INDEX( mask, SLAP_INDEX_SUBSTR ) && !( + ad->ad_type->sat_substr + && ad->ad_type->sat_substr->smr_indexer + && ad->ad_type->sat_substr->smr_filter ) ) + { + fprintf( stderr, "%s: line %d: " + "substr index of attribute \"%s\" disallowed\n", + fname, lineno, attrs[i] ); + return LDAP_INAPPROPRIATE_MATCHING; } - switch (avl_insert( &li->li_attrs, a, ainfo_cmp, ainfo_dup )) { - case 1: /* duplicate - updating init version */ - free( a->ai_type ); - free( (char *) a ); - break; - - case 2: /* user duplicate - ignore and warn */ - fprintf( stderr, - "%s: line %d: duplicate index definition for attr \"%s\" (ignored)\n", - fname, lineno, a->ai_type ); - free( a->ai_type ); - free( (char *) a ); - break; - - default:; /* inserted ok */ - /* FALL */ +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, DETAIL1, + "attr_index_config: index %s 0x%04lx\n", + ad->ad_cname.bv_val, mask, 0 ); +#else + Debug( LDAP_DEBUG_CONFIG, "index %s 0x%04lx\n", + ad->ad_cname.bv_val, mask, 0 ); +#endif + + + a->ai_desc = ad; + + a->ai_indexmask = mask; + + rc = avl_insert( &li->li_attrs, (caddr_t) a, + (AVL_CMP) ainfo_cmp, (AVL_DUP) avl_dup_error ); + + if( rc ) { + fprintf( stderr, "%s: line %d: duplicate index definition " + "for attr \"%s\" (ignored)\n", + fname, lineno, attrs[i] ); + + return LDAP_PARAM_ERROR; } } + charray_free( attrs ); - if ( argc > 1 ) - charray_free( indexes ); + if ( indexes != NULL ) charray_free( indexes ); + + return LDAP_SUCCESS; +} + +void +attr_index_destroy( Avlnode *tree ) +{ + avl_free( tree, free ); } diff --git a/servers/slapd/back-ldbm/attribute.c b/servers/slapd/back-ldbm/attribute.c index eaa8d3e116e2cece0b479d0b0cb8c1f4605e0b89..0dc5daf03a20fb31a7e4f2f50743b0f0b0145520 100644 --- a/servers/slapd/back-ldbm/attribute.c +++ b/servers/slapd/back-ldbm/attribute.c @@ -16,7 +16,6 @@ #include "back-ldbm.h" #include "proto-back-ldbm.h" - /* return LDAP_SUCCESS IFF we can retrieve the attributes * of entry with e_ndn */ @@ -41,13 +40,12 @@ ldbm_back_attribute( int nvals = 0; #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_ARGS, - "ldbm_back_attribute: gr dn: \"%s\"\n", entry_ndn->bv_val )); - LDAP_LOG(( "backend", LDAP_LEVEL_ARGS, - "ldbm_back_attribute: at: \"%s\"\n", entry_at_name)); - LDAP_LOG(( "backend", LDAP_LEVEL_ARGS, - "ldbm_back_attribute: tr dn: \"%s\"\n", - target ? target->e_ndn : "" )); + LDAP_LOG( BACK_LDBM, ARGS, + "ldbm_back_attribute: gr dn: \"%s\"\n", entry_ndn->bv_val, 0, 0 ); + LDAP_LOG( BACK_LDBM, ARGS, + "ldbm_back_attribute: at: \"%s\"\n", entry_at_name, 0, 0); + LDAP_LOG( BACK_LDBM, ARGS, "ldbm_back_attribute: tr dn: \"%s\"\n", + target ? target->e_ndn : "", 0, 0 ); #else Debug( LDAP_DEBUG_ARGS, "=> ldbm_back_attribute: gr dn: \"%s\"\n", @@ -65,9 +63,9 @@ ldbm_back_attribute( /* we already have a LOCKED copy of the entry */ e = target; #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "ldbm_back_attribute: target is LOCKED (%s)\n", - entry_ndn->bv_val )); + LDAP_LOG( BACK_LDBM, DETAIL1, + "ldbm_back_attribute: target is LOCKED (%s)\n", + entry_ndn->bv_val, 0, 0); #else Debug( LDAP_DEBUG_ARGS, "=> ldbm_back_attribute: target is entry: \"%s\"\n", @@ -79,9 +77,9 @@ ldbm_back_attribute( /* can we find entry with reader lock */ if ((e = dn2entry_r(be, entry_ndn, NULL )) == NULL) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, + LDAP_LOG( BACK_LDBM, INFO, "ldbm_back_attribute: cannot find entry (%s)\n", - entry_ndn->bv_val )); + entry_ndn->bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_ACL, "=> ldbm_back_attribute: cannot find entry: \"%s\"\n", @@ -92,9 +90,8 @@ ldbm_back_attribute( } #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "ldbm_back_attribute: found entry (%s)\n", - entry_ndn->bv_val )); + LDAP_LOG( BACK_LDBM, DETAIL1, + "ldbm_back_attribute: found entry (%s)\n", entry_ndn->bv_val, 0, 0); #else Debug( LDAP_DEBUG_ACL, "=> ldbm_back_attribute: found entry: \"%s\"\n", @@ -107,8 +104,8 @@ ldbm_back_attribute( if( is_entry_alias( e ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "ldbm_back_attribute: entry (%s) is an alias\n", e->e_dn )); + LDAP_LOG( BACK_LDBM, INFO, + "ldbm_back_attribute: entry (%s) is an alias\n", e->e_dn, 0, 0 ); #else Debug( LDAP_DEBUG_ACL, "<= ldbm_back_attribute: entry is an alias\n", 0, 0, 0 ); @@ -120,8 +117,8 @@ ldbm_back_attribute( if( is_entry_referral( e ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "ldbm_back_attribute: entry (%s) is a referral.\n", e->e_dn )); + LDAP_LOG( BACK_LDBM, INFO, + "ldbm_back_attribute: entry (%s) is a referral.\n", e->e_dn, 0, 0 ); #else Debug( LDAP_DEBUG_ACL, "<= ldbm_back_attribute: entry is an referral\n", 0, 0, 0 ); @@ -141,8 +138,8 @@ ldbm_back_attribute( if ((attr = attr_find(e->e_attrs, entry_at)) == NULL) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "ldbm_back_attribute: failed to find %s.\n", entry_at_name )); + LDAP_LOG( BACK_LDBM, INFO, + "ldbm_back_attribute: failed to find %s.\n", entry_at_name, 0, 0 ); #else Debug( LDAP_DEBUG_ACL, "<= ldbm_back_attribute: failed to find %s\n", @@ -199,9 +196,8 @@ return_results: } #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY, - "ldbm_back_attribute: rc=%d nvals=%d.\n", - rc, nvals )); + LDAP_LOG( BACK_LDBM, ENTRY, + "ldbm_back_attribute: rc=%d nvals=%d.\n", rc, nvals, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldbm_back_attribute: rc=%d nvals=%d\n", diff --git a/servers/slapd/back-ldbm/bind.c b/servers/slapd/back-ldbm/bind.c index 88fd4030c41df52a20815451fdc6491f4f431449..766e31c0c693bcfbb1d56c3a8de190acddcd8ff4 100644 --- a/servers/slapd/back-ldbm/bind.c +++ b/servers/slapd/back-ldbm/bind.c @@ -1,150 +1,275 @@ /* bind.c - ldbm backend bind and unbind routines */ +/* $OpenLDAP$ */ +/* + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ + +#include "portable.h" #include <stdio.h> -#include <string.h> -#include <sys/types.h> -#include <sys/socket.h> -#include "slap.h" -#include "back-ldbm.h" -#ifdef KERBEROS -#include "krb.h" -#endif -extern Entry *dn2entry(); -extern Attribute *attr_find(); +#include <ac/krb.h> +#include <ac/socket.h> +#include <ac/string.h> +#include <ac/unistd.h> -#ifdef KERBEROS -extern int krbv4_ldap_auth(); -#endif +#include "slap.h" +#include "back-ldbm.h" +#include "proto-back-ldbm.h" int ldbm_back_bind( Backend *be, Connection *conn, Operation *op, - char *dn, + struct berval *dn, + struct berval *ndn, int method, - struct berval *cred + struct berval *cred, + struct berval *edn ) { struct ldbminfo *li = (struct ldbminfo *) be->be_private; Entry *e; Attribute *a; int rc; - char *matched = NULL; -#ifdef KERBEROS + Entry *matched; +#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND char krbname[MAX_K_NAME_SZ + 1]; + AttributeDescription *krbattr = slap_schema.si_ad_krbName; AUTH_DAT ad; #endif - if ( (e = dn2entry( be, dn, &matched )) == NULL ) { - /* allow noauth binds */ - if ( method == LDAP_AUTH_SIMPLE && cred->bv_len == 0 ) { - /* - * bind successful, but return 1 so we don't - * authorize based on noauth credentials - */ - send_ldap_result( conn, op, LDAP_SUCCESS, NULL, NULL ); - rc = 1; - } else if ( be_isroot_pw( be, dn, cred ) ) { - /* front end will send result */ - rc = 0; + AttributeDescription *password = slap_schema.si_ad_userPassword; + +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ENTRY, + "ldbm_back_bind: dn: %s.\n", dn->bv_val, 0, 0 ); +#else + Debug(LDAP_DEBUG_ARGS, "==> ldbm_back_bind: dn: %s\n", dn->bv_val, 0, 0); +#endif + + dn = ndn; + + /* grab giant lock for reading */ + ldap_pvt_thread_rdwr_rlock(&li->li_giant_rwlock); + + /* get entry with reader lock */ + if ( (e = dn2entry_r( be, dn, &matched )) == NULL ) { + char *matched_dn = NULL; + BerVarray refs = NULL; + + if( matched != NULL ) { + matched_dn = ch_strdup( matched->e_dn ); + + refs = is_entry_referral( matched ) + ? get_entry_referrals( be, conn, op, matched ) + : NULL; + + cache_return_entry_r( &li->li_cache, matched ); + } else { - send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT, - matched, NULL ); - rc = 1; + refs = referral_rewrite( default_referral, + NULL, dn, LDAP_SCOPE_DEFAULT ); } - if ( matched != NULL ) { - free( matched ); + + ldap_pvt_thread_rdwr_runlock(&li->li_giant_rwlock); + + /* allow noauth binds */ + rc = 1; + if ( method == LDAP_AUTH_SIMPLE ) { + if ( be_isroot_pw( be, conn, dn, cred ) ) { + ber_dupbv( edn, be_root_dn( be ) ); + rc = 0; /* front end will send result */ + + } else if ( refs != NULL ) { + send_ldap_result( conn, op, LDAP_REFERRAL, + matched_dn, NULL, refs, NULL ); + + } else { + send_ldap_result( conn, op, LDAP_INVALID_CREDENTIALS, + NULL, NULL, NULL, NULL ); + } + + } else if ( refs != NULL ) { + send_ldap_result( conn, op, LDAP_REFERRAL, + matched_dn, NULL, refs, NULL ); + + } else { + send_ldap_result( conn, op, LDAP_INVALID_CREDENTIALS, + NULL, NULL, NULL, NULL ); } + + if ( refs ) ber_bvarray_free( refs ); + if ( matched_dn ) free( matched_dn ); return( rc ); } + ber_dupbv( edn, &e->e_name ); + + /* check for deleted */ + + if ( is_entry_alias( e ) ) { + /* entry is an alias, don't allow bind */ +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, INFO, + "ldbm_back_bind: entry (%s) is an alias.\n", e->e_dn, 0, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, "entry is alias\n", 0, + 0, 0 ); +#endif + + + send_ldap_result( conn, op, LDAP_ALIAS_PROBLEM, + NULL, "entry is alias", NULL, NULL ); + + rc = 1; + goto return_results; + } + + if ( is_entry_referral( e ) ) { + /* entry is a referral, don't allow bind */ + BerVarray refs = get_entry_referrals( be, + conn, op, e ); + +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, INFO, + "ldbm_back_bind: entry(%s) is a referral.\n", e->e_dn, 0, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0, + 0, 0 ); +#endif + + + if( refs != NULL ) { + send_ldap_result( conn, op, LDAP_REFERRAL, + e->e_dn, NULL, refs, NULL ); + + } else { + send_ldap_result( conn, op, LDAP_INVALID_CREDENTIALS, + NULL, NULL, NULL, NULL ); + } + + ber_bvarray_free( refs ); + + rc = 1; + goto return_results; + } + switch ( method ) { case LDAP_AUTH_SIMPLE: - if ( cred->bv_len == 0 ) { - send_ldap_result( conn, op, LDAP_SUCCESS, NULL, NULL ); - return( 1 ); - } else if ( be_isroot_pw( be, dn, cred ) ) { + /* check for root dn/passwd */ + if ( be_isroot_pw( be, conn, dn, cred ) ) { /* front end will send result */ - return( 0 ); + if(edn->bv_val != NULL) free( edn->bv_val ); + ber_dupbv( edn, be_root_dn( be ) ); + rc = 0; + goto return_results; } - if ( (a = attr_find( e->e_attrs, "userpassword" )) == NULL ) { - if ( be_isroot_pw( be, dn, cred ) ) { - /* front end will send result */ - return( 0 ); - } + if ( ! access_allowed( be, conn, op, e, + password, NULL, ACL_AUTH, NULL ) ) + { + send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS, + NULL, NULL, NULL, NULL ); + rc = 1; + goto return_results; + } + + if ( (a = attr_find( e->e_attrs, password )) == NULL ) { send_ldap_result( conn, op, LDAP_INAPPROPRIATE_AUTH, - NULL, NULL ); - cache_return_entry( &li->li_cache, e ); - return( 1 ); + NULL, NULL, NULL, NULL ); + + /* stop front end from sending result */ + rc = 1; + goto return_results; } - if ( value_find( a->a_vals, cred, a->a_syntax, 0 ) != 0 ) { - if ( be_isroot_pw( be, dn, cred ) ) { - /* front end will send result */ - return( 0 ); - } + if ( slap_passwd_check( conn, a, cred ) != 0 ) { send_ldap_result( conn, op, LDAP_INVALID_CREDENTIALS, - NULL, NULL ); - cache_return_entry( &li->li_cache, e ); - return( 1 ); + NULL, NULL, NULL, NULL ); + /* stop front end from sending result */ + rc = 1; + goto return_results; } + + rc = 0; break; -#ifdef KERBEROS +#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND case LDAP_AUTH_KRBV41: if ( krbv4_ldap_auth( be, cred, &ad ) != LDAP_SUCCESS ) { send_ldap_result( conn, op, LDAP_INVALID_CREDENTIALS, - NULL, NULL ); - cache_return_entry( &li->li_cache, e ); - return( 1 ); + NULL, NULL, NULL, NULL ); + rc = 1; + goto return_results; } + + if ( ! access_allowed( be, conn, op, e, + krbattr, NULL, ACL_AUTH, NULL ) ) + { + send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS, + NULL, NULL, NULL, NULL ); + rc = 1; + goto return_results; + } + sprintf( krbname, "%s%s%s@%s", ad.pname, *ad.pinst ? "." : "", ad.pinst, ad.prealm ); - if ( (a = attr_find( e->e_attrs, "krbname" )) == NULL ) { + + if ( (a = attr_find( e->e_attrs, krbattr )) == NULL ) { /* - * no krbName values present: check against DN + * no krbname values present: check against DN */ - if ( strcasecmp( dn, krbname ) == 0 ) { + if ( strcasecmp( dn->bv_val, krbname ) == 0 ) { + rc = 0; break; } send_ldap_result( conn, op, LDAP_INAPPROPRIATE_AUTH, - NULL, NULL ); - cache_return_entry( &li->li_cache, e ); - return( 1 ); - } else { /* look for krbName match */ + NULL, NULL, NULL, NULL ); + rc = 1; + goto return_results; + + } else { /* look for krbname match */ struct berval krbval; krbval.bv_val = krbname; krbval.bv_len = strlen( krbname ); - if ( value_find( a->a_vals, &krbval, a->a_syntax, 3 ) - != 0 ) { + if ( value_find( a->a_desc, a->a_vals, &krbval ) != 0 ) { send_ldap_result( conn, op, - LDAP_INVALID_CREDENTIALS, NULL, NULL ); - cache_return_entry( &li->li_cache, e ); - return( 1 ); + LDAP_INVALID_CREDENTIALS, + NULL, NULL, NULL, NULL ); + rc = 1; + goto return_results; } } + rc = 0; break; case LDAP_AUTH_KRBV42: - send_ldap_result( conn, op, LDAP_SUCCESS, NULL, NULL ); - cache_return_entry( &li->li_cache, e ); - return( 1 ); + send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, + NULL, "Kerberos bind step 2 not supported", + NULL, NULL ); + /* stop front end from sending result */ + rc = LDAP_UNWILLING_TO_PERFORM; + goto return_results; #endif default: send_ldap_result( conn, op, LDAP_STRONG_AUTH_NOT_SUPPORTED, - NULL, "auth method not supported" ); - cache_return_entry( &li->li_cache, e ); - return( 1 ); + NULL, "authentication method not supported", NULL, NULL ); + rc = 1; + goto return_results; } - cache_return_entry( &li->li_cache, e ); +return_results:; + /* free entry and reader lock */ + cache_return_entry_r( &li->li_cache, e ); + ldap_pvt_thread_rdwr_runlock(&li->li_giant_rwlock); - /* success: front end will send result */ - return( 0 ); + /* front end with send result on success (rc==0) */ + return( rc ); } + diff --git a/servers/slapd/back-ldbm/cache.c b/servers/slapd/back-ldbm/cache.c index 72ec35e9b72cb6ef6b74670f54e47ac8e924430f..4a26488a4e8bf3831a7ab06e4f6808fb1458f110 100644 --- a/servers/slapd/back-ldbm/cache.c +++ b/servers/slapd/back-ldbm/cache.c @@ -116,9 +116,9 @@ cache_return_entry_rw( Cache *cache, Entry *e, int rw ) ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1, + LDAP_LOG( CACHE, DETAIL1, "cache_return_entry_rw: return (%ld):%s, refcnt=%d\n", - id, rw ? "w" : "r", refcnt )); + id, rw ? "w" : "r", refcnt ); #else Debug( LDAP_DEBUG_TRACE, "====> cache_return_entry_%s( %ld ): created (%d)\n", @@ -131,9 +131,9 @@ cache_return_entry_rw( Cache *cache, Entry *e, int rw ) ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1, + LDAP_LOG( CACHE, DETAIL1, "cache_return_entry_rw: %ld, delete pending (%d).\n", - id, refcnt )); + id, refcnt, 0 ); #else Debug( LDAP_DEBUG_TRACE, "====> cache_return_entry_%s( %ld ): delete pending (%d)\n", @@ -150,9 +150,8 @@ cache_return_entry_rw( Cache *cache, Entry *e, int rw ) ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1, - "cache_return_entry_rw: (%ld): deleted (%d)\n", - id, refcnt )); + LDAP_LOG( CACHE, DETAIL1, + "cache_return_entry_rw: (%ld): deleted (%d)\n", id, refcnt, 0 ); #else Debug( LDAP_DEBUG_TRACE, "====> cache_return_entry_%s( %ld ): deleted (%d)\n", @@ -165,9 +164,9 @@ cache_return_entry_rw( Cache *cache, Entry *e, int rw ) ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1, + LDAP_LOG( CACHE, DETAIL1, "cache_return_entry_rw: ID %ld:%s returned (%d)\n", - id, rw ? "w": "r", refcnt )); + id, rw ? "w": "r", refcnt ); #else Debug( LDAP_DEBUG_TRACE, "====> cache_return_entry_%s( %ld ): returned (%d)\n", @@ -218,9 +217,9 @@ cache_add_entry_rw( Entry *ee; #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_ENTRY, + LDAP_LOG( CACHE, ENTRY, "cache_add_entry_rw: add (%s):%s to cache\n", - e->e_dn, rw ? "w" : "r" )); + e->e_dn, rw ? "w" : "r", 0 ); #endif /* set cache mutex */ ldap_pvt_thread_mutex_lock( &cache->c_mutex ); @@ -232,9 +231,9 @@ cache_add_entry_rw( ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_ERR, + LDAP_LOG( CACHE, ERR, "cache_add_entry_rw: add (%s):%ld private init failed!\n", - e->e_dn, e->e_id )); + e->e_dn, e->e_id, 0 ); #else Debug( LDAP_DEBUG_ANY, "====> cache_add_entry( %ld ): \"%s\": private init failed!\n", @@ -251,9 +250,9 @@ cache_add_entry_rw( ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1, - "cache_add_entry: (%s):%ld already in cache.\n", - e->e_dn, e->e_id )); + LDAP_LOG( CACHE, DETAIL1, + "cache_add_entry: (%s):%ld already in cache.\n", + e->e_dn, e->e_id, 0 ); #else Debug( LDAP_DEBUG_TRACE, "====> cache_add_entry( %ld ): \"%s\": already in dn cache\n", @@ -270,9 +269,9 @@ cache_add_entry_rw( (AVL_CMP) entry_id_cmp, avl_dup_error ) != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1, - "cache_add_entry: (%s):%ls already in cache.\n", - e->e_dn, e->e_id )); + LDAP_LOG( CACHE, DETAIL1, + "cache_add_entry: (%s):%ls already in cache.\n", + e->e_dn, e->e_id, 0 ); #else Debug( LDAP_DEBUG_ANY, "====> cache_add_entry( %ld ): \"%s\": already in id cache\n", @@ -284,9 +283,9 @@ cache_add_entry_rw( (AVL_CMP) entry_dn_cmp ) == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_INFO, - "cache_add_entry: can't delete (%s) from cache.\n", - e->e_dn )); + LDAP_LOG( CACHE, INFO, + "cache_add_entry: can't delete (%s) from cache.\n", + e->e_dn, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "====> can't delete from dn cache\n", 0, 0, 0 ); @@ -372,9 +371,9 @@ cache_update_entry( (AVL_CMP) entry_dn_cmp, avl_dup_error ) != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1, + LDAP_LOG( CACHE, DETAIL1, "cache_update_entry: (%s):%ld already in dn cache\n", - e->e_dn, e->e_id )); + e->e_dn, e->e_id, 0 ); #else Debug( LDAP_DEBUG_TRACE, "====> cache_update_entry( %ld ): \"%s\": already in dn cache\n", @@ -391,9 +390,9 @@ cache_update_entry( (AVL_CMP) entry_id_cmp, avl_dup_error ) != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1, + LDAP_LOG( CACHE, DETAIL1, "cache_update_entry: (%s)%ld already in id cache\n", - e->e_dn, e->e_id )); + e->e_dn, e->e_id, 0 ); #else Debug( LDAP_DEBUG_ANY, "====> cache_update_entry( %ld ): \"%s\": already in id cache\n", @@ -405,9 +404,9 @@ cache_update_entry( (AVL_CMP) entry_dn_cmp ) == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_INFO, - "cache_update_entry: can't delete (%s)%ld from dn cache.\n", - e->e_dn, e->e_id )); + LDAP_LOG( CACHE, INFO, + "cache_update_entry: can't delete (%s)%ld from dn cache.\n", + e->e_dn, e->e_id, 0 ); #else Debug( LDAP_DEBUG_ANY, "====> can't delete from dn cache\n", 0, 0, 0 ); @@ -511,9 +510,9 @@ try_again: ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_INFO, + LDAP_LOG( CACHE, INFO, "cache_find_entry_dn2id: (%s) %ld not ready: %d\n", - ndn->bv_val, id, state )); + ndn->bv_val, id, state ); #else Debug(LDAP_DEBUG_TRACE, "====> cache_find_entry_dn2id(\"%s\"): %ld (not ready) %d\n", @@ -532,9 +531,9 @@ try_again: ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1, + LDAP_LOG( CACHE, DETAIL1, "cache_find_entry_dn2id: (%s): %ld %d tries\n", - ndn->bv_val, id, count )); + ndn->bv_val, id, count ); #else Debug(LDAP_DEBUG_TRACE, "====> cache_find_entry_dn2id(\"%s\"): %ld (%d tries)\n", @@ -594,9 +593,9 @@ try_again: ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_INFO, + LDAP_LOG( CACHE, INFO, "cache_find_entry_id: (%ld)->%ld not ready (%d).\n", - id, ep_id, state )); + id, ep_id, state ); #else Debug(LDAP_DEBUG_TRACE, @@ -618,9 +617,9 @@ try_again: ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1, + LDAP_LOG( CACHE, DETAIL1, "cache_find_entry_id: %ld -> %s found %d tries.\n", - ep_id, ep->e_dn, count )); + ep_id, ep->e_dn, count ); #else Debug(LDAP_DEBUG_TRACE, "====> cache_find_entry_id( %ld ) \"%s\" (found) (%d tries)\n", @@ -661,8 +660,8 @@ cache_delete_entry( assert( e->e_private ); #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_ENTRY, - "cache_delete_entry: delete %ld.\n", e->e_id )); + LDAP_LOG( CACHE, ENTRY, + "cache_delete_entry: delete %ld.\n", e->e_id, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "====> cache_delete_entry( %ld )\n", e->e_id, 0, 0 ); @@ -723,8 +722,7 @@ cache_release_all( Cache *cache ) ldap_pvt_thread_mutex_lock( &cache->c_mutex ); #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_ENTRY, - "cache_release_all: enter\n" )); + LDAP_LOG( CACHE, ENTRY, "cache_release_all: enter\n" , 0, 0, 0); #else Debug( LDAP_DEBUG_TRACE, "====> cache_release_all\n", 0, 0, 0 ); #endif @@ -740,8 +738,8 @@ cache_release_all( Cache *cache ) if ( cache->c_cursize ) { #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_INFO, - "cache_release_all: Entry cache could not be emptied.\n" )); + LDAP_LOG( CACHE, INFO, + "cache_release_all: Entry cache could not be emptied.\n", 0, 0, 0); #else Debug( LDAP_DEBUG_TRACE, "Entry-cache could not be emptied\n", 0, 0, 0 ); #endif diff --git a/servers/slapd/back-ldbm/close.c b/servers/slapd/back-ldbm/close.c index d6758e143bf2113ef2d35b297eef002bad38332b..383817a5d9baf36b9c4f7cb4ba5699c069b00191 100644 --- a/servers/slapd/back-ldbm/close.c +++ b/servers/slapd/back-ldbm/close.c @@ -1,14 +1,45 @@ /* close.c - close ldbm backend */ +/* $OpenLDAP$ */ +/* + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ + +#include "portable.h" #include <stdio.h> -#include <sys/types.h> -#include <sys/socket.h> + +#include <ac/socket.h> + #include "slap.h" #include "back-ldbm.h" -ldbm_back_close( Backend *be ) +int +ldbm_back_db_close( Backend *be ) { + struct ldbminfo *li = (struct ldbminfo *) be->be_private; + if ( li->li_dbsyncfreq > 0 ) + { + li->li_dbshutdown++; + ldap_pvt_thread_join( li->li_dbsynctid, (void *) NULL ); + } +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, CRIT, + "ldbm_back_db_close: ldbm backend syncing\n", 0, 0, 0 ); +#else Debug( LDAP_DEBUG_TRACE, "ldbm backend syncing\n", 0, 0, 0 ); +#endif + ldbm_cache_flush_all( be ); +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, CRIT, + "ldbm_back_db_close: ldbm backend synch'ed\n", 0, 0, 0 ); +#else Debug( LDAP_DEBUG_TRACE, "ldbm backend done syncing\n", 0, 0, 0 ); +#endif + + + cache_release_all( &((struct ldbminfo *) be->be_private)->li_cache ); + + return 0; } diff --git a/servers/slapd/back-ldbm/compare.c b/servers/slapd/back-ldbm/compare.c index 4757a29b9228684dbfb6e834b74ed8fa0c66e857..b96dbd0163e45c2fa4061faa470396bb8bd5f76b 100644 --- a/servers/slapd/back-ldbm/compare.c +++ b/servers/slapd/back-ldbm/compare.c @@ -1,55 +1,124 @@ /* compare.c - ldbm backend compare routine */ +/* $OpenLDAP$ */ +/* + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ + +#include "portable.h" #include <stdio.h> -#include <string.h> -#include <sys/types.h> -#include <sys/socket.h> + +#include <ac/socket.h> +#include <ac/string.h> + #include "slap.h" #include "back-ldbm.h" - -extern Entry *dn2entry(); -extern Attribute *attr_find(); +#include "proto-back-ldbm.h" int ldbm_back_compare( Backend *be, Connection *conn, Operation *op, - char *dn, - Ava *ava + struct berval *dn, + struct berval *ndn, + AttributeAssertion *ava ) { struct ldbminfo *li = (struct ldbminfo *) be->be_private; - char *matched; + Entry *matched; Entry *e; Attribute *a; - int i; + int rc; + int manageDSAit = get_manageDSAit( op ); + + /* grab giant lock for reading */ + ldap_pvt_thread_rdwr_rlock(&li->li_giant_rwlock); + + /* get entry with reader lock */ + if ( (e = dn2entry_r( be, ndn, &matched )) == NULL ) { + char *matched_dn = NULL; + BerVarray refs = NULL; + + if ( matched != NULL ) { + matched_dn = ch_strdup( matched->e_dn ); + refs = is_entry_referral( matched ) + ? get_entry_referrals( be, conn, op, matched ) + : NULL; + cache_return_entry_r( &li->li_cache, matched ); + } else { + refs = referral_rewrite( default_referral, + NULL, dn, LDAP_SCOPE_DEFAULT ); + } + + ldap_pvt_thread_rdwr_runlock(&li->li_giant_rwlock); + + send_ldap_result( conn, op, LDAP_REFERRAL, + matched_dn, NULL, refs, NULL ); + + if ( refs ) ber_bvarray_free( refs ); + free( matched_dn ); - if ( (e = dn2entry( be, dn, &matched )) == NULL ) { - send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT, matched, "" ); return( 1 ); } - if ( ! access_allowed( be, conn, op, e, ava->ava_type, &ava->ava_value, - op->o_dn, ACL_COMPARE ) ) { - send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS, "", "" ); - cache_return_entry( &li->li_cache, e ); - return( 1 ); + if (!manageDSAit && is_entry_referral( e ) ) { + /* entry is a referral, don't allow add */ + BerVarray refs = get_entry_referrals( be, + conn, op, e ); + +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, INFO, + "ldbm_back_compare: entry (%s) is a referral.\n", e->e_dn, 0, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0, + 0, 0 ); +#endif + + + send_ldap_result( conn, op, LDAP_REFERRAL, + e->e_dn, NULL, refs, NULL ); + + if (refs ) ber_bvarray_free( refs ); + + rc = 1; + goto return_results; } - if ( (a = attr_find( e->e_attrs, ava->ava_type )) == NULL ) { - send_ldap_result( conn, op, LDAP_NO_SUCH_ATTRIBUTE, "", "" ); - cache_return_entry( &li->li_cache, e ); - return( 1 ); + if ( ! access_allowed( be, conn, op, e, + ava->aa_desc, &ava->aa_value, ACL_COMPARE, NULL ) ) + { + send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS, + NULL, NULL, NULL, NULL ); + rc = 1; + goto return_results; } - if ( value_find( a->a_vals, &ava->ava_value, a->a_syntax, 1 ) == 0 ) { - send_ldap_result( conn, op, LDAP_COMPARE_TRUE, "", "" ); - cache_return_entry( &li->li_cache, e ); - return( 0 ); + rc = LDAP_NO_SUCH_ATTRIBUTE; + + for(a = attrs_find( e->e_attrs, ava->aa_desc ); + a != NULL; + a = attrs_find( a->a_next, ava->aa_desc )) + { + rc = LDAP_COMPARE_FALSE; + + if ( value_find( ava->aa_desc, a->a_vals, &ava->aa_value ) == 0 ) { + rc = LDAP_COMPARE_TRUE; + break; + } } - send_ldap_result( conn, op, LDAP_COMPARE_FALSE, "", "" ); - cache_return_entry( &li->li_cache, e ); - return( 0 ); + send_ldap_result( conn, op, rc, + NULL, NULL, NULL, NULL ); + + if( rc != LDAP_NO_SUCH_ATTRIBUTE ) { + rc = 0; + } + + +return_results:; + cache_return_entry_r( &li->li_cache, e ); + ldap_pvt_thread_rdwr_runlock(&li->li_giant_rwlock); + return( rc ); } diff --git a/servers/slapd/back-ldbm/config.c b/servers/slapd/back-ldbm/config.c index 2cb64aa675aa263749c569475003c23ccc26427c..527f3c4c43874ae1425a8a00e692f0901cb7b538 100644 --- a/servers/slapd/back-ldbm/config.c +++ b/servers/slapd/back-ldbm/config.c @@ -107,9 +107,9 @@ ldbm_back_db_config( int i; if ( argc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "config", LDAP_LEVEL_ERR, "ldbm_back_db_config: %s: " + LDAP_LOG ( CONFIG, ERR, "ldbm_back_db_config: %s: " "line %d: missing frequency value in \"dbsync <frequency> " - "[<wait-times> [wait-interval]]\" line\n", fname, lineno )); + "[<wait-times> [wait-interval]]\" line\n", fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing frquency value in \"dbsync <frequency> [<wait-times> [wait-interval]]\" line\n", @@ -122,10 +122,11 @@ ldbm_back_db_config( if( i < 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "config", LDAP_LEVEL_ERR, "ldbm_back_db_config: %s: " + LDAP_LOG ( CONFIG, ERR, + "ldbm_back_db_config: %s: " "line %d: frequency value (%d) invalid \"dbsync " "<frequency> [<wait-times> [wait-interval]]\" line\n", - fname, lineno, i )); + fname, lineno, i ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: frquency value (%d) invalid \"dbsync <frequency> [<wait-times> [wait-interval]]\" line\n", @@ -140,10 +141,10 @@ ldbm_back_db_config( i = atoi( argv[2] ); if ( i < 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "config",LDAP_LEVEL_ERR, "ldbm_back_db_config: %s: " + LDAP_LOG ( CONFIG,ERR, "ldbm_back_db_config: %s: " "line %d: frequency value (%d) invalid \"dbsync " "<frequency> [<wait-times> [wait-interval]]\" line\n", - fname, lineno, i )); + fname, lineno, i ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: frquency value (%d) invalid \"dbsync <frequency> [<wait-times> [wait-interval]]\" line\n", @@ -158,10 +159,10 @@ ldbm_back_db_config( i = atoi( argv[3] ); if ( i <= 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "config",LDAP_LEVEL_ERR, "ldbm_back_db_config: %s: " + LDAP_LOG ( CONFIG,ERR, "ldbm_back_db_config: %s: " "line %d: frequency value (%d) invalid \"dbsync " "<frequency> [<wait-times> [wait-interval]]\" line\n", - fname, lineno, i )); + fname, lineno, i ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: frquency value (%d) invalid \"dbsync <frequency> [<wait-times> [wait-interval]]\" line\n", @@ -177,8 +178,8 @@ ldbm_back_db_config( #else #ifdef NEW_LOGGING - LDAP_LOG (( "config", LDAP_LEVEL_ERR, "ldbm_back_db_config: \"dbsync\"" - " policies not supported in non-threaded environments\n" )); + LDAP_LOG ( CONFIG, ERR, "ldbm_back_db_config: \"dbsync\"" + " policies not supported in non-threaded environments\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "\"dbsync\" policies not supported in non-threaded environments\n", 0, 0, 0); diff --git a/servers/slapd/back-ldbm/dbcache.c b/servers/slapd/back-ldbm/dbcache.c index 1cf5bf9bd129513fa49c448866285521dda9d8c9..b9407f4d1a8461ea9e3e1c26c4ef1dce26bf596e 100644 --- a/servers/slapd/back-ldbm/dbcache.c +++ b/servers/slapd/back-ldbm/dbcache.c @@ -54,8 +54,8 @@ ldbm_cache_open( } #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_ENTRY, - "ldbm_cache_open: \"%s\", %d, %o\n", buf, flags, li->li_mode )); + LDAP_LOG( CACHE, ENTRY, + "ldbm_cache_open: \"%s\", %d, %o\n", buf, flags, li->li_mode ); #else Debug( LDAP_DEBUG_TRACE, "=> ldbm_cache_open( \"%s\", %d, %o )\n", buf, flags, li->li_mode ); @@ -101,8 +101,8 @@ ldbm_cache_open( } li->li_dbcache[i].dbc_refcnt++; #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1, - "ldbm_cache_open: cache %d\n", i )); + LDAP_LOG( CACHE, DETAIL1, + "ldbm_cache_open: cache %d\n", i, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= ldbm_cache_open (cache %d)\n", i, 0, 0 ); @@ -132,8 +132,9 @@ ldbm_cache_open( li->li_dbcache[i].dbc_name = NULL; } else { #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_INFO, - "ldbm_cache_open: no unused db to close - waiting\n" )); + LDAP_LOG( CACHE, INFO, + "ldbm_cache_open: no unused db to close - waiting\n", + 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "ldbm_cache_open no unused db to close - waiting\n", @@ -155,10 +156,10 @@ ldbm_cache_open( { int err = errno; #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_ERR, - "ldbm_cache_open: \"%s\" failed, errono=%d, reason=%s\n", - buf, err, err > -1 && err < sys_nerr ? sys_errlist[err] : - "unknown" )); + LDAP_LOG( CACHE, ERR, + "ldbm_cache_open: \"%s\" failed, errono=%d, reason=%s\n", + buf, err, err > -1 && err < sys_nerr ? sys_errlist[err] : + "unknown" ); #else Debug( LDAP_DEBUG_TRACE, "<= ldbm_cache_open NULL \"%s\" errno=%d reason=\"%s\")\n", @@ -190,10 +191,10 @@ ldbm_cache_open( assert( li->li_dbcache[i].dbc_maxindirect < 256 ); #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_ARGS, + LDAP_LOG( CACHE, ARGS, "ldbm_cache_open: blksize:%ld maxids:%d maxindirect:%d\n", li->li_dbcache[i].dbc_blksize, li->li_dbcache[i].dbc_maxids, - li->li_dbcache[i].dbc_maxindirect )); + li->li_dbcache[i].dbc_maxindirect ); #else Debug( LDAP_DEBUG_ARGS, "ldbm_cache_open (blksize %ld) (maxids %d) (maxindirect %d)\n", @@ -202,8 +203,7 @@ ldbm_cache_open( #endif #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1, - "<= ldbm_cache_open: (opened %d)\n", i )); + LDAP_LOG( CACHE, DETAIL1, "<= ldbm_cache_open: (opened %d)\n", i, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= ldbm_cache_open (opened %d)\n", i, 0, 0 ); #endif @@ -259,9 +259,9 @@ ldbm_cache_flush_all( Backend *be ) for ( i = 0; i < MAXDBCACHE; i++ ) { if ( li->li_dbcache[i].dbc_name != NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1, + LDAP_LOG( CACHE, DETAIL1, "ldbm_cache_flush_all: flushing db (%s)\n", - li->li_dbcache[i].dbc_name )); + li->li_dbcache[i].dbc_name, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldbm flushing db (%s)\n", li->li_dbcache[i].dbc_name, 0, 0 ); @@ -271,9 +271,9 @@ ldbm_cache_flush_all( Backend *be ) li->li_dbcache[i].dbc_dirty = 0; if ( li->li_dbcache[i].dbc_refcnt != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_INFO, - "ldbm_cache_flush_all: couldn't close db (%s), refcnt=%d\n", - li->li_dbcache[i].dbc_name, li->li_dbcache[i].dbc_refcnt )); + LDAP_LOG( CACHE, INFO, + "ldbm_cache_flush_all: couldn't close db (%s), refcnt=%d\n", + li->li_dbcache[i].dbc_name, li->li_dbcache[i].dbc_refcnt,0); #else Debug( LDAP_DEBUG_TRACE, "refcnt = %d, couldn't close db (%s)\n", @@ -283,9 +283,9 @@ ldbm_cache_flush_all( Backend *be ) } else { #ifdef NEW_LOGGING - LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1, + LDAP_LOG( CACHE, DETAIL1, "ldbm_cache_flush_all: ldbm closing db (%s)\n", - li->li_dbcache[i].dbc_name )); + li->li_dbcache[i].dbc_name, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldbm closing db (%s)\n", @@ -312,8 +312,8 @@ ldbm_cache_sync( Backend *be ) for ( i = 0; i < MAXDBCACHE; i++ ) { if ( li->li_dbcache[i].dbc_name != NULL && li->li_dbcache[i].dbc_dirty ) { #ifdef NEW_LOGGING - LDAP_LOG (( "dbcache", LDAP_LEVEL_DETAIL1, "ldbm_cache_sync: " - "ldbm syncing db (%s)\n", li->li_dbcache[i].dbc_name )); + LDAP_LOG ( CACHE, DETAIL1, "ldbm_cache_sync: " + "ldbm syncing db (%s)\n", li->li_dbcache[i].dbc_name, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldbm syncing db (%s)\n", li->li_dbcache[i].dbc_name, 0, 0 ); @@ -391,8 +391,8 @@ ldbm_cache_sync_daemon( struct ldbminfo *li = (struct ldbminfo *) be->be_private; #ifdef NEW_LOGGING - LDAP_LOG (( "dbcache", LDAP_LEVEL_ARGS, "ldbm_cache_sync_daemon:" - " synchronizer starting for %s\n", li->li_directory )); + LDAP_LOG ( CACHE, ARGS, "ldbm_cache_sync_daemon:" + " synchronizer starting for %s\n", li->li_directory, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "synchronizer starting for %s\n", li->li_directory, 0, 0 ); #endif @@ -404,8 +404,8 @@ ldbm_cache_sync_daemon( while (i && ldap_pvt_thread_pool_backload(&connection_pool) != 0) { #ifdef NEW_LOGGING - LDAP_LOG (( "dbcache", LDAP_LEVEL_DETAIL1, "ldbm_cache_sync_daemon:" - " delay syncing %s\n", li->li_directory )); + LDAP_LOG ( CACHE, DETAIL1, "ldbm_cache_sync_daemon:" + " delay syncing %s\n", li->li_directory, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "delay syncing %s\n", li->li_directory, 0, 0 ); #endif @@ -415,8 +415,8 @@ ldbm_cache_sync_daemon( if (!li->li_dbshutdown) { #ifdef NEW_LOGGING - LDAP_LOG (( "dbcache", LDAP_LEVEL_DETAIL1, "ldbm_cache_sync_daemon:" - " syncing %s\n", li->li_directory )); + LDAP_LOG ( CACHE, DETAIL1, "ldbm_cache_sync_daemon:" + " syncing %s\n", li->li_directory, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "syncing %s\n", li->li_directory, 0, 0 ); #endif @@ -425,8 +425,8 @@ ldbm_cache_sync_daemon( } #ifdef NEW_LOGGING - LDAP_LOG (( "dbcache", LDAP_LEVEL_DETAIL1, "ldbm_cache_sync_daemon:" - " synchronizer stopping\n" )); + LDAP_LOG ( CACHE, DETAIL1, "ldbm_cache_sync_daemon:" + " synchronizer stopping\n", 0, 0, 0); #else Debug( LDAP_DEBUG_ANY, "synchronizer stopping\n", 0, 0, 0 ); #endif diff --git a/servers/slapd/back-ldbm/delete.c b/servers/slapd/back-ldbm/delete.c index c773929ffb43a64eb73ba3e3b7c28124a5655b08..d33e957f678f6dd3d1457399c586200fe8060e6a 100644 --- a/servers/slapd/back-ldbm/delete.c +++ b/servers/slapd/back-ldbm/delete.c @@ -1,67 +1,254 @@ /* delete.c - ldbm backend delete routine */ +/* $OpenLDAP$ */ +/* + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ + +#include "portable.h" #include <stdio.h> -#include <string.h> -#include <sys/types.h> -#include <sys/socket.h> + +#include <ac/string.h> +#include <ac/socket.h> + #include "slap.h" #include "back-ldbm.h" - -extern Entry *dn2entry(); -extern Attribute *attr_find(); +#include "proto-back-ldbm.h" int ldbm_back_delete( Backend *be, Connection *conn, Operation *op, - char *dn + struct berval *dn, + struct berval *ndn ) { struct ldbminfo *li = (struct ldbminfo *) be->be_private; - char *matched = NULL; - Entry *e; + Entry *matched; + struct berval pdn; + Entry *e, *p = NULL; + int rc = -1; + int manageDSAit = get_manageDSAit( op ); + AttributeDescription *children = slap_schema.si_ad_children; + +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ENTRY, "ldbm_back_delete: %s\n", dn->bv_val, 0, 0 ); +#else + Debug(LDAP_DEBUG_ARGS, "==> ldbm_back_delete: %s\n", dn->bv_val, 0, 0); +#endif + + /* grab giant lock for writing */ + ldap_pvt_thread_rdwr_wlock(&li->li_giant_rwlock); + + /* get entry with writer lock */ + if ( (e = dn2entry_w( be, ndn, &matched )) == NULL ) { + char *matched_dn = NULL; + BerVarray refs; + +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, INFO, + "ldbm_back_delete: no such object %s\n", dn->bv_val, 0, 0 ); +#else + Debug(LDAP_DEBUG_ARGS, "<=- ldbm_back_delete: no such object %s\n", + dn->bv_val, 0, 0); +#endif - if ( (e = dn2entry( be, dn, &matched )) == NULL ) { - send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT, matched, "" ); if ( matched != NULL ) { - free( matched ); + matched_dn = ch_strdup( matched->e_dn ); + refs = is_entry_referral( matched ) + ? get_entry_referrals( be, conn, op, matched ) + : NULL; + cache_return_entry_r( &li->li_cache, matched ); + + } else { + refs = referral_rewrite( default_referral, + NULL, dn, LDAP_SCOPE_DEFAULT ); } + + ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock); + + send_ldap_result( conn, op, LDAP_REFERRAL, + matched_dn, NULL, refs, NULL ); + + if ( refs ) ber_bvarray_free( refs ); + free( matched_dn ); + return( -1 ); } - if ( has_children( be, e ) ) { - send_ldap_result( conn, op, LDAP_NOT_ALLOWED_ON_NONLEAF, "", - "" ); - cache_return_entry( &li->li_cache, e ); - return( -1 ); + if ( !manageDSAit && is_entry_referral( e ) ) { + /* parent is a referral, don't allow add */ + /* parent is an alias, don't allow add */ + BerVarray refs = get_entry_referrals( be, + conn, op, e ); + +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, INFO, + "ldbm_back_delete: entry (%s) is a referral.\n", e->e_dn, 0, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0, + 0, 0 ); +#endif + + send_ldap_result( conn, op, LDAP_REFERRAL, + e->e_dn, NULL, refs, NULL ); + + if ( refs ) ber_bvarray_free( refs ); + + rc = 1; + goto return_results; } - if ( ! access_allowed( be, conn, op, e, "entry", NULL, op->o_dn, - ACL_WRITE ) ) { - send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS, "", "" ); - cache_return_entry( &li->li_cache, e ); - return( -1 ); + + if ( has_children( be, e ) ) { +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ERR, + "ldbm_back_delete: (%s) is a non-leaf node.\n", dn->bv_val, 0,0); +#else + Debug(LDAP_DEBUG_ARGS, "<=- ldbm_back_delete: non leaf %s\n", + dn->bv_val, 0, 0); +#endif + + send_ldap_result( conn, op, LDAP_NOT_ALLOWED_ON_NONLEAF, + NULL, "subtree delete not supported", NULL, NULL ); + goto return_results; } - /* XXX delete from parent's id2children entry XXX */ + /* delete from parent's id2children entry */ + if( !be_issuffix( be, &e->e_nname ) && (dnParent( &e->e_nname, &pdn ), + pdn.bv_len) ) { + if( (p = dn2entry_w( be, &pdn, NULL )) == NULL) { +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ERR, + "ldbm_back_delete: parent of (%s) does not exist\n", dn, 0, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, + "<=- ldbm_back_delete: parent does not exist\n", + 0, 0, 0); +#endif + + send_ldap_result( conn, op, LDAP_OTHER, + NULL, "could not locate parent of entry", NULL, NULL ); + goto return_results; + } + + /* check parent for "children" acl */ + if ( ! access_allowed( be, conn, op, p, + children, NULL, ACL_WRITE, NULL ) ) + { +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ERR, + "ldbm_back_delete: no access to parent of (%s)\n", + dn->bv_val, 0, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, + "<=- ldbm_back_delete: no access to parent\n", 0, + 0, 0 ); +#endif + + send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS, + NULL, NULL, NULL, NULL ); + goto return_results; + } + + } else { + /* no parent, must be root to delete */ + if( ! be_isroot( be, &op->o_ndn ) ) { + if ( be_issuffix( be, (struct berval *)&slap_empty_bv ) || be_isupdate( be, &op->o_ndn ) ) { + p = (Entry *)&slap_entry_root; + + rc = access_allowed( be, conn, op, p, + children, NULL, ACL_WRITE, NULL ); + p = NULL; + + /* check parent for "children" acl */ + if ( ! rc ) { +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ERR, + "ldbm_back_delete: no access " + "to parent of ("")\n", 0, 0, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, + "<=- ldbm_back_delete: no " + "access to parent\n", 0, 0, 0 ); +#endif + + send_ldap_result( conn, op, + LDAP_INSUFFICIENT_ACCESS, + NULL, NULL, NULL, NULL ); + goto return_results; + } + + } else { +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ERR, + "ldbm_back_delete: (%s) has no " + "parent & not a root.\n", dn, 0, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, + "<=- ldbm_back_delete: no parent & " + "not root\n", 0, 0, 0); +#endif + + send_ldap_result( conn, op, + LDAP_INSUFFICIENT_ACCESS, + NULL, NULL, NULL, NULL ); + goto return_results; + } + } + } /* delete from dn2id mapping */ - if ( dn2id_delete( be, e->e_dn ) != 0 ) { - send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" ); - cache_return_entry( &li->li_cache, e ); - return( -1 ); + if ( dn2id_delete( be, &e->e_nname, e->e_id ) != 0 ) { +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ERR, + "ldbm_back_delete: (%s) operations error\n", dn->bv_val, 0, 0 ); +#else + Debug(LDAP_DEBUG_ARGS, + "<=- ldbm_back_delete: operations error %s\n", + dn->bv_val, 0, 0); +#endif + + send_ldap_result( conn, op, LDAP_OTHER, + NULL, "DN index delete failed", NULL, NULL ); + goto return_results; } /* delete from disk and cache */ if ( id2entry_delete( be, e ) != 0 ) { - send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" ); - cache_return_entry( &li->li_cache, e ); - return( -1 ); +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ERR, + "ldbm_back_delete: (%s) operations error\n", dn->bv_val, 0, 0 ); +#else + Debug(LDAP_DEBUG_ARGS, + "<=- ldbm_back_delete: operations error %s\n", + dn->bv_val, 0, 0); +#endif + + send_ldap_result( conn, op, LDAP_OTHER, + NULL, "entry delete failed", NULL, NULL ); + goto return_results; } - cache_return_entry( &li->li_cache, e ); - send_ldap_result( conn, op, LDAP_SUCCESS, "", "" ); + /* delete attribute indices */ + (void) index_entry_del( be, e, e->e_attrs ); + + send_ldap_result( conn, op, LDAP_SUCCESS, + NULL, NULL, NULL, NULL ); + rc = 0; + +return_results:; + if( p != NULL ) { + /* free parent and writer lock */ + cache_return_entry_w( &li->li_cache, p ); + } + + /* free entry and writer lock */ + cache_return_entry_w( &li->li_cache, e ); + + ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock); - return( 0 ); + return rc; } diff --git a/servers/slapd/back-ldbm/dn2id.c b/servers/slapd/back-ldbm/dn2id.c index c4116086b00d5aab3d143a14f045956a3737c51d..757d4b0f7170158f9ec78c8c7769dfa510b42666 100644 --- a/servers/slapd/back-ldbm/dn2id.c +++ b/servers/slapd/back-ldbm/dn2id.c @@ -1,142 +1,345 @@ /* dn2id.c - routines to deal with the dn2id index */ +/* $OpenLDAP$ */ +/* + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ + +#include "portable.h" #include <stdio.h> -#include <string.h> -#include <sys/types.h> -#include <sys/socket.h> + +#include <ac/string.h> +#include <ac/socket.h> + #include "slap.h" #include "back-ldbm.h" - -extern struct dbcache *ldbm_cache_open(); -extern Entry *cache_find_entry_dn(); -extern Entry *id2entry(); -extern char *dn_parent(); -extern Datum ldbm_cache_fetch(); +#include "proto-back-ldbm.h" int dn2id_add( Backend *be, - char *dn, + struct berval *dn, ID id ) { - int rc; - struct dbcache *db; + int rc, flags; + DBCache *db; Datum key, data; + char *buf; + struct berval ptr, pdn; - Debug( LDAP_DEBUG_TRACE, "=> dn2id_add( \"%s\", %ld )\n", dn, id, 0 ); +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ENTRY, "dn2id_add: (%s):%ld\n", dn->bv_val, id, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, "=> dn2id_add( \"%s\", %ld )\n", dn->bv_val, id, 0 ); +#endif + + assert( id != NOID ); if ( (db = ldbm_cache_open( be, "dn2id", LDBM_SUFFIX, LDBM_WRCREAT )) == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ERR, + "dn2id_add: couldn't open/create dn2id%s\n", LDBM_SUFFIX, 0, 0 ); +#else Debug( LDAP_DEBUG_ANY, "Could not open/create dn2id%s\n", LDBM_SUFFIX, 0, 0 ); +#endif + return( -1 ); } - dn = strdup( dn ); - dn_normalize_case( dn ); + ldbm_datum_init( key ); + key.dsize = dn->bv_len + 2; + buf = ch_malloc( key.dsize ); + key.dptr = buf; + buf[0] = DN_BASE_PREFIX; + ptr.bv_val = buf + 1; + ptr.bv_len = dn->bv_len; + strcpy( ptr.bv_val, dn->bv_val ); - key.dptr = dn; - key.dsize = strlen( dn ) + 1; + ldbm_datum_init( data ); data.dptr = (char *) &id; data.dsize = sizeof(ID); - rc = ldbm_cache_store( db, key, data, LDBM_INSERT ); + flags = LDBM_INSERT; + rc = ldbm_cache_store( db, key, data, flags ); + + if ( rc != -1 && !be_issuffix( be, &ptr )) { + buf[0] = DN_SUBTREE_PREFIX; + ldap_pvt_thread_mutex_lock( &db->dbc_write_mutex ); + rc = idl_insert_key( be, db, key, id ); + ldap_pvt_thread_mutex_unlock( &db->dbc_write_mutex ); + + if ( rc != -1 ) { + dnParent( &ptr, &pdn ); + + pdn.bv_val[-1] = DN_ONE_PREFIX; + key.dsize = pdn.bv_len + 2; + key.dptr = pdn.bv_val - 1; + ptr = pdn; + ldap_pvt_thread_mutex_lock( &db->dbc_write_mutex ); + rc = idl_insert_key( be, db, key, id ); + ldap_pvt_thread_mutex_unlock( &db->dbc_write_mutex ); + } + } + + while ( rc != -1 && !be_issuffix( be, &ptr )) { + ptr.bv_val[-1] = DN_SUBTREE_PREFIX; + + ldap_pvt_thread_mutex_lock( &db->dbc_write_mutex ); + rc = idl_insert_key( be, db, key, id ); + ldap_pvt_thread_mutex_unlock( &db->dbc_write_mutex ); - free( dn ); + if( rc != 0 ) break; + dnParent( &ptr, &pdn ); + key.dsize = pdn.bv_len + 2; + key.dptr = pdn.bv_val - 1; + ptr = pdn; + } + + free( buf ); ldbm_cache_close( be, db ); +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ENTRY, "dn2id_add: return %d\n", rc, 0, 0 ); +#else Debug( LDAP_DEBUG_TRACE, "<= dn2id_add %d\n", rc, 0, 0 ); +#endif + return( rc ); } -ID +int dn2id( Backend *be, - char *dn + struct berval *dn, + ID *idp ) { struct ldbminfo *li = (struct ldbminfo *) be->be_private; - struct dbcache *db; - Entry *e; - ID id; + DBCache *db; Datum key, data; - Debug( LDAP_DEBUG_TRACE, "=> dn2id( \"%s\" )\n", dn, 0, 0 ); +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ENTRY, "dn2id: (%s)\n", dn->bv_val, 0, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, "=> dn2id( \"%s\" )\n", dn->bv_val, 0, 0 ); +#endif - dn = strdup( dn ); - dn_normalize_case( dn ); + assert( idp ); /* first check the cache */ - if ( (e = cache_find_entry_dn( &li->li_cache, dn )) != NULL ) { - id = e->e_id; - free( dn ); - Debug( LDAP_DEBUG_TRACE, "<= dn2id %d (in cache)\n", e->e_id, - 0, 0 ); - cache_return_entry( &li->li_cache, e ); - - return( id ); + if ( (*idp = cache_find_entry_ndn2id( be, &li->li_cache, dn )) != NOID ) { +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, DETAIL1, "dn2id: (%s)%ld in cache.\n", dn, *idp, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, "<= dn2id %ld (in cache)\n", *idp, + 0, 0 ); +#endif + + return( 0 ); } if ( (db = ldbm_cache_open( be, "dn2id", LDBM_SUFFIX, LDBM_WRCREAT )) - == NULL ) { - free( dn ); + == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ERR, + "dn2id: couldn't open dn2id%s\n", LDBM_SUFFIX, 0, 0 ); +#else Debug( LDAP_DEBUG_ANY, "<= dn2id could not open dn2id%s\n", - LDBM_SUFFIX, 0, 0 ); - return( NOID ); + LDBM_SUFFIX, 0, 0 ); +#endif + /* + * return code !0 if ldbm cache open failed; + * callers should handle this + */ + *idp = NOID; + return( -1 ); } - key.dptr = dn; - key.dsize = strlen( dn ) + 1; + ldbm_datum_init( key ); + + key.dsize = dn->bv_len + 2; + key.dptr = ch_malloc( key.dsize ); + sprintf( key.dptr, "%c%s", DN_BASE_PREFIX, dn->bv_val ); data = ldbm_cache_fetch( db, key ); ldbm_cache_close( be, db ); - free( dn ); + + free( key.dptr ); if ( data.dptr == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, INFO, "dn2id: (%s) NOID\n", dn, 0, 0 ); +#else Debug( LDAP_DEBUG_TRACE, "<= dn2id NOID\n", 0, 0, 0 ); - return( NOID ); +#endif + + *idp = NOID; + return( 0 ); } - (void) memcpy( (char *) &id, data.dptr, sizeof(ID) ); + AC_MEMCPY( (char *) idp, data.dptr, sizeof(ID) ); + + assert( *idp != NOID ); ldbm_datum_free( db->dbc_db, data ); - Debug( LDAP_DEBUG_TRACE, "<= dn2id %d\n", id, 0, 0 ); - return( id ); +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ENTRY, "dn2id: %ld\n", *idp, 0, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, "<= dn2id %ld\n", *idp, 0, 0 ); +#endif + + return( 0 ); +} + +int +dn2idl( + Backend *be, + struct berval *dn, + int prefix, + ID_BLOCK **idlp +) +{ + DBCache *db; + Datum key; + +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ENTRY, "dn2idl: \"%c%s\"\n", prefix, dn->bv_val, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, "=> dn2idl( \"%c%s\" )\n", prefix, dn->bv_val, 0 ); +#endif + + assert( idlp != NULL ); + *idlp = NULL; + + if ( prefix == DN_SUBTREE_PREFIX && be_issuffix(be, dn) ) { + *idlp = idl_allids( be ); + return 0; + } + + if ( (db = ldbm_cache_open( be, "dn2id", LDBM_SUFFIX, LDBM_WRCREAT )) + == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ERR, + "dn2idl: could not open dn2id%s\n", LDBM_SUFFIX, 0, 0 ); +#else + Debug( LDAP_DEBUG_ANY, "<= dn2idl could not open dn2id%s\n", + LDBM_SUFFIX, 0, 0 ); +#endif + + return -1; + } + + ldbm_datum_init( key ); + + key.dsize = dn->bv_len + 2; + key.dptr = ch_malloc( key.dsize ); + sprintf( key.dptr, "%c%s", prefix, dn->bv_val ); + + *idlp = idl_fetch( be, db, key ); + + ldbm_cache_close( be, db ); + + free( key.dptr ); + + return( 0 ); } + int dn2id_delete( Backend *be, - char *dn + struct berval *dn, + ID id ) { - struct ldbminfo *li = (struct ldbminfo *) be->be_private; - struct dbcache *db; + DBCache *db; Datum key; int rc; + char *buf; + struct berval ptr, pdn; - Debug( LDAP_DEBUG_TRACE, "=> dn2id_delete( \"%s\" )\n", dn, 0, 0 ); +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ENTRY, + "dn2id_delete: (%s)%ld\n", dn->bv_val, id, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, "=> dn2id_delete( \"%s\", %ld )\n", dn->bv_val, id, 0 ); +#endif + + + assert( id != NOID ); if ( (db = ldbm_cache_open( be, "dn2id", LDBM_SUFFIX, LDBM_WRCREAT )) == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ERR, + "dn2id_delete: couldn't open db2id%s\n", LDBM_SUFFIX, 0, 0 ); +#else Debug( LDAP_DEBUG_ANY, "<= dn2id_delete could not open dn2id%s\n", LDBM_SUFFIX, 0, 0 ); +#endif + return( -1 ); } - dn_normalize_case( dn ); - key.dptr = dn; - key.dsize = strlen( dn ) + 1; + ldbm_datum_init( key ); + key.dsize = dn->bv_len + 2; + buf = ch_malloc( key.dsize ); + key.dptr = buf; + buf[0] = DN_BASE_PREFIX; + ptr.bv_val = buf + 1; + ptr.bv_len = dn->bv_len; + strcpy( ptr.bv_val, dn->bv_val ); rc = ldbm_cache_delete( db, key ); + + if( !be_issuffix( be, &ptr )) { + buf[0] = DN_SUBTREE_PREFIX; + ldap_pvt_thread_mutex_lock( &db->dbc_write_mutex ); + (void) idl_delete_key( be, db, key, id ); + ldap_pvt_thread_mutex_unlock( &db->dbc_write_mutex ); + + dnParent( &ptr, &pdn ); + + pdn.bv_val[-1] = DN_ONE_PREFIX; + key.dsize = pdn.bv_len + 2; + key.dptr = pdn.bv_val - 1; + ptr = pdn; + + ldap_pvt_thread_mutex_lock( &db->dbc_write_mutex ); + (void) idl_delete_key( be, db, key, id ); + ldap_pvt_thread_mutex_unlock( &db->dbc_write_mutex ); + } + + while ( rc != -1 && !be_issuffix( be, &ptr )) { + ptr.bv_val[-1] = DN_SUBTREE_PREFIX; + + ldap_pvt_thread_mutex_lock( &db->dbc_write_mutex ); + (void) idl_delete_key( be, db, key, id ); + ldap_pvt_thread_mutex_unlock( &db->dbc_write_mutex ); + + dnParent( &ptr, &pdn ); + key.dsize = pdn.bv_len + 2; + key.dptr = pdn.bv_val - 1; + ptr = pdn; + } + + free( buf ); ldbm_cache_close( be, db ); +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ENTRY, "dn2id_delete: return %d\n", rc, 0, 0 ); +#else Debug( LDAP_DEBUG_TRACE, "<= dn2id_delete %d\n", rc, 0, 0 ); +#endif + return( rc ); } @@ -146,37 +349,66 @@ dn2id_delete( */ Entry * -dn2entry( +dn2entry_rw( Backend *be, - char *dn, - char **matched + struct berval *dn, + Entry **matched, + int rw ) { - struct ldbminfo *li = (struct ldbminfo *) be->be_private; ID id; - Entry *e; - char *pdn; + Entry *e = NULL; + struct berval pdn; + +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ENTRY, + "dn2entry_rw: %s entry %s\n", rw ? "w" : "r", dn->bv_val, 0 ); +#else + Debug(LDAP_DEBUG_TRACE, "dn2entry_%s: dn: \"%s\"\n", + rw ? "w" : "r", dn->bv_val, 0); +#endif - if ( (id = dn2id( be, dn )) != NOID && (e = id2entry( be, id )) - != NULL ) { - return( e ); + + if( matched != NULL ) { + /* caller cares about match */ + *matched = NULL; } - *matched = NULL; - /* stop when we get to the suffix */ - if ( be_issuffix( be, dn ) ) { + if ( dn2id( be, dn, &id ) ) { + /* something bad happened to ldbm cache */ return( NULL ); + + } else if ( id != NOID ) { + /* try to return the entry */ + if ((e = id2entry_rw( be, id, rw )) != NULL ) { + return( e ); + } + +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ERR, + "dn2entry_rw: no entry for valid id (%ld), dn (%s)\n", + id, dn->bv_val, 0 ); +#else + Debug(LDAP_DEBUG_ANY, + "dn2entry_%s: no entry for valid id (%ld), dn \"%s\"\n", + rw ? "w" : "r", id, dn->bv_val); +#endif + + /* must have been deleted from underneath us */ + /* treat as if NOID was found */ } + /* caller doesn't care about match */ + if( matched == NULL ) return NULL; + /* entry does not exist - see how much of the dn does exist */ - if ( (pdn = dn_parent( be, dn )) != NULL ) { - if ( (e = dn2entry( be, pdn, matched )) != NULL ) { - *matched = pdn; - cache_return_entry( &li->li_cache, e ); - } else { - free( pdn ); + if ( !be_issuffix( be, dn ) && (dnParent( dn, &pdn ), pdn.bv_len) ) { + /* get entry with reader lock */ + if ( (e = dn2entry_r( be, &pdn, matched )) != NULL ) { + *matched = e; } } - return( NULL ); + return NULL; } + diff --git a/servers/slapd/back-ldbm/filterindex.c b/servers/slapd/back-ldbm/filterindex.c index bc370f239b6916d167899796e692ca9e6c52cf62..c59145e296053538b536034e41210c794b75d965 100644 --- a/servers/slapd/back-ldbm/filterindex.c +++ b/servers/slapd/back-ldbm/filterindex.c @@ -39,7 +39,7 @@ filter_candidates( ID_BLOCK *result; #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, "filter_candidates: enter\n")); + LDAP_LOG( FILTER, ENTRY, "filter_candidates: enter\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "=> filter_candidates\n", 0, 0, 0 ); #endif @@ -49,8 +49,8 @@ filter_candidates( switch ( f->f_choice ) { case SLAPD_FILTER_DN_ONE: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "filter_candidates: DN ONE (%s)\n", f->f_dn )); + LDAP_LOG( FILTER, DETAIL1, + "filter_candidates: DN ONE (%s)\n", f->f_dn, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "\tDN ONE\n", 0, 0, 0 ); #endif @@ -65,8 +65,8 @@ filter_candidates( case SLAPD_FILTER_DN_SUBTREE: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "filter_candidates: DN SUBTREE (%s)\n", f->f_dn )); + LDAP_LOG( FILTER, DETAIL1, + "filter_candidates: DN SUBTREE (%s)\n", f->f_dn, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "\tDN SUBTREE\n", 0, 0, 0 ); #endif @@ -81,8 +81,9 @@ filter_candidates( case LDAP_FILTER_PRESENT: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "filter_candidates: Present (%s)\n", f->f_desc->ad_cname.bv_val )); + LDAP_LOG( FILTER, DETAIL1, + "filter_candidates: Present (%s)\n", + f->f_desc->ad_cname.bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "\tPRESENT\n", 0, 0, 0 ); #endif @@ -92,10 +93,10 @@ filter_candidates( case LDAP_FILTER_EQUALITY: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, + LDAP_LOG( FILTER, DETAIL1, "filter_candidates: EQUALITY (%s),(%s)\n", f->f_ava->aa_desc->ad_cname.bv_val, - f->f_ava->aa_value.bv_val )); + f->f_ava->aa_value.bv_val, 0 ); #else Debug( LDAP_DEBUG_FILTER, "\tEQUALITY\n", 0, 0, 0 ); #endif @@ -105,10 +106,10 @@ filter_candidates( case LDAP_FILTER_APPROX: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, + LDAP_LOG( FILTER, DETAIL1, "filter_candidates: APPROX (%s), (%s)\n", f->f_ava->aa_desc->ad_cname.bv_val, - f->f_ava->aa_value.bv_val )); + f->f_ava->aa_value.bv_val, 0 ); #else Debug( LDAP_DEBUG_FILTER, "\tAPPROX\n", 0, 0, 0 ); #endif @@ -118,8 +119,8 @@ filter_candidates( case LDAP_FILTER_SUBSTRINGS: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "filter_candidates: SUBSTRINGS\n")); + LDAP_LOG( FILTER, DETAIL1, + "filter_candidates: SUBSTRINGS\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "\tSUBSTRINGS\n", 0, 0, 0 ); #endif @@ -129,8 +130,7 @@ filter_candidates( case LDAP_FILTER_GE: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "filter_candidates: GE\n")); + LDAP_LOG( FILTER, DETAIL1, "filter_candidates: GE\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "\tGE\n", 0, 0, 0 ); #endif @@ -140,8 +140,7 @@ filter_candidates( case LDAP_FILTER_LE: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "filter_candidates: LE\n" )); + LDAP_LOG( FILTER, DETAIL1, "filter_candidates: LE\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "\tLE\n", 0, 0, 0 ); #endif @@ -151,8 +150,7 @@ filter_candidates( case LDAP_FILTER_AND: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "filter_candidates: AND\n" )); + LDAP_LOG( FILTER, DETAIL1, "filter_candidates: AND\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "\tAND\n", 0, 0, 0 ); #endif @@ -162,8 +160,7 @@ filter_candidates( case LDAP_FILTER_OR: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "filter_candidates: OR\n" )); + LDAP_LOG( FILTER, DETAIL1, "filter_candidates: OR\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "\tOR\n", 0, 0, 0 ); #endif @@ -173,8 +170,7 @@ filter_candidates( case LDAP_FILTER_NOT: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "filter_candidates: NOT\n" )); + LDAP_LOG( FILTER, DETAIL1, "filter_candidates: NOT\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "\tNOT\n", 0, 0, 0 ); #endif @@ -189,8 +185,7 @@ filter_candidates( break; default: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "filter_candidates: UNKNOWN\n" )); + LDAP_LOG( FILTER, DETAIL1, "filter_candidates: UNKNOWN\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "\tUNKNOWN\n", 0, 0, 0 ); #endif @@ -202,9 +197,9 @@ filter_candidates( } #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, - "filter_candidates: return %ld\n", - result ? ID_BLOCK_NIDS(result) : 0 )); + LDAP_LOG( FILTER, ENTRY, + "filter_candidates: return %ld\n", + result ? ID_BLOCK_NIDS(result) : 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= filter_candidates %ld\n", result ? ID_BLOCK_NIDS(result) : 0, 0, 0 ); @@ -227,8 +222,7 @@ presence_candidates( struct berval prefix = {0}; #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, - "presence_candidates: enter\n" )); + LDAP_LOG( FILTER, ENTRY, "presence_candidates: enter\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "=> presence_candidates\n", 0, 0, 0 ); #endif @@ -244,9 +238,8 @@ presence_candidates( if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_INFO, - "presence_candidates: index_param returned %d\n", - rc )); + LDAP_LOG( FILTER, INFO, + "presence_candidates: index_param returned %d\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= presence_candidates: index_param returned=%d\n", @@ -259,8 +252,7 @@ presence_candidates( if( dbname == NULL ) { /* not indexed */ #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_INFO, - "presence_candidates: not indexed\n" )); + LDAP_LOG( FILTER, INFO, "presence_candidates: not indexed\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= presense_candidates: not indexed\n", @@ -274,9 +266,9 @@ presence_candidates( if ( db == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_INFO, + LDAP_LOG( FILTER, INFO, "presence_candidates: db open failed (%s%s)\n", - dbname, LDBM_SUFFIX )); + dbname, LDBM_SUFFIX, 0 ); #else Debug( LDAP_DEBUG_ANY, "<= presense_candidates db open failed (%s%s)\n", @@ -294,8 +286,8 @@ presence_candidates( if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ERR, - "presence_candidates: key read failed (%d)\n", rc )); + LDAP_LOG( FILTER, ERR, + "presence_candidates: key read failed (%d)\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= presense_candidates key read failed (%d)\n", @@ -305,8 +297,7 @@ presence_candidates( } else if( idl == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "presence_candidates: NULL\n" )); + LDAP_LOG( FILTER, DETAIL1, "presence_candidates: NULL\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= presense_candidates NULL\n", @@ -319,9 +310,9 @@ presence_candidates( ldbm_cache_close( be, db ); #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, - "presence_candidates: return %ld\n", - idl ? ID_BLOCK_NIDS(idl) : 0 )); + LDAP_LOG( FILTER, ENTRY, + "presence_candidates: return %ld\n", + idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= presence_candidates %ld\n", idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 ); @@ -347,8 +338,7 @@ equality_candidates( MatchingRule *mr; #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, - "equality_candidates: enter\n" )); + LDAP_LOG( FILTER, ENTRY, "equality_candidates: enter\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "=> equality_candidates\n", 0, 0, 0 ); #endif @@ -361,8 +351,8 @@ equality_candidates( if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ERR, - "equality_candidates: index_param returned %d\n", rc )); + LDAP_LOG( FILTER, ERR, + "equality_candidates: index_param returned %d\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= equality_candidates: index_param returned=%d\n", @@ -375,8 +365,7 @@ equality_candidates( if( dbname == NULL ) { /* not indexed */ #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ERR, - "equality_candidates: not indexed\n" )); + LDAP_LOG( FILTER, ERR, "equality_candidates: not indexed\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= equality_candidates: not indexed\n", @@ -406,9 +395,9 @@ equality_candidates( if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ERR, + LDAP_LOG( FILTER, ERR, "equality_candidates: (%s%s) MR filter failed (%d\n", - dbname, LDBM_SUFFIX, rc )); + dbname, LDBM_SUFFIX, rc ); #else Debug( LDAP_DEBUG_TRACE, "<= equality_candidates: (%s%s) MR filter failed (%d)\n", @@ -420,9 +409,8 @@ equality_candidates( if( keys == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ERR, - "equality_candidates: no keys (%s%s)\n", - dbname, LDBM_SUFFIX )); + LDAP_LOG( FILTER, ERR, + "equality_candidates: no keys (%s%s)\n", dbname, LDBM_SUFFIX, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= equality_candidates: no keys (%s%s)\n", @@ -436,9 +424,8 @@ equality_candidates( if ( db == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ERR, - "equality_candidates: db open failed (%s%s)\n", - dbname, LDBM_SUFFIX )); + LDAP_LOG( FILTER, ERR, "equality_candidates: db open failed (%s%s)\n", + dbname, LDBM_SUFFIX, 0 ); #else Debug( LDAP_DEBUG_ANY, "<= equality_candidates db open failed (%s%s)\n", @@ -458,8 +445,8 @@ equality_candidates( idl_free( idl ); idl = NULL; #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ERR, - "equality_candidates: key read failed (%d)\n", rc )); + LDAP_LOG( FILTER, ERR, + "equality_candidates: key read failed (%d)\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= equality_candidates key read failed (%d)\n", @@ -473,8 +460,7 @@ equality_candidates( idl_free( idl ); idl = NULL; #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_INFO, - "equality_candidates NULL\n" )); + LDAP_LOG( FILTER, INFO, "equality_candidates NULL\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= equality_candidates NULL\n", @@ -498,9 +484,9 @@ equality_candidates( #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, - "equality_candidates: return %ld\n", - idl ? ID_BLOCK_NIDS(idl) : 0 )); + LDAP_LOG( FILTER, ENTRY, + "equality_candidates: return %ld\n", + idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= equality_candidates %ld\n", idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 ); @@ -526,8 +512,7 @@ approx_candidates( MatchingRule *mr; #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, - "approx_candidates: enter\n" )); + LDAP_LOG( FILTER, ENTRY, "approx_candidates: enter\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "=> approx_candidates\n", 0, 0, 0 ); #endif @@ -540,8 +525,8 @@ approx_candidates( if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ERR, - "approx_candidates: index_param returned %d\n", rc )); + LDAP_LOG( FILTER, ERR, + "approx_candidates: index_param returned %d\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= approx_candidates: index_param returned=%d\n", @@ -554,8 +539,7 @@ approx_candidates( if( dbname == NULL ) { /* not indexed */ #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ERR, - "approx_candidates: not indexed\n" )); + LDAP_LOG( FILTER, ERR, "approx_candidates: not indexed\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "<= approx_candidates: not indexed\n", @@ -590,9 +574,9 @@ approx_candidates( if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ERR, + LDAP_LOG( FILTER, ERR, "approx_candidates: (%s%s) MR filter failed (%d)\n", - dbname, LDBM_SUFFIX, rc )); + dbname, LDBM_SUFFIX, rc ); #else Debug( LDAP_DEBUG_TRACE, "<= approx_candidates: (%s%s) MR filter failed (%d)\n", @@ -604,9 +588,9 @@ approx_candidates( if( keys == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_INFO, + LDAP_LOG( FILTER, INFO, "approx_candidates: no keys (%s%s)\n", - dbname, LDBM_SUFFIX )); + dbname, LDBM_SUFFIX, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= approx_candidates: no keys (%s%s)\n", @@ -620,9 +604,9 @@ approx_candidates( if ( db == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ERR, - "approx_candidates db open failed (%s%s)\n", - dbname, LDBM_SUFFIX )); + LDAP_LOG( FILTER, ERR, + "approx_candidates db open failed (%s%s)\n", + dbname, LDBM_SUFFIX, 0 ); #else Debug( LDAP_DEBUG_ANY, "<= approx_candidates db open failed (%s%s)\n", @@ -642,8 +626,8 @@ approx_candidates( idl_free( idl ); idl = NULL; #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ERR, - "approx_candidates: key read failed (%d)\n", rc )); + LDAP_LOG( FILTER, ERR, + "approx_candidates: key read failed (%d)\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= approx_candidates key read failed (%d)\n", rc, 0, 0 ); @@ -656,8 +640,7 @@ approx_candidates( idl_free( idl ); idl = NULL; #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_INFO, - "approx_candidates: NULL\n" )); + LDAP_LOG( FILTER, INFO, "approx_candidates: NULL\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= approx_candidates NULL\n", 0, 0, 0 ); @@ -679,9 +662,9 @@ approx_candidates( ldbm_cache_close( be, db ); #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, - "approx_candidates: return %ld\n", - idl ? ID_BLOCK_NIDS(idl) : 0 )); + LDAP_LOG( FILTER, ENTRY, + "approx_candidates: return %ld\n", + idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= approx_candidates %ld\n", idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 ); @@ -701,8 +684,7 @@ list_candidates( Filter *f; #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, - "list_candidates: 0x%x\n", ftype )); + LDAP_LOG( FILTER, ENTRY, "list_candidates: 0x%x\n", ftype, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "=> list_candidates 0x%x\n", ftype, 0, 0 ); #endif @@ -713,8 +695,7 @@ list_candidates( if ( (tmp = filter_candidates( be, f )) == NULL && ftype == LDAP_FILTER_AND ) { #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_INFO, - "list_candidates: NULL\n" )); + LDAP_LOG( FILTER, INFO, "list_candidates: NULL\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= list_candidates NULL\n", 0, 0, 0 ); @@ -739,9 +720,8 @@ list_candidates( } #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, - "list_candidates: return %ld\n", - idl ? ID_BLOCK_NIDS(idl) : 0 )); + LDAP_LOG( FILTER, ENTRY, "list_candidates: return %ld\n", + idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= list_candidates %ld\n", idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 ); @@ -767,8 +747,7 @@ substring_candidates( MatchingRule *mr; #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, - "substrings_candidates: enter\n" )); + LDAP_LOG( FILTER, ENTRY, "substrings_candidates: enter\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "=> substrings_candidates\n", 0, 0, 0 ); #endif @@ -781,8 +760,8 @@ substring_candidates( if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ERR, - "substrings_candidates: index_param returned %d\n", rc )); + LDAP_LOG( FILTER, ERR, + "substrings_candidates: index_param returned %d\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= substrings_candidates: index_param returned=%d\n", @@ -795,8 +774,7 @@ substring_candidates( if( dbname == NULL ) { /* not indexed */ #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ERR, - "substrings_candidates: not indexed\n" )); + LDAP_LOG( FILTER, ERR, "substrings_candidates: not indexed\n", 0, 0, 0); #else Debug( LDAP_DEBUG_ANY, "<= substrings_candidates: not indexed\n", @@ -827,9 +805,9 @@ substring_candidates( if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ERR, + LDAP_LOG( FILTER, ERR, "substrings_candidates: (%s%s) MR filter failed (%d)\n", - dbname, LDBM_SUFFIX, rc )); + dbname, LDBM_SUFFIX, rc ); #else Debug( LDAP_DEBUG_TRACE, "<= substrings_candidates: (%s%s) MR filter failed (%d)\n", @@ -841,9 +819,9 @@ substring_candidates( if( keys == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ERR, + LDAP_LOG( FILTER, ERR, "substrings_candidates: (0x%04lx) no keys (%s%s)\n", - mask, dbname, LDBM_SUFFIX )); + mask, dbname, LDBM_SUFFIX ); #else Debug( LDAP_DEBUG_TRACE, "<= substrings_candidates: (0x%04lx) no keys (%s%s)\n", @@ -857,9 +835,9 @@ substring_candidates( if ( db == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ERR, + LDAP_LOG( FILTER, ERR, "substrings_candidates: db open failed (%s%s)\n", - dbname, LDBM_SUFFIX )); + dbname, LDBM_SUFFIX, 0 ); #else Debug( LDAP_DEBUG_ANY, "<= substrings_candidates db open failed (%s%s)\n", @@ -879,9 +857,8 @@ substring_candidates( idl_free( idl ); idl = NULL; #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ERR, - "substrings_candidates: key read failed (%d)\n", - rc )); + LDAP_LOG( FILTER, ERR, + "substrings_candidates: key read failed (%d)\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= substrings_candidates key read failed (%d)\n", rc, 0, 0 ); @@ -894,8 +871,7 @@ substring_candidates( idl_free( idl ); idl = NULL; #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_INFO, - "substrings_candidates: NULL\n" )); + LDAP_LOG( FILTER, INFO, "substrings_candidates: NULL\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= substrings_candidates NULL\n", 0, 0, 0 ); @@ -917,9 +893,9 @@ substring_candidates( ldbm_cache_close( be, db ); #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, + LDAP_LOG( FILTER, ENTRY, "substrings_candidates: return %ld\n", - idl ? ID_BLOCK_NIDS(idl) : 0 )); + idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= substrings_candidates %ld\n", idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 ); diff --git a/servers/slapd/back-ldbm/group.c b/servers/slapd/back-ldbm/group.c new file mode 100644 index 0000000000000000000000000000000000000000..f8d5074bc8ff5dba34a8977ffe077b7a5fe9f6f3 --- /dev/null +++ b/servers/slapd/back-ldbm/group.c @@ -0,0 +1,223 @@ +/* group.c - ldbm backend acl group routine */ +/* $OpenLDAP$ */ +/* + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ + +#include "portable.h" + +#include <stdio.h> + +#include <ac/socket.h> +#include <ac/string.h> + +#include "slap.h" +#include "back-ldbm.h" +#include "proto-back-ldbm.h" + + +/* return 0 IFF op_dn is a value in member attribute + * of entry with gr_dn AND that entry has an objectClass + * value of groupOfNames + */ +int +ldbm_back_group( + Backend *be, + Connection *conn, + Operation *op, + Entry *target, + struct berval *gr_ndn, + struct berval *op_ndn, + ObjectClass *group_oc, + AttributeDescription *group_at +) +{ + struct ldbminfo *li = (struct ldbminfo *) be->be_private; + Entry *e; + int rc = 1; + Attribute *attr; + + const char *group_oc_name = NULL; + const char *group_at_name = group_at->ad_cname.bv_val; + + if( group_oc->soc_names && group_oc->soc_names[0] ) { + group_oc_name = group_oc->soc_names[0]; + } else { + group_oc_name = group_oc->soc_oid; + } + +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ENTRY, + "ldbm_back_group: check (%s) member of (%s), oc %s\n", + op_ndn->bv_val, gr_ndn->bv_val, group_oc_name ); +#else + Debug( LDAP_DEBUG_ARGS, + "=> ldbm_back_group: gr dn: \"%s\"\n", + gr_ndn->bv_val, 0, 0 ); + + Debug( LDAP_DEBUG_ARGS, + "=> ldbm_back_group: op dn: \"%s\"\n", + op_ndn->bv_val, 0, 0 ); + Debug( LDAP_DEBUG_ARGS, + "=> ldbm_back_group: oc: \"%s\" at: \"%s\"\n", + group_oc_name, group_at_name, 0 ); + + Debug( LDAP_DEBUG_ARGS, + "=> ldbm_back_group: tr dn: \"%s\"\n", + target->e_ndn, 0, 0 ); +#endif + + if (dn_match(&target->e_nname, gr_ndn)) { + /* we already have a LOCKED copy of the entry */ + e = target; +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, DETAIL1, + "ldbm_back_group: target is group (%s)\n", gr_ndn->bv_val, 0, 0 ); +#else + Debug( LDAP_DEBUG_ARGS, + "=> ldbm_back_group: target is group: \"%s\"\n", + gr_ndn->bv_val, 0, 0 ); +#endif + + + } else { + /* can we find group entry with reader lock */ + if ((e = dn2entry_r(be, gr_ndn, NULL )) == NULL) { +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, DETAIL1, + "ldbm_back_group: cannot find group (%s)\n", + gr_ndn->bv_val, 0, 0 ); +#else + Debug( LDAP_DEBUG_ACL, + "=> ldbm_back_group: cannot find group: \"%s\"\n", + gr_ndn->bv_val, 0, 0 ); +#endif + + return( 1 ); + } + +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, DETAIL1, + "ldbm_back_group: found group (%s)\n", gr_ndn->bv_val, 0, 0 ); +#else + Debug( LDAP_DEBUG_ACL, + "=> ldbm_back_group: found group: \"%s\"\n", + gr_ndn->bv_val, 0, 0 ); +#endif + + } + + /* find it's objectClass and member attribute values + * make sure this is a group entry + * finally test if we can find op_dn in the member attribute value list * + */ + + rc = 1; + + + if( is_entry_alias( e ) ) { +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, INFO, + "ldbm_back_group: group (%s) is an alias\n", gr_ndn->bv_val, 0, 0 ); +#else + Debug( LDAP_DEBUG_ACL, + "<= ldbm_back_group: group is an alias\n", 0, 0, 0 ); +#endif + + goto return_results; + } + + if( is_entry_referral( e ) ) { +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, INFO, + "ldbm_back_group: group (%s) is a referral.\n", gr_ndn->bv_val,0,0); +#else + Debug( LDAP_DEBUG_ACL, + "<= ldbm_back_group: group is an referral\n", 0, 0, 0 ); +#endif + + goto return_results; + } + + if( !is_entry_objectclass( e, group_oc, 0 ) ) { +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ERR, + "ldbm_back_group: failed to find %s in objectClass.\n", + group_oc_name, 0, 0 ); +#else + Debug( LDAP_DEBUG_ACL, + "<= ldbm_back_group: failed to find %s in objectClass\n", + group_oc_name, 0, 0 ); +#endif + + goto return_results; + } + + if ((attr = attr_find(e->e_attrs, group_at)) == NULL) { +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, INFO, + "ldbm_back_group: failed to find %s\n", group_at_name, 0, 0 ); +#else + Debug( LDAP_DEBUG_ACL, + "<= ldbm_back_group: failed to find %s\n", + group_at_name, 0, 0 ); +#endif + + goto return_results; + } + +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ENTRY, + "ldbm_back_group: found objectClass %s and %s\n", + group_oc_name, group_at_name, 0 ); +#else + Debug( LDAP_DEBUG_ACL, + "<= ldbm_back_group: found objectClass %s and %s\n", + group_oc_name, group_at_name, 0 ); +#endif + + + if( value_find( group_at, attr->a_vals, op_ndn ) != LDAP_SUCCESS ) { +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, DETAIL1, + "ldbm_back_group: \"%s\" not in \"%s\": %s\n", + op_ndn->bv_val, gr_ndn->bv_val, group_at_name ); +#else + Debug( LDAP_DEBUG_ACL, + "<= ldbm_back_group: \"%s\" not in \"%s\": %s\n", + op_ndn->bv_val, gr_ndn->bv_val, group_at_name ); +#endif + + goto return_results; + } + + +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, DETAIL1, + "ldbm_back_group: %s is in %s: %s\n", + op_ndn->bv_val, gr_ndn->bv_val, group_at_name ); +#else + Debug( LDAP_DEBUG_ACL, + "<= ldbm_back_group: \"%s\" is in \"%s\": %s\n", + op_ndn->bv_val, gr_ndn->bv_val, group_at_name ); +#endif + + + rc = 0; + +return_results: + if( target != e ) { + /* free entry and reader lock */ + cache_return_entry_r( &li->li_cache, e ); + } + +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ENTRY, "ldbm_back_group: rc=%d\n", rc, 0, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, "ldbm_back_group: rc=%d\n", rc, 0, 0 ); +#endif + + return(rc); +} + diff --git a/servers/slapd/back-ldbm/id2children.c b/servers/slapd/back-ldbm/id2children.c index c27496d5730b6f5a47e6370ee3ba6c71239f56a8..8c375a6c169b7b9df2c44d00cfb4a97899e0c4bd 100644 --- a/servers/slapd/back-ldbm/id2children.c +++ b/servers/slapd/back-ldbm/id2children.c @@ -15,7 +15,6 @@ #include "slap.h" #include "back-ldbm.h" - int has_children( Backend *be, @@ -30,8 +29,7 @@ has_children( ldbm_datum_init( key ); #ifdef NEW_LOGGING - LDAP_LOG(( "id2children", LDAP_LEVEL_ENTRY, - "has_children: enter %ld\n", p->e_id )); + LDAP_LOG( INDEX, ENTRY, "has_children: enter %ld\n", p->e_id, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "=> has_children( %ld )\n", p->e_id , 0, 0 ); #endif @@ -40,9 +38,8 @@ has_children( if ( (db = ldbm_cache_open( be, "dn2id", LDBM_SUFFIX, LDBM_WRCREAT )) == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "id2children", LDAP_LEVEL_ERR, - "has_children: could not open \"dn2id%s\"\n", - LDBM_SUFFIX )); + LDAP_LOG( INDEX, ERR, + "has_children: could not open \"dn2id%s\"\n", LDBM_SUFFIX, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "<= has_children -1 could not open \"dn2id%s\"\n", @@ -68,9 +65,9 @@ has_children( } #ifdef NEW_LOGGING - LDAP_LOG(( "id2children", LDAP_LEVEL_ENTRY, + LDAP_LOG( INDEX, ENTRY, "has_children: id (%ld) %s children.\n", - p->e_id, rc ? "has" : "doesn't have" )); + p->e_id, rc ? "has" : "doesn't have", 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= has_children( %ld ): %s\n", p->e_id, rc ? "yes" : "no", 0 ); diff --git a/servers/slapd/back-ldbm/id2entry.c b/servers/slapd/back-ldbm/id2entry.c index 0bcde14620a4f1e7ffdf4b15c6b32ab39be9702b..2f071b84420c002c7cdc9de2395138309111658e 100644 --- a/servers/slapd/back-ldbm/id2entry.c +++ b/servers/slapd/back-ldbm/id2entry.c @@ -33,8 +33,7 @@ id2entry_add( Backend *be, Entry *e ) ldbm_datum_init( data ); #ifdef NEW_LOGGING - LDAP_LOG(( "id2entry", LDAP_LEVEL_ENTRY, - "id2entry_add: (%s)%ld\n", e->e_dn, e->e_id )); + LDAP_LOG( INDEX, ENTRY, "id2entry_add: (%s)%ld\n", e->e_dn, e->e_id, 0 ); #else Debug( LDAP_DEBUG_TRACE, "=> id2entry_add( %ld, \"%s\" )\n", e->e_id, e->e_dn, 0 ); @@ -44,9 +43,9 @@ id2entry_add( Backend *be, Entry *e ) if ( (db = ldbm_cache_open( be, "id2entry", LDBM_SUFFIX, LDBM_WRCREAT )) == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "id2entry", LDAP_LEVEL_ERR, - "id2entry_add: could not open/create id2entry%s\n", - LDBM_SUFFIX )); + LDAP_LOG( INDEX, ERR, + "id2entry_add: could not open/create id2entry%s\n", + LDBM_SUFFIX, 0,0 ); #else Debug( LDAP_DEBUG_ANY, "Could not open/create id2entry%s\n", LDBM_SUFFIX, 0, 0 ); @@ -76,8 +75,7 @@ id2entry_add( Backend *be, Entry *e ) ldbm_cache_close( be, db ); #ifdef NEW_LOGGING - LDAP_LOG(( "id2entry", LDAP_LEVEL_ENTRY, - "id2entry_add: return %d\n", rc )); + LDAP_LOG( INDEX, ENTRY, "id2entry_add: return %d\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= id2entry_add %d\n", rc, 0, 0 ); #endif @@ -98,8 +96,7 @@ id2entry_delete( Backend *be, Entry *e ) #endif #ifdef NEW_LOGGING - LDAP_LOG(( "id2entry", LDAP_LEVEL_ENTRY, - "id2entry_delete: (%s)%ld\n", e->e_dn, e->e_id )); + LDAP_LOG( INDEX, ENTRY, "id2entry_delete: (%s)%ld\n", e->e_dn, e->e_id, 0 ); #else Debug(LDAP_DEBUG_TRACE, "=> id2entry_delete( %ld, \"%s\" )\n", e->e_id, e->e_dn, 0 ); @@ -118,9 +115,9 @@ id2entry_delete( Backend *be, Entry *e ) if ( (db = ldbm_cache_open( be, "id2entry", LDBM_SUFFIX, LDBM_WRCREAT )) == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "id2entry", LDAP_LEVEL_ERR, + LDAP_LOG( INDEX, ERR, "id2entry_delete: could not open/create id2entry%s\n", - LDBM_SUFFIX )); + LDBM_SUFFIX, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "Could not open/create id2entry%s\n", LDBM_SUFFIX, 0, 0 ); @@ -131,9 +128,9 @@ id2entry_delete( Backend *be, Entry *e ) if ( cache_delete_entry( &li->li_cache, e ) != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "id2entry", LDAP_LEVEL_ERR, + LDAP_LOG( INDEX, ERR, "id2entry_delete: Could not delete (%s)%ld from cache\n", - e->e_dn, e->e_id )); + e->e_dn, e->e_id, 0 ); #else Debug(LDAP_DEBUG_ANY, "could not delete %ld (%s) from cache\n", e->e_id, e->e_dn, 0 ); @@ -154,8 +151,7 @@ id2entry_delete( Backend *be, Entry *e ) ldbm_cache_close( be, db ); #ifdef NEW_LOGGING - LDAP_LOG(( "id2entry", LDAP_LEVEL_ENTRY, - "id2entry_delete: return %d\n", rc )); + LDAP_LOG( INDEX, ENTRY, "id2entry_delete: return %d\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= id2entry_delete %d\n", rc, 0, 0 ); #endif @@ -179,9 +175,8 @@ id2entry_rw( Backend *be, ID id, int rw ) ldbm_datum_init( data ); #ifdef NEW_LOGGING - LDAP_LOG(( "id2entry", LDAP_LEVEL_ENTRY, - "id2entry_rw: %s (%ld)\n", - rw ? "write" : "read", id )); + LDAP_LOG( INDEX, ENTRY, + "id2entry_rw: %s (%ld)\n", rw ? "write" : "read", id, 0 ); #else Debug( LDAP_DEBUG_TRACE, "=> id2entry_%s( %ld )\n", rw ? "w" : "r", id, 0 ); @@ -190,9 +185,9 @@ id2entry_rw( Backend *be, ID id, int rw ) if ( (e = cache_find_entry_id( &li->li_cache, id, rw )) != NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "id2entry", LDAP_LEVEL_DETAIL1, + LDAP_LOG( INDEX, DETAIL1, "id2entry_rw: %s (%ld) 0x%lx (cache).\n", - rw ? "write" : "read", id, (unsigned long)e )); + rw ? "write" : "read", id, (unsigned long)e ); #else Debug( LDAP_DEBUG_TRACE, "<= id2entry_%s( %ld ) 0x%lx (cache)\n", rw ? "w" : "r", id, (unsigned long) e ); @@ -204,8 +199,8 @@ id2entry_rw( Backend *be, ID id, int rw ) if ( (db = ldbm_cache_open( be, "id2entry", LDBM_SUFFIX, LDBM_WRCREAT )) == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "id2entry", LDAP_LEVEL_ERR, - "id2entry_rw: could not open id2entry%s\n", LDBM_SUFFIX )); + LDAP_LOG( INDEX, ERR, + "id2entry_rw: could not open id2entry%s\n", LDBM_SUFFIX, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "Could not open id2entry%s\n", LDBM_SUFFIX, 0, 0 ); @@ -226,8 +221,8 @@ id2entry_rw( Backend *be, ID id, int rw ) if ( data.dptr == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "id2entry", LDAP_LEVEL_ERR, - "id2entry_rw: (%ld) not found\n", id )); + LDAP_LOG( INDEX, ERR, + "id2entry_rw: (%ld) not found\n", id, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= id2entry_%s( %ld ) not found\n", rw ? "w" : "r", id, 0 ); @@ -243,9 +238,8 @@ id2entry_rw( Backend *be, ID id, int rw ) if ( e == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "id2entry", LDAP_LEVEL_ERR, - "id2entry_rw: %s of %ld failed\n", - rw ? "write" : "read", id )); + LDAP_LOG( INDEX, ERR, + "id2entry_rw: %s of %ld failed\n", rw ? "write" : "read", id, 0); #else Debug( LDAP_DEBUG_TRACE, "<= id2entry_%s( %ld ) (failed)\n", rw ? "w" : "r", id, 0 ); @@ -265,9 +259,9 @@ id2entry_rw( Backend *be, ID id, int rw ) */ if ( (e = cache_find_entry_id( &li->li_cache, id, rw )) != NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "id2entry", LDAP_LEVEL_DETAIL1, + LDAP_LOG( INDEX, DETAIL1, "id2entry_rw: %s of %ld 0x%lx (cache)\n", - rw ? "write" : "read", id, (unsigned long)e )); + rw ? "write" : "read", id, (unsigned long)e ); #else Debug( LDAP_DEBUG_TRACE, "<= id2entry_%s( %ld ) 0x%lx (cache)\n", rw ? "w" : "r", id, (unsigned long) e ); @@ -277,9 +271,9 @@ id2entry_rw( Backend *be, ID id, int rw ) } #ifdef NEW_LOGGING - LDAP_LOG(( "id2entry", LDAP_LEVEL_ERR, + LDAP_LOG( INDEX, ERR, "id2entry_rw: %s of %ld (cache add failed)\n", - rw ? "write" : "read", id )); + rw ? "write" : "read", id, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= id2entry_%s( %ld ) (cache add failed)\n", rw ? "w" : "r", id, 0 ); @@ -289,9 +283,9 @@ id2entry_rw( Backend *be, ID id, int rw ) } #ifdef NEW_LOGGING - LDAP_LOG(( "id2entry", LDAP_LEVEL_ENTRY, + LDAP_LOG( INDEX, ENTRY, "id2entry_rw: %s of %ld 0x%lx (disk)\n", - rw ? "write" : "read", id, (unsigned long)e )); + rw ? "write" : "read", id, (unsigned long)e ); #else Debug( LDAP_DEBUG_TRACE, "<= id2entry_%s( %ld ) 0x%lx (disk)\n", rw ? "w" : "r", id, (unsigned long) e ); diff --git a/servers/slapd/back-ldbm/idl.c b/servers/slapd/back-ldbm/idl.c index 60ca3e65946d383f7e63d8cc1c5a8d85bec41eda..a070f46adf399002cb42b59d386bad7cc9bb4f01 100644 --- a/servers/slapd/back-ldbm/idl.c +++ b/servers/slapd/back-ldbm/idl.c @@ -104,8 +104,7 @@ idl_free( ID_BLOCK *idl ) { if ( idl == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_INFO, - "idl_free: called with NULL pointer\n" )); + LDAP_LOG( INDEX, INFO, "idl_free: called with NULL pointer\n" , 0,0,0); #else Debug( LDAP_DEBUG_TRACE, "idl_free: called with NULL pointer\n", @@ -217,8 +216,8 @@ idl_fetch( if ( (tmp[i] = idl_fetch_one( be, db, data )) == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_INFO, - "idl_fetch: idl_fetch_one returned NULL\n" )); + LDAP_LOG( INDEX, INFO, + "idl_fetch: idl_fetch_one returned NULL\n", 0,0,0 ); #else Debug( LDAP_DEBUG_ANY, "idl_fetch: one returned NULL\n", 0, 0, 0 ); @@ -259,9 +258,9 @@ idl_fetch( #endif #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_ENTRY, + LDAP_LOG( INDEX, ENTRY, "idl_fetch: %ld ids (%ld max)\n", - ID_BLOCK_NIDS(idl), ID_BLOCK_NMAXN(idl) )); + ID_BLOCK_NIDS(idl), ID_BLOCK_NMAXN(idl), 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= idl_fetch %ld ids (%ld max)\n", ID_BLOCK_NIDS(idl), ID_BLOCK_NMAXN(idl), 0 ); @@ -408,8 +407,8 @@ idl_change_first( /* delete old key block */ if ( (rc = ldbm_cache_delete( db, bkey )) != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_INFO, - "idl_change_first: ldbm_cache_delete returned %d\n", rc )); + LDAP_LOG( INDEX, INFO, + "idl_change_first: ldbm_cache_delete returned %d\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "idl_change_first: ldbm_cache_delete returned %d\n", @@ -424,8 +423,8 @@ idl_change_first( if ( (rc = idl_store( be, db, bkey, b )) != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_INFO, - "idl_change_first: idl_store returned %d\n", rc )); + LDAP_LOG( INDEX, INFO, + "idl_change_first: idl_store returned %d\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "idl_change_first: idl_store returned %d\n", rc, 0, 0 ); @@ -438,8 +437,8 @@ idl_change_first( ID_BLOCK_ID(h, pos) = ID_BLOCK_ID(b, 0); if ( (rc = idl_store( be, db, hkey, h )) != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_INFO, - "idl_change_first: idl_store returned %s\n", rc )); + LDAP_LOG( INDEX, INFO, + "idl_change_first: idl_store returned %s\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "idl_change_first: idl_store returned %d\n", rc, 0, 0 ); @@ -572,8 +571,8 @@ idl_insert_key( if ( (tmp = idl_fetch_one( be, db, k2 )) == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_ERR, - "idl_insert_key: nonexistent continuation block\n" )); + LDAP_LOG( INDEX, ERR, + "idl_insert_key: nonexistent continuation block\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "idl_insert_key: nonexistent continuation block\n", 0, 0, 0 ); @@ -589,8 +588,8 @@ idl_insert_key( case 0: /* id inserted ok */ if ( (rc = idl_store( be, db, k2, tmp )) != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_ERR, - "ids_insert_key: idl_store returned %d\n", rc )); + LDAP_LOG( INDEX, ERR, + "ids_insert_key: idl_store returned %d\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "idl_insert_key: idl_store returned %d\n", rc, 0, 0 ); @@ -632,8 +631,8 @@ idl_insert_key( cont_id( &k2, ID_BLOCK_ID(idl, i) ); if ( (tmp2 = idl_fetch_one( be, db, k2 )) == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_ERR, - "idl_insert_key: idl_fetch_one returned NULL\n")); + LDAP_LOG( INDEX, ERR, + "idl_insert_key: idl_fetch_one returned NULL\n", 0, 0, 0); #else Debug( LDAP_DEBUG_ANY, "idl_insert_key: idl_fetch_one returned NULL\n", @@ -661,8 +660,8 @@ idl_insert_key( if ( (rc = idl_store( be, db, k2, tmp )) != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_ERR, - "idl_insert_key: idl_store returned %d\n", rc )); + LDAP_LOG( INDEX, ERR, + "idl_insert_key: idl_store returned %d\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "idl_insert_key: idl_store returned %d\n", rc, 0, 0 ); @@ -692,9 +691,9 @@ idl_insert_key( */ if ( rc == 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_INFO, + LDAP_LOG( INDEX, INFO, "idl_insert_key: id %ld is already in next block\n", - id )); + id, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "idl_insert_key: id %ld already in next block\n", @@ -947,8 +946,8 @@ idl_delete_key ( if ( (tmp = idl_fetch_one( be, db, data )) == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "idl", LDAP_LEVEL_INFO, - "idl_delete_key: idl_fetch_one returned NULL\n" )); + LDAP_LOG( INDEX, INFO, + "idl_delete_key: idl_fetch_one returned NULL\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "idl_delete_key: idl_fetch of returned NULL\n", 0, 0, 0 ); diff --git a/servers/slapd/back-ldbm/index.c b/servers/slapd/back-ldbm/index.c index 3d75a091d3166f497ebbc9fa9a58bbff92521014..f5078c0051313dffcc2ff3e3940e31349b07cba6 100644 --- a/servers/slapd/back-ldbm/index.c +++ b/servers/slapd/back-ldbm/index.c @@ -1,364 +1,325 @@ /* index.c - routines for dealing with attribute indexes */ +/* $OpenLDAP$ */ +/* + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ -#include <stdio.h> -#include <string.h> -#include <sys/types.h> -#include <sys/socket.h> -#include "slap.h" -#include "back-ldbm.h" +#include "portable.h" -extern char *first_word(); -extern char *next_word(); -extern char *phonetic(); -extern IDList *idl_fetch(); -extern IDList *idl_allids(); -extern struct dbcache *ldbm_cache_open(); +#include <stdio.h> -int index_add_values(); +#include <ac/string.h> +#include <ac/socket.h> -static int add_value(); -static int index2prefix(); +#include "slap.h" +#include "back-ldbm.h" -int -index_add_entry( - Backend *be, - Entry *e -) +static slap_mask_t index_mask( + Backend *be, + AttributeDescription *desc, + char **dbname, + struct berval *atname ) { - Attribute *ap; - char *dnval; - struct berval bv; - struct berval *bvals[2]; - - Debug( LDAP_DEBUG_TRACE, "=> index_add( %ld, \"%s\" )\n", e->e_id, - e->e_dn, 0 ); - - /* - * dn index entry - make it look like an attribute so it works - * with index_add_values() call - */ + AttributeType *at; + slap_mask_t mask = 0; - bv.bv_val = strdup( e->e_dn ); - bv.bv_len = strlen( bv.bv_val ); - (void) dn_normalize_case( bv.bv_val ); - bvals[0] = &bv; - bvals[1] = NULL; + attr_mask( be->be_private, desc, &mask ); - /* add the dn to the indexes */ - index_add_values( be, "dn", bvals, e->e_id ); + if( mask ) { + *atname = desc->ad_cname; + *dbname = desc->ad_cname.bv_val; + return mask; + } - free( bv.bv_val ); + /* If there is a language tag, did we ever index the base + * type? If so, check for mask, otherwise it's not there. + */ + if( slap_ad_is_lang( desc ) && desc != desc->ad_type->sat_ad ) { + /* has language tag */ + attr_mask( be->be_private, desc->ad_type->sat_ad, &mask ); + + if( mask && ( mask ^ SLAP_INDEX_NOLANG ) ) { + *atname = desc->ad_type->sat_cname; + *dbname = desc->ad_type->sat_cname.bv_val; + return mask; + } + } - /* add each attribute to the indexes */ - for ( ap = e->e_attrs; ap != NULL; ap = ap->a_next ) { - index_add_values( be, ap->a_type, ap->a_vals, e->e_id ); + /* see if supertype defined mask for its subtypes */ + for( at = desc->ad_type->sat_sup; at != NULL ; at = at->sat_sup ) { + /* If no AD, we've never indexed this type */ + if (!at->sat_ad) + continue; + + attr_mask( be->be_private, at->sat_ad, &mask ); + + if( mask && ( mask ^ SLAP_INDEX_NOSUBTYPES ) ) { + *atname = at->sat_cname; + *dbname = at->sat_cname.bv_val; + return mask; + } } - Debug( LDAP_DEBUG_TRACE, "<= index_add( %ld, \"%s\" ) 0\n", e->e_id, - e->e_dn, 0 ); - return( 0 ); + return 0; } -int -index_add_mods( - Backend *be, - LDAPMod *mods, - ID id -) +int index_is_indexed( + Backend *be, + AttributeDescription *desc ) { - int rc; - - for ( ; mods != NULL; mods = mods->mod_next ) { - switch ( mods->mod_op & ~LDAP_MOD_BVALUES ) { - case LDAP_MOD_ADD: - case LDAP_MOD_REPLACE: - rc = index_add_values( be, mods->mod_type, - mods->mod_bvalues, id ); - break; - - case LDAP_MOD_DELETE: - rc = 0; - break; - } + slap_mask_t mask; + char *dbname; + struct berval prefix; - if ( rc != 0 ) { - return( rc ); - } + mask = index_mask( be, desc, &dbname, &prefix ); + + if( mask == 0 ) { + return LDAP_INAPPROPRIATE_MATCHING; } - return( 0 ); + return LDAP_SUCCESS; } -IDList * -index_read( - Backend *be, - char *type, - int indextype, - char *val -) +int index_param( + Backend *be, + AttributeDescription *desc, + int ftype, + char **dbnamep, + slap_mask_t *maskp, + struct berval *prefixp ) { - struct dbcache *db; - Datum key; - IDList *idl; - int indexmask, syntax; - char prefix; - char *realval, *tmpval; - char buf[BUFSIZ]; - - prefix = index2prefix( indextype ); - Debug( LDAP_DEBUG_TRACE, "=> index_read( \"%s\" \"%c\" \"%s\" )\n", - type, prefix, val ); - - attr_masks( be->be_private, type, &indexmask, &syntax ); - if ( ! (indextype & indexmask) ) { - idl = idl_allids( be ); - Debug( LDAP_DEBUG_TRACE, - "<= index_read %d candidates (allids - not indexed)\n", - idl ? idl->b_nids : 0, 0, 0 ); - return( idl ); - } + slap_mask_t mask; + char *dbname; - attr_normalize( type ); - if ( (db = ldbm_cache_open( be, type, LDBM_SUFFIX, LDBM_WRCREAT )) - == NULL ) { - Debug( LDAP_DEBUG_ANY, - "<= index_read NULL (could not open %s%s)\n", type, - LDBM_SUFFIX, 0 ); - return( NULL ); + mask = index_mask( be, desc, &dbname, prefixp ); + + if( mask == 0 ) { + return LDAP_INAPPROPRIATE_MATCHING; } - realval = val; - tmpval = NULL; - if ( prefix != '\0' ) { - int len; - - if ( (len = strlen( val )) < sizeof(buf) ) { - buf[0] = prefix; - strcpy( &buf[1], val ); - realval = buf; - } else { - /* value + prefix + null */ - tmpval = (char *) ch_malloc( len + 2 ); - tmpval[0] = prefix; - strcat( &tmpval[1], val ); - realval = tmpval; + switch( ftype ) { + case LDAP_FILTER_PRESENT: + if( IS_SLAP_INDEX( mask, SLAP_INDEX_PRESENT ) ) { + goto done; } - } + break; + + case LDAP_FILTER_APPROX: + if( IS_SLAP_INDEX( mask, SLAP_INDEX_APPROX ) ) { + goto done; + } + /* fall thru */ + + case LDAP_FILTER_EQUALITY: + if( IS_SLAP_INDEX( mask, SLAP_INDEX_EQUALITY ) ) { + goto done; + } + break; - key.dptr = realval; - key.dsize = strlen( realval ) + 1; + case LDAP_FILTER_SUBSTRINGS: + if( IS_SLAP_INDEX( mask, SLAP_INDEX_SUBSTR ) ) { + goto done; + } + break; - idl = idl_fetch( be, db, key ); + default: + return LDAP_OTHER; + } - ldbm_cache_close( be, db ); + return LDAP_INAPPROPRIATE_MATCHING; - Debug( LDAP_DEBUG_TRACE, "<= index_read %d candidates\n", - idl ? idl->b_nids : 0, 0, 0 ); - return( idl ); +done: + *dbnamep = dbname; + *maskp = mask; + return LDAP_SUCCESS; } -static int -add_value( - Backend *be, - struct dbcache *db, - char *type, - int indextype, - char *val, - ID id -) +static int indexer( + Backend *be, + char *dbname, + struct berval *atname, + BerVarray vals, + ID id, + int op, + slap_mask_t mask ) { - int rc; - Datum key; - IDList *idl; - char prefix; - char *realval, *tmpval, *s; - char buf[BUFSIZ]; - - prefix = index2prefix( indextype ); - Debug( LDAP_DEBUG_TRACE, "=> add_value( \"%c%s\" )\n", prefix, val, 0 ); - - realval = val; - tmpval = NULL; - idl = NULL; - if ( prefix != '\0' ) { - int len; - - if ( (len = strlen( val )) < sizeof(buf) ) { - buf[0] = prefix; - strcpy( &buf[1], val ); - realval = buf; - } else { - /* value + prefix + null */ - tmpval = (char *) ch_malloc( len + 2 ); - tmpval[0] = prefix; - strcat( &tmpval[1], val ); - realval = tmpval; - } - } + int rc, i; + const char *text; + DBCache *db; + AttributeDescription *ad = NULL; + struct berval *keys; - key.dptr = realval; - key.dsize = strlen( realval ) + 1; + assert( mask ); - rc = idl_insert_key( be, db, key, id ); + rc = slap_bv2ad( atname, &ad, &text ); - if ( tmpval != NULL ) { - free( tmpval ); - } - idl_free( idl ); + if( rc != LDAP_SUCCESS ) return rc; - pthread_yield(); - - /* Debug( LDAP_DEBUG_TRACE, "<= add_value %d\n", rc, 0, 0 ); */ - return( rc ); -} + db = ldbm_cache_open( be, dbname, LDBM_SUFFIX, LDBM_WRCREAT ); + + if ( db == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG( INDEX, ERR, + "index_read: Could not open db %s%s\n", dbname, LDBM_SUFFIX, 0 ); +#else + Debug( LDAP_DEBUG_ANY, + "<= index_read NULL (could not open %s%s)\n", + dbname, LDBM_SUFFIX, 0 ); +#endif -int -index_add_values( - Backend *be, - char *type, - struct berval **vals, - ID id -) -{ - char *val, *p, *code, *w; - int i, j, len; - int indexmask, syntax; - char buf[SUBLEN + 1]; - char vbuf[BUFSIZ]; - char *bigbuf; - struct dbcache *db; - - Debug( LDAP_DEBUG_TRACE, "=> index_add_values( \"%s\", %ld )\n", type, - id, 0 ); - - attr_masks( be->be_private, type, &indexmask, &syntax ); - if ( indexmask == 0 ) { - return( 0 ); + return LDAP_OTHER; } - if ( (db = ldbm_cache_open( be, type, LDBM_SUFFIX, LDBM_WRCREAT )) - == NULL ) { - Debug( LDAP_DEBUG_ANY, - "<= index_add_values -1 (could not open/create %s%s)\n", - type, LDBM_SUFFIX, 0 ); - return( -1 ); + if( IS_SLAP_INDEX( mask, SLAP_INDEX_PRESENT ) ) { + key_change( be, db, atname, id, op ); } + if( IS_SLAP_INDEX( mask, SLAP_INDEX_EQUALITY ) ) { + rc = ad->ad_type->sat_equality->smr_indexer( + LDAP_FILTER_EQUALITY, + mask, + ad->ad_type->sat_syntax, + ad->ad_type->sat_equality, + atname, vals, &keys ); + + if( rc == LDAP_SUCCESS && keys != NULL ) { + for( i=0; keys[i].bv_val != NULL; i++ ) { + key_change( be, db, &keys[i], id, op ); + } + ber_bvarray_free( keys ); + } + } - for ( i = 0; vals[i] != NULL; i++ ) { - /* - * presence index entry - */ - if ( indexmask & INDEX_PRESENCE ) { - add_value( be, db, type, INDEX_PRESENCE, "*", id ); + if( IS_SLAP_INDEX( mask, SLAP_INDEX_APPROX ) ) { + rc = ad->ad_type->sat_approx->smr_indexer( + LDAP_FILTER_APPROX, + mask, + ad->ad_type->sat_syntax, + ad->ad_type->sat_approx, + atname, vals, &keys ); + + if( rc == LDAP_SUCCESS && keys != NULL ) { + for( i=0; keys[i].bv_val != NULL; i++ ) { + key_change( be, db, &keys[i], id, op ); + } + ber_bvarray_free( keys ); } + } - Debug( LDAP_DEBUG_TRACE, "*** index_add_values syntax 0x%x syntax bin 0x%x\n", - syntax, SYNTAX_BIN, 0 ); - if ( syntax & SYNTAX_BIN ) { - ldbm_cache_close( be, db ); - return( 0 ); + if( IS_SLAP_INDEX( mask, SLAP_INDEX_SUBSTR ) ) { + rc = ad->ad_type->sat_substr->smr_indexer( + LDAP_FILTER_SUBSTRINGS, + mask, + ad->ad_type->sat_syntax, + ad->ad_type->sat_substr, + atname, vals, &keys ); + + if( rc == LDAP_SUCCESS && keys != NULL ) { + for( i=0; keys[i].bv_val != NULL; i++ ) { + key_change( be, db, &keys[i], id, op ); + } + ber_bvarray_free( keys ); } + } - bigbuf = NULL; - len = vals[i]->bv_len; + ldbm_cache_close( be, db ); + return LDAP_SUCCESS; +} - /* value + null */ - if ( len + 2 > sizeof(vbuf) ) { - bigbuf = (char *) ch_malloc( len + 1 ); - val = bigbuf; - } else { - val = vbuf; - } - (void) memcpy( val, vals[i]->bv_val, len ); - val[len] = '\0'; +static int index_at_values( + Backend *be, + AttributeType *type, + struct berval *lang, + BerVarray vals, + ID id, + int op ) +{ + slap_mask_t mask = 0; - value_normalize( val, syntax ); + if( type->sat_sup ) { + /* recurse */ + (void) index_at_values( be, + type->sat_sup, lang, + vals, id, op ); + } - /* - * equality index entry - */ - if ( indexmask & INDEX_EQUALITY ) { - add_value( be, db, type, INDEX_EQUALITY, val, id ); - } + /* If this type has no AD, we've never used it before */ + if( type->sat_ad ) { + attr_mask( be->be_private, type->sat_ad, &mask ); + } - /* - * approximate index entry - */ - if ( indexmask & INDEX_APPROX ) { - for ( w = first_word( val ); w != NULL; - w = next_word( w ) ) { - if ( (code = phonetic( w )) != NULL ) { - add_value( be, db, type, INDEX_APPROX, - code, id ); - free( code ); - } - } - } + if( mask ) { + indexer( be, type->sat_cname.bv_val, + &type->sat_cname, + vals, id, op, + mask ); + } - /* - * substrings index entry - */ - if ( indexmask & INDEX_SUB ) { - /* leading and trailing */ - if ( len > SUBLEN - 2 ) { - buf[0] = '^'; - for ( j = 0; j < SUBLEN - 1; j++ ) { - buf[j + 1] = val[j]; - } - buf[SUBLEN] = '\0'; - - add_value( be, db, type, INDEX_SUB, buf, id ); - - p = val + len - SUBLEN + 1; - for ( j = 0; j < SUBLEN - 1; j++ ) { - buf[j] = p[j]; - } - buf[SUBLEN - 1] = '$'; - buf[SUBLEN] = '\0'; - - add_value( be, db, type, INDEX_SUB, buf, id ); - } + if( lang->bv_len ) { + AttributeDescription *desc; - /* any */ - for ( p = val; p < (val + len - SUBLEN + 1); p++ ) { - for ( j = 0; j < SUBLEN; j++ ) { - buf[j] = p[j]; - } - buf[SUBLEN] = '\0'; + mask = 0; - add_value( be, db, type, INDEX_SUB, buf, id ); - } + desc = ad_find_lang(type, lang); + if( desc ) { + attr_mask( be->be_private, desc, &mask ); } - if ( bigbuf != NULL ) { - free( bigbuf ); + if( mask ) { + indexer( be, desc->ad_cname.bv_val, &desc->ad_cname, + vals, id, op, + mask ); } } - ldbm_cache_close( be, db ); - return( 0 ); + return LDAP_SUCCESS; } -static int -index2prefix( int indextype ) +int index_values( + Backend *be, + AttributeDescription *desc, + BerVarray vals, + ID id, + int op ) { - int prefix; + (void) index_at_values( be, + desc->ad_type, &desc->ad_lang, + vals, id, op ); - switch ( indextype ) { - case INDEX_EQUALITY: - prefix = EQ_PREFIX; - break; - case INDEX_APPROX: - prefix = APPROX_PREFIX; - break; - case INDEX_SUB: - prefix = SUB_PREFIX; - break; - default: - prefix = '\0'; - break; + return LDAP_SUCCESS; +} + +int +index_entry( + Backend *be, + int op, + Entry *e, + Attribute *ap ) +{ +#ifdef NEW_LOGGING + LDAP_LOG( INDEX, ENTRY, + "index_entry: %s (%s)%ld\n", op == SLAP_INDEX_ADD_OP ? "add" : "del", + e->e_dn, e->e_id ); +#else + Debug( LDAP_DEBUG_TRACE, "=> index_entry_%s( %ld, \"%s\" )\n", + op == SLAP_INDEX_ADD_OP ? "add" : "del", + e->e_id, e->e_dn ); +#endif + + /* add each attribute to the indexes */ + for ( ; ap != NULL; ap = ap->a_next ) { + index_values( be, ap->a_desc, ap->a_vals, e->e_id, op ); } - return( prefix ); +#ifdef NEW_LOGGING + LDAP_LOG( INDEX, ENTRY, "index_entry: success\n", 0, 0, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, "<= index_entry_%s( %ld, \"%s\" ) success\n", + op == SLAP_INDEX_ADD_OP ? "add" : "del", + e->e_id, e->e_dn ); +#endif + + return LDAP_SUCCESS; } + diff --git a/servers/slapd/back-ldbm/init.c b/servers/slapd/back-ldbm/init.c index d3e16e31c95b4b709180b1ca7e4aaf4f20a8e401..be55fac73c7de7d47d77186e5d3188493fb6bab5 100644 --- a/servers/slapd/back-ldbm/init.c +++ b/servers/slapd/back-ldbm/init.c @@ -202,8 +202,8 @@ ldbm_back_db_open( if ( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "init", LDAP_LEVEL_ERR, "ldbm_back_db_open: sync " - "ldap_pvt_thread_create failed (%d)\n", rc )); + LDAP_LOG ( BACK_LDBM, ERR, "ldbm_back_db_open: sync " + "ldap_pvt_thread_create failed (%d)\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "sync ldap_pvt_thread_create failed (%d)\n", rc, 0, 0 ); diff --git a/servers/slapd/back-ldbm/key.c b/servers/slapd/back-ldbm/key.c new file mode 100644 index 0000000000000000000000000000000000000000..0ea188a473bdf1c6f3d185da46c0ffa41495683c --- /dev/null +++ b/servers/slapd/back-ldbm/key.c @@ -0,0 +1,104 @@ +/* index.c - routines for dealing with attribute indexes */ +/* $OpenLDAP$ */ +/* + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ + +#include "portable.h" + +#include <stdio.h> + +#include <ac/string.h> +#include <ac/socket.h> + +#include "slap.h" +#include "back-ldbm.h" + +/* read a key */ +int +key_read( + Backend *be, + DBCache *db, + struct berval *k, + ID_BLOCK **idout +) +{ + Datum key; + ID_BLOCK *idl; + +#ifdef NEW_LOGGING + LDAP_LOG( INDEX, ENTRY, "key_read: enter\n", 0, 0, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, "=> key_read\n", 0, 0, 0 ); +#endif + + + ldbm_datum_init( key ); + key.dptr = k->bv_val; + key.dsize = k->bv_len; + + idl = idl_fetch( be, db, key ); + +#ifdef NEW_LOGGING + LDAP_LOG( INDEX, ENTRY, + "key_read: %ld candidates\n", idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, "<= index_read %ld candidates\n", + idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 ); +#endif + + + *idout = idl; + return LDAP_SUCCESS; +} + +/* Add or remove stuff from index files */ +int +key_change( + Backend *be, + DBCache *db, + struct berval *k, + ID id, + int op +) +{ + int rc; + Datum key; + +#ifdef NEW_LOGGING + LDAP_LOG( INDEX, ENTRY, "key_change: %s ID %lx\n", + op == SLAP_INDEX_ADD_OP ? "Add" : "Delete", (long)id, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, "=> key_change(%s,%lx)\n", + op == SLAP_INDEX_ADD_OP ? "ADD":"DELETE", (long) id, 0 ); +#endif + + + ldbm_datum_init( key ); + key.dptr = k->bv_val; + key.dsize = k->bv_len; + + ldap_pvt_thread_mutex_lock( &db->dbc_write_mutex ); + if (op == SLAP_INDEX_ADD_OP) { + /* Add values */ + rc = idl_insert_key( be, db, key, id ); + + } else { + /* Delete values */ + rc = idl_delete_key( be, db, key, id ); + } + ldap_pvt_thread_mutex_unlock( &db->dbc_write_mutex ); + + +#ifdef NEW_LOGGING + LDAP_LOG( INDEX, ENTRY, "key_change: return %d\n", rc, 0, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, "<= key_change %d\n", rc, 0, 0 ); +#endif + + + ldap_pvt_thread_yield(); + + return rc; +} diff --git a/servers/slapd/back-ldbm/modify.c b/servers/slapd/back-ldbm/modify.c index 03f81b1687aa2675d3faa87f8f9577538e062331..a34cc06e979d6ed07a4d41966dd468b2f294f327 100644 --- a/servers/slapd/back-ldbm/modify.c +++ b/servers/slapd/back-ldbm/modify.c @@ -41,8 +41,7 @@ int ldbm_modify_internal( Attribute *ap; #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY, - "ldbm_modify_internal: %s\n", dn )); + LDAP_LOG( BACK_LDBM, ENTRY, "ldbm_modify_internal: %s\n", dn, 0, 0 ); #else Debug(LDAP_DEBUG_TRACE, "ldbm_modify_internal: %s\n", dn, 0, 0); #endif @@ -61,8 +60,7 @@ int ldbm_modify_internal( switch ( mod->sm_op ) { case LDAP_MOD_ADD: #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "ldbm_modify_internal: add\n" )); + LDAP_LOG( BACK_LDBM, DETAIL1, "ldbm_modify_internal: add\n", 0, 0, 0); #else Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: add\n", 0, 0, 0); #endif @@ -70,9 +68,8 @@ int ldbm_modify_internal( rc = modify_add_values( e, mod, text, textbuf, textlen ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "ldbm_modify_internal: failed %d (%s)\n", - rc, *text )); + LDAP_LOG( BACK_LDBM, INFO, + "ldbm_modify_internal: failed %d (%s)\n", rc, *text, 0 ); #else Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: %d %s\n", rc, *text, 0); @@ -82,8 +79,7 @@ int ldbm_modify_internal( case LDAP_MOD_DELETE: #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "ldbm_modify_internal: delete\n" )); + LDAP_LOG( BACK_LDBM, DETAIL1, "ldbm_modify_internal: delete\n", 0,0,0); #else Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: delete\n", 0, 0, 0); #endif @@ -92,8 +88,8 @@ int ldbm_modify_internal( assert( rc != LDAP_TYPE_OR_VALUE_EXISTS ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "ldbm_modify_internal: failed %d (%s)\n", rc, *text )); + LDAP_LOG( BACK_LDBM, INFO, + "ldbm_modify_internal: failed %d (%s)\n", rc, *text, 0 ); #else Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: %d %s\n", rc, *text, 0); @@ -103,8 +99,7 @@ int ldbm_modify_internal( case LDAP_MOD_REPLACE: #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "ldbm_modify_internal: replace\n" )); + LDAP_LOG( BACK_LDBM, DETAIL1, "ldbm_modify_internal: replace\n",0,0,0); #else Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: replace\n", 0, 0, 0); #endif @@ -112,8 +107,8 @@ int ldbm_modify_internal( rc = modify_replace_values( e, mod, text, textbuf, textlen ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "ldbm_modify_internal: failed %d (%s)\n", rc, *text )); + LDAP_LOG( BACK_LDBM, INFO, + "ldbm_modify_internal: failed %d (%s)\n", rc, *text, 0 ); #else Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: %d %s\n", rc, *text, 0); @@ -123,8 +118,8 @@ int ldbm_modify_internal( case SLAP_MOD_SOFTADD: #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "ldbm_modify_internal: softadd\n" )); + LDAP_LOG( BACK_LDBM, DETAIL1, + "ldbm_modify_internal: softadd\n", 0, 0, 0 ); #else Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: softadd\n", 0, 0, 0); #endif @@ -141,8 +136,8 @@ int ldbm_modify_internal( if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "ldbm_modify_internal: failed %d (%s)\n", rc, *text )); + LDAP_LOG( BACK_LDBM, INFO, + "ldbm_modify_internal: failed %d (%s)\n", rc, *text, 0 ); #else Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: %d %s\n", rc, *text, 0); @@ -152,8 +147,8 @@ int ldbm_modify_internal( default: #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_ERR, - "ldbm_modify_internal: invalid op %d\n", mod->sm_op )); + LDAP_LOG( BACK_LDBM, ERR, + "ldbm_modify_internal: invalid op %d\n", mod->sm_op, 0, 0 ); #else Debug(LDAP_DEBUG_ANY, "ldbm_modify_internal: invalid op %d\n", mod->sm_op, 0, 0); @@ -162,8 +157,8 @@ int ldbm_modify_internal( rc = LDAP_OTHER; *text = "Invalid modify operation"; #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "ldbm_modify_internal: %d (%s)\n", rc, *text )); + LDAP_LOG( BACK_LDBM, INFO, + "ldbm_modify_internal: %d (%s)\n", rc, *text, 0 ); #else Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: %d %s\n", rc, *text, 0); @@ -194,9 +189,9 @@ int ldbm_modify_internal( rc = entry_schema_check( be, e, save_attrs, text, textbuf, textlen ); if ( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_ERR, - "ldbm_modify_internal: entry failed schema check: %s\n", - *text )); + LDAP_LOG( BACK_LDBM, ERR, + "ldbm_modify_internal: entry failed schema check: %s\n", + *text, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "entry failed schema check: %s\n", *text, 0, 0 ); @@ -220,8 +215,9 @@ int ldbm_modify_internal( SLAP_INDEX_DELETE_OP ); if ( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_ERR, - "ldbm_modify_internal: Attribute index delete failure\n" )); + LDAP_LOG( BACK_LDBM, ERR, + "ldbm_modify_internal: Attribute index delete failure\n", + 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "Attribute index delete failure", @@ -240,8 +236,9 @@ int ldbm_modify_internal( SLAP_INDEX_ADD_OP ); if ( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_ERR, - "ldbm_modify_internal: Attribute index add failure\n" )); + LDAP_LOG( BACK_LDBM, ERR, + "ldbm_modify_internal: Attribute index add failure\n", + 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "Attribute index add failure", @@ -287,8 +284,7 @@ ldbm_back_modify( size_t textlen = sizeof textbuf; #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY, - "ldbm_back_modify: enter\n" )); + LDAP_LOG( BACK_LDBM, ENTRY, "ldbm_back_modify: enter\n", 0, 0, 0); #else Debug(LDAP_DEBUG_ARGS, "ldbm_back_modify:\n", 0, 0, 0); #endif @@ -329,8 +325,8 @@ ldbm_back_modify( conn, op, e ); #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "ldbm_back_modify: entry (%s) is referral\n", ndn->bv_val )); + LDAP_LOG( BACK_LDBM, INFO, + "ldbm_back_modify: entry (%s) is referral\n", ndn->bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0, 0, 0 ); diff --git a/servers/slapd/back-ldbm/modrdn.c b/servers/slapd/back-ldbm/modrdn.c index 59aee6894c5d6a2318369dc978ef29c46b4a4701..eb01cee71dfb28018ac3d06b4858fac0b735f0de 100644 --- a/servers/slapd/back-ldbm/modrdn.c +++ b/servers/slapd/back-ldbm/modrdn.c @@ -74,11 +74,10 @@ ldbm_back_modrdn( int manageDSAit = get_manageDSAit( op ); #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY, + LDAP_LOG( BACK_LDBM, ENTRY, "ldbm_back_modrdn: dn: %s newSuperior=%s\n", dn->bv_len ? dn->bv_val : "NULL", - ( newSuperior && newSuperior->bv_len ) - ? newSuperior->bv_val : "NULL" )); + ( newSuperior && newSuperior->bv_len ) ? newSuperior->bv_val : "NULL",0 ); #else Debug( LDAP_DEBUG_TRACE, "==>ldbm_back_modrdn: dn: %s newSuperior=%s\n", @@ -124,8 +123,8 @@ ldbm_back_modrdn( conn, op, e ); #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "ldbm_back_modrdn: entry %s is a referral\n", e->e_dn )); + LDAP_LOG( BACK_LDBM, INFO, + "ldbm_back_modrdn: entry %s is a referral\n", e->e_dn, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "entry %s is referral\n", e->e_dn, 0, 0 ); @@ -140,8 +139,8 @@ ldbm_back_modrdn( if ( has_children( be, e ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "ldbm_back_modrdn: entry %s has children\n", e->e_dn )); + LDAP_LOG( BACK_LDBM, INFO, + "ldbm_back_modrdn: entry %s has children\n", e->e_dn, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "entry %s has children\n", e->e_dn, 0, 0 ); @@ -165,8 +164,9 @@ ldbm_back_modrdn( if( (p = dn2entry_w( be, &p_ndn, NULL )) == NULL) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "ldbm_back_modrdn: parent of %s does not exist\n", e->e_ndn )); + LDAP_LOG( BACK_LDBM, INFO, + "ldbm_back_modrdn: parent of %s does not exist\n", + e->e_ndn, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "parent does not exist\n", 0, 0, 0); @@ -183,8 +183,9 @@ ldbm_back_modrdn( children, NULL, ACL_WRITE, NULL ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "ldbm_back_modrdn: no access to parent of (%s)\n", e->e_dn )); + LDAP_LOG( BACK_LDBM, INFO, + "ldbm_back_modrdn: no access to parent of (%s)\n", + e->e_dn, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "no access to parent\n", 0, 0, 0 ); @@ -196,9 +197,9 @@ ldbm_back_modrdn( } #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "ldbm_back_modrdn: wr to children of entry %s OK\n", - p_ndn.bv_val )); + LDAP_LOG( BACK_LDBM, DETAIL1, + "ldbm_back_modrdn: wr to children of entry %s OK\n", + p_ndn.bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: wr to children of entry %s OK\n", @@ -212,8 +213,8 @@ ldbm_back_modrdn( } #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "ldbm_back_modrdn: parent dn=%s\n", p_dn.bv_val )); + LDAP_LOG( BACK_LDBM, DETAIL1, + "ldbm_back_modrdn: parent dn=%s\n", p_dn.bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: parent dn=%s\n", p_dn.bv_val, 0, 0 ); @@ -233,9 +234,8 @@ ldbm_back_modrdn( /* check parent for "children" acl */ if ( ! rc ) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_ERR, - "ldbm_back_modrdn: no access " - "to parent \"\"\n" )); + LDAP_LOG( BACK_LDBM, ERR, + "ldbm_back_modrdn: no access to parent \"\"\n", 0,0,0 ); #else Debug( LDAP_DEBUG_TRACE, "<=- ldbm_back_modrdn: no " @@ -250,9 +250,9 @@ ldbm_back_modrdn( } else { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_ERR, - "ldbm_back_modrdn: (%s) has no " - "parent & not a root.\n", dn )); + LDAP_LOG( BACK_LDBM, ERR, + "ldbm_back_modrdn: (%s) has no parent & not a root.\n", + dn, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<=- ldbm_back_modrdn: no parent & " @@ -267,8 +267,8 @@ ldbm_back_modrdn( } #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "ldbm_back_modrdn: (%s) no parent, locked root.\n", e->e_dn )); + LDAP_LOG( BACK_LDBM, INFO, + "ldbm_back_modrdn: (%s) no parent, locked root.\n", e->e_dn, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: no parent, locked root\n", @@ -280,9 +280,9 @@ ldbm_back_modrdn( if ( newSuperior != NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, + LDAP_LOG( BACK_LDBM, DETAIL1, "ldbm_back_modrdn: new parent \"%s\" requested\n", - newSuperior->bv_val )); + newSuperior->bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: new parent \"%s\" requested...\n", @@ -294,10 +294,9 @@ ldbm_back_modrdn( /* newSuperior == oldParent? */ if ( dn_match( &p_ndn, np_ndn ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, "ldbm_back_modrdn: " + LDAP_LOG( BACK_LDBM, INFO, "ldbm_back_modrdn: " "new parent\"%s\" seems to be the same as the " - "old parent \"%s\"\n", - newSuperior->bv_val, p_dn.bv_val )); + "old parent \"%s\"\n", newSuperior->bv_val, p_dn.bv_val, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: " "new parent\"%s\" seems to be the same as the " @@ -316,8 +315,9 @@ ldbm_back_modrdn( if ( nnewSuperior->bv_len ) { if( (np = dn2entry_w( be, np_ndn, NULL )) == NULL) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_ERR, - "ldbm_back_modrdn: newSup(ndn=%s) not found.\n", np_ndn->bv_val )); + LDAP_LOG( BACK_LDBM, ERR, + "ldbm_back_modrdn: newSup(ndn=%s) not found.\n", + np_ndn->bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: newSup(ndn=%s) not here!\n", @@ -330,9 +330,9 @@ ldbm_back_modrdn( } #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, + LDAP_LOG( BACK_LDBM, DETAIL1, "ldbm_back_modrdn: wr to new parent OK np=%p, id=%ld\n", - np, np->e_id )); + np, np->e_id, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: wr to new parent OK np=%p, id=%ld\n", @@ -344,8 +344,8 @@ ldbm_back_modrdn( ACL_WRITE, NULL ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "ldbm_back_modrdn: no wr to newSup children.\n" )); + LDAP_LOG( BACK_LDBM, INFO, + "ldbm_back_modrdn: no wr to newSup children.\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: no wr to newSup children\n", @@ -360,8 +360,8 @@ ldbm_back_modrdn( if ( is_entry_alias( np ) ) { /* parent is an alias, don't allow add */ #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "ldbm_back_modrdn: entry (%s) is an alias.\n", np->e_dn )); + LDAP_LOG( BACK_LDBM, INFO, + "ldbm_back_modrdn: entry (%s) is an alias.\n", np->e_dn,0,0); #else Debug( LDAP_DEBUG_TRACE, "entry is alias\n", 0, 0, 0 ); #endif @@ -376,9 +376,9 @@ ldbm_back_modrdn( if ( is_entry_referral( np ) ) { /* parent is a referral, don't allow add */ #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, + LDAP_LOG( BACK_LDBM, INFO, "ldbm_back_modrdn: entry (%s) is a referral\n", - np->e_dn )); + np->e_dn, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "entry (%s) is referral\n", np->e_dn, 0, 0 ); @@ -408,9 +408,9 @@ ldbm_back_modrdn( /* check parent for "children" acl */ if ( ! rc ) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_ERR, + LDAP_LOG( BACK_LDBM, ERR, "ldbm_back_modrdn: no access " - "to new superior \"\"\n" )); + "to new superior \"\"\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<=- ldbm_back_modrdn: no " @@ -425,9 +425,9 @@ ldbm_back_modrdn( } else { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_ERR, - "ldbm_back_modrdn: \"\" " - "not allowed as new superior\n" )); + LDAP_LOG( BACK_LDBM, ERR, + "ldbm_back_modrdn: \"\" not allowed as new superior\n", + 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<=- ldbm_back_modrdn: \"\" " @@ -444,8 +444,8 @@ ldbm_back_modrdn( } #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "ldbm_back_modrdn: wr to new parent's children OK.\n" )); + LDAP_LOG( BACK_LDBM, DETAIL1, + "ldbm_back_modrdn: wr to new parent's children OK.\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: wr to new parent's children OK\n", @@ -460,8 +460,8 @@ ldbm_back_modrdn( dnNormalize2( NULL, &new_dn, &new_ndn ); #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "ldbm_back_modrdn: new ndn=%s\n", new_ndn.bv_val )); + LDAP_LOG( BACK_LDBM, DETAIL1, "ldbm_back_modrdn: new ndn=%s\n", + new_ndn.bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: new ndn=%s\n", new_ndn.bv_val, 0, 0 ); @@ -481,8 +481,8 @@ ldbm_back_modrdn( } #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "ldbm_back_modrdn: new ndn (%s) does not exist\n", new_ndn.bv_val )); + LDAP_LOG( BACK_LDBM, INFO, "ldbm_back_modrdn: new ndn (%s) does not exist\n", + new_ndn.bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: new ndn=%s does not exist\n", @@ -497,8 +497,9 @@ ldbm_back_modrdn( LDAP_DN_FORMAT_LDAP ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "ldbm_back_modrdn: can't figure out type(s)/value(s) of newrdn\n" )); + LDAP_LOG( BACK_LDBM, INFO, + "ldbm_back_modrdn: can't figure out type(s)/value(s) of newrdn\n", + 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: can't figure out type(s)/value(s) of newrdn\n", @@ -511,9 +512,9 @@ ldbm_back_modrdn( } #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "ldbm_back_modrdn: new_rdn_type=\"%s\", new_rdn_val=\"%s\"\n", - new_rdn[0][0]->la_attr.bv_val, new_rdn[0][0]->la_value.bv_val )); + LDAP_LOG( BACK_LDBM, DETAIL1, + "ldbm_back_modrdn: new_rdn_type=\"%s\", new_rdn_val=\"%s\"\n", + new_rdn[0][0]->la_attr.bv_val, new_rdn[0][0]->la_value.bv_val, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: new_rdn_type=\"%s\", new_rdn_val=\"%s\"\n", @@ -525,8 +526,9 @@ ldbm_back_modrdn( LDAP_DN_FORMAT_LDAP ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "ldbm_back_modrdn: can't figure out the old_rdn type(s)/value(s).\n" )); + LDAP_LOG( BACK_LDBM, INFO, + "ldbm_back_modrdn: can't figure out the old_rdn " + "type(s)/value(s).\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: can't figure out the old_rdn type(s)/value(s)\n", @@ -544,9 +546,9 @@ ldbm_back_modrdn( { /* Not a big deal but we may say something */ #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, + LDAP_LOG( BACK_LDBM, INFO, "ldbm_back_modrdn: old_rdn_type=%s new_rdn_type=%s\n", - old_rdn_types[0], new_rdn_types[0] )); + old_rdn_types[0], new_rdn_types[0], 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: old_rdn_type=%s, new_rdn_type=%s!\n", @@ -556,8 +558,7 @@ ldbm_back_modrdn( #endif #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "ldbm_back_modrdn: DN_X500\n" )); + LDAP_LOG( BACK_LDBM, DETAIL1, "ldbm_back_modrdn: DN_X500\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: DN_X500\n", 0, 0, 0 ); @@ -573,9 +574,9 @@ ldbm_back_modrdn( if ( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "ldbm_back_modrdn: slap_bv2ad error: %s (%s)\n", - text, new_rdn[0][a_cnt]->la_attr.bv_val )); + LDAP_LOG( BACK_LDBM, INFO, + "ldbm_back_modrdn: slap_bv2ad error: %s (%s)\n", + text, new_rdn[0][a_cnt]->la_attr.bv_val, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: %s: %s (new)\n", @@ -591,10 +592,9 @@ ldbm_back_modrdn( if ( ! access_allowed( be, conn, op, e, desc, &new_rdn[0][a_cnt]->la_value, ACL_WRITE, NULL ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "ldbm_back_modrdn: access " - "not allowed to attr \"%s\"\n", - new_rdn[0][a_cnt]->la_attr.bv_val )); + LDAP_LOG( BACK_LDBM, INFO, + "ldbm_back_modrdn: access not allowed to attr \"%s\"\n", + new_rdn[0][a_cnt]->la_attr.bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: access not allowed " @@ -624,8 +624,9 @@ ldbm_back_modrdn( /* Get value of old rdn */ if ( old_rdn == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "ldbm_back_modrdn: can't figure out old RDN value(s) from old RDN\n" )); + LDAP_LOG( BACK_LDBM, INFO, + "ldbm_back_modrdn: can't figure out old RDN value(s) " + "from old RDN\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: can't figure out oldRDN value(s) from old RDN\n", @@ -646,9 +647,9 @@ ldbm_back_modrdn( if ( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "ldbm_back_modrdn: %s: %s (old)\n", - text, old_rdn[0][d_cnt]->la_attr.bv_val )); + LDAP_LOG( BACK_LDBM, INFO, + "ldbm_back_modrdn: %s: %s (old)\n", + text, old_rdn[0][d_cnt]->la_attr.bv_val, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: %s: %s (old)\n", @@ -664,10 +665,9 @@ ldbm_back_modrdn( if ( ! access_allowed( be, conn, op, e, desc, &old_rdn[0][d_cnt]->la_value, ACL_WRITE, NULL ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "ldbm_back_modrdn: access " - "not allowed to attr \"%s\"\n", - old_rdn[0][d_cnt]->la_attr.bv_val )); + LDAP_LOG( BACK_LDBM, INFO, + "ldbm_back_modrdn: access not allowed to attr \"%s\"\n", + old_rdn[0][d_cnt]->la_attr.bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: access not allowed " @@ -693,8 +693,9 @@ ldbm_back_modrdn( mod = mod_tmp; #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "ldbm_back_modrdn: removing old_rdn_val=%s\n", old_rdn[0][d_cnt]->la_value.bv_val )); + LDAP_LOG( BACK_LDBM, DETAIL1, + "ldbm_back_modrdn: removing old_rdn_val=%s\n", + old_rdn[0][d_cnt]->la_value.bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: removing old_rdn_val=%s\n", diff --git a/servers/slapd/back-ldbm/nextid.c b/servers/slapd/back-ldbm/nextid.c index e51f4d84e76ce4de24f4dc6a4819befdc4cc3deb..8159ccf39ba8abfd20d1a0703ed32fe815743676 100644 --- a/servers/slapd/back-ldbm/nextid.c +++ b/servers/slapd/back-ldbm/nextid.c @@ -1,132 +1,136 @@ -/* id.c - keep track of the next id to be given out */ +/* nextid.c - keep track of the next id to be given out */ +/* $OpenLDAP$ */ +/* + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ + +#include "portable.h" #include <stdio.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <sys/param.h> + +#include <ac/string.h> +#include <ac/socket.h> +#include <ac/param.h> + #include "slap.h" #include "back-ldbm.h" -ID -next_id( Backend *be ) +static int +next_id_read( Backend *be, ID *idp ) { - struct ldbminfo *li = (struct ldbminfo *) be->be_private; - char buf[MAXPATHLEN]; - char buf2[20]; - FILE *fp; - ID id; - - sprintf( buf, "%s/NEXTID", li->li_directory ); - - pthread_mutex_lock( &li->li_nextid_mutex ); - /* first time in here since startup - try to read the nexid */ - if ( li->li_nextid == -1 ) { - if ( (fp = fopen( buf, "r" )) == NULL ) { - Debug( LDAP_DEBUG_ANY, - "next_id %d: could not open \"%s\"\n", - li->li_nextid, buf, 0 ); - li->li_nextid = 1; - } else { - if ( fgets( buf2, sizeof(buf2), fp ) != NULL ) { - li->li_nextid = atol( buf2 ); - } else { - Debug( LDAP_DEBUG_ANY, - "next_id %d: could not fgets nextid from \"%s\"\n", - li->li_nextid, buf2, 0 ); - li->li_nextid = 1; - } - fclose( fp ); - } + Datum key, data; + DBCache *db; + + *idp = NOID; + + if ( (db = ldbm_cache_open( be, "nextid", LDBM_SUFFIX, LDBM_WRCREAT )) + == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, CRIT, + "next_id_read: could not open/create nextid%s\n", LDBM_SUFFIX, 0, 0 ); +#else + Debug( LDAP_DEBUG_ANY, "Could not open/create nextid" LDBM_SUFFIX "\n", + 0, 0, 0 ); +#endif + + return( -1 ); } - li->li_nextid++; - if ( (fp = fopen( buf, "w" )) == NULL ) { - Debug( LDAP_DEBUG_ANY, "next_id %d: could not open \"%s\"\n", - li->li_nextid, buf, 0 ); + ldbm_datum_init( key ); + key.dptr = (char *) idp; + key.dsize = sizeof(ID); + + data = ldbm_cache_fetch( db, key ); + + if( data.dptr != NULL ) { + AC_MEMCPY( idp, data.dptr, sizeof( ID ) ); + ldbm_datum_free( db->dbc_db, data ); + } else { - if ( fprintf( fp, "%ld\n", li->li_nextid ) == EOF ) { - Debug( LDAP_DEBUG_ANY, "next_id %d: cannot fprintf\n", - li->li_nextid, 0, 0 ); - } - if( fclose( fp ) != 0 ) { - Debug( LDAP_DEBUG_ANY, "next_id %d: cannot fclose\n", - li->li_nextid, 0, 0 ); - } + *idp = 1; } - id = li->li_nextid - 1; - pthread_mutex_unlock( &li->li_nextid_mutex ); - return( id ); + ldbm_cache_close( be, db ); + return( 0 ); } -void -next_id_return( Backend *be, ID id ) +int +next_id_write( Backend *be, ID id ) { - struct ldbminfo *li = (struct ldbminfo *) be->be_private; - char buf[MAXPATHLEN]; - FILE *fp; + Datum key, data; + DBCache *db; + ID noid = NOID; + int flags, rc = 0; - pthread_mutex_lock( &li->li_nextid_mutex ); - if ( id != li->li_nextid - 1 ) { - pthread_mutex_unlock( &li->li_nextid_mutex ); - return; + if ( (db = ldbm_cache_open( be, "nextid", LDBM_SUFFIX, LDBM_WRCREAT )) + == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, CRIT, + "next_id_write: Could not open/create nextid%s\n", LDBM_SUFFIX, 0, 0 ); +#else + Debug( LDAP_DEBUG_ANY, "Could not open/create nextid" LDBM_SUFFIX "\n", + 0, 0, 0 ); +#endif + + return( -1 ); } - sprintf( buf, "%s/NEXTID", li->li_directory ); + ldbm_datum_init( key ); + ldbm_datum_init( data ); - li->li_nextid--; - if ( (fp = fopen( buf, "w" )) == NULL ) { - Debug( LDAP_DEBUG_ANY, - "next_id_return of %d: could not open \"%s\" next id %d\n", - id, buf, li->li_nextid ); - } else { - if ( fprintf( fp, "%ld\n", li->li_nextid ) == EOF ) { - Debug( LDAP_DEBUG_ANY, - "next_id_return of %d: cannot fprintf \"%s\" next id %d\n", - id, buf, li->li_nextid ); - } - if( fclose( fp ) != 0 ) { - Debug( LDAP_DEBUG_ANY, - "next_id_return of %d: cannot fclose \"%s\" next id %d\n", - id, buf, li->li_nextid ); + key.dptr = (char *) &noid; + key.dsize = sizeof(ID); + + data.dptr = (char *) &id; + data.dsize = sizeof(ID); + + flags = LDBM_REPLACE; + if ( ldbm_cache_store( db, key, data, flags ) != 0 ) { + rc = -1; + } + + ldbm_cache_close( be, db ); + return( rc ); +} + +int +next_id_get( Backend *be, ID *idp ) +{ + struct ldbminfo *li = (struct ldbminfo *) be->be_private; + int rc = 0; + + *idp = NOID; + + if ( li->li_nextid == NOID ) { + if ( ( rc = next_id_read( be, idp ) ) ) { + return( rc ); } + li->li_nextid = *idp; } - pthread_mutex_unlock( &li->li_nextid_mutex ); + + *idp = li->li_nextid; + + return( rc ); } -ID -next_id_get( Backend *be ) +int +next_id( Backend *be, ID *idp ) { struct ldbminfo *li = (struct ldbminfo *) be->be_private; - char buf[MAXPATHLEN]; - char buf2[20]; - FILE *fp; - ID id; - - sprintf( buf, "%s/NEXTID", li->li_directory ); - - pthread_mutex_lock( &li->li_nextid_mutex ); - /* first time in here since startup - try to read the nexid */ - if ( li->li_nextid == -1 ) { - if ( (fp = fopen( buf, "r" )) == NULL ) { - Debug( LDAP_DEBUG_ANY, - "next_id %d: could not open \"%s\"\n", - li->li_nextid, buf, 0 ); - li->li_nextid = 1; - } else { - if ( fgets( buf2, sizeof(buf2), fp ) != NULL ) { - li->li_nextid = atol( buf2 ); - } else { - Debug( LDAP_DEBUG_ANY, - "next_id %d: cannot fgets nextid from \"%s\"\n", - li->li_nextid, buf2, 0 ); - li->li_nextid = 1; - } - fclose( fp ); + int rc = 0; + + if ( li->li_nextid == NOID ) { + if ( ( rc = next_id_read( be, idp ) ) ) { + return( rc ); } + li->li_nextid = *idp; + } + + *idp = li->li_nextid++; + if ( next_id_write( be, li->li_nextid ) ) { + rc = -1; } - id = li->li_nextid; - pthread_mutex_unlock( &li->li_nextid_mutex ); - return( id ); + return( rc ); } diff --git a/servers/slapd/back-ldbm/passwd.c b/servers/slapd/back-ldbm/passwd.c index ae0f245858baf04814381e36a3d84261622085b1..e7df1ae28fa5e3249901e93dace665fa0ff3eb1f 100644 --- a/servers/slapd/back-ldbm/passwd.c +++ b/servers/slapd/back-ldbm/passwd.c @@ -48,9 +48,8 @@ ldbm_back_exop_passwd( &id, NULL, &new, text ); #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY, - "ldbm_back_exop_passwd: \"%s\"\n", - id.bv_val ? id.bv_val : "" )); + LDAP_LOG( BACK_LDBM, ENTRY, + "ldbm_back_exop_passwd: \"%s\"\n", id.bv_val ? id.bv_val : "", 0,0 ); #else Debug( LDAP_DEBUG_ARGS, "==> ldbm_back_exop_passwd: \"%s\"\n", id.bv_val ? id.bv_val : "", 0, 0 ); @@ -88,9 +87,9 @@ ldbm_back_exop_passwd( } #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, + LDAP_LOG( BACK_LDBM, DETAIL1, "ldbm_back_exop_passwd: \"%s\"%s\n", - dn.bv_val, id.bv_len ? " (proxy)" : "" )); + dn.bv_val, id.bv_len ? " (proxy)" : "", 0 ); #else Debug( LDAP_DEBUG_TRACE, "passwd: \"%s\"%s\n", dn.bv_val, id.bv_len ? " (proxy)" : "", 0 ); diff --git a/servers/slapd/back-ldbm/referral.c b/servers/slapd/back-ldbm/referral.c new file mode 100644 index 0000000000000000000000000000000000000000..a1e34bd5b830b4019ff9f4d2c88d52d3bfdc6746 --- /dev/null +++ b/servers/slapd/back-ldbm/referral.c @@ -0,0 +1,128 @@ +/* referral.c - LDBM backend referral handler */ +/* $OpenLDAP$ */ +/* + * Copyright 2000-2002 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ + +#include "portable.h" + +#include <stdio.h> + +#include <ac/string.h> +#include <ac/socket.h> + +#include "slap.h" +#include "back-ldbm.h" + +int +ldbm_back_referrals( + Backend *be, + Connection *conn, + Operation *op, + struct berval *dn, + struct berval *ndn, + const char **text ) +{ + struct ldbminfo *li = (struct ldbminfo *) be->be_private; + int rc = LDAP_SUCCESS; + Entry *e, *matched; + + if( op->o_tag == LDAP_REQ_SEARCH ) { + /* let search take care of itself */ + return rc; + } + + if( get_manageDSAit( op ) ) { + /* let op take care of DSA management */ + return rc; + } + + /* grab giant lock for reading */ + ldap_pvt_thread_rdwr_rlock(&li->li_giant_rwlock); + + /* get entry with reader lock */ + e = dn2entry_r( be, ndn, &matched ); + if ( e == NULL ) { + char *matched_dn = NULL; + BerVarray refs = NULL; + + if ( matched != NULL ) { + matched_dn = ch_strdup( matched->e_dn ); + +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, DETAIL1, + "ldbm_back_referrals: op=%ld target=\"%s\" matched=\"%s\"\n", + op->o_tag, dn->bv_val, matched_dn ); +#else + Debug( LDAP_DEBUG_TRACE, + "ldbm_referrals: op=%ld target=\"%s\" matched=\"%s\"\n", + op->o_tag, dn->bv_val, matched_dn ); +#endif + + if( is_entry_referral( matched ) ) { + rc = LDAP_OTHER; + refs = get_entry_referrals( be, conn, op, matched ); + } + + cache_return_entry_r( &li->li_cache, matched ); + + } else if ( default_referral != NULL ) { + rc = LDAP_OTHER; + refs = referral_rewrite( default_referral, + NULL, dn, LDAP_SCOPE_DEFAULT ); + } + + ldap_pvt_thread_rdwr_runlock(&li->li_giant_rwlock); + + if( refs != NULL ) { + /* send referrals */ + send_ldap_result( conn, op, rc = LDAP_REFERRAL, + matched_dn, NULL, refs, NULL ); + ber_bvarray_free( refs ); + + } else if ( rc != LDAP_SUCCESS ) { + send_ldap_result( conn, op, rc, matched_dn, + matched_dn ? "bad referral object" : "bad default referral", + NULL, NULL ); + } + + if ( matched_dn ) free( matched_dn ); + return rc; + } + + if ( is_entry_referral( e ) ) { + /* entry is a referral */ + BerVarray refs = get_entry_referrals( be, conn, op, e ); + BerVarray rrefs = referral_rewrite( + refs, &e->e_name, dn, LDAP_SCOPE_DEFAULT ); + +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, DETAIL1, + "ldbm_referrals: op=%ld target=\"%s\" matched=\"%s\"\n", + op->o_tag, dn->bv_val, e->e_dn ); +#else + Debug( LDAP_DEBUG_TRACE, + "ldbm_referrals: op=%ld target=\"%s\" matched=\"%s\"\n", + op->o_tag, dn->bv_val, e->e_dn ); +#endif + + if( rrefs != NULL ) { + send_ldap_result( conn, op, rc = LDAP_REFERRAL, + e->e_dn, NULL, rrefs, NULL ); + + ber_bvarray_free( rrefs ); + + } else { + send_ldap_result( conn, op, rc = LDAP_OTHER, e->e_dn, + "bad referral object", NULL, NULL ); + } + + if( refs != NULL ) ber_bvarray_free( refs ); + } + + cache_return_entry_r( &li->li_cache, e ); + ldap_pvt_thread_rdwr_runlock(&li->li_giant_rwlock); + + return rc; +} diff --git a/servers/slapd/back-ldbm/search.c b/servers/slapd/back-ldbm/search.c index 91549f1b8b4c8d4a2d3b013df766e0e304ce1920..87f4b9278b1676360089b3b42d5fd18445464e53 100644 --- a/servers/slapd/back-ldbm/search.c +++ b/servers/slapd/back-ldbm/search.c @@ -58,8 +58,7 @@ ldbm_back_search( int isroot = 0; #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY, - "ldbm_back_search: enter\n" )); + LDAP_LOG( BACK_LDBM, ENTRY, "ldbm_back_search: enter\n", 0, 0, 0 ); #else Debug(LDAP_DEBUG_TRACE, "=> ldbm_back_search\n", 0, 0, 0); #endif @@ -142,9 +141,9 @@ ldbm_back_search( ldap_pvt_thread_rdwr_runlock(&li->li_giant_rwlock); #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, + LDAP_LOG( BACK_LDBM, INFO, "ldbm_search: entry (%s) is a referral.\n", - e->e_dn )); + e->e_dn, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldbm_search: entry is referral\n", @@ -198,8 +197,8 @@ searchit: if ( candidates == NULL ) { /* no candidates */ #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "ldbm_search: no candidates\n" )); + LDAP_LOG( BACK_LDBM, INFO, + "ldbm_search: no candidates\n" , 0, 0, 0); #else Debug( LDAP_DEBUG_TRACE, "ldbm_search: no candidates\n", 0, 0, 0 ); @@ -313,8 +312,8 @@ searchit: if ( e == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "ldbm_search: candidate %ld not found.\n", id )); + LDAP_LOG( BACK_LDBM, INFO, + "ldbm_search: candidate %ld not found.\n", id, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldbm_search: candidate %ld not found\n", @@ -352,8 +351,8 @@ searchit: } else if ( dnIsSuffix( &e->e_nname, &realbase ) ) { /* alias is within scope */ #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "ldbm_search: alias \"%s\" in subtree\n", e->e_dn )); + LDAP_LOG( BACK_LDBM, DETAIL1, + "ldbm_search: alias \"%s\" in subtree\n", e->e_dn, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldbm_search: alias \"%s\" in subtree\n", @@ -408,9 +407,9 @@ searchit: } else { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL2, + LDAP_LOG( BACK_LDBM, DETAIL2, "ldbm_search: candidate referral %ld scope not okay\n", - id )); + id, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldbm_search: candidate referral %ld scope not okay\n", @@ -470,8 +469,9 @@ searchit: } } else { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL2, - "ldbm_search: candidate entry %ld scope not okay\n", id )); + LDAP_LOG( BACK_LDBM, DETAIL2, + "ldbm_search: candidate entry %ld scope not okay\n", + id, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldbm_search: candidate entry %ld scope not okay\n", @@ -481,8 +481,9 @@ searchit: } else { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL2, - "ldbm_search: candidate entry %ld does not match filter\n", id )); + LDAP_LOG( BACK_LDBM, DETAIL2, + "ldbm_search: candidate entry %ld does not match filter\n", + id, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldbm_search: candidate entry %ld does not match filter\n", @@ -525,8 +526,7 @@ base_candidate( ID_BLOCK *idl; #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY, - "base_candidate: base (%s)\n", e->e_dn )); + LDAP_LOG( BACK_LDBM, ENTRY, "base_candidate: base (%s)\n", e->e_dn, 0, 0 ); #else Debug(LDAP_DEBUG_TRACE, "base_candidates: base: \"%s\"\n", e->e_dn, 0, 0); @@ -555,9 +555,9 @@ search_candidates( struct berval bv_alias = { sizeof("ALIAS")-1, "ALIAS" }; #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, + LDAP_LOG( BACK_LDBM, DETAIL1, "search_candidates: base (%s) scope %d deref %d\n", - e->e_ndn, scope, deref )); + e->e_ndn, scope, deref ); #else Debug(LDAP_DEBUG_TRACE, "search_candidates: base=\"%s\" s=%d d=%d\n", diff --git a/servers/slapd/back-ldbm/tools.c b/servers/slapd/back-ldbm/tools.c new file mode 100644 index 0000000000000000000000000000000000000000..5d0855bfe53ed749a95d6268b5d6b0854fa572e8 --- /dev/null +++ b/servers/slapd/back-ldbm/tools.c @@ -0,0 +1,325 @@ +/* tools.c - tools for slap tools */ +/* $OpenLDAP$ */ +/* + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ + +#include "portable.h" + +#include <stdio.h> + +#include <ac/string.h> +#include <ac/socket.h> + +#include "slap.h" +#include "back-ldbm.h" + +static LDBMCursor *cursorp = NULL; +static DBCache *id2entry = NULL; + +int ldbm_tool_entry_open( + BackendDB *be, int mode ) +{ + struct ldbminfo *li = (struct ldbminfo *) be->be_private; + int flags; + + assert( slapMode & SLAP_TOOL_MODE ); + assert( id2entry == NULL ); + + switch( mode ) { + case 1: + flags = LDBM_WRCREAT; + break; + case 2: +#ifdef TRUNCATE_MODE + flags = LDBM_NEWDB; +#else + flags = LDBM_WRCREAT; +#endif + break; + default: + flags = LDBM_READER; + } + + li->li_dbwritesync = 0; + + if ( (id2entry = ldbm_cache_open( be, "id2entry", LDBM_SUFFIX, flags )) + == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, CRIT, + "Could not open/create id2entry%s\n", LDBM_SUFFIX, 0, 0 ); +#else + Debug( LDAP_DEBUG_ANY, "Could not open/create id2entry" LDBM_SUFFIX "\n", + 0, 0, 0 ); +#endif + + return( -1 ); + } + + return 0; +} + +int ldbm_tool_entry_close( + BackendDB *be ) +{ + struct ldbminfo *li = (struct ldbminfo *) be->be_private; + + assert( slapMode & SLAP_TOOL_MODE ); + assert( id2entry != NULL ); + + ldbm_cache_close( be, id2entry ); + li->li_dbwritesync = 1; + id2entry = NULL; + + return 0; +} + +ID ldbm_tool_entry_first( + BackendDB *be ) +{ + Datum key; + ID id; + + assert( slapMode & SLAP_TOOL_MODE ); + assert( id2entry != NULL ); + + key = ldbm_firstkey( id2entry->dbc_db, &cursorp ); + + if( key.dptr == NULL ) { + return NOID; + } + + AC_MEMCPY( &id, key.dptr, key.dsize ); +#ifndef WORDS_BIGENDIAN + id = ntohl( id ); +#endif + + ldbm_datum_free( id2entry->dbc_db, key ); + + return id; +} + +ID ldbm_tool_entry_next( + BackendDB *be ) +{ + Datum key; + ID id; + + assert( slapMode & SLAP_TOOL_MODE ); + assert( id2entry != NULL ); + + /* allow for NEXTID */ + ldbm_datum_init( key ); + + key = ldbm_nextkey( id2entry->dbc_db, key, cursorp ); + + if( key.dptr == NULL ) { + return NOID; + } + + AC_MEMCPY( &id, key.dptr, key.dsize ); +#ifndef WORDS_BIGENDIAN + id = ntohl( id ); +#endif + + ldbm_datum_free( id2entry->dbc_db, key ); + + return id; +} + +Entry* ldbm_tool_entry_get( BackendDB *be, ID id ) +{ + Entry *e; + Datum key, data; +#ifndef WORDS_BIGENDIAN + ID id2; +#endif + assert( slapMode & SLAP_TOOL_MODE ); + assert( id2entry != NULL ); + + ldbm_datum_init( key ); + +#ifndef WORDS_BIGENDIAN + id2 = htonl( id ); + key.dptr = (char *) &id2; +#else + key.dptr = (char *) &id; +#endif + key.dsize = sizeof(ID); + + data = ldbm_cache_fetch( id2entry, key ); + + if ( data.dptr == NULL ) { + return NULL; + } + + e = str2entry( data.dptr ); + ldbm_datum_free( id2entry->dbc_db, data ); + + if( e != NULL ) { + e->e_id = id; + } + + return e; +} + +ID ldbm_tool_entry_put( + BackendDB *be, + Entry *e, + struct berval *text ) +{ + struct ldbminfo *li = (struct ldbminfo *) be->be_private; + Datum key, data; + int rc, len; + ID id; + + assert( slapMode & SLAP_TOOL_MODE ); + assert( id2entry != NULL ); + + assert( text ); + assert( text->bv_val ); + assert( text->bv_val[0] == '\0' ); + + if ( next_id_get( be, &id ) || id == NOID ) { + strncpy( text->bv_val, "unable to get nextid", text->bv_len ); + return NOID; + } + + e->e_id = li->li_nextid++; + +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ENTRY, + "ldbm_tool_entry_put: (%s)%ld\n", e->e_dn, e->e_id ,0 ); +#else + Debug( LDAP_DEBUG_TRACE, "=> ldbm_tool_entry_put( %ld, \"%s\" )\n", + e->e_id, e->e_dn, 0 ); +#endif + + if ( dn2id( be, &e->e_nname, &id ) ) { + /* something bad happened to ldbm cache */ + strncpy( text->bv_val, "ldbm cache corrupted", text->bv_len ); + return NOID; + } + + if( id != NOID ) { +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ENTRY, + "ldbm_tool_entry_put: \"%s\" already exists (id=%ld)\n", + e->e_dn, id, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, + "<= ldbm_tool_entry_put: \"%s\" already exists (id=%ld)\n", + e->e_ndn, id, 0 ); +#endif + strncpy( text->bv_val, "already exists", text->bv_len ); + return NOID; + } + + rc = index_entry_add( be, e, e->e_attrs ); + if( rc != 0 ) { + strncpy( text->bv_val, "index add failed", text->bv_len ); + return NOID; + } + + rc = dn2id_add( be, &e->e_nname, e->e_id ); + if( rc != 0 ) { + strncpy( text->bv_val, "dn2id add failed", text->bv_len ); + return NOID; + } + + ldbm_datum_init( key ); + ldbm_datum_init( data ); + +#ifndef WORDS_BIGENDIAN + id = htonl( e->e_id ); + key.dptr = (char *) &id; +#else + key.dptr = (char *) &e->e_id; +#endif + key.dsize = sizeof(ID); + + data.dptr = entry2str( e, &len ); + data.dsize = len + 1; + + /* store it */ + rc = ldbm_cache_store( id2entry, key, data, LDBM_REPLACE ); + + if( rc != 0 ) { + (void) dn2id_delete( be, &e->e_nname, e->e_id ); + strncpy( text->bv_val, "cache store failed", text->bv_len ); + return NOID; + } + + return e->e_id; +} + +int ldbm_tool_entry_reindex( + BackendDB *be, + ID id ) +{ + int rc; + Entry *e; + +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ENTRY, "ldbm_tool_entry_reindex: ID=%ld\n", + (long)id, 0, 0 ); +#else + Debug( LDAP_DEBUG_ARGS, "=> ldbm_tool_entry_reindex( %ld )\n", + (long) id, 0, 0 ); +#endif + + + e = ldbm_tool_entry_get( be, id ); + + if( e == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, INFO, + "ldbm_tool_entry_reindex: could not locate id %ld\n", + (long)id, 0, 0 ); +#else + Debug( LDAP_DEBUG_ANY, + "ldbm_tool_entry_reindex:: could not locate id=%ld\n", + (long) id, 0, 0 ); +#endif + + return -1; + } + + /* + * just (re)add them for now + * assume that some other routine (not yet implemented) + * will zap index databases + * + */ + +#ifdef NEW_LOGGING + LDAP_LOG( BACK_LDBM, ENTRY, + "ldbm_tool_entry_reindex: (%s) %ld\n", e->e_dn, id, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, "=> ldbm_tool_entry_reindex( %ld, \"%s\" )\n", + id, e->e_dn, 0 ); +#endif + + dn2id_add( be, &e->e_nname, e->e_id ); + rc = index_entry_add( be, e, e->e_attrs ); + + entry_free( e ); + + return rc; +} + +int ldbm_tool_sync( BackendDB *be ) +{ + struct ldbminfo *li = (struct ldbminfo *) be->be_private; + + assert( slapMode & SLAP_TOOL_MODE ); + + if ( li->li_nextid != NOID ) { + if ( next_id_write( be, li->li_nextid ) ) { + return( -1 ); + } + } + + return 0; +} diff --git a/servers/slapd/back-meta/add.c b/servers/slapd/back-meta/add.c new file mode 100644 index 0000000000000000000000000000000000000000..ce3d73fecdb4175218be7f7343a1fc638c5ee778 --- /dev/null +++ b/servers/slapd/back-meta/add.c @@ -0,0 +1,214 @@ +/* + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + * + * Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it> + * + * This work has been developed to fulfill the requirements + * of SysNet s.n.c. <http:www.sys-net.it> and it has been donated + * to the OpenLDAP Foundation in the hope that it may be useful + * to the Open Source community, but WITHOUT ANY WARRANTY. + * + * Permission is granted to anyone to use this software for any purpose + * on any computer system, and to alter it and redistribute it, subject + * to the following restrictions: + * + * 1. The author and SysNet s.n.c. are not responsible for the consequences + * of use of this software, no matter how awful, even if they arise from + * flaws in it. + * + * 2. The origin of this software must not be misrepresented, either by + * explicit claim or by omission. Since few users ever read sources, + * credits should appear in the documentation. + * + * 3. Altered versions must be plainly marked as such, and must not be + * misrepresented as being the original software. Since few users + * ever read sources, credits should appear in the documentation. + * SysNet s.n.c. cannot be responsible for the consequences of the + * alterations. + * + * 4. This notice may not be removed or altered. + * + * + * This software is based on the backend back-ldap, implemented + * by Howard Chu <hyc@highlandsun.com>, and modified by Mark Valence + * <kurash@sassafras.com>, Pierangelo Masarati <ando@sys-net.it> and other + * contributors. The contribution of the original software to the present + * implementation is acknowledged in this copyright statement. + * + * A special acknowledgement goes to Howard for the overall architecture + * (and for borrowing large pieces of code), and to Mark, who implemented + * from scratch the attribute/objectclass mapping. + * + * The original copyright statement follows. + * + * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com> + * + * Permission is granted to anyone to use this software for any purpose + * on any computer system, and to alter it and redistribute it, subject + * to the following restrictions: + * + * 1. The author is not responsible for the consequences of use of this + * software, no matter how awful, even if they arise from flaws in it. + * + * 2. The origin of this software must not be misrepresented, either by + * explicit claim or by omission. Since few users ever read sources, + * credits should appear in the documentation. + * + * 3. Altered versions must be plainly marked as such, and must not be + * misrepresented as being the original software. Since few users + * ever read sources, credits should appear in the + * documentation. + * + * 4. This notice may not be removed or altered. + * + */ + + +#include "portable.h" + +#include <stdio.h> + +#include <ac/string.h> +#include <ac/socket.h> + +#include "slap.h" +#include "../back-ldap/back-ldap.h" +#include "back-meta.h" + +int +meta_back_add( + Backend *be, + Connection *conn, + Operation *op, + Entry *e +) +{ + struct metainfo *li = ( struct metainfo * )be->be_private; + struct metaconn *lc; + int i, candidate = -1; + Attribute *a; + LDAPMod **attrs; + struct berval mdn = { 0, NULL }, mapped; + +#ifdef NEW_LOGGING + LDAP_LOG( BACK_META, ENTRY, "meta_back_add: %s\n", e->e_dn, 0, 0 ); +#else /* !NEW_LOGGING */ + Debug(LDAP_DEBUG_ARGS, "==> meta_back_add: %s\n%s%s", e->e_dn, "", ""); +#endif /* !NEW_LOGGING */ + + /* + * get the current connection + */ + lc = meta_back_getconn( li, conn, op, META_OP_REQUIRE_SINGLE, + &e->e_nname, &candidate ); + if ( !lc || !meta_back_dobind( lc, op ) || !meta_back_is_valid( lc, candidate ) ) { + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, NULL, NULL, NULL ); + return -1; + } + + /* + * Rewrite the add dn, if needed + */ + switch ( rewrite_session( li->targets[ candidate ]->rwinfo, + "addDn", e->e_dn, conn, &mdn.bv_val )) { + case REWRITE_REGEXEC_OK: + if ( mdn.bv_val != NULL && mdn.bv_val[ 0 ] != '\0' ) { + mdn.bv_len = strlen( mdn.bv_val ); + } else { + mdn = e->e_name; + } + +#ifdef NEW_LOGGING + LDAP_LOG( BACK_META, DETAIL1, + "[rw] addDn: \"%s\" -> \"%s\"\n", e->e_dn, mdn.bv_val, 0 ); +#else /* !NEW_LOGGING */ + Debug( LDAP_DEBUG_ARGS, "rw> addDn: \"%s\" -> \"%s\"\n%s", + e->e_dn, mdn.bv_val, "" ); +#endif /* !NEW_LOGGING */ + break; + + case REWRITE_REGEXEC_UNWILLING: + send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, + NULL, NULL, NULL, NULL ); + return -1; + + case REWRITE_REGEXEC_ERR: + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, NULL, NULL, NULL ); + return -1; + } + + /* Count number of attributes in entry */ + for ( i = 1, a = e->e_attrs; a; i++, a = a->a_next ); + + /* Create array of LDAPMods for ldap_add() */ + attrs = ch_malloc( sizeof( LDAPMod * )*i ); + + for ( i = 0, a = e->e_attrs; a; a = a->a_next ) { + int j; + /* + * lastmod should always be <off>, so that + * creation/modification operational attrs + * of the target directory are used, if available + */ +#if 0 + if ( !strcasecmp( a->a_desc->ad_cname.bv_val, + slap_schema.si_ad_creatorsName->ad_cname.bv_val ) + || !strcasecmp( a->a_desc->ad_cname.bv_val, + slap_schema.si_ad_createTimestamp->ad_cname.bv_val ) + || !strcasecmp( a->a_desc->ad_cname.bv_val, + slap_schema.si_ad_modifiersName->ad_cname.bv_val ) + || !strcasecmp( a->a_desc->ad_cname.bv_val, + slap_schema.si_ad_modifyTimestamp->ad_cname.bv_val ) + ) { + continue; + } +#endif + + ldap_back_map( &li->targets[ candidate ]->at_map, + &a->a_desc->ad_cname, &mapped, 0); + if ( mapped.bv_val == NULL ) { + continue; + } + + attrs[ i ] = ch_malloc( sizeof( LDAPMod ) ); + if ( attrs[ i ] == NULL ) { + continue; + } + attrs[ i ]->mod_op = LDAP_MOD_BVALUES; + attrs[ i ]->mod_type = mapped.bv_val; + + /* + * FIXME: dn-valued attrs should be rewritten + * to allow their use in ACLs at the back-ldap + * level. + */ + if ( strcmp( a->a_desc->ad_type->sat_syntax->ssyn_oid, + SLAPD_DN_SYNTAX ) == 0 ) { + ldap_dnattr_rewrite( li->targets[ candidate ]->rwinfo, + a->a_vals, conn ); + } + + for (j=0; a->a_vals[ j ].bv_val; j++); + attrs[ i ]->mod_vals.modv_bvals = ch_malloc((j+1)*sizeof(struct berval *)); + for (j=0; a->a_vals[ j ].bv_val; j++) + attrs[ i ]->mod_vals.modv_bvals[ j ] = &a->a_vals[ j ]; + attrs[ i ]->mod_vals.modv_bvals[ j ] = NULL; + i++; + } + attrs[ i ] = NULL; + + ldap_add_s( lc->conns[ candidate ]->ld, mdn.bv_val, attrs ); + for ( --i; i >= 0; --i ) { + free( attrs[ i ]->mod_vals.modv_bvals ); + free( attrs[ i ] ); + } + free( attrs ); + if ( mdn.bv_val != e->e_dn ) { + free( mdn.bv_val ); + } + return meta_back_op_result( lc, op ); +} + diff --git a/servers/slapd/back-meta/bind.c b/servers/slapd/back-meta/bind.c index 808bb689099217f02146fa397ce8166bf3095ee8..9dc738a87327d977d4bee30a420a2dd9b20d4df0 100644 --- a/servers/slapd/back-meta/bind.c +++ b/servers/slapd/back-meta/bind.c @@ -102,8 +102,8 @@ meta_back_bind( int realmethod = method; #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY, - "meta_back_bind: dn: %s.\n", dn->bv_val )); + LDAP_LOG( BACK_META, ENTRY, + "meta_back_bind: dn: %s.\n", dn->bv_val, 0, 0 ); #else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ARGS, "meta_back_bind: dn: %s.\n%s%s", dn->bv_val, "", "" ); #endif /* !NEW_LOGGING */ @@ -117,9 +117,8 @@ meta_back_bind( lc = meta_back_getconn( li, conn, op, op_type, ndn, NULL ); if ( !lc ) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_NOTICE, - "meta_back_bind: no target for dn %s.\n", - dn->bv_val )); + LDAP_LOG( BACK_META, NOTICE, + "meta_back_bind: no target for dn %s.\n", dn->bv_val, 0, 0 ); #else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ANY, "meta_back_bind: no target for dn %s.\n%s%s", @@ -153,10 +152,10 @@ meta_back_bind( * ONE CANDIDATE ONLY! */ #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_WARNING, + LDAP_LOG( BACK_META, WARNING, "==>meta_back_bind: more than one" " candidate is attempting to bind" - " ...\n" )); + " ...\n" , 0, 0, 0 ); #else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ANY, "==>meta_back_bind: more than one" @@ -248,8 +247,8 @@ meta_back_do_single_bind( mdn = *dn; } #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "[rw] bindDn: \"%s\" -> \"%s\"\n", dn->bv_val, mdn.bv_val )); + LDAP_LOG( BACK_META, DETAIL1, + "[rw] bindDn: \"%s\" -> \"%s\"\n", dn->bv_val, mdn.bv_val, 0 ); #else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ARGS, "rw> bindDn: \"%s\" -> \"%s\"\n%s", @@ -334,12 +333,12 @@ meta_back_dobind( struct metaconn *lc, Operation *op ) if ( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_WARNING, + LDAP_LOG( BACK_META, WARNING, "meta_back_dobind: (anonymous)" " bind as \"%s\" failed" " with error \"%s\"\n", lsc[ 0 ]->bound_dn.bv_val, - ldap_err2string( rc ) )); + ldap_err2string( rc ), 0 ); #else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ANY, "==>meta_back_dobind: (anonymous)" @@ -424,12 +423,12 @@ meta_back_op_result( struct metaconn *lc, Operation *op ) err = ldap_back_map_result( err ); #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_RESULTS, + LDAP_LOG( BACK_META, RESULTS, "meta_back_op_result: target" " <%d> sending msg \"%s\"" " (matched \"%s\")\n", i, ( msg ? msg : "" ), - ( match ? match : "" ) )); + ( match ? match : "" ) ); #else /* !NEW_LOGGING */ Debug(LDAP_DEBUG_ANY, "==> meta_back_op_result: target" diff --git a/servers/slapd/back-meta/compare.c b/servers/slapd/back-meta/compare.c new file mode 100644 index 0000000000000000000000000000000000000000..40cc65159ace4f554e7a14785b47ae1ec535423a --- /dev/null +++ b/servers/slapd/back-meta/compare.c @@ -0,0 +1,358 @@ +/* + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + * + * Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it> + * + * This work has been developed to fulfill the requirements + * of SysNet s.n.c. <http:www.sys-net.it> and it has been donated + * to the OpenLDAP Foundation in the hope that it may be useful + * to the Open Source community, but WITHOUT ANY WARRANTY. + * + * Permission is granted to anyone to use this software for any purpose + * on any computer system, and to alter it and redistribute it, subject + * to the following restrictions: + * + * 1. The author and SysNet s.n.c. are not responsible for the consequences + * of use of this software, no matter how awful, even if they arise from + * flaws in it. + * + * 2. The origin of this software must not be misrepresented, either by + * explicit claim or by omission. Since few users ever read sources, + * credits should appear in the documentation. + * + * 3. Altered versions must be plainly marked as such, and must not be + * misrepresented as being the original software. Since few users + * ever read sources, credits should appear in the documentation. + * SysNet s.n.c. cannot be responsible for the consequences of the + * alterations. + * + * 4. This notice may not be removed or altered. + * + * + * This software is based on the backend back-ldap, implemented + * by Howard Chu <hyc@highlandsun.com>, and modified by Mark Valence + * <kurash@sassafras.com>, Pierangelo Masarati <ando@sys-net.it> and other + * contributors. The contribution of the original software to the present + * implementation is acknowledged in this copyright statement. + * + * A special acknowledgement goes to Howard for the overall architecture + * (and for borrowing large pieces of code), and to Mark, who implemented + * from scratch the attribute/objectclass mapping. + * + * The original copyright statement follows. + * + * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com> + * + * Permission is granted to anyone to use this software for any purpose + * on any computer system, and to alter it and redistribute it, subject + * to the following restrictions: + * + * 1. The author is not responsible for the consequences of use of this + * software, no matter how awful, even if they arise from flaws in it. + * + * 2. The origin of this software must not be misrepresented, either by + * explicit claim or by omission. Since few users ever read sources, + * credits should appear in the documentation. + * + * 3. Altered versions must be plainly marked as such, and must not be + * misrepresented as being the original software. Since few users + * ever read sources, credits should appear in the + * documentation. + * + * 4. This notice may not be removed or altered. + * + */ + +#include "portable.h" + +#include <stdio.h> + +#include <ac/string.h> +#include <ac/socket.h> + +#include "slap.h" +#include "../back-ldap/back-ldap.h" +#include "back-meta.h" + +int +meta_back_compare( + Backend *be, + Connection *conn, + Operation *op, + struct berval *dn, + struct berval *ndn, + AttributeAssertion *ava +) +{ + struct metainfo *li = ( struct metainfo * )be->be_private; + struct metaconn *lc; + struct metasingleconn **lsc; + char *match = NULL, *err = NULL, *mmatch = NULL; + int candidates = 0, last = 0, i, count, rc; + int cres = LDAP_SUCCESS, rres = LDAP_SUCCESS; + int *msgid; + + lc = meta_back_getconn( li, conn, op, META_OP_ALLOW_MULTIPLE, + ndn, NULL ); + if ( !lc || !meta_back_dobind( lc, op ) ) { + return -1; + } + + msgid = ch_calloc( sizeof( int ), li->ntargets ); + if ( msgid == NULL ) { + return -1; + } + + /* + * start an asynchronous compare for each candidate target + */ + for ( i = 0, lsc = lc->conns; lsc[ 0 ] != NULL; ++i, ++lsc ) { + char *mdn = NULL; + struct berval mapped_attr = ava->aa_desc->ad_cname; + struct berval mapped_value = ava->aa_value; + + if ( lsc[ 0 ]->candidate != META_CANDIDATE ) { + continue; + } + + /* + * Rewrite the compare dn, if needed + */ + switch ( rewrite_session( li->targets[ i ]->rwinfo, + "compareDn", + dn->bv_val, conn, &mdn ) ) { + case REWRITE_REGEXEC_OK: + if ( mdn == NULL ) { + mdn = ( char * )dn->bv_val; + } +#ifdef NEW_LOGGING + LDAP_LOG( BACK_META, DETAIL1, + "[rw] compareDn: \"%s\" -> \"%s\"\n", dn->bv_val, mdn, 0 ); +#else /* !NEW_LOGGING */ + Debug( LDAP_DEBUG_ARGS, + "rw> compareDn: \"%s\" -> \"%s\"\n%s", + dn->bv_val, 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; + } + + /* + * if attr is objectClass, try to remap the value + */ + if ( ava->aa_desc->ad_type->sat_oid + == slap_schema.si_ad_objectClass->ad_type->sat_oid ) { + ldap_back_map( &li->targets[ i ]->oc_map, + &ava->aa_value, &mapped_value, 0 ); + + if ( mapped_value.bv_val == NULL ) { + lsc[ 0 ]->candidate = META_NOT_CANDIDATE; + continue; + } + /* + * else try to remap the attribute + */ + } else { + ldap_back_map( &li->targets[ i ]->at_map, + &ava->aa_desc->ad_cname, &mapped_attr, 0 ); + if ( mapped_attr.bv_val == NULL ) { + lsc[ 0 ]->candidate = META_NOT_CANDIDATE; + continue; + } + } + + /* + * the compare op is spawned across the targets and the first + * that returns determines the result; a constraint on unicity + * of the result ought to be enforced + */ + msgid[ i ] = ldap_compare( lc->conns[ i ]->ld, mdn, + mapped_attr.bv_val, mapped_value.bv_val ); + if ( msgid[ i ] == -1 ) { + lsc[ 0 ]->candidate = META_NOT_CANDIDATE; + continue; + } + + if ( mdn != dn->bv_val ) { + free( mdn ); + } + if ( mapped_attr.bv_val != ava->aa_desc->ad_cname.bv_val ) { + free( mapped_attr.bv_val ); + } + if ( mapped_value.bv_val != ava->aa_value.bv_val ) { + free( mapped_value.bv_val ); + } + + ++candidates; + } + + /* + * wait for replies + */ + for ( rc = 0, count = 0; candidates > 0; ) { + + /* + * FIXME: should we check for abandon? + */ + for ( i = 0, lsc = lc->conns; lsc[ 0 ] != NULL; lsc++, i++ ) { + int lrc; + LDAPMessage *res = NULL; + + if ( lsc[ 0 ]->candidate != META_CANDIDATE ) { + continue; + } + + lrc = ldap_result( lsc[ 0 ]->ld, msgid[ i ], + 0, NULL, &res ); + + if ( lrc == 0 ) { + /* + * FIXME: should we yield? + */ + if ( res ) { + ldap_msgfree( res ); + } + continue; + } else if ( lrc == LDAP_RES_COMPARE ) { + if ( count > 0 ) { + rres = LDAP_OPERATIONS_ERROR; + rc = -1; + goto finish; + } + + cres = ldap_result2error( lsc[ 0 ]->ld, + res, 1 ); + switch ( cres ) { + case LDAP_COMPARE_TRUE: + case LDAP_COMPARE_FALSE: + + /* + * true or flase, got it; + * sending to cache ... + */ + if ( li->cache.ttl != META_DNCACHE_DISABLED ) { + ( void )meta_dncache_update_entry( &li->cache, ndn, i ); + } + + count++; + rc = 0; + break; + + default: + rres = ldap_back_map_result( cres ); + + if ( err != NULL ) { + free( err ); + } + ldap_get_option( lsc[ 0 ]->ld, + LDAP_OPT_ERROR_STRING, &err ); + + if ( match != NULL ) { + free( match ); + } + ldap_get_option( lsc[ 0 ]->ld, + LDAP_OPT_MATCHED_DN, &match ); + + last = i; + break; + } + lsc[ 0 ]->candidate = META_NOT_CANDIDATE; + --candidates; + } else { + lsc[ 0 ]->candidate = META_NOT_CANDIDATE; + --candidates; + if ( res ) { + ldap_msgfree( res ); + } + break; + } + } + } + +finish:; + + /* + * Rewrite the matched portion of the search base, if required + * + * FIXME: only the last one gets caught! + */ + if ( count == 1 ) { + if ( match != NULL ) { + free( match ); + match = NULL; + } + + /* + * the result of the compare is assigned to the res code + * that will be returned + */ + rres = cres; + + } else if ( match != NULL ) { + + /* + * At least one compare failed with matched portion, + * and none was successful + */ + switch ( rewrite_session( li->targets[ last ]->rwinfo, + "matchedDn", match, conn, &mmatch ) ) { + case REWRITE_REGEXEC_OK: + if ( mmatch == NULL ) { + mmatch = ( char * )match; + } +#ifdef NEW_LOGGING + LDAP_LOG( BACK_META, DETAIL1, + "[rw] matchedDn: \"%s\" -> \"%s\"\n", match, mmatch, 0 ); +#else /* !NEW_LOGGING */ + Debug( LDAP_DEBUG_ARGS, "rw> matchedDn:" + " \"%s\" -> \"%s\"\n%s", + match, mmatch, "" ); +#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 cleanup; + + case REWRITE_REGEXEC_ERR: + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, "Operations error", + NULL, NULL ); + rc = -1; + goto cleanup; + } + } + + send_ldap_result( conn, op, rres, mmatch, err, NULL, NULL ); + +cleanup:; + if ( match != NULL ) { + if ( mmatch != match ) { + free( mmatch ); + } + free( match ); + } + + if ( msgid ) { + free( msgid ); + } + + return rc; +} + diff --git a/servers/slapd/back-meta/conn.c b/servers/slapd/back-meta/conn.c index 8f17f60590917869eb9784313da395c6e2916e26..739af0e44b5ab6c1ebf767d319027dfdac17327d 100644 --- a/servers/slapd/back-meta/conn.c +++ b/servers/slapd/back-meta/conn.c @@ -289,9 +289,9 @@ init_one_conn( ber_dupbv( &lsc->bound_dn, &conn->c_dn ); } #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "[rw] bindDn: \"%s\" -> \"%s\"\n", - conn->c_dn.bv_val, lsc->bound_dn.bv_val )); + LDAP_LOG( BACK_META, DETAIL1, + "[rw] bindDn: \"%s\" -> \"%s\"\n", + conn->c_dn.bv_val, lsc->bound_dn.bv_val, 0 ); #else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ARGS, "rw> bindDn: \"%s\" -> \"%s\"\n", @@ -402,10 +402,9 @@ meta_back_getconn( } #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "meta_back_getconn: got target %d" - " for ndn=\"%s\" from cache\n", - i, ndn->bv_val )); + LDAP_LOG( BACK_META, INFO, + "meta_back_getconn: got target %d for ndn=\"%s\" from cache\n", + i, ndn->bv_val, 0 ); #else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_CACHE, "==>meta_back_getconn: got target %d for ndn=\"%s\" from cache\n%s", @@ -513,9 +512,8 @@ 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 )); + LDAP_LOG( BACK_META, INFO, + "meta_back_getconn: conn %ld inserted\n", lc->conn->c_connid, 0, 0); #else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_TRACE, "=>meta_back_getconn: conn %ld inserted\n%s%s", @@ -533,9 +531,8 @@ meta_back_getconn( } } else { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "meta_back_getconn: conn %ld fetched\n", - lc->conn->c_connid )); + LDAP_LOG( BACK_META, INFO, + "meta_back_getconn: conn %ld fetched\n", lc->conn->c_connid, 0, 0 ); #else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_TRACE, "=>meta_back_getconn: conn %ld fetched\n%s%s", diff --git a/servers/slapd/back-meta/delete.c b/servers/slapd/back-meta/delete.c new file mode 100644 index 0000000000000000000000000000000000000000..21613c591df294cce871d3b1d0e83c36f0ec2673 --- /dev/null +++ b/servers/slapd/back-meta/delete.c @@ -0,0 +1,138 @@ +/* + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + * + * Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it> + * + * This work has been developed to fulfill the requirements + * of SysNet s.n.c. <http:www.sys-net.it> and it has been donated + * to the OpenLDAP Foundation in the hope that it may be useful + * to the Open Source community, but WITHOUT ANY WARRANTY. + * + * Permission is granted to anyone to use this software for any purpose + * on any computer system, and to alter it and redistribute it, subject + * to the following restrictions: + * + * 1. The author and SysNet s.n.c. are not responsible for the consequences + * of use of this software, no matter how awful, even if they arise from + * flaws in it. + * + * 2. The origin of this software must not be misrepresented, either by + * explicit claim or by omission. Since few users ever read sources, + * credits should appear in the documentation. + * + * 3. Altered versions must be plainly marked as such, and must not be + * misrepresented as being the original software. Since few users + * ever read sources, credits should appear in the documentation. + * SysNet s.n.c. cannot be responsible for the consequences of the + * alterations. + * + * 4. This notice may not be removed or altered. + * + * + * This software is based on the backend back-ldap, implemented + * by Howard Chu <hyc@highlandsun.com>, and modified by Mark Valence + * <kurash@sassafras.com>, Pierangelo Masarati <ando@sys-net.it> and other + * contributors. The contribution of the original software to the present + * implementation is acknowledged in this copyright statement. + * + * A special acknowledgement goes to Howard for the overall architecture + * (and for borrowing large pieces of code), and to Mark, who implemented + * from scratch the attribute/objectclass mapping. + * + * The original copyright statement follows. + * + * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com> + * + * Permission is granted to anyone to use this software for any purpose + * on any computer system, and to alter it and redistribute it, subject + * to the following restrictions: + * + * 1. The author is not responsible for the consequences of use of this + * software, no matter how awful, even if they arise from flaws in it. + * + * 2. The origin of this software must not be misrepresented, either by + * explicit claim or by omission. Since few users ever read sources, + * credits should appear in the documentation. + * + * 3. Altered versions must be plainly marked as such, and must not be + * misrepresented as being the original software. Since few users + * ever read sources, credits should appear in the + * documentation. + * + * 4. This notice may not be removed or altered. + * + */ + +#include "portable.h" + +#include <stdio.h> + +#include <ac/string.h> +#include <ac/socket.h> + +#include "slap.h" +#include "../back-ldap/back-ldap.h" +#include "back-meta.h" + +int +meta_back_delete( + Backend *be, + Connection *conn, + Operation *op, + struct berval *dn, + struct berval *ndn +) +{ + struct metainfo *li = ( struct metainfo * )be->be_private; + struct metaconn *lc; + int candidate = -1; + + char *mdn = NULL; + + lc = meta_back_getconn( li, conn, op, META_OP_REQUIRE_SINGLE, + ndn, &candidate ); + if ( !lc || !meta_back_dobind( lc, op ) || !meta_back_is_valid( lc, candidate ) ) { + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, NULL, NULL, NULL ); + return -1; + } + + /* + * Rewrite the compare dn, if needed + */ + switch ( rewrite_session( li->targets[ candidate ]->rwinfo, + "deleteDn", dn->bv_val, conn, &mdn ) ) { + case REWRITE_REGEXEC_OK: + if ( mdn == NULL ) { + mdn = ( char * )dn->bv_val; + } +#ifdef NEW_LOGGING + LDAP_LOG( BACK_META, DETAIL1, + "[rw] deleteDn: \"%s\" -> \"%s\"\n", dn->bv_val, mdn, 0 ); +#else /* !NEW_LOGGING */ + Debug( LDAP_DEBUG_ARGS, "rw> deleteDn: \"%s\" -> \"%s\"\n%s", + dn->bv_val, mdn, "" ); +#endif /* !NEW_LOGGING */ + break; + + case REWRITE_REGEXEC_UNWILLING: + send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, + NULL, NULL, NULL, NULL ); + return -1; + + case REWRITE_REGEXEC_ERR: + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, NULL, NULL, NULL ); + return -1; + } + + ldap_delete_s( lc->conns[ candidate ]->ld, mdn ); + + if ( mdn != dn->bv_val ) { + free( mdn ); + } + + return meta_back_op_result( lc, op ); +} + diff --git a/servers/slapd/back-meta/group.c b/servers/slapd/back-meta/group.c index 53b5ed5aee298853e73f080fe2f80d98ca875eb2..67886898a3236262b2767914b2d6d7407327fc51 100644 --- a/servers/slapd/back-meta/group.c +++ b/servers/slapd/back-meta/group.c @@ -75,7 +75,6 @@ #include "../back-ldap/back-ldap.h" #include "back-meta.h" - /* return 0 IFF op_dn is a value in group_at (member) attribute * of entry with gr_dn AND that entry has an objectClass * value of group_oc (groupOfNames) @@ -171,10 +170,9 @@ meta_back_group( mop_ndn = *op_ndn; } #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "[rw] bindDn (op ndn in group):" - " \"%s\" -> \"%s\"\n", - op_ndn->bv_val, mop_ndn.bv_val)); + LDAP_LOG( BACK_META, DETAIL1, + "[rw] bindDn (op ndn in group): \"%s\" -> \"%s\"\n", + op_ndn->bv_val, mop_ndn.bv_val, 0 ); #else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ARGS, "rw> bindDn (op ndn in group):" @@ -203,10 +201,9 @@ meta_back_group( mgr_ndn = *gr_ndn; } #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "[rw] searchBase (gr ndn in group):" - " \"%s\" -> \"%s\"\n", - gr_ndn->bv_val, mgr_ndn.bv_val )); + LDAP_LOG( BACK_META, DETAIL1, + "[rw] searchBase (gr ndn in group): \"%s\" -> \"%s\"\n", + gr_ndn->bv_val, mgr_ndn.bv_val, 0 ); #else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ARGS, "rw> searchBase (gr ndn in group):" @@ -253,12 +250,12 @@ meta_back_group( goto cleanup; } - ptr = slap_strcopy( filter, "(&(objectclass=" ); - ptr = slap_strcopy( ptr , group_oc_name.bv_val ); - ptr = slap_strcopy( ptr , ")(" ); - ptr = slap_strcopy( ptr , group_at_name.bv_val ); - ptr = slap_strcopy( ptr , "=" ); - ptr = slap_strcopy( ptr , mop_ndn.bv_val ); + ptr = lutil_strcopy( filter, "(&(objectclass=" ); + ptr = lutil_strcopy( ptr , group_oc_name.bv_val ); + ptr = lutil_strcopy( ptr , ")(" ); + ptr = lutil_strcopy( ptr , group_at_name.bv_val ); + ptr = lutil_strcopy( ptr , "=" ); + ptr = lutil_strcopy( ptr , mop_ndn.bv_val ); strcpy( ptr , "))" ); gattr[ 0 ] = "objectclass"; diff --git a/servers/slapd/back-meta/modify.c b/servers/slapd/back-meta/modify.c new file mode 100644 index 0000000000000000000000000000000000000000..9a2813e38c8d58afb8ce6ad5dbf8966896c4aace --- /dev/null +++ b/servers/slapd/back-meta/modify.c @@ -0,0 +1,214 @@ +/* + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + * + * Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it> + * + * This work has been developed to fulfill the requirements + * of SysNet s.n.c. <http:www.sys-net.it> and it has been donated + * to the OpenLDAP Foundation in the hope that it may be useful + * to the Open Source community, but WITHOUT ANY WARRANTY. + * + * Permission is granted to anyone to use this software for any purpose + * on any computer system, and to alter it and redistribute it, subject + * to the following restrictions: + * + * 1. The author and SysNet s.n.c. are not responsible for the consequences + * of use of this software, no matter how awful, even if they arise from + * flaws in it. + * + * 2. The origin of this software must not be misrepresented, either by + * explicit claim or by omission. Since few users ever read sources, + * credits should appear in the documentation. + * + * 3. Altered versions must be plainly marked as such, and must not be + * misrepresented as being the original software. Since few users + * ever read sources, credits should appear in the documentation. + * SysNet s.n.c. cannot be responsible for the consequences of the + * alterations. + * + * 4. This notice may not be removed or altered. + * + * + * This software is based on the backend back-ldap, implemented + * by Howard Chu <hyc@highlandsun.com>, and modified by Mark Valence + * <kurash@sassafras.com>, Pierangelo Masarati <ando@sys-net.it> and other + * contributors. The contribution of the original software to the present + * implementation is acknowledged in this copyright statement. + * + * A special acknowledgement goes to Howard for the overall architecture + * (and for borrowing large pieces of code), and to Mark, who implemented + * from scratch the attribute/objectclass mapping. + * + * The original copyright statement follows. + * + * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com> + * + * Permission is granted to anyone to use this software for any purpose + * on any computer system, and to alter it and redistribute it, subject + * to the following restrictions: + * + * 1. The author is not responsible for the consequences of use of this + * software, no matter how awful, even if they arise from flaws in it. + * + * 2. The origin of this software must not be misrepresented, either by + * explicit claim or by omission. Since few users ever read sources, + * credits should appear in the documentation. + * + * 3. Altered versions must be plainly marked as such, and must not be + * misrepresented as being the original software. Since few users + * ever read sources, credits should appear in the + * documentation. + * + * 4. This notice may not be removed or altered. + * + */ + +#include "portable.h" + +#include <stdio.h> + +#include <ac/string.h> +#include <ac/socket.h> + +#include "slap.h" +#include "../back-ldap/back-ldap.h" +#include "back-meta.h" + +int +meta_back_modify( + Backend *be, + Connection *conn, + Operation *op, + struct berval *dn, + struct berval *ndn, + Modifications *modlist +) +{ + struct metainfo *li = ( struct metainfo * )be->be_private; + struct metaconn *lc; + LDAPMod **modv; + LDAPMod *mods; + Modifications *ml; + int candidate = -1, i; + char *mdn; + struct berval mapped; + + lc = meta_back_getconn( li, conn, op, META_OP_REQUIRE_SINGLE, + ndn, &candidate ); + if ( !lc || !meta_back_dobind( lc, op ) || !meta_back_is_valid( lc, candidate ) ) { + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, NULL, NULL, NULL ); + return -1; + } + + /* + * Rewrite the modify dn, if needed + */ + switch ( rewrite_session( li->targets[ candidate ]->rwinfo, + "modifyDn", dn->bv_val, conn, &mdn ) ) { + case REWRITE_REGEXEC_OK: + if ( mdn == NULL ) { + mdn = ( char * )dn->bv_val; + } +#ifdef NEW_LOGGING + LDAP_LOG( BACK_META, DETAIL1, + "[rw] modifyDn: \"%s\" -> \"%s\"\n", dn->bv_val, mdn, 0 ); +#else /* !NEW_LOGGING */ + Debug( LDAP_DEBUG_ARGS, "rw> modifyDn: \"%s\" -> \"%s\"\n%s", + dn->bv_val, mdn, "" ); +#endif /* !NEW_LOGGING */ + break; + + case REWRITE_REGEXEC_UNWILLING: + send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, + NULL, NULL, NULL, NULL ); + return -1; + + case REWRITE_REGEXEC_ERR: + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, NULL, NULL, NULL ); + return -1; + } + + for ( i = 0, ml = modlist; ml; i++ ,ml = ml->sml_next ) + ; + + mods = ch_malloc( sizeof( LDAPMod )*i ); + if ( mods == NULL ) { + if ( mdn != dn->bv_val ) { + free( mdn ); + } + return -1; + } + modv = ( LDAPMod ** )ch_malloc( ( i + 1 )*sizeof( LDAPMod * ) ); + if ( modv == NULL ) { + free( mods ); + if ( mdn != dn->bv_val ) { + free( mdn ); + } + return -1; + } + + for ( i = 0, ml = modlist; ml; ml = ml->sml_next ) { + int j; + /* + * lastmod should always be <off> + */ +#if 0 + if ( !strcasecmp( a->a_desc->ad_cname.bv_val, + slap_schema.si_ad_creatorsName->ad_cname.bv_val ) + || !strcasecmp( a->a_desc->ad_cname.bv_val, + slap_schema.si_ad_createTimestamp->ad_cname.bv_val ) + || !strcasecmp( a->a_desc->ad_cname.bv_val, + slap_schema.si_ad_modifiersName->ad_cname.bv_val ) + || !strcasecmp( a->a_desc->ad_cname.bv_val, + slap_schema.si_ad_modifyTimestamp->ad_cname.bv_val ) ) { + continue; + } +#endif + + ldap_back_map( &li->targets[ candidate ]->at_map, + &ml->sml_desc->ad_cname, &mapped, 0 ); + if ( mapped.bv_val == NULL ) { + continue; + } + + modv[ i ] = &mods[ i ]; + mods[ i ].mod_op = ml->sml_op | LDAP_MOD_BVALUES; + mods[ i ].mod_type = mapped.bv_val; + + /* + * FIXME: dn-valued attrs should be rewritten + * to allow their use in ACLs at the back-ldap + * level. + */ + if ( strcmp( ml->sml_desc->ad_type->sat_syntax->ssyn_oid, + SLAPD_DN_SYNTAX ) == 0 ) { + ldap_dnattr_rewrite( + li->targets[ candidate ]->rwinfo, + ml->sml_bvalues, conn ); + } + + for (j = 0; ml->sml_bvalues[ j ].bv_val; j++); + mods[ i ].mod_bvalues = (struct berval **)ch_malloc((j+1) * + sizeof(struct berval *)); + for (j = 0; ml->sml_bvalues[ j ].bv_val; j++) + mods[ i ].mod_bvalues[ j ] = &ml->sml_bvalues[j]; + mods[ i ].mod_bvalues[ j ] = NULL; + i++; + } + modv[ i ] = 0; + + ldap_modify_s( lc->conns[ candidate ]->ld, mdn, modv ); + + if ( mdn != dn->bv_val ) { + free( mdn ); + } + for ( i=0; modv[ i ]; i++) + free( modv[ i ]->mod_bvalues ); + free( mods ); + free( modv ); + return meta_back_op_result( lc, op ); +} + diff --git a/servers/slapd/back-meta/modrdn.c b/servers/slapd/back-meta/modrdn.c new file mode 100644 index 0000000000000000000000000000000000000000..1ce1c53146c9849c8b48dcb5cf297a66b80b269e --- /dev/null +++ b/servers/slapd/back-meta/modrdn.c @@ -0,0 +1,209 @@ +/* + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + * + * Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it> + * + * This work has been developed to fulfill the requirements + * of SysNet s.n.c. <http:www.sys-net.it> and it has been donated + * to the OpenLDAP Foundation in the hope that it may be useful + * to the Open Source community, but WITHOUT ANY WARRANTY. + * + * Permission is granted to anyone to use this software for any purpose + * on any computer system, and to alter it and redistribute it, subject + * to the following restrictions: + * + * 1. The author and SysNet s.n.c. are not responsible for the consequences + * of use of this software, no matter how awful, even if they arise from + * flaws in it. + * + * 2. The origin of this software must not be misrepresented, either by + * explicit claim or by omission. Since few users ever read sources, + * credits should appear in the documentation. + * + * 3. Altered versions must be plainly marked as such, and must not be + * misrepresented as being the original software. Since few users + * ever read sources, credits should appear in the documentation. + * SysNet s.n.c. cannot be responsible for the consequences of the + * alterations. + * + * 4. This notice may not be removed or altered. + * + * + * This software is based on the backend back-ldap, implemented + * by Howard Chu <hyc@highlandsun.com>, and modified by Mark Valence + * <kurash@sassafras.com>, Pierangelo Masarati <ando@sys-net.it> and other + * contributors. The contribution of the original software to the present + * implementation is acknowledged in this copyright statement. + * + * A special acknowledgement goes to Howard for the overall architecture + * (and for borrowing large pieces of code), and to Mark, who implemented + * from scratch the attribute/objectclass mapping. + * + * The original copyright statement follows. + * + * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com> + * + * Permission is granted to anyone to use this software for any purpose + * on any computer system, and to alter it and redistribute it, subject + * to the following restrictions: + * + * 1. The author is not responsible for the consequences of use of this + * software, no matter how awful, even if they arise from flaws in it. + * + * 2. The origin of this software must not be misrepresented, either by + * explicit claim or by omission. Since few users ever read sources, + * credits should appear in the documentation. + * + * 3. Altered versions must be plainly marked as such, and must not be + * misrepresented as being the original software. Since few users + * ever read sources, credits should appear in the + * documentation. + * + * 4. This notice may not be removed or altered. + * + */ + +#include "portable.h" + +#include <stdio.h> + +#include <ac/socket.h> +#include <ac/string.h> + +#include "slap.h" +#include "../back-ldap/back-ldap.h" +#include "back-meta.h" + +int +meta_back_modrdn( + Backend *be, + Connection *conn, + Operation *op, + struct berval *dn, + struct berval *ndn, + struct berval *newrdn, + struct berval *nnewrdn, + int deleteoldrdn, + struct berval *newSuperior, + struct berval *nnewSuperior +) +{ + struct metainfo *li = ( struct metainfo * )be->be_private; + struct metaconn *lc; + int candidate = -1; + + char *mdn = NULL, *mnewSuperior = NULL; + + lc = meta_back_getconn( li, conn, op, META_OP_REQUIRE_SINGLE, + ndn, &candidate ); + if ( !lc || !meta_back_dobind( lc, op ) || !meta_back_is_valid( lc, candidate ) ) { + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, NULL, NULL, NULL ); + return -1; + } + + if ( newSuperior ) { + int nsCandidate, version = LDAP_VERSION3; + + nsCandidate = meta_back_select_unique_candidate( li, + newSuperior ); + + if ( nsCandidate != candidate ) { + /* + * FIXME: one possibility is to delete the entry + * from one target and add it to the other; + * unfortunately we'd need write access to both, + * which is nearly impossible; for administration + * needs, the rootdn of the metadirectory could + * be mapped to an administrative account on each + * target (the binddn?); we'll see. + */ + /* + * FIXME: is this the correct return code? + */ + send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, + NULL, NULL, NULL, NULL ); + return -1; + } + + ldap_set_option( lc->conns[ nsCandidate ]->ld, + LDAP_OPT_PROTOCOL_VERSION, &version ); + + /* + * Rewrite the new superior, if defined and required + */ + switch ( rewrite_session( li->targets[ nsCandidate ]->rwinfo, + "newSuperiorDn", + newSuperior->bv_val, + conn, + &mnewSuperior ) ) { + case REWRITE_REGEXEC_OK: + if ( mnewSuperior == NULL ) { + mnewSuperior = ( char * )newSuperior; + } +#ifdef NEW_LOGGING + LDAP_LOG( BACK_META, DETAIL1, + "[rw] newSuperiorDn: \"%s\" -> \"%s\"\n", + newSuperior, mnewSuperior, 0 ); +#else /* !NEW_LOGGING */ + Debug( LDAP_DEBUG_ARGS, "rw> newSuperiorDn:" + " \"%s\" -> \"%s\"\n%s", + newSuperior->bv_val, mnewSuperior, "" ); +#endif /* !NEW_LOGGING */ + break; + + case REWRITE_REGEXEC_UNWILLING: + send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, + NULL, NULL, NULL, NULL ); + return -1; + + case REWRITE_REGEXEC_ERR: + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, NULL, NULL, NULL ); + return -1; + } + } + + /* + * Rewrite the modrdn dn, if required + */ + switch ( rewrite_session( li->targets[ candidate ]->rwinfo, + "modrDn", dn->bv_val, conn, &mdn ) ) { + case REWRITE_REGEXEC_OK: + if ( mdn == NULL ) { + mdn = ( char * )dn->bv_val; + } +#ifdef NEW_LOGGING + LDAP_LOG( BACK_META, DETAIL1, + "[rw] modrDn: \"%s\" -> \"%s\"\n", dn->bv_val, mdn, 0 ); +#else /* !NEW_LOGGING */ + Debug( LDAP_DEBUG_ARGS, "rw> modrDn: \"%s\" -> \"%s\"\n%s", + dn->bv_val, mdn, "" ); +#endif /* !NEW_LOGGING */ + break; + + case REWRITE_REGEXEC_UNWILLING: + send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, + NULL, NULL, NULL, NULL ); + return -1; + + case REWRITE_REGEXEC_ERR: + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, NULL, NULL, NULL ); + return -1; + } + + ldap_rename2_s( lc->conns[ candidate ]->ld, mdn, newrdn->bv_val, + mnewSuperior, deleteoldrdn ); + + if ( mdn != dn->bv_val ) { + free( mdn ); + } + if ( mnewSuperior != NULL && mnewSuperior != newSuperior->bv_val ) { + free( mnewSuperior ); + } + + return meta_back_op_result( lc, op ); +} + diff --git a/servers/slapd/back-meta/search.c b/servers/slapd/back-meta/search.c index 7d00e2a2ff4cb5579f5145059a8a326b2a72c686..f1b2f698cb4b7c0c94a653cd7dfe8406f095c99f 100644 --- a/servers/slapd/back-meta/search.c +++ b/servers/slapd/back-meta/search.c @@ -77,6 +77,7 @@ #include "back-meta.h" #include "ldap_pvt.h" #undef ldap_debug /* silence a warning in ldap-int.h */ +#include "ldap_log.h" #include "../../../libraries/libldap/ldap-int.h" static void @@ -277,9 +278,8 @@ meta_back_search( mbase = realbase; } #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "[rw] searchBase: \"%s\" -> \"%s\"\n", - base->bv_val, mbase )); + LDAP_LOG( BACK_META, DETAIL1, + "[rw] searchBase: \"%s\" -> \"%s\"\n", base->bv_val, mbase, 0 ); #else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ARGS, "rw> searchBase: \"%s\" -> \"%s\"\n%s", base->bv_val, mbase, "" ); @@ -317,9 +317,9 @@ meta_back_search( mfilter = *filterstr; } #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "[rw] searchFilter: \"%s\" -> \"%s\"\n", - filterstr->bv_val, mfilter.bv_val )); + LDAP_LOG( BACK_META, DETAIL1, + "[rw] searchFilter: \"%s\" -> \"%s\"\n", + filterstr->bv_val, mfilter.bv_val, 0 ); #else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ARGS, "rw> searchFilter: \"%s\" -> \"%s\"\n%s", @@ -348,7 +348,9 @@ meta_back_search( if ( mapped_filter == NULL ) { mapped_filter = ( char * )mfilter.bv_val; } else { - free( mfilter.bv_val ); + if ( mfilter.bv_val != filterstr->bv_val ) { + free( mfilter.bv_val ); + } } mfilter.bv_val = NULL; mfilter.bv_len = 0; @@ -464,10 +466,9 @@ meta_back_search( LDAP_OPT_MATCHED_DN, &match ); #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_ERR, - "meta_back_search [%d]" - " match=\"%s\" err=\"%s\"\n", - i, match, err )); + LDAP_LOG( BACK_META, 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", @@ -521,9 +522,8 @@ meta_back_search( mmatch = ( char * )match; } #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "[rw] matchedDn: \"%s\" -> \"%s\"\n", - match, mmatch )); + LDAP_LOG( BACK_META, DETAIL1, + "[rw] matchedDn: \"%s\" -> \"%s\"\n", match, mmatch, 0 ); #else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ARGS, "rw> matchedDn:" " \"%s\" -> \"%s\"\n%s", @@ -602,10 +602,9 @@ meta_send_entry( } else { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "[rw] searchResult[%d]:" - " \"%s\" -> \"%s\"\n", - target, bdn.bv_val, ent.e_name.bv_val )); + LDAP_LOG( BACK_META, DETAIL1, + "[rw] searchResult[%d]: \"%s\" -> \"%s\"\n", + target, bdn.bv_val, ent.e_name.bv_val ); #else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ARGS, "rw> searchResult[%d]: \"%s\"" " -> \"%s\"\n", target, bdn.bv_val, ent.e_name.bv_val ); @@ -653,9 +652,8 @@ meta_send_entry( if ( slap_bv2undef_ad( &mapped, &attr->a_desc, &text ) != LDAP_SUCCESS) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "slap_bv2undef_ad(%s): " - "%s\n", mapped.bv_val, text )); + LDAP_LOG( BACK_META, DETAIL1, + "slap_bv2undef_ad(%s): %s\n", mapped.bv_val, text, 0 ); #else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ANY, "slap_bv2undef_ad(%s): " @@ -672,8 +670,10 @@ meta_send_entry( continue; } - if ( ber_scanf( &ber, "[W]", &attr->a_vals ) == LBER_ERROR ) { + if ( ber_scanf( &ber, "[W]", &attr->a_vals ) == LBER_ERROR + || attr->a_vals == NULL ) { attr->a_vals = &dummy; + } else if ( attr->a_desc == slap_schema.si_ad_objectClass || attr->a_desc == slap_schema.si_ad_structuralObjectClass ) { int i, last; @@ -723,13 +723,10 @@ meta_send_entry( 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_val, - bv->bv_val, newval )); + LDAP_LOG( BACK_META, DETAIL1, + "[rw] searchResult on attr=%s: \"%s\" -> \"%s\"\n", + attr->a_desc->ad_type->sat_cname.bv_val, + bv->bv_val, newval ); #else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ARGS, "rw> searchResult on attr=%s:" diff --git a/servers/slapd/back-meta/unbind.c b/servers/slapd/back-meta/unbind.c new file mode 100644 index 0000000000000000000000000000000000000000..84b36adb21fa555aa7c3fdc47ecbb1231c5c8890 --- /dev/null +++ b/servers/slapd/back-meta/unbind.c @@ -0,0 +1,138 @@ +/* + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + * + * Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it> + * + * This work has been developed to fulfill the requirements + * of SysNet s.n.c. <http:www.sys-net.it> and it has been donated + * to the OpenLDAP Foundation in the hope that it may be useful + * to the Open Source community, but WITHOUT ANY WARRANTY. + * + * Permission is granted to anyone to use this software for any purpose + * on any computer system, and to alter it and redistribute it, subject + * to the following restrictions: + * + * 1. The author and SysNet s.n.c. are not responsible for the consequences + * of use of this software, no matter how awful, even if they arise from + * flaws in it. + * + * 2. The origin of this software must not be misrepresented, either by + * explicit claim or by omission. Since few users ever read sources, + * credits should appear in the documentation. + * + * 3. Altered versions must be plainly marked as such, and must not be + * misrepresented as being the original software. Since few users + * ever read sources, credits should appear in the documentation. + * SysNet s.n.c. cannot be responsible for the consequences of the + * alterations. + * + * 4. This notice may not be removed or altered. + * + * + * This software is based on the backend back-ldap, implemented + * by Howard Chu <hyc@highlandsun.com>, and modified by Mark Valence + * <kurash@sassafras.com>, Pierangelo Masarati <ando@sys-net.it> and other + * contributors. The contribution of the original software to the present + * implementation is acknowledged in this copyright statement. + * + * A special acknowledgement goes to Howard for the overall architecture + * (and for borrowing large pieces of code), and to Mark, who implemented + * from scratch the attribute/objectclass mapping. + * + * The original copyright statement follows. + * + * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com> + * + * Permission is granted to anyone to use this software for any purpose + * on any computer system, and to alter it and redistribute it, subject + * to the following restrictions: + * + * 1. The author is not responsible for the consequences of use of this + * software, no matter how awful, even if they arise from flaws in it. + * + * 2. The origin of this software must not be misrepresented, either by + * explicit claim or by omission. Since few users ever read sources, + * credits should appear in the documentation. + * + * 3. Altered versions must be plainly marked as such, and must not be + * misrepresented as being the original software. Since few users + * ever read sources, credits should appear in the + * documentation. + * + * 4. This notice may not be removed or altered. + * + */ + +#include "portable.h" + +#include <stdio.h> + +#include <ac/socket.h> +#include <ac/string.h> + +#include "slap.h" +#include "../back-ldap/back-ldap.h" +#include "back-meta.h" + +int +meta_back_conn_destroy( + Backend *be, + Connection *conn +) +{ + struct metainfo *li = ( struct metainfo * )be->be_private; + struct metaconn *lc, lc_curr; + +#ifdef NEW_LOGGING + LDAP_LOG( BACK_META, ENTRY, + "meta_back_conn_destroy: fetching conn %ld\n", conn->c_connid, 0, 0 ); +#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; + + ldap_pvt_thread_mutex_lock( &li->conn_mutex ); + lc = avl_delete( &li->conntree, ( caddr_t )&lc_curr, + meta_back_conn_cmp ); + ldap_pvt_thread_mutex_unlock( &li->conn_mutex ); + + if ( lc ) { + int i; + +#ifdef NEW_LOGGING + LDAP_LOG( BACK_META, INFO, + "meta_back_conn_destroy: destroying conn %ld\n", + lc->conn->c_connid, 0, 0 ); +#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 + */ + for ( i = 0; i < li->ntargets; ++i ) { + if ( lc->conns[ i ]->ld == NULL ) { + free( lc->conns[ i ] ); + continue; + } + + rewrite_session_delete( li->targets[ i ]->rwinfo, conn ); + meta_clear_one_candidate( lc->conns[ i ], 1 ); + free( lc->conns[ i ] ); + } + + free( lc->conns ); + free( lc ); + } + + /* no response to unbind */ + + return 0; +} + diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index a962aabd063fc36a540a56ec07f20cda21495b4c..3389fceddd787c5ef4cc25a028c3bec3df7a3f3f 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -124,8 +124,8 @@ int backend_init(void) if((nBackendInfo != 0) || (backendInfo != NULL)) { /* already initialized */ #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_ERR, - "backend_init: backend already initialized\n" )); + LDAP_LOG( BACKEND, ERR, + "backend_init: backend already initialized\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "backend_init: already initialized.\n", 0, 0, 0 ); @@ -141,9 +141,9 @@ int backend_init(void) if(rc != 0) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, + LDAP_LOG( BACKEND, INFO, "backend_init: initialized for type \"%s\"\n", - binfo[nBackendInfo].bi_type )); + binfo[nBackendInfo].bi_type, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "backend_init: initialized for type \"%s\"\n", @@ -173,8 +173,7 @@ int backend_init(void) #else #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_ERR, - "backend_init: failed\n" )); + LDAP_LOG( BACKEND, ERR, "backend_init: failed\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "backend_init: failed\n", @@ -191,9 +190,9 @@ int backend_add(BackendInfo *aBackendInfo) if ((rc = aBackendInfo->bi_init(aBackendInfo)) != 0) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_ERR, + LDAP_LOG( BACKEND, ERR, "backend_add: initialization for type \"%s\" failed\n", - aBackendInfo->bi_type )); + aBackendInfo->bi_type, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "backend_add: initialization for type \"%s\" failed\n", @@ -232,9 +231,8 @@ int backend_startup(Backend *be) if( ! ( nBackendDB > 0 ) ) { /* no databases */ #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "backend_startup: %d databases to startup. \n", - nBackendDB )); + LDAP_LOG( BACKEND, INFO, + "backend_startup: %d databases to startup. \n", nBackendDB, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "backend_startup: %d databases to startup.\n", @@ -246,9 +244,8 @@ int backend_startup(Backend *be) if(be != NULL) { /* startup a specific backend database */ #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, - "backend_startup: starting \"%s\"\n", - be->be_suffix[0].bv_val )); + LDAP_LOG( BACKEND, DETAIL1, "backend_startup: starting \"%s\"\n", + be->be_suffix[0].bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "backend_startup: starting \"%s\"\n", @@ -261,8 +258,7 @@ int backend_startup(Backend *be) if(rc != 0) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_CRIT, - "backend_startup: bi_open failed!\n" )); + LDAP_LOG( BACKEND, CRIT, "backend_startup: bi_open failed!\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "backend_startup: bi_open failed!\n", @@ -278,8 +274,8 @@ int backend_startup(Backend *be) if(rc != 0) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_CRIT, - "backend_startup: bi_db_open failed! (%d)\n", rc )); + LDAP_LOG( BACKEND, CRIT, + "backend_startup: bi_db_open failed! (%d)\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "backend_startup: bi_db_open failed! (%d)\n", @@ -305,8 +301,8 @@ int backend_startup(Backend *be) if(rc != 0) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_CRIT, - "backend_startup: bi_open %d failed!\n", i )); + LDAP_LOG( BACKEND, CRIT, + "backend_startup: bi_open %d failed!\n", i, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "backend_startup: bi_open %d failed!\n", @@ -328,9 +324,8 @@ int backend_startup(Backend *be) if(rc != 0) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_CRIT, - "backend_startup: bi_db_open(%d) failed! (%d)\n", - i, rc )); + LDAP_LOG( BACKEND, CRIT, + "backend_startup: bi_db_open(%d) failed! (%d)\n", i, rc, 0 ); #else Debug( LDAP_DEBUG_ANY, "backend_startup: bi_db_open(%d) failed! (%d)\n", @@ -388,9 +383,9 @@ int backend_shutdown( Backend *be ) if(rc != 0) { #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_NOTICE, - "backend_shutdown: bi_close %s failed!\n", - backendDB[i].be_type )); + LDAP_LOG( BACKEND, NOTICE, + "backend_shutdown: bi_close %s failed!\n", + backendDB[i].be_type, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "backend_close: bi_close %s failed!\n", @@ -914,7 +909,7 @@ backend_check_restrictions( if( op->o_ndn.bv_len == 0 ) { *text = "modifications require authentication"; - return LDAP_OPERATIONS_ERROR; + return LDAP_STRONG_AUTH_REQUIRED; } } } @@ -1031,6 +1026,7 @@ backend_group( } ldap_pvt_thread_mutex_lock( &conn->c_mutex ); + for (g = conn->c_groups; g; g=g->ga_next) { if (g->ga_be != be || g->ga_oc != group_oc || g->ga_at != group_at || g->ga_len != gr_ndn->bv_len) @@ -1038,7 +1034,9 @@ backend_group( if (strcmp( g->ga_ndn, gr_ndn->bv_val ) == 0) break; } + ldap_pvt_thread_mutex_unlock( &conn->c_mutex ); + if (g) { return g->ga_res; } @@ -1048,7 +1046,7 @@ backend_group( target, gr_ndn, op_ndn, group_oc, group_at ); - if (op->o_tag != LDAP_REQ_BIND) { + if ( op->o_tag != LDAP_REQ_BIND && !op->o_do_not_cache ) { g = ch_malloc(sizeof(GroupAssertion) + gr_ndn->bv_len); g->ga_be = be; g->ga_oc = group_oc; diff --git a/servers/slapd/bind.c b/servers/slapd/bind.c index 15055120b4e5ca95d24336b916bfb50a5e83a81b..81898e3ea083dd5c6bf159d522581e6e789db920 100644 --- a/servers/slapd/bind.c +++ b/servers/slapd/bind.c @@ -48,8 +48,7 @@ do_bind( Backend *be; #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, - "do_bind: conn %d\n", conn->c_connid )); + LDAP_LOG( OPERATION, ENTRY, "do_bind: conn %d\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "do_bind\n", 0, 0, 0 ); #endif @@ -58,7 +57,9 @@ do_bind( * Force to connection to "anonymous" until bind succeeds. */ ldap_pvt_thread_mutex_lock( &conn->c_mutex ); + if ( conn->c_sasl_bind_in_progress ) be = conn->c_authz_backend; connection2anonymous( conn ); + if ( conn->c_sasl_bind_in_progress ) conn->c_authz_backend = be; ldap_pvt_thread_mutex_unlock( &conn->c_mutex ); if ( op->o_dn.bv_val != NULL ) { @@ -97,8 +98,8 @@ do_bind( if ( tag == LBER_ERROR ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "do_bind: conn %d ber_scanf failed\n", conn->c_connid )); + LDAP_LOG( OPERATION, ERR, + "do_bind: conn %d ber_scanf failed\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "bind: ber_scanf failed\n", 0, 0, 0 ); #endif @@ -144,8 +145,8 @@ do_bind( if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, - "do_bind: conn %d get_ctrls failed\n", conn->c_connid )); + LDAP_LOG( OPERATION, INFO, + "do_bind: conn %d get_ctrls failed\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_bind: get_ctrls failed\n", 0, 0, 0 ); #endif @@ -155,9 +156,9 @@ do_bind( rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn ); if ( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, - "do_bind: conn %d invalid dn (%s)\n", - conn->c_connid, dn.bv_val )); + LDAP_LOG( OPERATION, INFO, + "do_bind: conn %d invalid dn (%s)\n", + conn->c_connid, dn.bv_val, 0 ); #else Debug( LDAP_DEBUG_ANY, "bind: invalid dn (%s)\n", dn.bv_val, 0, 0 ); @@ -169,9 +170,9 @@ do_bind( if( method == LDAP_AUTH_SASL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, - "do_sasl_bind: conn %d dn (%s) mech %s\n", conn->c_connid, - pdn.bv_val, mech.bv_val )); + LDAP_LOG( OPERATION, DETAIL1, + "do_sasl_bind: conn %d dn (%s) mech %s\n", + conn->c_connid, pdn.bv_val, mech.bv_val ); #else Debug( LDAP_DEBUG_TRACE, "do_sasl_bind: dn (%s) mech %s\n", pdn.bv_val, mech.bv_val, NULL ); @@ -179,10 +180,9 @@ do_bind( } else { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, - "do_bind: conn %d version=%ld dn=\"%s\" method=%ld\n", - conn->c_connid, (unsigned long) version, - pdn.bv_val, (unsigned long)method )); + LDAP_LOG( OPERATION, DETAIL1, + "do_bind: version=%ld dn=\"%s\" method=%ld\n", + (unsigned long) version, pdn.bv_val, (unsigned long)method ); #else Debug( LDAP_DEBUG_TRACE, "do_bind: version=%ld dn=\"%s\" method=%ld\n", @@ -196,9 +196,9 @@ do_bind( if ( version < LDAP_VERSION_MIN || version > LDAP_VERSION_MAX ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + LDAP_LOG( OPERATION, INFO, "do_bind: conn %d unknown version = %ld\n", - conn->c_connid, (unsigned long)version )); + conn->c_connid, (unsigned long)version, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_bind: unknown version=%ld\n", (unsigned long) version, 0, 0 ); @@ -236,9 +236,9 @@ do_bind( if ( version < LDAP_VERSION3 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + LDAP_LOG( OPERATION, INFO, "do_bind: conn %d sasl with LDAPv%ld\n", - conn->c_connid, (unsigned long)version )); + conn->c_connid, (unsigned long)version , 0 ); #else Debug( LDAP_DEBUG_ANY, "do_bind: sasl with LDAPv%ld\n", (unsigned long) version, 0, 0 ); @@ -251,9 +251,9 @@ do_bind( if( mech.bv_len == 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + LDAP_LOG( OPERATION, INFO, "do_bind: conn %d no SASL mechanism provided\n", - conn->c_connid )); + conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_bind: no sasl mechanism provided\n", @@ -378,9 +378,9 @@ do_bind( send_ldap_result( conn, op, rc, NULL, text, NULL, NULL ); #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, + LDAP_LOG( OPERATION, DETAIL1, "do_bind: conn %d v%d anonymous bind\n", - conn->c_connid, version )); + conn->c_connid, version , 0 ); #else Debug( LDAP_DEBUG_TRACE, "do_bind: v%d anonymous bind\n", version, 0, 0 ); @@ -395,9 +395,9 @@ do_bind( send_ldap_result( conn, op, rc, NULL, text, NULL, NULL ); #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + LDAP_LOG( OPERATION, INFO, "do_bind: conn %d v%d simple bind(%s) disallowed\n", - conn->c_connid, version, ndn.bv_val )); + conn->c_connid, version, ndn.bv_val ); #else Debug( LDAP_DEBUG_TRACE, "do_bind: v%d simple bind(%s) disallowed\n", @@ -416,9 +416,9 @@ do_bind( NULL, text, NULL, NULL ); #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, "do_bind: conn %d " + LDAP_LOG( OPERATION, INFO, "do_bind: conn %d " "v%d unprotected simple bind(%s) disallowed\n", - conn->c_connid, version, ndn.bv_val )); + conn->c_connid, version, ndn.bv_val ); #else Debug( LDAP_DEBUG_TRACE, "do_bind: v%d unprotected simple bind(%s) disallowed\n", @@ -437,9 +437,9 @@ do_bind( send_ldap_result( conn, op, rc, NULL, text, NULL, NULL ); #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, + LDAP_LOG( OPERATION, DETAIL1, "do_bind: conn %d v%d Kerberos V4 bind\n", - conn->c_connid, version )); + conn->c_connid, version , 0 ); #else Debug( LDAP_DEBUG_TRACE, "do_bind: v%d Kerberos V4 bind\n", version, 0, 0 ); @@ -455,9 +455,9 @@ do_bind( send_ldap_result( conn, op, rc, NULL, text, NULL, NULL ); #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + LDAP_LOG( OPERATION, INFO, "do_bind: conn %ld v%d unknown authentication method (%ld)\n", - conn->c_connid, version, method )); + conn->c_connid, version, method ); #else Debug( LDAP_DEBUG_TRACE, "do_bind: v%d unknown authentication method (%ld)\n", @@ -534,9 +534,9 @@ do_bind( } #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, - "do_bind: conn %d v%d bind: \"%s\" to \"%s\" \n", - conn->c_connid, version, dn.bv_val, conn->c_dn.bv_val )); + LDAP_LOG( OPERATION, DETAIL1, + "do_bind: v%d bind: \"%s\" to \"%s\" \n", + version, conn->c_dn.bv_val, conn->c_dn.bv_val ); #else Debug( LDAP_DEBUG_TRACE, "do_bind: v%d bind: \"%s\" to \"%s\"\n", diff --git a/servers/slapd/ch_malloc.c b/servers/slapd/ch_malloc.c index 43ec4c9adb08ebd63a0eaec3e9967f9bc3252379..c9af173946e0f06c03a56f9692ba91f180de5678 100644 --- a/servers/slapd/ch_malloc.c +++ b/servers/slapd/ch_malloc.c @@ -1,58 +1,127 @@ /* ch_malloc.c - malloc routines that test returns from malloc and friends */ +/* $OpenLDAP$ */ +/* + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ + +#define CH_FREE 1 + +#include "portable.h" #include <stdio.h> -#include <sys/types.h> -#include <sys/socket.h> + +#include <ac/stdlib.h> + +#include <ac/string.h> +#include <ac/socket.h> + #include "slap.h" -char * +#ifndef CSRIMALLOC + +void * ch_malloc( - unsigned long size + ber_len_t size ) { - char *new; + void *new; - if ( (new = (char *) malloc( size )) == NULL ) { - Debug( LDAP_DEBUG_ANY, "malloc of %d bytes failed\n", size, 0, 0 ); - exit( 1 ); + if ( (new = (void *) ber_memalloc( size )) == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG( OPERATION, ERR, + "ch_malloc: allocation of %lu bytes failed\n", (long)size, 0,0 ); +#else + Debug( LDAP_DEBUG_ANY, "ch_malloc of %lu bytes failed\n", + (long) size, 0, 0 ); +#endif + assert( 0 ); + exit( EXIT_FAILURE ); } return( new ); } -char * +void * ch_realloc( - char *block, - unsigned long size + void *block, + ber_len_t size ) { - char *new; + void *new; if ( block == NULL ) { return( ch_malloc( size ) ); } - if ( (new = (char *) realloc( block, size )) == NULL ) { - Debug( LDAP_DEBUG_ANY, "realloc of %d bytes failed\n", size, 0, 0 ); - exit( 1 ); + if( size == 0 ) { + ch_free( block ); + } + + if ( (new = (void *) ber_memrealloc( block, size )) == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG( OPERATION, ERR, + "ch_realloc: reallocation of %lu bytes failed\n", (long)size, 0,0 ); +#else + Debug( LDAP_DEBUG_ANY, "ch_realloc of %lu bytes failed\n", + (long) size, 0, 0 ); +#endif + assert( 0 ); + exit( EXIT_FAILURE ); } return( new ); } -char * +void * ch_calloc( - unsigned long nelem, - unsigned long size + ber_len_t nelem, + ber_len_t size +) +{ + void *new; + + if ( (new = (void *) ber_memcalloc( nelem, size )) == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG( OPERATION, ERR, + "ch_calloc: allocation of %lu elements of %lu bytes faild\n", + (long)nelem, (long)size, 0 ); +#else + Debug( LDAP_DEBUG_ANY, "ch_calloc of %lu elems of %lu bytes failed\n", + (long) nelem, (long) size, 0 ); +#endif + assert( 0 ); + exit( EXIT_FAILURE ); + } + + return( new ); +} + +char * +ch_strdup( + const char *string ) { char *new; - if ( (new = (char *) calloc( nelem, size )) == NULL ) { - Debug( LDAP_DEBUG_ANY, "calloc of %d elems of %d bytes failed\n", - nelem, size, 0 ); - exit( 1 ); + if ( (new = ber_strdup( string )) == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG( OPERATION, ERR, + "chr_strdup: duplication of \"%s\" failed\n", string, 0, 0 ); +#else + Debug( LDAP_DEBUG_ANY, "ch_strdup(%s) failed\n", string, 0, 0 ); +#endif + assert( 0 ); + exit( EXIT_FAILURE ); } return( new ); } + +void +ch_free( void *ptr ) +{ + ber_memfree( ptr ); +} + +#endif diff --git a/servers/slapd/charray.c b/servers/slapd/charray.c index e8c3dbc048d1f74a11d5f6de7b8334c8bfceef64..46bff0714af508f3ff9819c9bafd00528180d9b8 100644 --- a/servers/slapd/charray.c +++ b/servers/slapd/charray.c @@ -211,38 +211,3 @@ charray_strcasecmp( const char **a1, const char **a2 ) return 0; } - -/* strcopy is like strcpy except it returns a pointer to the trailing NUL of - * the result string. This allows fast construction of catenated strings - * without the overhead of strlen/strcat. - */ -char * -slap_strcopy( - char *a, - const char *b -) -{ - if (!a || !b) - return a; - - while ((*a++ = *b++)) ; - return a-1; -} - -/* strncopy is like strcpy except it returns a pointer to the trailing NUL of - * the result string. This allows fast construction of catenated strings - * without the overhead of strlen/strcat. - */ -char * -slap_strncopy( - char *a, - const char *b, - size_t n -) -{ - if (!a || !b || n == 0) - return a; - - while ((*a++ = *b++) && n-- > 0) ; - return a-1; -} diff --git a/servers/slapd/compare.c b/servers/slapd/compare.c index ead4af626e45d00cbc9611d403c19202e12178ff..b62d69dc4ad9410bfcb9271f1a460d1f65017576 100644 --- a/servers/slapd/compare.c +++ b/servers/slapd/compare.c @@ -50,8 +50,7 @@ do_compare( ava.aa_desc = NULL; #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, - "do_compare: conn %d\n", conn->c_connid )); + LDAP_LOG( OPERATION, ENTRY, "do_compare: conn %d\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "do_compare\n", 0, 0, 0 ); #endif @@ -69,8 +68,8 @@ do_compare( if ( ber_scanf( op->o_ber, "{m" /*}*/, &dn ) == LBER_ERROR ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "do_compare: conn %d ber_scanf failed\n", conn->c_connid )); + LDAP_LOG( OPERATION, ERR, + "do_compare: conn %d ber_scanf failed\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0, 0 ); #endif @@ -81,8 +80,8 @@ do_compare( if ( ber_scanf( op->o_ber, "{mm}", &desc, &value ) == LBER_ERROR ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "do_compare: conn %d get ava failed\n", conn->c_connid )); + LDAP_LOG( OPERATION, ERR, + "do_compare: conn %d get ava failed\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_compare: get ava failed\n", 0, 0, 0 ); #endif @@ -94,8 +93,8 @@ do_compare( if ( ber_scanf( op->o_ber, /*{*/ "}" ) == LBER_ERROR ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "do_compare: conn %d ber_scanf failed\n", conn->c_connid )); + LDAP_LOG( OPERATION, ERR, + "do_compare: conn %d ber_scanf failed\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0, 0 ); #endif @@ -107,8 +106,8 @@ do_compare( if( ( rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, - "do_compare: conn %d get_ctrls failed\n", conn->c_connid )); + LDAP_LOG( OPERATION, INFO, + "do_compare: conn %d get_ctrls failed\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_compare: get_ctrls failed\n", 0, 0, 0 ); #endif @@ -118,9 +117,9 @@ do_compare( rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + LDAP_LOG( OPERATION, INFO, "do_compare: conn %d invalid dn (%s)\n", - conn->c_connid, dn.bv_val )); + conn->c_connid, dn.bv_val, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_compare: invalid dn (%s)\n", dn.bv_val, 0, 0 ); @@ -145,10 +144,9 @@ do_compare( if( strcasecmp( ndn.bv_val, LDAP_ROOT_DSE ) == 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ARGS, - "do_compare: conn %d dn (%s) attr(%s) value (%s)\n", - conn->c_connid, pdn.bv_val, - ava.aa_desc->ad_cname.bv_val, ava.aa_value.bv_val )); + LDAP_LOG( OPERATION, ARGS, + "do_compare: dn (%s) attr(%s) value (%s)\n", + pdn.bv_val, ava.aa_desc->ad_cname.bv_val, ava.aa_value.bv_val ); #else Debug( LDAP_DEBUG_ARGS, "do_compare: dn (%s) attr (%s) value (%s)\n", pdn.bv_val, ava.aa_desc->ad_cname.bv_val, ava.aa_value.bv_val ); @@ -173,10 +171,10 @@ do_compare( } else if ( strcasecmp( ndn.bv_val, SLAPD_SCHEMA_DN ) == 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ARGS, - "do_compare: conn %d dn (%s) attr(%s) value (%s)\n", - conn->c_connid, pdn.bv_val, ava.aa_desc->ad_cname.bv_val, - ava.aa_value.bv_val )); + LDAP_LOG( OPERATION, ARGS, + "do_compare: dn (%s) attr(%s) value (%s)\n", + pdn.bv_val, ava.aa_desc->ad_cname.bv_val, + ava.aa_value.bv_val ); #else Debug( LDAP_DEBUG_ARGS, "do_compare: dn (%s) attr (%s) value (%s)\n", pdn.bv_val, ava.aa_desc->ad_cname.bv_val, ava.aa_value.bv_val ); @@ -249,10 +247,9 @@ do_compare( } #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ARGS, - "do_compare: conn %d dn (%s) attr(%s) value (%s)\n", - conn->c_connid, pdn.bv_val, ava.aa_desc->ad_cname.bv_val, - ava.aa_value.bv_val )); + LDAP_LOG( OPERATION, ARGS, + "do_compare: dn (%s) attr(%s) value (%s)\n", + pdn.bv_val, ava.aa_desc->ad_cname.bv_val, ava.aa_value.bv_val ); #else Debug( LDAP_DEBUG_ARGS, "do_compare: dn (%s) attr (%s) value (%s)\n", pdn.bv_val, ava.aa_desc->ad_cname.bv_val, ava.aa_value.bv_val ); diff --git a/servers/slapd/config.c b/servers/slapd/config.c index d3619af88924439ffdd6bbd6374e08adb490b455..5362cbdb9efd245576f6511f89b5c45be9ee054b 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -96,9 +96,9 @@ read_config( const char *fname ) if ( (fp = fopen( fname, "r" )) == NULL ) { ldap_syslog = 1; #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_ENTRY, "read_config: " - "could not open config file \"%s\": %s (%d)\n", - fname, strerror(errno), errno )); + LDAP_LOG( CONFIG, ENTRY, + "read_config: " "could not open config file \"%s\": %s (%d)\n", + fname, strerror(errno), errno ); #else Debug( LDAP_DEBUG_ANY, "could not open config file \"%s\": %s (%d)\n", @@ -108,8 +108,8 @@ read_config( const char *fname ) } #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_ENTRY, - "read_config: reading config file %s\n", fname )); + LDAP_LOG( CONFIG, ENTRY, + "read_config: reading config file %s\n", fname, 0, 0 ); #else Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 ); #endif @@ -132,9 +132,8 @@ read_config( const char *fname ) if ( cargc < 1 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, - "%s: line %d: bad config line (ignored)\n", - fname, lineno )); + LDAP_LOG( CONFIG, INFO, + "%s: line %d: bad config line (ignored)\n", fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: bad config line (ignored)\n", @@ -147,9 +146,9 @@ read_config( const char *fname ) if ( strcasecmp( cargv[0], "backend" ) == 0 ) { if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s : line %d: missing type in \"backend\" line.\n", - fname, lineno )); + fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing type in \"backend <type>\" line\n", @@ -161,9 +160,9 @@ read_config( const char *fname ) if( be != NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: backend line must appear before any " - "database definition.\n", fname, lineno )); + "database definition.\n", fname, lineno , 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: backend line must appear before any database definition\n", @@ -177,9 +176,9 @@ read_config( const char *fname ) if( bi == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "read_config: backend %s initialization failed.\n", - cargv[1] )); + cargv[1], 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "backend %s initialization failed.\n", @@ -191,9 +190,9 @@ read_config( const char *fname ) } else if ( strcasecmp( cargv[0], "database" ) == 0 ) { if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "%s: line %d: missing type in \"database <type>\" line\n", - fname, lineno )); + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: missing type in \"database <type>\" line\n", + fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing type in \"database <type>\" line\n", @@ -208,9 +207,8 @@ read_config( const char *fname ) if( be == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "database %s initialization failed.\n", - cargv[1] )); + LDAP_LOG( CONFIG, CRIT, + "database %s initialization failed.\n", cargv[1], 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "database %s initialization failed.\n", @@ -225,9 +223,9 @@ read_config( const char *fname ) int c; if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "%s: line %d: missing level in \"concurrency <level\" line\n", - fname, lineno )); + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: missing level in \"concurrency <level\" " + " line\n", fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing level in \"concurrency <level>\" line\n", @@ -241,10 +239,9 @@ read_config( const char *fname ) if( c < 1 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "%s: line %d: invalid level (%d) in " - "\"concurrency <level>\" line.\n", - fname, lineno, c )); + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: invalid level (%d) in " + "\"concurrency <level>\" line.\n", fname, lineno, c ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n", @@ -261,9 +258,9 @@ read_config( const char *fname ) long max; if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n", - fname, lineno )); + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: missing max in \"sockbuf_max_incoming " + "<bytes>\" line\n", fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n", @@ -277,10 +274,10 @@ read_config( const char *fname ) if( max < 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: invalid max value (%ld) in " "\"sockbuf_max_incoming <bytes>\" line.\n", - fname, lineno, max )); + fname, lineno, max ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: invalid max value (%ld) in " @@ -298,9 +295,9 @@ read_config( const char *fname ) long max; if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n", - fname, lineno )); + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: missing max in \"sockbuf_max_incoming_auth " + "<bytes>\" line\n", fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n", @@ -314,10 +311,10 @@ read_config( const char *fname ) if( max < 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: invalid max value (%ld) in " "\"sockbuf_max_incoming_auth <bytes>\" line.\n", - fname, lineno, max )); + fname, lineno, max ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: invalid max value (%ld) in " @@ -334,9 +331,9 @@ read_config( const char *fname ) } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) { if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: missing dn in \"defaultSearchBase <dn\" " - "line\n", fname, lineno )); + "line\n", fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: " "missing dn in \"defaultSearchBase <dn>\" line\n", @@ -347,10 +344,10 @@ read_config( const char *fname ) } else if ( cargc > 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, + LDAP_LOG( CONFIG, INFO, "%s: line %d: extra cruft after <dn> in " "\"defaultSearchBase %s\" line (ignored)\n", - fname, lineno, cargv[1] )); + fname, lineno, cargv[1] ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: " "extra cruft after <dn> in \"defaultSearchBase %s\", " @@ -361,10 +358,10 @@ read_config( const char *fname ) if ( bi != NULL || be != NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: defaultSearchBase line must appear " "prior to any backend or database definitions\n", - fname, lineno )); + fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: " "defaultSearchBaase line must appear prior to " @@ -377,10 +374,10 @@ read_config( const char *fname ) if ( default_search_nbase.bv_len ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: " + LDAP_LOG( CONFIG, INFO, "%s: line %d: " "default search base \"%s\" already defined " "(discarding old)\n", fname, lineno, - default_search_base.bv_val )); + default_search_base.bv_val ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: " "default search base \"%s\" already defined " @@ -406,9 +403,9 @@ read_config( const char *fname ) if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: defaultSearchBase DN is invalid.\n", - fname, lineno )); + fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: defaultSearchBase DN is invalid\n", @@ -423,9 +420,9 @@ read_config( const char *fname ) int c; if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "%s: line %d: missing count in \"threads <count>\" line\n", - fname, lineno )); + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: missing count in \"threads <count>\" line\n", + fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing count in \"threads <count>\" line\n", @@ -439,9 +436,9 @@ read_config( const char *fname ) if( c < 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: invalid level (%d) in \"threads <count>\"" - "line\n",fname, lineno, c )); + "line\n", fname, lineno, c ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: invalid level (%d) in \"threads <count>\" line\n", @@ -460,9 +457,9 @@ read_config( const char *fname ) } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) { if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "%s: line %d missing file name in \"pidfile <file>\" line.\n", - fname, lineno )); + LDAP_LOG( CONFIG, CRIT, + "%s: line %d missing file name in \"pidfile <file>\" " + "line.\n", fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing file name in \"pidfile <file>\" line\n", @@ -478,10 +475,10 @@ read_config( const char *fname ) } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) { if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: %d: missing file name in " "\"argsfile <file>\" line.\n", - fname, lineno )); + fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing file name in \"argsfile <file>\" line\n", @@ -497,10 +494,10 @@ read_config( const char *fname ) } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) { if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: missing hash in " "\"password-hash <hash>\" line.\n", - fname, lineno )); + fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing hash in \"password-hash <hash>\" line\n", @@ -511,9 +508,9 @@ read_config( const char *fname ) } if ( default_passwd_hash != NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: already set default password_hash!\n", - fname, lineno )); + fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: already set default password_hash!\n", @@ -526,9 +523,9 @@ read_config( const char *fname ) if ( lutil_passwd_scheme( cargv[1] ) == 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: password scheme \"%s\" not available\n", - fname, lineno, cargv[1] )); + fname, lineno, cargv[1] ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: password scheme \"%s\" not available\n", @@ -543,10 +540,10 @@ read_config( const char *fname ) { if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: missing format in " "\"password-crypt-salt-format <format>\" line\n", - fname, lineno )); + fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing format in " "\"password-crypt-salt-format <format>\" line\n", @@ -570,10 +567,9 @@ read_config( const char *fname ) int err; if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: missing path in " - "\"ucdata-path <path>\" line.\n", - fname, lineno )); + "\"ucdata-path <path>\" line.\n", fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing path in \"ucdata-path <path>\" line\n", @@ -587,11 +583,10 @@ read_config( const char *fname ) if ( err <= 0 ) { if ( err == 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: ucdata already loaded, ucdata-path " "must be set earlier in the file and/or be " - "specified only once!\n", - fname, lineno )); + "specified only once!\n", fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n", @@ -609,9 +604,9 @@ read_config( const char *fname ) if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "%s: line %d: missing limit in \"sizelimit <limit>\" line.\n", - fname, lineno )); + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: missing limit in \"sizelimit <limit>\" " + "line.\n", fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing limit in \"sizelimit <limit>\" line\n", @@ -637,12 +632,10 @@ read_config( const char *fname ) if ( rc ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "%s: line %d: unable " - "to parse value \"%s\" " - "in \"sizelimit " - "<limit>\" line.\n", - fname, lineno, cargv[i] )); + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: unable " + "to parse value \"%s\" in \"sizelimit " + "<limit>\" line.\n", fname, lineno, cargv[i] ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: unable " @@ -661,9 +654,9 @@ read_config( const char *fname ) if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "%s: line %d missing limit in \"timelimit <limit>\" line.\n", - fname, lineno )); + LDAP_LOG( CONFIG, CRIT, + "%s: line %d missing limit in \"timelimit <limit>\" " + "line.\n", fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing limit in \"timelimit <limit>\" line\n", @@ -689,12 +682,10 @@ read_config( const char *fname ) if ( rc ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "%s: line %d: unable " - "to parse value \"%s\" " - "in \"timelimit " - "<limit>\" line.\n", - fname, lineno, cargv[i] )); + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: unable to parse value \"%s\" " + "in \"timelimit <limit>\" line.\n", + fname, lineno, cargv[i] ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: unable " @@ -710,9 +701,9 @@ read_config( const char *fname ) } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) { if ( be == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_WARNING, - "%s: line %d \"limits\" allowed only in database environment.\n", - fname, lineno )); + LDAP_LOG( CONFIG, WARNING, + "%s: line %d \"limits\" allowed only in database " + "environment.\n", fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d \"limits\" allowed only in database environment.\n%s", @@ -729,9 +720,9 @@ read_config( const char *fname ) } else if ( strcasecmp( cargv[0], "subordinate" ) == 0 ) { if ( be == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: " + LDAP_LOG( CONFIG, INFO, "%s: line %d: " "subordinate keyword must appear inside a database " - "definition.\n", fname, lineno )); + "definition.\n", fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line " "must appear inside a database definition.\n", @@ -751,9 +742,9 @@ read_config( const char *fname ) if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: missing dn in \"suffix <dn>\" line.\n", - fname, lineno )); + fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: " "missing dn in \"suffix <dn>\" line\n", @@ -764,9 +755,9 @@ read_config( const char *fname ) } else if ( cargc > 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, + LDAP_LOG( CONFIG, INFO, "%s: line %d: extra cruft after <dn> in \"suffix %s\"" - " line (ignored).\n", fname, lineno, cargv[1] )); + " line (ignored).\n", fname, lineno, cargv[1] ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: extra cruft " "after <dn> in \"suffix %s\" line (ignored)\n", @@ -776,9 +767,9 @@ read_config( const char *fname ) if ( be == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, + LDAP_LOG( CONFIG, INFO, "%s: line %d: suffix line must appear inside a database " - "definition.\n", fname, lineno )); + "definition.\n", fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line " "must appear inside a database definition\n", @@ -790,9 +781,9 @@ read_config( const char *fname ) /* "cn=Monitor" is reserved for monitoring slap */ } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: \"" + LDAP_LOG( CONFIG, CRIT, "%s: line %d: \"" SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n", - fname, lineno )); + fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: \"" SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n", @@ -810,9 +801,9 @@ read_config( const char *fname ) rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: suffix DN is invalid.\n", - fname, lineno )); + fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix DN is invalid\n", @@ -824,9 +815,9 @@ read_config( const char *fname ) tmp_be = select_backend( &ndn, 0, 0 ); if ( tmp_be == be ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, + LDAP_LOG( CONFIG, INFO, "%s: line %d: suffix already served by this backend " - "(ignored)\n", fname, lineno )); + "(ignored)\n", fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix " "already served by this backend (ignored)\n", @@ -837,10 +828,10 @@ read_config( const char *fname ) } else if ( tmp_be != NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, + LDAP_LOG( CONFIG, INFO, "%s: line %d: suffix already served by a preceding " "backend \"%s\"\n", fname, lineno, - tmp_be->be_suffix[0].bv_val )); + tmp_be->be_suffix[0].bv_val ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix " "already served by a preceeding backend \"%s\"\n", @@ -852,10 +843,10 @@ read_config( const char *fname ) } else if( pdn.bv_len == 0 && default_search_nbase.bv_len ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, + LDAP_LOG( CONFIG, INFO, "%s: line %d: suffix DN empty and default search " "base provided \"%s\" (assuming okay).\n", - fname, lineno, default_search_base.bv_val )); + fname, lineno, default_search_base.bv_val ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: " "suffix DN empty and default " @@ -875,10 +866,10 @@ read_config( const char *fname ) if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: missing alias and aliased_dn in " "\"suffixAlias <alias> <aliased_dn>\" line.\n", - fname, lineno )); + fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing alias and aliased_dn in " @@ -889,10 +880,10 @@ read_config( const char *fname ) return( 1 ); } else if ( cargc < 3 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: missing aliased_dn in " "\"suffixAlias <alias> <aliased_dn>\" line\n", - fname, lineno )); + fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing aliased_dn in " @@ -903,9 +894,9 @@ read_config( const char *fname ) } else if ( cargc > 3 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: extra cruft in suffixAlias line (ignored)\n", - fname, lineno )); + fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: extra cruft in suffixAlias line (ignored)\n", @@ -915,9 +906,9 @@ read_config( const char *fname ) if ( be == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, - "%s: line %d: suffixAlias line must appear inside a " - "database definition.\n", fname, lineno )); + LDAP_LOG( CONFIG, INFO, + "%s: line %d: suffix line must appear inside a database " + "definition.\n", fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: suffixAlias line" @@ -935,9 +926,8 @@ read_config( const char *fname ) rc = dnPrettyNormal( NULL, &alias, &palias, &nalias ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "%s: line %d: alias DN is invalid.\n", - fname, lineno )); + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: alias DN is invalid.\n", fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: alias DN is invalid\n", @@ -950,10 +940,10 @@ read_config( const char *fname ) free( nalias.bv_val ); if ( tmp_be && tmp_be != be ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, + LDAP_LOG( CONFIG, INFO, "%s: line %d: suffixAlias served by a preceeding " - "backend \"%s\"\n", - fname, lineno, tmp_be->be_suffix[0].bv_val )); + "backend \"%s\"\n", fname, lineno, + tmp_be->be_suffix[0].bv_val ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: suffixAlias served by" @@ -970,9 +960,8 @@ read_config( const char *fname ) rc = dnPrettyNormal( NULL, &aliased, &paliased, &naliased ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "%s: line %d: aliased DN is invalid.\n", - fname, lineno )); + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: aliased DN is invalid.\n", fname, lineno,0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: aliased DN is invalid\n", @@ -986,10 +975,10 @@ read_config( const char *fname ) free( naliased.bv_val ); if ( tmp_be && tmp_be != be ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, + LDAP_LOG( CONFIG, INFO, "%s: line %d: suffixAlias derefs to a different backend " "a preceeding backend \"%s\"\n", - fname, lineno, tmp_be->be_suffix[0].bv_val )); + fname, lineno, tmp_be->be_suffix[0].bv_val ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: suffixAlias derefs to differnet backend" @@ -1009,9 +998,9 @@ read_config( const char *fname ) int i; if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: missing depth in \"maxDerefDepth <depth>\"" - " line\n", fname, lineno )); + " line\n", fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n", @@ -1022,9 +1011,9 @@ read_config( const char *fname ) } if ( be == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, + LDAP_LOG( CONFIG, INFO, "%s: line %d: depth line must appear inside a database " - "definition.\n", fname, lineno )); + "definition.\n", fname, lineno ,0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: depth line must appear inside a database definition.\n", @@ -1034,9 +1023,9 @@ read_config( const char *fname ) } else if ((i = atoi(cargv[1])) < 0) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, + LDAP_LOG( CONFIG, INFO, "%s: line %d: depth must be positive.\n", - fname, lineno )); + fname, lineno ,0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: depth must be positive.\n", @@ -1054,9 +1043,9 @@ read_config( const char *fname ) } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) { if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, + LDAP_LOG( CONFIG, INFO, "%s: line %d: missing dn in \"rootdn <dn>\" line.\n", - fname, lineno )); + fname, lineno ,0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing dn in \"rootdn <dn>\" line\n", @@ -1068,9 +1057,9 @@ read_config( const char *fname ) if ( be == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, + LDAP_LOG( CONFIG, INFO, "%s: line %d: rootdn line must appear inside a database " - "definition.\n", fname, lineno )); + "definition.\n", fname, lineno ,0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: rootdn line must appear inside a database definition.\n", @@ -1092,9 +1081,9 @@ read_config( const char *fname ) if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "%s: line %d: rootdn DN is invalid.\n", - fname, lineno )); + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: rootdn DN is invalid.\n", + fname, lineno ,0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: rootdn DN is invalid\n", @@ -1108,9 +1097,9 @@ read_config( const char *fname ) } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) { if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: missing passwd in \"rootpw <passwd>\"" - " line\n", fname, lineno )); + " line\n", fname, lineno ,0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: " "missing passwd in \"rootpw <passwd>\" line\n", @@ -1122,9 +1111,9 @@ read_config( const char *fname ) if ( be == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: " + LDAP_LOG( CONFIG, INFO, "%s: line %d: " "rootpw line must appear inside a database " - "definition.\n", fname, lineno )); + "definition.\n", fname, lineno ,0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: " "rootpw line must appear inside a database " @@ -1138,10 +1127,10 @@ read_config( const char *fname ) if( tmp_be != be ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, + LDAP_LOG( CONFIG, INFO, "%s: line %d: " - "rootpw can only be set when rootdn is under suffix\n" - fname, lineno )); + "rootpw can only be set when rootdn is under suffix\n", + fname, lineno, "" ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: " "rootpw can only be set when rootdn is under suffix\n", @@ -1158,9 +1147,9 @@ read_config( const char *fname ) } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) { if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "%s: line %d: missing on|off in \"readonly <on|off>\" line.\n", - fname, lineno )); + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: missing on|off in \"readonly <on|off>\" " + "line.\n", fname, lineno ,0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing on|off in \"readonly <on|off>\" line\n", @@ -1192,9 +1181,9 @@ read_config( const char *fname ) if ( be != NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, + LDAP_LOG( CONFIG, INFO, "%s: line %d: allow line must appear prior to " - "database definitions.\n", fname, lineno )); + "database definitions.\n", fname, lineno ,0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: allow line must appear prior to database definitions\n", @@ -1205,9 +1194,9 @@ read_config( const char *fname ) if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: missing feature(s) in \"allow <features>\"" - " line\n", fname, lineno )); + " line\n", fname, lineno ,0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing feature(s) in \"allow <features>\" line\n", @@ -1231,10 +1220,10 @@ read_config( const char *fname ) } else if( strcasecmp( cargv[i], "none" ) != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: unknown feature %s in " "\"allow <features>\" line.\n", - fname, lineno, cargv[1] )); + fname, lineno, cargv[1] ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: unknown feature %s in \"allow <features>\" line\n", @@ -1255,9 +1244,9 @@ read_config( const char *fname ) if ( be != NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, + LDAP_LOG( CONFIG, INFO, "%s: line %d: disallow line must appear prior to " - "database definitions.\n", fname, lineno )); + "database definitions.\n", fname, lineno ,0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: disallow line must appear prior to database definitions\n", @@ -1268,9 +1257,9 @@ read_config( const char *fname ) if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "%s: line %d: missing feature(s) in \"disallow <features>\"" - " line.\n", fname, lineno )); + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: missing feature(s) in \"disallow <features>\"" + " line.\n", fname, lineno ,0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing feature(s) in \"disallow <features>\" line\n", @@ -1303,10 +1292,10 @@ read_config( const char *fname ) } else if( strcasecmp( cargv[i], "none" ) != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: unknown feature %s in " "\"disallow <features>\" line.\n", - fname, lineno, cargv[i] )); + fname, lineno, cargv[i] ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: unknown feature %s in \"disallow <features>\" line\n", @@ -1327,9 +1316,9 @@ read_config( const char *fname ) if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: missing feature(s) in " - "\"require <features>\" line.\n", fname, lineno )); + "\"require <features>\" line.\n", fname, lineno ,0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing feature(s) in \"require <features>\" line\n", @@ -1359,10 +1348,10 @@ read_config( const char *fname ) } else if( strcasecmp( cargv[i], "none" ) != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: unknown feature %s in " - "\"require <features>\" line.\n", - fname, lineno )); + "\"require <features>\" line.\n", + fname, lineno , cargv[i] ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: unknown feature %s in \"require <features>\" line\n", @@ -1385,9 +1374,9 @@ read_config( const char *fname ) if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "%s: line %d: missing factor(s) in \"security <factors>\"" - " line.\n", fname, lineno )); + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: missing factor(s) in \"security <factors>\"" + " line.\n", fname, lineno ,0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing factor(s) in \"security <factors>\" line\n", @@ -1454,10 +1443,10 @@ read_config( const char *fname ) } else { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: unknown factor %S in " "\"security <factors>\" line.\n", - fname, lineno, cargv[1] )); + fname, lineno, cargv[1] ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: unknown factor %s in \"security <factors>\" line\n", @@ -1471,9 +1460,9 @@ read_config( const char *fname ) } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) { if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "%s: line %d: missing URL in \"referral <URL>\"" - " line.\n", fname, lineno )); + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: missing URL in \"referral <URL>\"" + " line.\n", fname, lineno , 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing URL in \"referral <URL>\" line\n", @@ -1485,9 +1474,9 @@ read_config( const char *fname ) if( validate_global_referral( cargv[1] ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: " - "invalid URL (%s) in \"referral\" line.\n", - fname, lineno, cargv[1] )); + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: invalid URL (%s) in \"referral\" line.\n", + fname, lineno, cargv[1] ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: " "invalid URL (%s) in \"referral\" line.\n", @@ -1505,9 +1494,9 @@ read_config( const char *fname ) FILE *logfile; if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "%s: line %d: Error in logfile directive, " - "\"logfile <filename>\"\n", fname, lineno )); + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: Error in logfile directive, " + "\"logfile <filename>\"\n", fname, lineno , 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: Error in logfile directive, \"logfile filename\"\n", @@ -1517,7 +1506,7 @@ read_config( const char *fname ) return( 1 ); } logfile = fopen( cargv[1], "w" ); - if ( logfile != NULL ) lutil_debug_file( logfile ); + if ( logfile != NULL ) lutil_debug_file( logfile ); #endif /* start of a new database definition */ @@ -1525,9 +1514,9 @@ read_config( const char *fname ) int level; if ( cargc < 3 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: Error in debug directive, " - "\"debug <subsys> <level>\"\n", fname, lineno )); + "\"debug <subsys> <level>\"\n", fname, lineno , 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: Error in debug directive, \"debug subsys level\"\n", @@ -1554,9 +1543,9 @@ read_config( const char *fname ) } else { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, - "%s: line %d: old objectclass format not supported\n", - fname, lineno )); + LDAP_LOG( CONFIG, INFO, + "%s: line %d: old objectclass format not supported\n", + fname, lineno , 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: old objectclass format not supported.\n", @@ -1576,9 +1565,9 @@ read_config( const char *fname ) } else { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, - "%s: line %d: old attribute type format not supported.\n", - fname, lineno )); + LDAP_LOG( CONFIG, INFO, + "%s: line %d: old attribute type format not supported.\n", + fname, lineno , 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: old attribute type format not supported.\n", @@ -1591,10 +1580,9 @@ read_config( const char *fname ) } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) { if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "%s: line %d: missing on|off in " - "\"schemacheck <on|off>\" line.\n", - fname, lineno )); + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: missing on|off in \"schemacheck <on|off>\"" + " line.\n", fname, lineno , 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n", @@ -1605,9 +1593,9 @@ read_config( const char *fname ) } if ( strcasecmp( cargv[1], "off" ) == 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "%s: line %d: schema checking disabled! your mileage may vary!\n", - fname, lineno )); + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: schema checking disabled! your mileage may " + "vary!\n", fname, lineno , 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: schema checking disabled! your mileage may vary!\n", @@ -1626,9 +1614,9 @@ read_config( const char *fname ) } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) { if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "%s: line %d: missing level in \"loglevel <level>\"" - " line.\n", fname, lineno )); + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: missing level in \"loglevel <level>\"" + " line.\n", fname, lineno , 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing level in \"loglevel <level>\" line\n", @@ -1648,9 +1636,9 @@ read_config( const char *fname ) } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) { if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "%s: line %d: missing host in \"replica " - " <host[:port]\" line\n", fname, lineno )); + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: missing host in \"replica " + " <host[:port]\" line\n", fname, lineno , 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing host in \"replica <host[:port]>\" line\n", @@ -1661,9 +1649,9 @@ read_config( const char *fname ) } if ( be == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, - "%s: line %d: replica line must appear inside " - "a database definition.\n", fname, lineno )); + LDAP_LOG( CONFIG, INFO, + "%s: line %d: replica line must appear inside " + "a database definition.\n", fname, lineno, 0); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: replica line must appear inside a database definition\n", @@ -1684,9 +1672,9 @@ read_config( const char *fname ) } if ( i == cargc ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, - "%s: line %d: missing host in \"replica\" line\n", - fname, lineno )); + LDAP_LOG( CONFIG, INFO, + "%s: line %d: missing host in \"replica\" line\n", + fname, lineno , 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing host in \"replica\" line\n", @@ -1696,11 +1684,11 @@ read_config( const char *fname ) } else if ( nr == -1 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, + LDAP_LOG( CONFIG, INFO, "%s: line %d: unable to add" - " replica \"%s\"\n", + " replica \"%s\"\n", fname, lineno, - cargv[i] + 5 )); + cargv[i] + 5 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: unable to add replica \"%s\"\n", @@ -1714,9 +1702,10 @@ read_config( const char *fname ) switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) { case 1: #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, - "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n", - fname, lineno, cargv[i] + 7 )); + LDAP_LOG( CONFIG, INFO, + "%s: line %d: suffix \"%s\" in \"replica\"" + " line is not valid for backend(ignored)\n", + fname, lineno, cargv[i] + 7 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n", @@ -1726,9 +1715,10 @@ read_config( const char *fname ) case 2: #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, - "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n", - fname, lineno )); + LDAP_LOG( CONFIG, INFO, + "%s: line %d: unable to normalize suffix" + " in \"replica\" line (ignored)\n", + fname, lineno , 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n", @@ -1752,9 +1742,10 @@ read_config( const char *fname ) if ( add_replica_attrs( be, nr, arg + 1, exclude ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, - "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n", - fname, lineno, arg + 1 )); + LDAP_LOG( CONFIG, INFO, + "%s: line %d: attribute \"%s\" in " + "\"replica\" line is unknown\n", + fname, lineno, arg + 1 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n", @@ -1771,9 +1762,9 @@ read_config( const char *fname ) } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) { if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "%s: line %d: missing dn in \"updatedn <dn>\"" - " line.\n", fname, lineno )); + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: missing dn in \"updatedn <dn>\"" + " line.\n", fname, lineno , 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing dn in \"updatedn <dn>\" line\n", @@ -1784,10 +1775,10 @@ read_config( const char *fname ) } if ( be == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, - "%s: line %d: updatedn line must appear inside " - "a database definition\n", - fname, lineno )); + LDAP_LOG( CONFIG, INFO, + "%s: line %d: updatedn line must appear inside " + "a database definition\n", + fname, lineno , 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: updatedn line must appear inside a database definition\n", @@ -1806,9 +1797,9 @@ read_config( const char *fname ) rc = dnNormalize2( NULL, &dn, &be->be_update_ndn ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: updatedn DN is invalid.\n", - fname, lineno )); + fname, lineno , 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: updatedn DN is invalid\n", @@ -1821,9 +1812,9 @@ read_config( const char *fname ) } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) { if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: " + LDAP_LOG( CONFIG, CRIT, "%s: line %d: " "missing url in \"updateref <ldapurl>\" line.\n", - fname, lineno )); + fname, lineno , 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: " "missing url in \"updateref <ldapurl>\" line\n", @@ -1834,9 +1825,9 @@ read_config( const char *fname ) } if ( be == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: updateref" + LDAP_LOG( CONFIG, INFO, "%s: line %d: updateref" " line must appear inside a database definition\n", - fname, lineno )); + fname, lineno , 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref" " line must appear inside a database definition\n", @@ -1846,9 +1837,9 @@ read_config( const char *fname ) } else if ( !be->be_update_ndn.bv_len ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: " + LDAP_LOG( CONFIG, INFO, "%s: line %d: " "updateref line must come after updatedn.\n", - fname, lineno )); + fname, lineno , 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: " "updateref line must after updatedn.\n", @@ -1859,9 +1850,9 @@ read_config( const char *fname ) if( validate_global_referral( cargv[1] ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: " + LDAP_LOG( CONFIG, CRIT, "%s: line %d: " "invalid URL (%s) in \"updateref\" line.\n", - fname, lineno, cargv[1] )); + fname, lineno, cargv[1] ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: " "invalid URL (%s) in \"updateref\" line.\n", @@ -1878,9 +1869,9 @@ read_config( const char *fname ) } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) { if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "%s: line %d: missing filename in \"replogfile <filename>\"" - " line.\n", fname, lineno )); + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: missing filename in \"replogfile <filename>\"" + " line.\n", fname, lineno , 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing filename in \"replogfile <filename>\" line\n", @@ -1899,9 +1890,9 @@ read_config( const char *fname ) } else if ( strcasecmp( cargv[0], "rootDSE" ) == 0) { if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: " + LDAP_LOG( CONFIG, CRIT, "%s: line %d: " "missing filename in \"rootDSE <filename>\" line.\n", - fname, lineno )); + fname, lineno , 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: " "missing filename in \"rootDSE <filename>\" line.\n", @@ -1912,9 +1903,9 @@ read_config( const char *fname ) if( read_root_dse_file( cargv[1] ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: " + LDAP_LOG( CONFIG, CRIT, "%s: line %d: " "could not read \"rootDSE <filename>\" line.\n", - fname, lineno )); + fname, lineno , 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: " "could not read \"rootDSE <filename>\" line\n", @@ -1927,9 +1918,9 @@ read_config( const char *fname ) } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) { if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: missing on|off in \"lastmod <on|off>\"" - " line.\n", fname, lineno )); + " line.\n", fname, lineno , 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n", @@ -1973,9 +1964,9 @@ read_config( const char *fname ) int i; if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "%s: line %d: missing timeout value in " - "\"idletimeout <seconds>\" line.\n", fname, lineno )); + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: missing timeout value in " + "\"idletimeout <seconds>\" line.\n", fname, lineno , 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n", @@ -1989,10 +1980,9 @@ read_config( const char *fname ) if( i < 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "%s: line %d: timeout value (%d) invalid " - "\"idletimeout <seconds>\" line.\n", - fname, lineno, i )); + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: timeout value (%d) invalid " + "\"idletimeout <seconds>\" line.\n", fname, lineno, i ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n", @@ -2008,9 +1998,9 @@ read_config( const char *fname ) } else if ( strcasecmp( cargv[0], "include" ) == 0 ) { if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "%s: line %d: missing filename in \"include " - "<filename>\" line.\n", fname, lineno )); + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: missing filename in \"include " + "<filename>\" line.\n", fname, lineno , 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing filename in \"include <filename>\" line\n", @@ -2033,9 +2023,9 @@ read_config( const char *fname ) } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) { if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "%s: line %d: missing filename in \"srvtab " - "<filename>\" line.\n", fname, lineno )); + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: missing filename in \"srvtab " + "<filename>\" line.\n", fname, lineno , 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing filename in \"srvtab <filename>\" line\n", @@ -2050,9 +2040,9 @@ read_config( const char *fname ) } else if (strcasecmp( cargv[0], "moduleload") == 0 ) { if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, - "%s: line %d: missing filename in \"moduleload " - "<filename>\" line.\n", fname, lineno )); + LDAP_LOG( CONFIG, INFO, + "%s: line %d: missing filename in \"moduleload " + "<filename>\" line.\n", fname, lineno , 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing filename in \"moduleload <filename>\" line\n", @@ -2063,9 +2053,9 @@ read_config( const char *fname ) } if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "%s: line %d: failed to load or initialize module %s\n", - fname, lineno, cargv[1] )); + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: failed to load or initialize module %s\n", + fname, lineno, cargv[1] ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: failed to load or initialize module %s\n", @@ -2077,9 +2067,9 @@ read_config( const char *fname ) } else if (strcasecmp( cargv[0], "modulepath") == 0 ) { if ( cargc != 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, - "%s: line %d: missing path in \"modulepath <path>\"" - " line\n", fname, lineno )); + LDAP_LOG( CONFIG, INFO, + "%s: line %d: missing path in \"modulepath <path>\"" + " line\n", fname, lineno , 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing path in \"modulepath <path>\" line\n", @@ -2090,9 +2080,9 @@ read_config( const char *fname ) } if (module_path( cargv[1] )) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "%s: line %d: failed to set module search path to %s.\n", - fname, lineno, cargv[1] )); + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: failed to set module search path to %s.\n", + fname, lineno, cargv[1] ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: failed to set module search path to %s\n", @@ -2167,10 +2157,9 @@ read_config( const char *fname ) #ifdef SLAPD_RLOOKUPS if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, - "%s: line %d: reverse-lookup: " - "missing \"on\" or \"off\"\n", - fname, lineno )); + LDAP_LOG( CONFIG, INFO, + "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n", + fname, lineno , 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n", @@ -2185,11 +2174,9 @@ read_config( const char *fname ) use_reverse_lookup = 0; } else { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, - "%s: line %d: reverse-lookup: " - "must be \"on\" (default) " - "or \"off\"\n", - fname, lineno )); + LDAP_LOG( CONFIG, INFO, + "%s: line %d: reverse-lookup: " + "must be \"on\" (default) or \"off\"\n", fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: reverse-lookup: must be \"on\" (default) or \"off\"\n", @@ -2200,10 +2187,9 @@ read_config( const char *fname ) #else /* !SLAPD_RLOOKUPS */ #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, - "%s: line %d: reverse lookups " - "are not configured (ignored).\n", - fname, lineno )); + LDAP_LOG( CONFIG, INFO, + "%s: line %d: reverse lookups " + "are not configured (ignored).\n", fname, lineno , 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: reverse lookups are not configured (ignored).\n", @@ -2216,10 +2202,10 @@ read_config( const char *fname ) if ( bi != NULL ) { if ( bi->bi_config == 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, - "%s: line %d: unknown directive \"%s\" inside " - "backend info definition (ignored).\n", - fname, lineno, cargv[0] )); + LDAP_LOG( CONFIG, INFO, + "%s: line %d: unknown directive \"%s\" inside " + "backend info definition (ignored).\n", + fname, lineno, cargv[0] ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n", @@ -2236,10 +2222,10 @@ read_config( const char *fname ) } else if ( be != NULL ) { if ( be->be_config == 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, - "%s: line %d: uknown directive \"%s\" inside " - "backend database definition (ignored).\n", - fname, lineno, cargv[0] )); + LDAP_LOG( CONFIG, INFO, + "%s: line %d: uknown directive \"%s\" inside " + "backend database definition (ignored).\n", + fname, lineno, cargv[0] ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n", @@ -2255,10 +2241,10 @@ read_config( const char *fname ) } } else { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, - "%s: line %d: unknown directive \"%s\" outside backend " - "info and database definitions (ignored).\n", - fname, lineno, cargv[0] )); + LDAP_LOG( CONFIG, INFO, + "%s: line %d: unknown directive \"%s\" outside backend " + "info and database definitions (ignored).\n", + fname, lineno, cargv[0] ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n", @@ -2289,23 +2275,29 @@ fp_parse_line( token = strtok_quote( line, " \t" ); logline = line; - if ( token && - (strcasecmp( token, "rootpw" ) == 0 || - strcasecmp( token, "replica" ) == 0 || /* contains "credentials" */ - strcasecmp( token, "bindpw" ) == 0 || /* used in back-ldap */ - strcasecmp( token, "pseudorootpw" ) == 0 || /* used in back-meta */ - strcasecmp( token, "dbpasswd" ) == 0 ) ) /* used in back-sql */ - sprintf( logline = logbuf, "%s ***", token ); - if ( strtok_quote_ptr ) + + if ( token && ( strcasecmp( token, "rootpw" ) == 0 || + strcasecmp( token, "replica" ) == 0 || /* contains "credentials" */ + strcasecmp( token, "bindpw" ) == 0 || /* used in back-ldap */ + strcasecmp( token, "pseudorootpw" ) == 0 || /* used in back-meta */ + strcasecmp( token, "dbpasswd" ) == 0 ) ) /* used in back-sql */ + { + snprintf( logline = logbuf, sizeof logbuf, "%s ***", token ); + } + + if ( strtok_quote_ptr ) { *strtok_quote_ptr = ' '; + } + #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_DETAIL1, - "line %d (%s)\n", lineno, logline )); + LDAP_LOG( CONFIG, DETAIL1, "line %d (%s)\n", lineno, logline , 0 ); #else Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, logline, 0 ); #endif - if ( strtok_quote_ptr ) + + if ( strtok_quote_ptr ) { *strtok_quote_ptr = '\0'; + } for ( ; token != NULL; token = strtok_quote( NULL, " \t" ) ) { if ( cargc == cargv_size - 1 ) { @@ -2314,9 +2306,7 @@ fp_parse_line( sizeof(*cargv) ); if ( tmp == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_ERR, - "line %d: out of memory\n", - lineno )); + LDAP_LOG( CONFIG, ERR, "line %d: out of memory\n", lineno, 0,0 ); #else Debug( LDAP_DEBUG_ANY, "line %d: out of memory\n", @@ -2390,18 +2380,18 @@ strtok_quote( char *line, char *sep ) static char buf[BUFSIZ]; static char *line; -static int lmax, lcur; - -#define CATLINE( buf ) { \ - int len; \ - len = strlen( buf ); \ - while ( lcur + len + 1 > lmax ) { \ - lmax += BUFSIZ; \ - line = (char *) ch_realloc( line, lmax ); \ - } \ - strcpy( line + lcur, buf ); \ - lcur += len; \ -} +static size_t lmax, lcur; + +#define CATLINE( buf ) \ + do { \ + size_t len = strlen( buf ); \ + while ( lcur + len + 1 > lmax ) { \ + lmax += BUFSIZ; \ + line = (char *) ch_realloc( line, lmax ); \ + } \ + strcpy( line + lcur, buf ); \ + lcur += len; \ + } while( 0 ) static char * fp_getline( FILE *fp, int *lineno ) @@ -2469,8 +2459,8 @@ load_ucdata( char *path ) err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL ); if ( err ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "load_ucdata: Error %d loading ucdata.\n", err )); + LDAP_LOG( CONFIG, CRIT, + "load_ucdata: Error %d loading ucdata.\n", err, 0,0 ); #else Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n", err, 0, 0 ); diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index 6425e199f2561e28e8e49ebfa1dca01f64d001f4..8570a4a16322c33c1abb63edf8825240c7c97072 100644 --- a/servers/slapd/connection.c +++ b/servers/slapd/connection.c @@ -74,8 +74,8 @@ int connections_init(void) if( connections != NULL) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_INFO, - "connections_init: already initialized.\n" )); + LDAP_LOG( CONNECTION, INFO, + "connections_init: already initialized.\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "connections_init: already initialized.\n", 0, 0, 0 ); @@ -90,9 +90,9 @@ int connections_init(void) if( connections == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_ERR, - "connections_init: allocation (%d * %ld) of connection array failed\n", - dtblsize, (long) sizeof(Connection) )); + LDAP_LOG( CONNECTION, ERR, + "connections_init: allocation (%d * %ld) of connection " + "array failed\n", dtblsize, (long) sizeof(Connection), 0 ); #else Debug( LDAP_DEBUG_ANY, "connections_init: allocation (%d*%ld) of connection array failed\n", @@ -123,8 +123,8 @@ int connections_destroy(void) if( connections == NULL) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_INFO, - "connections_destroy: nothing to destroy.\n")); + LDAP_LOG( CONNECTION, INFO, + "connections_destroy: nothing to destroy.\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "connections_destroy: nothing to destroy.\n", 0, 0, 0 ); @@ -208,8 +208,7 @@ static Connection* connection_get( ber_socket_t s ) Connection *c; #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_ENTRY, - "connection_get: socket %ld\n", (long)s )); + LDAP_LOG( CONNECTION, ENTRY, "connection_get: socket %ld\n", (long)s, 0, 0 ); #else Debug( LDAP_DEBUG_ARGS, "connection_get(%ld)\n", @@ -273,8 +272,8 @@ static Connection* connection_get( ber_socket_t s ) assert( sd == AC_SOCKET_INVALID ); #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_ARGS, - "connection_get: connection %d not used\n", s )); + LDAP_LOG( CONNECTION, ARGS, + "connection_get: connection %d not used\n", s, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "connection_get(%d): connection not used\n", @@ -286,8 +285,8 @@ static Connection* connection_get( ber_socket_t s ) } #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_RESULTS, - "connection_get: get for %d got connid %lu\n", s, c->c_connid )); + LDAP_LOG( CONNECTION, RESULTS, + "connection_get: get for %d got connid %lu\n", s, c->c_connid, 0 ); #else Debug( LDAP_DEBUG_TRACE, "connection_get(%d): got connid=%lu\n", @@ -342,8 +341,8 @@ long connection_init( if( s == AC_SOCKET_INVALID ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_INFO, - "connection_init: init of socket %ld invalid.\n", (long)s )); + LDAP_LOG( CONNECTION, INFO, + "connection_init: init of socket %ld invalid.\n", (long)s, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "connection_init(%ld): invalid.\n", @@ -394,9 +393,9 @@ long connection_init( if( c == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_INFO, + LDAP_LOG( CONNECTION, INFO, "connection_init: skt %d connection table full (%d/%d)\n", - s, i, dtblsize )); + s, i, dtblsize ); #else Debug( LDAP_DEBUG_ANY, "connection_init(%d): connection table full (%d/%d)\n", @@ -529,9 +528,9 @@ long connection_init( c /* non-NULL */ ) < 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_INFO, + LDAP_LOG( CONNECTION, INFO, "connection_init: conn %lu set nonblocking failed\n", - c->c_connid )); + c->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "connection_init(%d, %s): set nonblocking failed\n", @@ -753,9 +752,9 @@ void connection_closing( Connection *c ) ber_sockbuf_ctrl( c->c_sb, LBER_SB_OPT_GET_FD, &sd ); #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1, + LDAP_LOG( CONNECTION, DETAIL1, "connection_closing: conn %lu readying socket %d for close.\n", - c->c_connid, sd )); + c->c_connid, sd, 0 ); #else Debug( LDAP_DEBUG_TRACE, "connection_closing: readying conn=%lu sd=%d for close\n", @@ -790,9 +789,9 @@ static void connection_close( Connection *c ) ber_sockbuf_ctrl( c->c_sb, LBER_SB_OPT_GET_FD, &sd ); if( !LDAP_STAILQ_EMPTY(&c->c_ops) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1, + LDAP_LOG( CONNECTION, DETAIL1, "connection_close: conn %lu deferring sd %d\n", - c->c_connid, sd )); + c->c_connid, sd, 0 ); #else Debug( LDAP_DEBUG_TRACE, "connection_close: deferring conn=%lu sd=%d\n", @@ -802,9 +801,8 @@ static void connection_close( Connection *c ) } #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_RESULTS, - "connection_close: conn %lu sd %d\n", - c->c_connid, sd )); + LDAP_LOG( CONNECTION, RESULTS, + "connection_close: conn %lu sd %d\n", c->c_connid, sd, 0 ); #else Debug( LDAP_DEBUG_TRACE, "connection_close: conn=%lu sd=%d\n", c->c_connid, sd, 0 ); @@ -922,9 +920,9 @@ connection_operation( void *arg_v ) if( conn->c_sasl_bind_in_progress && tag != LDAP_REQ_BIND ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_ERR, - "connection_operation: conn %lu SASL bind in progress (tag=%ld).\n", - conn->c_connid, (long)tag )); + LDAP_LOG( CONNECTION, ERR, + "connection_operation: conn %lu SASL bind in progress (tag=%ld).\n", + conn->c_connid, (long)tag, 0 ); #else Debug( LDAP_DEBUG_ANY, "connection_operation: " "error: SASL bind in progress (tag=%ld).\n", @@ -989,9 +987,9 @@ connection_operation( void *arg_v ) default: #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_INFO, + LDAP_LOG( CONNECTION, INFO, "connection_operation: conn %lu unknown LDAP request 0x%lx\n", - conn->c_connid, tag )); + conn->c_connid, tag, 0 ); #else Debug( LDAP_DEBUG_ANY, "unknown LDAP request 0x%lx\n", tag, 0, 0 ); @@ -1087,6 +1085,7 @@ int connection_read(ber_socket_t s) { int rc = 0; Connection *c; + assert( connections != NULL ); ldap_pvt_thread_mutex_lock( &connections_mutex ); @@ -1096,9 +1095,8 @@ int connection_read(ber_socket_t s) if( c == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_INFO, - "connection_read: sock %ld no connection\n", - (long)s )); + LDAP_LOG( CONNECTION, INFO, + "connection_read: sock %ld no connection\n", (long)s, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "connection_read(%ld): no connection!\n", @@ -1114,9 +1112,9 @@ int connection_read(ber_socket_t s) if( c->c_conn_state == SLAP_C_CLOSING ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_INFO, - "connection_read: conn %lu connection closing, ignoring input\n", - c->c_connid)); + LDAP_LOG( CONNECTION, INFO, + "connection_read: conn %lu connection closing, ignoring input\n", + c->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "connection_read(%d): closing, ignoring input for id=%lu\n", @@ -1128,8 +1126,9 @@ int connection_read(ber_socket_t s) } #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1, - "connection_read: conn %lu checking for input.\n", c->c_connid )); + LDAP_LOG( CONNECTION, DETAIL1, + "connection_read: conn %lu checking for input.\n", + c->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "connection_read(%d): checking for input on id=%lu\n", @@ -1146,9 +1145,9 @@ int connection_read(ber_socket_t s) #endif #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_ERR, + LDAP_LOG( CONNECTION, ERR, "connection_read: conn %lu TLS accept error, error %d\n", - c->c_connid, rc )); + c->c_connid, rc, 0 ); #else Debug( LDAP_DEBUG_TRACE, "connection_read(%d): TLS accept error " @@ -1192,9 +1191,9 @@ int connection_read(ber_socket_t s) rc = dnX509peerNormalize( ssl, &authid ); if ( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_INFO, - "connection_read: conn %lu unable to get TLS client DN, error %d\n", - c->c_connid, rc)); + LDAP_LOG( CONNECTION, INFO, + "connection_read: conn %lu unable to get TLS client DN, " + "error %d\n", c->c_connid, rc, 0 ); #else Debug( LDAP_DEBUG_TRACE, "connection_read(%d): unable to get TLS client DN " @@ -1225,9 +1224,9 @@ int connection_read(ber_socket_t s) if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_ERR, - "connection_read: conn %lu SASL install error %d, closing\n", - c->c_connid, rc )); + LDAP_LOG( CONNECTION, ERR, + "connection_read: conn %lu SASL install error %d, closing\n", + c->c_connid, rc, 0 ); #else Debug( LDAP_DEBUG_TRACE, "connection_read(%d): SASL install error " @@ -1258,9 +1257,9 @@ int connection_read(ber_socket_t s) if( rc < 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_ERR, - "connection_read: conn %lu input error %d, closing.\n", - c->c_connid, rc )); + LDAP_LOG( CONNECTION, ERR, + "connection_read: conn %lu input error %d, closing.\n", + c->c_connid, rc, 0 ); #else Debug( LDAP_DEBUG_TRACE, "connection_read(%d): input error=%d id=%lu, closing.\n", @@ -1305,9 +1304,9 @@ connection_input( if ( conn->c_currentber == NULL && (conn->c_currentber = ber_alloc()) == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_ERR, - "connection_input: conn %lu ber_alloc failed.\n", - conn->c_connid )); + LDAP_LOG( CONNECTION, ERR, + "connection_input: conn %lu ber_alloc failed.\n", + conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "ber_alloc failed\n", 0, 0, 0 ); #endif @@ -1340,9 +1339,9 @@ connection_input( ber_sockbuf_ctrl( conn->c_sb, LBER_SB_OPT_GET_FD, &sd ); #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_ERR, - "connection_input: conn %lu ber_get_next failed, errno %d (%s).\n", - conn->c_connid, err, sock_errstr(err) )); + LDAP_LOG( CONNECTION, ERR, + "connection_input: conn %lu ber_get_next failed, errno %d (%s).\n", + conn->c_connid, err, sock_errstr(err) ); #else Debug( LDAP_DEBUG_TRACE, "ber_get_next on fd %d failed errno=%d (%s)\n", @@ -1364,9 +1363,9 @@ connection_input( if ( (tag = ber_get_int( ber, &msgid )) != LDAP_TAG_MSGID ) { /* log, close and send error */ #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_ERR, - "connection_input: conn %lu ber_get_int returns 0x%lx.\n", - conn->c_connid, tag )); + LDAP_LOG( CONNECTION, ERR, + "connection_input: conn %lu ber_get_int returns 0x%lx.\n", + conn->c_connid, tag, 0 ); #else Debug( LDAP_DEBUG_ANY, "ber_get_int returns 0x%lx\n", tag, 0, 0 ); @@ -1378,9 +1377,9 @@ connection_input( if ( (tag = ber_peek_tag( ber, &len )) == LBER_ERROR ) { /* log, close and send error */ #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_ERR, + LDAP_LOG( CONNECTION, ERR, "connection_input: conn %lu ber_peek_tag returns 0x%lx.\n", - conn->c_connid, tag )); + conn->c_connid, tag, 0 ); #else Debug( LDAP_DEBUG_ANY, "ber_peek_tag returns 0x%lx\n", tag, 0, 0 ); @@ -1398,9 +1397,9 @@ connection_input( } if (tag != LDAP_REQ_ABANDON && tag != LDAP_REQ_SEARCH) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_ERR, + LDAP_LOG( CONNECTION, ERR, "connection_input: conn %lu invalid req for UDP 0x%lx.\n", - conn->c_connid, tag )); + conn->c_connid, tag, 0 ); #else Debug( LDAP_DEBUG_ANY, "invalid req for UDP 0x%lx\n", tag, 0, 0 ); @@ -1432,9 +1431,9 @@ connection_input( || conn->c_conn_state == SLAP_C_CLOSING ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_INFO, - "connection_input: conn %lu deferring operation\n", - conn->c_connid )); + LDAP_LOG( CONNECTION, INFO, + "connection_input: conn %lu deferring operation\n", + conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "deferring operation\n", 0, 0, 0 ); #endif @@ -1472,9 +1471,9 @@ connection_resched( Connection *conn ) if( rc ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1, - "connection_resched: conn %lu reaquiring locks.\n", - conn->c_connid )); + LDAP_LOG( CONNECTION, DETAIL1, + "connection_resched: conn %lu reaquiring locks.\n", + conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "connection_resched: reaquiring locks conn=%lu sd=%d\n", @@ -1492,9 +1491,9 @@ connection_resched( Connection *conn ) if( conn->c_conn_state != SLAP_C_CLOSING ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_INFO, - "connection_resched: conn %lu closed by other thread.\n", - conn->c_connid )); + LDAP_LOG( CONNECTION, INFO, + "connection_resched: conn %lu closed by other thread.\n", + conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "connection_resched: " "closed by other thread conn=%lu sd=%d\n", @@ -1502,9 +1501,9 @@ connection_resched( Connection *conn ) #endif } else { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1, - "connection_resched: conn %lu attempting closing.\n", - conn->c_connid )); + LDAP_LOG( CONNECTION, DETAIL1, + "connection_resched: conn %lu attempting closing.\n", + conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "connection_resched: " "attempting closing conn=%lu sd=%d\n", @@ -1577,9 +1576,9 @@ static int connection_op_activate( Connection *conn, Operation *op ) if ( status != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_ERR, - "connection_op_activate: conn %lu thread pool submit failed.\n", - conn->c_connid )); + LDAP_LOG( CONNECTION, ERR, + "connection_op_activate: conn %lu thread pool submit failed.\n", + conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "ldap_pvt_thread_pool_submit failed (%d)\n", status, 0, 0 ); @@ -1593,6 +1592,7 @@ static int connection_op_activate( Connection *conn, Operation *op ) int connection_write(ber_socket_t s) { Connection *c; + assert( connections != NULL ); ldap_pvt_thread_mutex_lock( &connections_mutex ); @@ -1603,8 +1603,8 @@ int connection_write(ber_socket_t s) if( c == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_ERR, - "connection_write: sock %ld no connection!\n",(long)s)); + LDAP_LOG( CONNECTION, ERR, + "connection_write: sock %ld no connection!\n", (long)s, 0, 0); #else Debug( LDAP_DEBUG_ANY, "connection_write(%ld): no connection!\n", @@ -1618,9 +1618,8 @@ int connection_write(ber_socket_t s) c->c_n_write++; #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1, - "connection_write conn %lu waking output.\n", - c->c_connid )); + LDAP_LOG( CONNECTION, DETAIL1, + "connection_write conn %lu waking output.\n", c->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "connection_write(%d): waking output for id=%lu\n", diff --git a/servers/slapd/controls.c b/servers/slapd/controls.c index 16ea8cb6ccc87b76c224fdd30728a7a0a3c446a6..535345c2e208468b85830eb698609e2d09877526 100644 --- a/servers/slapd/controls.c +++ b/servers/slapd/controls.c @@ -132,8 +132,7 @@ int get_ctrls( } #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, - "get_ctrls: conn %lu\n", conn->c_connid )); + LDAP_LOG( OPERATION, ENTRY, "get_ctrls: conn %lu\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "=> get_ctrls\n", 0, 0, 0 ); #endif @@ -203,9 +202,8 @@ int get_ctrls( if( tag == LBER_ERROR ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, - "get_ctrls: conn %lu get OID failed.\n", - conn->c_connid )); + LDAP_LOG( OPERATION, INFO, "get_ctrls: conn %lu get OID failed.\n", + conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "=> get_ctrls: get oid failed.\n", 0, 0, 0 ); @@ -225,9 +223,9 @@ int get_ctrls( if( tag == LBER_ERROR ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, - "get_ctrls: conn %lu get crit failed.\n", - conn->c_connid )); + LDAP_LOG( OPERATION, INFO, + "get_ctrls: conn %lu get crit failed.\n", + conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "=> get_ctrls: get crit failed.\n", 0, 0, 0 ); @@ -248,11 +246,10 @@ int get_ctrls( if( tag == LBER_ERROR ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, "get_ctrls: conn %lu: " + LDAP_LOG( OPERATION, INFO, "get_ctrls: conn %lu: " "%s (%scritical): get value failed.\n", - conn->c_connid, - c->ldctl_oid ? c->ldctl_oid : "(NULL)", - c->ldctl_iscritical ? "" : "non" )); + conn->c_connid, c->ldctl_oid ? c->ldctl_oid : "(NULL)", + c->ldctl_iscritical ? "" : "non" ); #else Debug( LDAP_DEBUG_TRACE, "=> get_ctrls: conn %lu: " "%s (%scritical): get value failed.\n", @@ -269,11 +266,10 @@ int get_ctrls( } #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + LDAP_LOG( OPERATION, INFO, "get_ctrls: conn %lu oid=\"%s\" (%scritical)\n", - conn->c_connid, - c->ldctl_oid ? c->ldctl_oid : "(NULL)", - c->ldctl_iscritical ? "" : "non" )); + conn->c_connid, c->ldctl_oid ? c->ldctl_oid : "(NULL)", + c->ldctl_iscritical ? "" : "non" ); #else Debug( LDAP_DEBUG_TRACE, "=> get_ctrls: oid=\"%s\" (%scritical)\n", c->ldctl_oid ? c->ldctl_oid : "(NULL)", @@ -355,9 +351,8 @@ int get_ctrls( return_results: #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_RESULTS, - "get_ctrls: conn=%lu n=%d rc=%d err=%s\n", - conn->c_connid, nctrls, rc, errmsg ? errmsg : "" )); + LDAP_LOG( OPERATION, RESULTS, + "get_ctrls: n=%d rc=%d err=%s\n", nctrls, rc, errmsg ? errmsg : "" ); #else Debug( LDAP_DEBUG_TRACE, "<= get_ctrls: n=%d rc=%d err=%s\n", nctrls, rc, errmsg ? errmsg : ""); @@ -576,9 +571,9 @@ int parseValuesReturnFilter ( } #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ARGS, - "parseValuesReturnFilter: conn %d vrFilter: %s\n", conn->c_connid, - fstr.bv_len ? fstr.bv_val : "empty" )); + LDAP_LOG( OPERATION, ARGS, + "parseValuesReturnFilter: conn %d vrFilter: %s\n", + conn->c_connid, fstr.bv_len ? fstr.bv_val : "empty" , 0 ); #else Debug( LDAP_DEBUG_ARGS, " vrFilter: %s\n", fstr.bv_len ? fstr.bv_val : "empty", 0, 0 ); diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index 1a72f5b070348f87c04c9a8c7088d5cb68160901..c732e1afa68c268f3d15aece89b7307a449d21db 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -33,7 +33,11 @@ int deny_severity = LOG_NOTICE; #define LDAPI_MOD_URLEXT "x-mod" #endif /* LDAP_PF_LOCAL */ +#ifdef LDAP_PF_INET6 int slap_inet4or6 = AF_UNSPEC; +#else +int slap_inet4or6 = AF_INET; +#endif /* globals */ time_t starttime; @@ -103,7 +107,7 @@ void slapd_slp_init( const char* urls ) { slapd_srvurls[i] = (char *) realloc( slapd_srvurls[i], strlen( host ) + sizeof( LDAP_SRVTYPE_PREFIX ) ); - strcpy( slap_strcopy(slapd_srvurls[i], + strcpy( lutil_strcopy(slapd_srvurls[i], LDAP_SRVTYPE_PREFIX ), host ); ch_free( host ); @@ -115,7 +119,7 @@ void slapd_slp_init( const char* urls ) { slapd_srvurls[i] = (char *) realloc( slapd_srvurls[i], strlen( host ) + sizeof( LDAPS_SRVTYPE_PREFIX ) ); - strcpy( slap_strcopy(slapd_srvurls[i], + strcpy( lutil_strcopy(slapd_srvurls[i], LDAPS_SRVTYPE_PREFIX ), host ); ch_free( host ); @@ -200,11 +204,10 @@ static void slapd_add(ber_socket_t s) { FD_SET( s, &slap_daemon.sd_readers ); #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1, - "slapd_add: added %ld%s%s\n", - (long)s, - FD_ISSET(s, &slap_daemon.sd_readers) ? "r" : "", - FD_ISSET(s, &slap_daemon.sd_writers) ? "w" : "" )); + LDAP_LOG( CONNECTION, DETAIL1, + "slapd_add: added %ld%s%s\n", (long)s, + FD_ISSET(s, &slap_daemon.sd_readers) ? "r" : "", + FD_ISSET(s, &slap_daemon.sd_writers) ? "w" : "" ); #else Debug( LDAP_DEBUG_CONNS, "daemon: added %ld%s%s\n", (long) s, @@ -223,11 +226,10 @@ void slapd_remove(ber_socket_t s, int wake) { slap_daemon.sd_nactives--; #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1, - "slapd_remove: removing %ld%s%s\n", - (long) s, - FD_ISSET(s, &slap_daemon.sd_readers) ? "r" : "", - FD_ISSET(s, &slap_daemon.sd_writers) ? "w" : "" )); + LDAP_LOG( CONNECTION, DETAIL1, + "slapd_remove: removing %ld%s%s\n", (long) s, + FD_ISSET(s, &slap_daemon.sd_readers) ? "r" : "", + FD_ISSET(s, &slap_daemon.sd_writers) ? "w" : "" ); #else Debug( LDAP_DEBUG_CONNS, "daemon: removing %ld%s%s\n", (long) s, @@ -286,8 +288,7 @@ void slapd_set_read(ber_socket_t s, int wake) { static void slapd_close(ber_socket_t s) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1, - "slapd_close: closing %ld\n", (long)s )); + LDAP_LOG( CONNECTION, DETAIL1, "slapd_close: closing %ld\n", (long)s, 0, 0); #else Debug( LDAP_DEBUG_CONNS, "daemon: closing %ld\n", (long) s, 0, 0 ); @@ -391,9 +392,9 @@ static int slap_get_listener_addresses( if ( strlen(host) > (sizeof(((struct sockaddr_un *)*sap)->sun_path) - 1) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_INFO, - "slap_get_listener_addresses: domain socket path (%s) too long in URL\n", - host )); + LDAP_LOG( CONNECTION, INFO, + "slap_get_listener_addresses: domain socket path (%s) " + "too long in URL\n", host, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "daemon: domain socket path (%s) too long in URL", @@ -421,9 +422,9 @@ static int slap_get_listener_addresses( if ( (err = getaddrinfo(host, serv, &hints, &res)) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_INFO, + LDAP_LOG( CONNECTION, INFO, "slap_get_listener_addresses: getaddrinfo failed: %s\n", - AC_GAI_STRERROR(err) )); + AC_GAI_STRERROR(err), 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "daemon: getaddrinfo failed: %s\n", AC_GAI_STRERROR(err), 0, 0); @@ -446,9 +447,9 @@ static int slap_get_listener_addresses( for ( sai=res; sai; sai=sai->ai_next ) { if( sai->ai_addr == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_INFO, + LDAP_LOG( CONNECTION, INFO, "slap_get_listener_addresses: " - "getaddrinfo ai_addr is NULL?\n" )); + "getaddrinfo ai_addr is NULL?\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "slap_get_listener_addresses: " "getaddrinfo ai_addr is NULL?\n", 0, 0, 0 ); @@ -503,9 +504,8 @@ static int slap_get_listener_addresses( he = gethostbyname( host ); if( he == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_INFO, - "slap_get_listener_addresses: invalid host %s\n", - host )); + LDAP_LOG( CONNECTION, INFO, + "slap_get_listener_addresses: invalid host %s\n", host, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "daemon: invalid host %s", host, 0, 0); @@ -560,6 +560,7 @@ static int slap_open_listener( int err, addrlen = 0; struct sockaddr **sal, **psal; int socktype = SOCK_STREAM; /* default to COTS */ + #ifdef LDAP_PF_LOCAL mode_t perms = S_IRWXU; int crit = 1; @@ -569,9 +570,9 @@ static int slap_open_listener( if( rc != LDAP_URL_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_ERR, - "slap_open_listener: listen URL \"%s\" parse error %d\n", - url, rc )); + LDAP_LOG( CONNECTION, ERR, + "slap_open_listener: listen URL \"%s\" parse error %d\n", + url, rc , 0 ); #else Debug( LDAP_DEBUG_ANY, "daemon: listen URL \"%s\" parse error=%d\n", @@ -583,9 +584,8 @@ static int slap_open_listener( #ifndef HAVE_TLS if( ldap_pvt_url_scheme2tls( lud->lud_scheme ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_INFO, - "slap_open_listener: TLS is not supported (%s)\n", - url )); + LDAP_LOG( CONNECTION, INFO, + "slap_open_listener: TLS is not supported (%s)\n", url, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "daemon: TLS not supported (%s)\n", @@ -624,9 +624,8 @@ static int slap_open_listener( #else #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_INFO, - "slap_open_listener: URL scheme is not supported: %s\n", - url )); + LDAP_LOG( CONNECTION, INFO, + "slap_open_listener: URL scheme is not supported: %s\n", url, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "daemon: URL scheme not supported: %s", url, 0, 0); @@ -684,9 +683,9 @@ static int slap_open_listener( if ( l.sl_sd == AC_SOCKET_INVALID ) { int err = sock_errno(); #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_ERR, - "slap_open_listener: socket() failed errno=%d (%s)\n", - err, sock_errstr(err) )); + LDAP_LOG( CONNECTION, ERR, + "slap_open_listener: socket() failed errno=%d (%s)\n", + err, sock_errstr(err), 0 ); #else Debug( LDAP_DEBUG_ANY, "daemon: socket() failed errno=%d (%s)\n", err, @@ -698,9 +697,9 @@ static int slap_open_listener( #ifndef HAVE_WINSOCK if ( l.sl_sd >= dtblsize ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_ERR, - "slap_open_listener: listener descriptor %ld is too great %ld\n", - (long)l.sl_sd, (long)dtblsize )); + LDAP_LOG( CONNECTION, ERR, + "slap_open_listener: listener descriptor %ld is too " + "great %ld\n", (long)l.sl_sd, (long)dtblsize, 0 ); #else Debug( LDAP_DEBUG_ANY, "daemon: listener descriptor %ld is too great %ld\n", @@ -725,9 +724,10 @@ static int slap_open_listener( if ( rc == AC_SOCKET_ERROR ) { int err = sock_errno(); #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_INFO, - "slap_open_listener: setsockopt( %ld, SO_REUSEADDR ) failed errno %d (%s)\n", - (long)l.sl_sd, err, sock_errstr(err) )); + LDAP_LOG( CONNECTION, INFO, + "slap_open_listener: setsockopt( %ld, SO_REUSEADDR ) " + "failed errno %d (%s)\n", (long)l.sl_sd, err, + sock_errstr(err) ); #else Debug( LDAP_DEBUG_ANY, "slapd(%ld): setsockopt(SO_REUSEADDR) failed errno=%d (%s)\n", @@ -751,9 +751,9 @@ static int slap_open_listener( if ( rc == AC_SOCKET_ERROR ) { int err = sock_errno(); #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_INFO, + LDAP_LOG( CONNECTION, INFO, "slap_open_listener: setsockopt( %ld, IPV6_V6ONLY ) failed errno %d (%s)\n", - (long)l.sl_sd, err, sock_errstr(err) )); + (long)l.sl_sd, err, sock_errstr(err) ); #else Debug( LDAP_DEBUG_ANY, "slapd(%ld): setsockopt(IPV6_V6ONLY) failed errno=%d (%s)\n", @@ -774,9 +774,9 @@ static int slap_open_listener( if (bind(l.sl_sd, *sal, addrlen)) { err = sock_errno(); #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_INFO, - "slap_open_listener: bind(%ld) failed errno=%d (%s)\n", - (long)l.sl_sd, err, sock_errstr(err) )); + LDAP_LOG( CONNECTION, INFO, + "slap_open_listener: bind(%ld) failed errno=%d (%s)\n", + (long)l.sl_sd, err, sock_errstr(err) ); #else Debug( LDAP_DEBUG_ANY, "daemon: bind(%ld) failed errno=%d (%s)\n", (long) l.sl_sd, err, sock_errstr(err) ); @@ -793,9 +793,9 @@ static int slap_open_listener( if ( chmod( addr, perms ) < 0 && crit ) { int err = sock_errno(); #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_INFO, - "slap_open_listener: fchmod(%ld) failed errno=%d (%s)\n", - (long)l.sl_sd, err, sock_errstr(err) )); + LDAP_LOG( CONNECTION, INFO, + "slap_open_listener: fchmod(%ld) failed errno=%d (%s)\n", + (long)l.sl_sd, err, sock_errstr(err) ); #else Debug( LDAP_DEBUG_ANY, "daemon: fchmod(%ld) failed errno=%d (%s)", (long) l.sl_sd, err, sock_errstr(err) ); @@ -838,9 +838,9 @@ static int slap_open_listener( default: #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_INFO, - "slap_open_listener: unsupported address family (%d)\n", - (int)(*sal)->sa_family )); + LDAP_LOG( CONNECTION, INFO, + "slap_open_listener: unsupported address family (%d)\n", + (int)(*sal)->sa_family, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "daemon: unsupported address family (%d)\n", (int) (*sal)->sa_family, 0, 0 ); @@ -862,8 +862,8 @@ static int slap_open_listener( #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_RESULTS, - "slap_open_listener: daemon initialized %s\n", l.sl_url )); + LDAP_LOG( CONNECTION, RESULTS, + "slap_open_listener: daemon initialzed %s\n", l.sl_url, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "daemon: initialized %s\n", l.sl_url, 0, 0 ); @@ -880,9 +880,8 @@ int slapd_daemon_init( const char *urls ) char **u; #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_ARGS, - "slapd_daemon_init: %s\n", - urls ? urls : "<null>" )); + LDAP_LOG( CONNECTION, ARGS, + "slapd_daemon_init: %s\n", urls ? urls : "<null>", 0, 0 ); #else Debug( LDAP_DEBUG_ARGS, "daemon_init: %s\n", urls ? urls : "<null>", 0, 0 ); @@ -912,8 +911,8 @@ int slapd_daemon_init( const char *urls ) */ if( (rc = lutil_pair( wake_sds )) < 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_ERR, - "slap_daemon_init: lutil_pair() failed rc=%d\n", rc )); + LDAP_LOG( CONNECTION, ERR, + "slap_daemon_init: lutil_pair() failed rc=%d\n", rc, 0, 0); #else Debug( LDAP_DEBUG_ANY, "daemon: lutil_pair() failed rc=%d\n", rc, 0, 0 ); @@ -932,8 +931,8 @@ int slapd_daemon_init( const char *urls ) if( u == NULL || u[0] == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_ERR, - "slap_daemon_init: no urls (%s) provided.\n", urls )); + LDAP_LOG( CONNECTION, ERR, + "slap_daemon_init: no urls (%s) provided.\n", urls, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "daemon_init: no urls (%s) provided.\n", urls, 0, 0 ); @@ -943,8 +942,8 @@ int slapd_daemon_init( const char *urls ) for( i=0; u[i] != NULL; i++ ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1, - "slap_daemon_init: listen on %s\n.", u[i] )); + LDAP_LOG( CONNECTION, DETAIL1, + "slap_daemon_init: listen on %s\n.", u[i], 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "daemon_init: listen on %s\n", u[i], 0, 0 ); @@ -953,8 +952,8 @@ int slapd_daemon_init( const char *urls ) if( i == 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_INFO, - "slap_daemon_init: no listeners to open (%s)\n", urls )); + LDAP_LOG( CONNECTION, INFO, + "slap_daemon_init: no listeners to open (%s)\n", urls, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "daemon_init: no listeners to open (%s)\n", urls, 0, 0 ); @@ -964,8 +963,8 @@ int slapd_daemon_init( const char *urls ) } #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_INFO, - "slap_daemon_init: %d listeners to open...\n", i )); + LDAP_LOG( CONNECTION, INFO, + "slap_daemon_init: %d listeners to open...\n", i, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "daemon_init: %d listeners to open...\n", i, 0, 0 ); @@ -981,8 +980,8 @@ int slapd_daemon_init( const char *urls ) slap_listeners[j] = NULL; #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1, - "slap_daemon_init: %d listeners opened\n", i )); + LDAP_LOG( CONNECTION, DETAIL1, + "slap_daemon_init: %d listeners opened\n", i, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "daemon_init: %d listeners opened\n", i, 0, 0 ); @@ -1096,8 +1095,8 @@ slapd_daemon_task( if ( i < l ) { /* We are already listening to in6addr_any */ #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_WARNING, - "slapd_daemon_task: Attempt to listen to 0.0.0.0 failed, already listening on ::, assuming IPv4 included\n" )); + LDAP_LOG(CONNECTION, WARNING, + "slapd_daemon_task: Attempt to listen to 0.0.0.0 failed, already listening on ::, assuming IPv4 included\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_CONNS, "daemon: Attempt to listen to 0.0.0.0 failed, already listening on ::, assuming IPv4 included\n", @@ -1111,9 +1110,9 @@ slapd_daemon_task( } #endif #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_ERR, - "slapd_daemon_task: listen( %s, 5 ) failed errno=%d (%s)\n", - slap_listeners[l]->sl_url, err, sock_errstr(err) )); + LDAP_LOG( CONNECTION, ERR, + "slapd_daemon_task: listen( %s, 5 ) failed errno=%d (%s)\n", + slap_listeners[l]->sl_url, err, sock_errstr(err) ); #else Debug( LDAP_DEBUG_ANY, "daemon: listen(%s, 5) failed errno=%d (%s)\n", @@ -1240,9 +1239,10 @@ slapd_daemon_task( continue; #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1, - "slapd_daemon_task: select: listen=%d active_threads=%d tvp=%s\n", - slap_listeners[l]->sl_sd, at, tvp == NULL ? "NULL" : "zero" )); + LDAP_LOG( CONNECTION, DETAIL1, + "slapd_daemon_task: select: listen=%d " + "active_threads=%d tvp=%s\n", + slap_listeners[l]->sl_sd, at, tvp == NULL ? "NULL" : "zero" ); #else Debug( LDAP_DEBUG_CONNS, "daemon: select: listen=%d active_threads=%d tvp=%s\n", @@ -1275,9 +1275,9 @@ slapd_daemon_task( if( err != EINTR ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_INFO, - "slapd_daemon_task: select failed (%d): %s\n", - err, sock_errstr(err) )); + LDAP_LOG( CONNECTION, INFO, + "slapd_daemon_task: select failed (%d): %s\n", + err, sock_errstr(err), 0 ); #else Debug( LDAP_DEBUG_CONNS, "daemon: select failed (%d): %s\n", @@ -1291,8 +1291,8 @@ slapd_daemon_task( case 0: /* timeout - let threads run */ ebadf = 0; #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL2, - "slapd_daemon_task: select timeout - yielding\n" )); + LDAP_LOG( CONNECTION, DETAIL2, + "slapd_daemon_task: select timeout - yielding\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_CONNS, "daemon: select timeout - yielding\n", 0, 0, 0 ); @@ -1305,8 +1305,8 @@ slapd_daemon_task( ebadf = 0; #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL2, - "slapd_daemon_task: activity on %d descriptors\n", ns )); + LDAP_LOG( CONNECTION, DETAIL2, + "slapd_daemon_task: activity on %d descriptors\n", ns, 0, 0 ); #else Debug( LDAP_DEBUG_CONNS, "daemon: activity on %d descriptors\n", ns, 0, 0 ); @@ -1389,9 +1389,10 @@ slapd_daemon_task( if( emfile < 3 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_ERR, + LDAP_LOG( CONNECTION, ERR, "slapd_daemon_task: accept(%ld) failed errno=%d (%s)\n", - (long)slap_listeners[l]->sl_sd, err, sock_errstr(err) )); + (long)slap_listeners[l]->sl_sd, + err, sock_errstr(err) ); #else Debug( LDAP_DEBUG_ANY, "daemon: accept(%ld) failed errno=%d (%s)\n", @@ -1416,9 +1417,9 @@ slapd_daemon_task( /* make sure descriptor number isn't too great */ if ( s >= dtblsize ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_ERR, + LDAP_LOG( CONNECTION, ERR, "slapd_daemon_task: %ld beyond descriptor table size %ld\n", - (long)s, (long)dtblsize )); + (long)s, (long)dtblsize, 0 ); #else Debug( LDAP_DEBUG_ANY, "daemon: %ld beyond descriptor table size %ld\n", @@ -1458,9 +1459,10 @@ slapd_daemon_task( if ( rc == AC_SOCKET_ERROR ) { int err = sock_errno(); #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_ERR, - "slapd_daemon_task: setsockopt( %ld, SO_KEEPALIVE) failed errno=%d (%s)\n", - (long)s, err, sock_errstr(err) )); + LDAP_LOG( CONNECTION, ERR, + "slapd_daemon_task: setsockopt( %ld, SO_KEEPALIVE)" + " failed errno=%d (%s)\n", + (long)s, err, sock_errstr(err) ); #else Debug( LDAP_DEBUG_ANY, "slapd(%ld): setsockopt(SO_KEEPALIVE) failed " @@ -1476,9 +1478,10 @@ slapd_daemon_task( if ( rc == AC_SOCKET_ERROR ) { int err = sock_errno(); #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_ERR, - "slapd_daemon_task: setsockopt( %ld, TCP_NODELAY) failed errno=%d (%s)\n", - (long)s, err, sock_errstr(err) )); + LDAP_LOG( CONNECTION, ERR, + "slapd_daemon_task: setsockopt( %ld, " + "TCP_NODELAY) failed errno=%d (%s)\n", + (long)s, err, sock_errstr(err) ); #else Debug( LDAP_DEBUG_ANY, "slapd(%ld): setsockopt(TCP_NODELAY) failed " @@ -1490,8 +1493,8 @@ slapd_daemon_task( #endif #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1, - "slapd_daemon_task: new connection on %ld\n", (long)s )); + LDAP_LOG( CONNECTION, DETAIL1, + "slapd_daemon_task: new connection on %ld\n", (long)s, 0, 0 ); #else Debug( LDAP_DEBUG_CONNS, "daemon: new connection on %ld\n", (long) s, 0, 0 ); @@ -1599,9 +1602,9 @@ slapd_daemon_task( if( id < 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_INFO, - "slapd_daemon_task: connection_init(%ld, %s, %s) failed.\n", - (long)s, peername, slap_listeners[l]->sl_name )); + LDAP_LOG( CONNECTION, INFO, + "slapd_daemon_task: connection_init(%ld, %s, %s) failed.\n", + (long)s, peername, slap_listeners[l]->sl_name ); #else Debug( LDAP_DEBUG_ANY, "daemon: connection_init(%ld, %s, %s) failed.\n", @@ -1626,16 +1629,16 @@ slapd_daemon_task( #ifdef LDAP_DEBUG #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL2, - "slapd_daemon_task: activity on " )); + LDAP_LOG( CONNECTION, DETAIL2, + "slapd_daemon_task: activity on ", 0, 0, 0 ); #else Debug( LDAP_DEBUG_CONNS, "daemon: activity on:", 0, 0, 0 ); #endif #ifdef HAVE_WINSOCK for ( i = 0; i < readfds.fd_count; i++ ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL2, - " %d%s", readfds.fd_array[i], "r", 0 )); + LDAP_LOG( CONNECTION, DETAIL2, + " %d%s", readfds.fd_array[i], "r", 0, 0 ); #else Debug( LDAP_DEBUG_CONNS, " %d%s", readfds.fd_array[i], "r", 0 ); @@ -1643,8 +1646,8 @@ slapd_daemon_task( } for ( i = 0; i < writefds.fd_count; i++ ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL2, - " %d%s", writefds.fd_array[i], "w" )); + LDAP_LOG( CONNECTION, DETAIL2, + " %d%s", writefds.fd_array[i], "w" , 0 ); #else Debug( LDAP_DEBUG_CONNS, " %d%s", writefds.fd_array[i], "w", 0 ); @@ -1676,9 +1679,8 @@ slapd_daemon_task( w = FD_ISSET( i, &writefds ); if ( r || w ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL2, - " %d%s%s", i, - r ? "r" : "", w ? "w" : "" )); + LDAP_LOG( CONNECTION, DETAIL2, + " %d%s%s", i, r ? "r" : "", w ? "w" : "" ); #else Debug( LDAP_DEBUG_CONNS, " %d%s%s", i, r ? "r" : "", w ? "w" : "" ); @@ -1687,7 +1689,7 @@ slapd_daemon_task( } #endif #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL2, "\n" )); + LDAP_LOG( CONNECTION, DETAIL2, "\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_CONNS, "\n", 0, 0, 0 ); #endif @@ -1726,8 +1728,8 @@ slapd_daemon_task( continue; } #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL2, - "slapd_daemon_task: write active on %d\n", wd )); + LDAP_LOG( CONNECTION, DETAIL2, + "slapd_daemon_task: write active on %d\n", wd, 0, 0 ); #else Debug( LDAP_DEBUG_CONNS, "daemon: write active on %d\n", @@ -1779,8 +1781,8 @@ slapd_daemon_task( } #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL2, - "slapd_daemon_task: read activity on %d\n", rd )); + LDAP_LOG( CONNECTION, DETAIL2, + "slapd_daemon_task: read activity on %d\n", rd, 0, 0 ); #else Debug ( LDAP_DEBUG_CONNS, "daemon: read activity on %d\n", rd, 0, 0 ); @@ -1801,8 +1803,8 @@ slapd_daemon_task( if( slapd_shutdown == 1 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_CRIT, - "slapd_daemon_task: shutdown requested and initiated.\n")); + LDAP_LOG( CONNECTION, CRIT, + "slapd_daemon_task: shutdown requested and initiated.\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "daemon: shutdown requested and initiated.\n", @@ -1812,8 +1814,9 @@ slapd_daemon_task( } else if ( slapd_shutdown == 2 ) { #ifdef HAVE_NT_SERVICE_MANAGER #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_CRIT, - "slapd_daemon_task: shutdown initiated by Service Manager.\n")); + LDAP_LOG( CONNECTION, CRIT, + "slapd_daemon_task: shutdown initiated by Service Manager.\n", + 0, 0, 0); #else Debug( LDAP_DEBUG_TRACE, "daemon: shutdown initiated by Service Manager.\n", @@ -1821,8 +1824,9 @@ slapd_daemon_task( #endif #else /* !HAVE_NT_SERVICE_MANAGER */ #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_CRIT, - "slapd_daemon_task: abnormal condition, shutdown initiated.\n" )); + LDAP_LOG( CONNECTION, CRIT, + "slapd_daemon_task: abnormal condition, " + "shutdown initiated.\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "daemon: abnormal condition, shutdown initiated.\n", @@ -1831,8 +1835,9 @@ slapd_daemon_task( #endif /* !HAVE_NT_SERVICE_MANAGER */ } else { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_CRIT, - "slapd_daemon_task: no active streams, shutdown initiated.\n" )); + LDAP_LOG( CONNECTION, CRIT, + "slapd_daemon_task: no active streams, shutdown initiated.\n", + 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "daemon: no active streams, shutdown initiated.\n", @@ -1846,9 +1851,9 @@ slapd_daemon_task( slap_listeners = NULL; #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_CRIT, - "slapd_daemon_task: shutdown waiting for %d threads to terminate.\n", - ldap_pvt_thread_pool_backload(&connection_pool) )); + LDAP_LOG( CONNECTION, CRIT, + "slapd_daemon_task: shutdown waiting for %d threads to terminate.\n", + ldap_pvt_thread_pool_backload(&connection_pool), 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "slapd shutdown: waiting for %d threads to terminate\n", @@ -1877,8 +1882,9 @@ int slapd_daemon( void ) if ( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_ERR, - "slapd_daemon: listener ldap_pvt_thread_create failed (%d).\n", rc )); + LDAP_LOG( CONNECTION, ERR, + "slapd_daemon: listener ldap_pvt_thread_create failed (%d).\n", + rc, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "listener ldap_pvt_thread_create failed (%d)\n", rc, 0, 0 ); @@ -1951,8 +1957,8 @@ RETSIGTYPE slap_sig_shutdown( int sig ) { #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_CRIT, - "slap_sig_shutdown: signal %d\n", sig )); + LDAP_LOG( CONNECTION, CRIT, + "slap_sig_shutdown: signal %d\n", sig, 0, 0 ); #else Debug(LDAP_DEBUG_TRACE, "slap_sig_shutdown: signal %d\n", sig, 0, 0); #endif @@ -1966,8 +1972,8 @@ slap_sig_shutdown( int sig ) #if HAVE_NT_SERVICE_MANAGER && SIGBREAK if (is_NT_Service && sig == SIGBREAK) #ifdef NEW_LOGGING - LDAP_LOG(( "connection", LDAP_LEVEL_CRIT, - "slap_sig_shutdown: SIGBREAK ignored.\n" )); + LDAP_LOG( CONNECTION, CRIT, + "slap_sig_shutdown: SIGBREAK ignored.\n", 0, 0, 0 ); #else Debug(LDAP_DEBUG_TRACE, "slap_sig_shutdown: SIGBREAK ignored.\n", 0, 0, 0); diff --git a/servers/slapd/delete.c b/servers/slapd/delete.c index 37a59aa1ea542ccd2390a3a9c5ce4e1c9bda94a3..89e405c43f0ef76a7321b08e369550b93fba2d22 100644 --- a/servers/slapd/delete.c +++ b/servers/slapd/delete.c @@ -40,8 +40,8 @@ do_delete( int manageDSAit; #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, - "do_delete: conn %d\n", conn->c_connid )); + LDAP_LOG( OPERATION, ENTRY, + "do_delete: conn %d\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "do_delete\n", 0, 0, 0 ); #endif @@ -54,8 +54,8 @@ do_delete( if ( ber_scanf( op->o_ber, "m", &dn ) == LBER_ERROR ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "do_delete: conn: %d ber_scanf failed\n", conn->c_connid )); + LDAP_LOG( OPERATION, ERR, + "do_delete: conn: %d ber_scanf failed\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0, 0 ); #endif @@ -66,8 +66,8 @@ do_delete( if( ( rc = get_ctrls( conn, op, 1 ) ) != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "do_delete: conn %d get_ctrls failed\n", conn->c_connid )); + LDAP_LOG( OPERATION, ERR, + "do_delete: conn %d get_ctrls failed\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_delete: get_ctrls failed\n", 0, 0, 0 ); #endif @@ -77,9 +77,9 @@ do_delete( rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + LDAP_LOG( OPERATION, INFO, "do_delete: conn %d invalid dn (%s)\n", - conn->c_connid, dn.bv_val )); + conn->c_connid, dn.bv_val, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_delete: invalid dn (%s)\n", dn.bv_val, 0, 0 ); @@ -91,8 +91,9 @@ do_delete( if( ndn.bv_len == 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, "do_delete: conn %d: " - "Attempt to delete root DSE.\n", conn->c_connid )); + LDAP_LOG( OPERATION, INFO, + "do_delete: conn %d: Attempt to delete root DSE.\n", + conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_delete: root dse!\n", 0, 0, 0 ); #endif @@ -105,8 +106,8 @@ do_delete( } else if ( strcasecmp( ndn.bv_val, SLAPD_SCHEMA_DN ) == 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, "do_delete: conn %d: " - "Attempt to delete subschema subentry.\n", conn->c_connid )); + LDAP_LOG( OPERATION, INFO, "do_delete: conn %d: " + "Attempt to delete subschema subentry.\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_delete: subschema subentry!\n", 0, 0, 0 ); #endif diff --git a/servers/slapd/dn.c b/servers/slapd/dn.c index 75a349b4333dfecf05e838aad623154e6e47c670..23aa4e78399eac50b14aee2a5505ef497439b452 100644 --- a/servers/slapd/dn.c +++ b/servers/slapd/dn.c @@ -439,7 +439,11 @@ dnPretty2( assert( val ); assert( out ); +#ifdef NEW_LOGGING + LDAP_LOG( OPERATION, ARGS, ">>> dnPretty: <%s>\n", val->bv_val, 0, 0 ); +#else Debug( LDAP_DEBUG_TRACE, ">>> dnPretty: <%s>\n", val->bv_val, 0, 0 ); +#endif if ( val->bv_len == 0 ) { ber_dupbv( out, val ); @@ -496,7 +500,11 @@ dnPrettyNormal( struct berval *pretty, struct berval *normal) { +#ifdef NEW_LOGGING + LDAP_LOG ( OPERATION, ENTRY, ">>> dnPrettyNormal: <%s>\n", val->bv_val, 0, 0 ); +#else Debug( LDAP_DEBUG_TRACE, ">>> dnPrettyNormal: <%s>\n", val->bv_val, 0, 0 ); +#endif assert( val ); assert( pretty ); @@ -562,8 +570,13 @@ dnPrettyNormal( } } +#ifdef NEW_LOGGING + LDAP_LOG (OPERATION, RESULTS, "<<< dnPrettyNormal: <%s>, <%s>\n", + pretty->bv_val, normal->bv_val, 0 ); +#else Debug( LDAP_DEBUG_TRACE, "<<< dnPrettyNormal: <%s>, <%s>\n", pretty->bv_val, normal->bv_val, 0 ); +#endif return LDAP_SUCCESS; } @@ -595,9 +608,8 @@ dnMatch( } #ifdef NEW_LOGGING - LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY, - "dnMatch: %d\n %s\n %s\n", match, - value->bv_val, asserted->bv_val )); + LDAP_LOG( CONFIG, ENTRY, "dnMatch: %d\n %s\n %s\n", + match, value->bv_val, asserted->bv_val ); #else Debug( LDAP_DEBUG_ARGS, "dnMatch %d\n\t\"%s\"\n\t\"%s\"\n", match, value->bv_val, asserted->bv_val ); @@ -787,7 +799,7 @@ build_new_dn( struct berval * new_dn, new_dn->bv_len = parent_dn->bv_len + newrdn->bv_len + 1; new_dn->bv_val = (char *) ch_malloc( new_dn->bv_len + 1 ); - ptr = slap_strcopy( new_dn->bv_val, newrdn->bv_val ); + ptr = lutil_strcopy( new_dn->bv_val, newrdn->bv_val ); *ptr++ = ','; strcpy( ptr, parent_dn->bv_val ); } diff --git a/servers/slapd/entry.c b/servers/slapd/entry.c index f5829d395af02a3555138d88234b8df301b6e68e..98f5842f8a45e66f9544ee3430d512900406c6dd 100644 --- a/servers/slapd/entry.c +++ b/servers/slapd/entry.c @@ -63,8 +63,7 @@ str2entry( char *s ) */ #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, - "str2entry: \"%s\"\n", s ? s : "NULL" )); + LDAP_LOG( OPERATION, DETAIL1, "str2entry: \"%s\"\n", s ? s : "NULL", 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "=> str2entry\n", s ? s : "NULL", 0, 0 ); @@ -75,8 +74,7 @@ str2entry( char *s ) if( e == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "str2entry: entry allocation failed.\n" )); + LDAP_LOG( OPERATION, ERR, "str2entry: entry allocation failed.\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "<= str2entry NULL (entry allocation failed)\n", @@ -99,8 +97,7 @@ str2entry( char *s ) if ( ldif_parse_line( s, &type, &vals[0].bv_val, &vals[0].bv_len ) != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, - "str2entry: NULL (parse_line)\n" )); + LDAP_LOG( OPERATION, DETAIL1, "str2entry: NULL (parse_line)\n",0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= str2entry NULL (parse_line)\n", 0, 0, 0 ); @@ -113,10 +110,10 @@ str2entry( char *s ) if ( e->e_dn != NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, "str2entry: " + LDAP_LOG( OPERATION, DETAIL1, "str2entry: " "entry %ld has multiple DNs \"%s\" and \"%s\"\n", (long) e->e_id, e->e_dn, - vals[0].bv_val != NULL ? vals[0].bv_val : "" )); + vals[0].bv_val != NULL ? vals[0].bv_val : "" ); #else Debug( LDAP_DEBUG_ANY, "str2entry: " "entry %ld has multiple DNs \"%s\" and \"%s\"\n", @@ -131,9 +128,9 @@ str2entry( char *s ) rc = dnPrettyNormal( NULL, &vals[0], &e->e_name, &e->e_nname ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, "str2entry: " - "entry %ld has invalid DN \"%s\"\n", - (long) e->e_id, vals[0].bv_val )); + LDAP_LOG( OPERATION, DETAIL1, + "str2entry: entry %ld has invalid DN \"%s\"\n", + (long) e->e_id, vals[0].bv_val, 0 ); #else Debug( LDAP_DEBUG_ANY, "str2entry: " "entry %ld has invalid DN \"%s\"\n", @@ -152,8 +149,8 @@ str2entry( char *s ) if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, - "str2entry: str2ad(%s): %s\n", type, text )); + LDAP_LOG( OPERATION, DETAIL1, + "str2entry: str2ad(%s): %s\n", type, text, 0 ); #else Debug( slapMode & SLAP_TOOL_MODE ? LDAP_DEBUG_ANY : LDAP_DEBUG_TRACE, @@ -169,8 +166,8 @@ str2entry( char *s ) rc = slap_str2undef_ad( type, &ad, &text ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, - "str2entry: str2undef_ad(%s): %s\n", type, text )); + LDAP_LOG( OPERATION, DETAIL1, + "str2entry: str2undef_ad(%s): %s\n", type, text, 0 ); #else Debug( LDAP_DEBUG_ANY, "<= str2entry: str2undef_ad(%s): %s\n", @@ -202,9 +199,9 @@ str2entry( char *s ) } else { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + LDAP_LOG( OPERATION, INFO, "str2entry: no validator for syntax %s\n", - ad->ad_type->sat_syntax->ssyn_oid )); + ad->ad_type->sat_syntax->ssyn_oid, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "str2entry: no validator for syntax %s\n", @@ -218,9 +215,9 @@ str2entry( char *s ) if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + LDAP_LOG( OPERATION, ERR, "str2entry: invalid value for syntax %s\n", - ad->ad_type->sat_syntax->ssyn_oid )); + ad->ad_type->sat_syntax->ssyn_oid, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "str2entry: invalid value for syntax %s\n", @@ -241,8 +238,8 @@ str2entry( char *s ) rc = attr_merge( e, ad, vals ); if( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, - "str2entry: NULL (attr_merge)\n" )); + LDAP_LOG( OPERATION, DETAIL1, + "str2entry: NULL (attr_merge)\n" , 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "<= str2entry NULL (attr_merge)\n", 0, 0, 0 ); @@ -260,9 +257,8 @@ str2entry( char *s ) /* check to make sure there was a dn: line */ if ( e->e_dn == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, - "str2entry: entry %ld has no dn.\n", - (long) e->e_id )); + LDAP_LOG( OPERATION, INFO, + "str2entry: entry %ld has no dn.\n", (long) e->e_id, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "str2entry: entry %ld has no dn\n", (long) e->e_id, 0, 0 ); @@ -272,8 +268,8 @@ str2entry( char *s ) } #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL2, - "str2entry(%s) -> 0x%lx\n", e->e_dn, (unsigned long)e )); + LDAP_LOG( OPERATION, DETAIL2, + "str2entry(%s) -> 0x%lx\n", e->e_dn, (unsigned long)e, 0 ); #else Debug(LDAP_DEBUG_TRACE, "<= str2entry(%s) -> 0x%lx\n", e->e_dn, (unsigned long) e, 0 ); @@ -477,9 +473,8 @@ int entry_encode(Entry *e, struct berval *bv) unsigned char *ptr; #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, - "entry_encode: id: 0x%08lx \"%s\"\n", - (long) e->e_id, e->e_dn )); + LDAP_LOG( OPERATION, DETAIL1, "entry_encode: id: 0x%08lx \"%s\"\n", + (long) e->e_id, e->e_dn, 0 ); #else Debug( LDAP_DEBUG_TRACE, "=> entry_encode(0x%08lx): %s\n", (long) e->e_id, e->e_dn, 0 ); @@ -572,8 +567,7 @@ int entry_decode(struct berval *bv, Entry **e) x->e_nname.bv_len = i; ptr += i+1; #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL2, - "entry_decode: \"%s\"\n", x->e_dn )); + LDAP_LOG( OPERATION, DETAIL2, "entry_decode: \"%s\"\n", x->e_dn, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "entry_decode: \"%s\"\n", @@ -601,8 +595,8 @@ int entry_decode(struct berval *bv, Entry **e) if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, - "entry_decode: str2ad(%s): %s\n", ptr, text )); + LDAP_LOG( OPERATION, INFO, + "entry_decode: str2ad(%s): %s\n", ptr, text, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= entry_decode: str2ad(%s): %s\n", ptr, text, 0 ); @@ -611,8 +605,8 @@ int entry_decode(struct berval *bv, Entry **e) if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, - "entry_decode: str2undef_ad(%s): %s\n", ptr, text)); + LDAP_LOG( OPERATION, INFO, + "entry_decode: str2undef_ad(%s): %s\n", ptr, text, 0 ); #else Debug( LDAP_DEBUG_ANY, "<= entry_decode: str2undef_ad(%s): %s\n", @@ -643,8 +637,7 @@ int entry_decode(struct berval *bv, Entry **e) if (a) a->a_next = NULL; #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, - "entry_decode: %s\n", x->e_dn )); + LDAP_LOG( OPERATION, DETAIL1, "entry_decode: %s\n", x->e_dn, 0, 0 ); #else Debug(LDAP_DEBUG_TRACE, "<= entry_decode(%s)\n", x->e_dn, 0, 0 ); diff --git a/servers/slapd/extended.c b/servers/slapd/extended.c index 63f46bd2b23bc2bc097e3e50ac9b20b92fb34e0a..2d315f36ce1a5b12dbb01bc6952ecf4afb1bed53 100644 --- a/servers/slapd/extended.c +++ b/servers/slapd/extended.c @@ -103,17 +103,15 @@ do_extended( LDAPControl **rspctrls; #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, - "do_extended: conn %d\n", conn->c_connid )); + LDAP_LOG( OPERATION, ENTRY, "do_extended: conn %d\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "do_extended\n", 0, 0, 0 ); #endif if( op->o_protocol < LDAP_VERSION3 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "do_extended: protocol version (%d) too low.\n", - op->o_protocol )); + LDAP_LOG( OPERATION, ERR, + "do_extended: protocol version (%d) too low.\n", op->o_protocol, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_extended: protocol version (%d) too low\n", @@ -127,8 +125,8 @@ do_extended( if ( ber_scanf( op->o_ber, "{m" /*}*/, &reqoid ) == LBER_ERROR ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "do_extended: conn %d ber_scanf failed\n", conn->c_connid )); + LDAP_LOG( OPERATION, ERR, "do_extended: conn %d ber_scanf failed\n", + conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_extended: ber_scanf failed\n", 0, 0 ,0 ); #endif @@ -140,9 +138,9 @@ do_extended( if( !(ext = find_extop(supp_ext_list, &reqoid)) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + LDAP_LOG( OPERATION, ERR, "do_extended: conn %d unsupported operation \"%s\"\n", - conn->c_connid, reqoid.bv_val )); + conn->c_connid, reqoid.bv_val, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_extended: unsupported operation \"%s\"\n", reqoid.bv_val, 0 ,0 ); @@ -157,8 +155,9 @@ do_extended( if( ber_peek_tag( op->o_ber, &len ) == LDAP_TAG_EXOP_REQ_VALUE ) { if( ber_scanf( op->o_ber, "m", &reqdata ) == LBER_ERROR ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "do_extended: conn %d ber_scanf failed\n", conn->c_connid )); + LDAP_LOG( OPERATION, ERR, + "do_extended: conn %d ber_scanf failed\n", + conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_extended: ber_scanf failed\n", 0, 0 ,0 ); #endif @@ -171,8 +170,8 @@ do_extended( if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "do_extended: conn %d get_ctrls failed\n", conn->c_connid )); + LDAP_LOG( OPERATION, ERR, + "do_extended: conn %d get_ctrls failed\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_extended: get_ctrls failed\n", 0, 0 ,0 ); #endif @@ -189,8 +188,8 @@ do_extended( } #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, - "do_extended: conn %d oid=%d\n.", conn->c_connid, reqoid.bv_val )); + LDAP_LOG( OPERATION, DETAIL1, + "do_extended: conn %d oid=%d\n.", conn->c_connid, reqoid.bv_val, 0 ); #else Debug( LDAP_DEBUG_ARGS, "do_extended: oid=%s\n", reqoid.bv_val, 0 ,0 ); #endif diff --git a/servers/slapd/filter.c b/servers/slapd/filter.c index e4905493a6b44d6f68c5ba2cc6c2ea8f66b7e1f6..69a26bf34bd30a3fe0fed81e8f50b53c701b903a 100644 --- a/servers/slapd/filter.c +++ b/servers/slapd/filter.c @@ -54,8 +54,7 @@ get_filter( Filter *f; #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, "get_filter: conn %d\n", - conn->c_connid )); + LDAP_LOG( FILTER, ENTRY, "get_filter: conn %d\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "begin get_filter\n", 0, 0, 0 ); #endif @@ -108,8 +107,8 @@ get_filter( switch ( f->f_choice ) { case LDAP_FILTER_EQUALITY: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL2, - "get_filter: conn %d EQUALITY\n", conn->c_connid )); + LDAP_LOG( FILTER, DETAIL2, + "get_filter: conn %d EQUALITY\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "EQUALITY\n", 0, 0, 0 ); #endif @@ -123,8 +122,8 @@ get_filter( case LDAP_FILTER_SUBSTRINGS: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "get_filter: conn %d SUBSTRINGS\n", conn->c_connid )); + LDAP_LOG( FILTER, DETAIL1, + "get_filter: conn %d SUBSTRINGS\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "SUBSTRINGS\n", 0, 0, 0 ); #endif @@ -133,8 +132,8 @@ get_filter( case LDAP_FILTER_GE: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "get_filter: conn %d GE\n", conn->c_connid )); + LDAP_LOG( FILTER, DETAIL1, + "get_filter: conn %d GE\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "GE\n", 0, 0, 0 ); #endif @@ -146,8 +145,8 @@ get_filter( case LDAP_FILTER_LE: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "get_filter: conn %d LE\n", conn->c_connid )); + LDAP_LOG( FILTER, DETAIL1, + "get_filter: conn %d LE\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "LE\n", 0, 0, 0 ); #endif @@ -161,8 +160,8 @@ get_filter( struct berval type; #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "get_filter: conn %d PRESENT\n", conn->c_connid )); + LDAP_LOG( FILTER, DETAIL1, + "get_filter: conn %d PRESENT\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "PRESENT\n", 0, 0, 0 ); #endif @@ -186,8 +185,8 @@ get_filter( case LDAP_FILTER_APPROX: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "get_filter: conn %d APPROX\n", conn->c_connid )); + LDAP_LOG( FILTER, DETAIL1, + "get_filter: conn %d APPROX\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "APPROX\n", 0, 0, 0 ); #endif @@ -199,8 +198,8 @@ get_filter( case LDAP_FILTER_AND: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "get_filter: conn %d AND\n", conn->c_connid )); + LDAP_LOG( FILTER, DETAIL1, + "get_filter: conn %d AND\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "AND\n", 0, 0, 0 ); #endif @@ -212,8 +211,8 @@ get_filter( case LDAP_FILTER_OR: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "get_filter: conn %d OR\n", conn->c_connid )); + LDAP_LOG( FILTER, DETAIL1, + "get_filter: conn %d OR\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "OR\n", 0, 0, 0 ); #endif @@ -225,8 +224,8 @@ get_filter( case LDAP_FILTER_NOT: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "get_filter: conn %d NOT\n", conn->c_connid )); + LDAP_LOG( FILTER, DETAIL1, + "get_filter: conn %d NOT\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "NOT\n", 0, 0, 0 ); #endif @@ -239,8 +238,8 @@ get_filter( case LDAP_FILTER_EXT: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "get_filter: conn %d EXTENSIBLE\n", conn->c_connid )); + LDAP_LOG( FILTER, DETAIL1, + "get_filter: conn %d EXTENSIBLE\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "EXTENSIBLE\n", 0, 0, 0 ); #endif @@ -256,9 +255,9 @@ get_filter( default: (void) ber_scanf( ber, "x" ); /* skip the element */ #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ERR, + LDAP_LOG( FILTER, ERR, "get_filter: conn %d unknown filter type=%lu\n", - conn->c_connid, f->f_choice )); + conn->c_connid, f->f_choice, 0 ); #else Debug( LDAP_DEBUG_ANY, "get_filter: unknown filter type=%lu\n", f->f_choice, 0, 0 ); @@ -285,8 +284,8 @@ get_filter( } #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL2, - "get_filter: conn %d exit\n", conn->c_connid )); + LDAP_LOG( FILTER, DETAIL2, + "get_filter: conn %d exit\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "end get_filter %d\n", err, 0, 0 ); #endif @@ -305,8 +304,8 @@ get_filter_list( Connection *conn, BerElement *ber, char *last; #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, - "get_filter_list: conn %d start\n", conn->c_connid )); + LDAP_LOG( FILTER, ENTRY, + "get_filter_list: conn %d start\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "begin get_filter_list\n", 0, 0, 0 ); #endif @@ -322,8 +321,8 @@ get_filter_list( Connection *conn, BerElement *ber, *new = NULL; #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, - "get_filter_list: conn %d exit\n", conn->c_connid )); + LDAP_LOG( FILTER, ENTRY, + "get_filter_list: conn %d exit\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "end get_filter_list\n", 0, 0, 0 ); #endif @@ -346,8 +345,8 @@ get_substring_filter( *text = "error decoding filter"; #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, - "get_substring_filter: conn %d begin\n", conn->c_connid )); + LDAP_LOG( FILTER, ENTRY, + "get_substring_filter: conn %d begin\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "begin get_substring_filter\n", 0, 0, 0 ); #endif @@ -404,9 +403,9 @@ get_substring_filter( rc = LDAP_PROTOCOL_ERROR; #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ERR, + LDAP_LOG( FILTER, ERR, "get_filter_substring: conn %d unknown substring choice=%ld\n", - conn->c_connid, (long)tag )); + conn->c_connid, (long)tag, 0 ); #else Debug( LDAP_DEBUG_FILTER, " unknown substring choice=%ld\n", @@ -435,9 +434,8 @@ get_substring_filter( switch ( tag ) { case LDAP_SUBSTRING_INITIAL: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "get_substring_filter: conn %d INITIAL\n", - conn->c_connid )); + LDAP_LOG( FILTER, DETAIL1, + "get_substring_filter: conn %d INITIAL\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, " INITIAL\n", 0, 0, 0 ); #endif @@ -455,9 +453,8 @@ get_substring_filter( case LDAP_SUBSTRING_ANY: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "get_substring_filter: conn %d ANY\n", - conn->c_connid )); + LDAP_LOG( FILTER, DETAIL1, + "get_substring_filter: conn %d ANY\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, " ANY\n", 0, 0, 0 ); #endif @@ -472,9 +469,8 @@ get_substring_filter( case LDAP_SUBSTRING_FINAL: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "get_substring_filter: conn %d FINAL\n", - conn->c_connid )); + LDAP_LOG( FILTER, DETAIL1, + "get_substring_filter: conn %d FINAL\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, " FINAL\n", 0, 0, 0 ); #endif @@ -489,9 +485,9 @@ get_substring_filter( default: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_INFO, + LDAP_LOG( FILTER, INFO, "get_substring_filter: conn %d unknown substring type %ld\n", - conn->c_connid, (long)tag )); + conn->c_connid, (long)tag, 0 ); #else Debug( LDAP_DEBUG_FILTER, " unknown substring type=%ld\n", @@ -502,9 +498,9 @@ get_substring_filter( return_error: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_INFO, + LDAP_LOG( FILTER, INFO, "get_substring_filter: conn %d error %ld\n", - conn->c_connid, (long)rc )); + conn->c_connid, (long)rc, 0 ); #else Debug( LDAP_DEBUG_FILTER, " error=%ld\n", (long) rc, 0, 0 ); @@ -518,8 +514,8 @@ return_error: } #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, - "get_substring_filter: conn %d exit\n", conn->c_connid )); + LDAP_LOG( FILTER, ENTRY, + "get_substring_filter: conn %d exit\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "end get_substring_filter\n", 0, 0, 0 ); #endif @@ -575,8 +571,8 @@ filter_free( Filter *f ) default: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ERR, - "filter_free: unknown filter type %lu\n", f->f_choice )); + LDAP_LOG( FILTER, ERR, + "filter_free: unknown filter type %lu\n", f->f_choice, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "filter_free: unknown filter type=%lu\n", f->f_choice, 0, 0 ); @@ -821,8 +817,8 @@ get_simple_vrFilter( ValuesReturnFilter *f; #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, "get_simple_vrFilter: conn %d\n", - conn->c_connid )); + LDAP_LOG( FILTER, ENTRY, + "get_simple_vrFilter: conn %d\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "begin get_simple_vrFilter\n", 0, 0, 0 ); #endif @@ -843,8 +839,8 @@ get_simple_vrFilter( switch ( f->f_choice ) { case LDAP_FILTER_EQUALITY: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL2, - "get_simple_vrFilter: conn %d EQUALITY\n", conn->c_connid )); + LDAP_LOG( FILTER, DETAIL2, + "get_simple_vrFilter: conn %d EQUALITY\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "EQUALITY\n", 0, 0, 0 ); #endif @@ -858,8 +854,8 @@ get_simple_vrFilter( case LDAP_FILTER_SUBSTRINGS: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "get_simple_vrFilter: conn %d SUBSTRINGS\n", conn->c_connid )); + LDAP_LOG( FILTER, DETAIL1, + "get_simple_vrFilter: conn %d SUBSTRINGS\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "SUBSTRINGS\n", 0, 0, 0 ); #endif @@ -868,8 +864,8 @@ get_simple_vrFilter( case LDAP_FILTER_GE: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "get_simple_vrFilter: conn %d GE\n", conn->c_connid )); + LDAP_LOG( FILTER, DETAIL1, + "get_simple_vrFilter: conn %d GE\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "GE\n", 0, 0, 0 ); #endif @@ -881,8 +877,8 @@ get_simple_vrFilter( case LDAP_FILTER_LE: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "get_simple_vrFilter: conn %d LE\n", conn->c_connid )); + LDAP_LOG( FILTER, DETAIL1, + "get_simple_vrFilter: conn %d LE\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "LE\n", 0, 0, 0 ); #endif @@ -896,8 +892,8 @@ get_simple_vrFilter( struct berval type; #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "get_simple_vrFilter: conn %d PRESENT\n", conn->c_connid )); + LDAP_LOG( FILTER, DETAIL1, + "get_simple_vrFilter: conn %d PRESENT\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "PRESENT\n", 0, 0, 0 ); #endif @@ -921,8 +917,8 @@ get_simple_vrFilter( case LDAP_FILTER_APPROX: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "get_simple_vrFilter: conn %d APPROX\n", conn->c_connid )); + LDAP_LOG( FILTER, DETAIL1, + "get_simple_vrFilter: conn %d APPROX\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "APPROX\n", 0, 0, 0 ); #endif @@ -934,8 +930,8 @@ get_simple_vrFilter( case LDAP_FILTER_EXT: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "get_simple_vrFilter: conn %d EXTENSIBLE\n", conn->c_connid )); + LDAP_LOG( FILTER, DETAIL1, + "get_simple_vrFilter: conn %d EXTENSIBLE\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "EXTENSIBLE\n", 0, 0, 0 ); #endif @@ -951,9 +947,9 @@ get_simple_vrFilter( default: (void) ber_scanf( ber, "x" ); /* skip the element */ #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ERR, + LDAP_LOG( FILTER, ERR, "get_simple_vrFilter: conn %d unknown filter type=%lu\n", - conn->c_connid, f->f_choice )); + conn->c_connid, f->f_choice, 0 ); #else Debug( LDAP_DEBUG_ANY, "get_simple_vrFilter: unknown filter type=%lu\n", f->f_choice, 0, 0 ); @@ -980,8 +976,8 @@ get_simple_vrFilter( } #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL2, - "get_simple_vrFilter: conn %d exit\n", conn->c_connid )); + LDAP_LOG( FILTER, DETAIL2, + "get_simple_vrFilter: conn %d exit\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "end get_simple_vrFilter %d\n", err, 0, 0 ); #endif @@ -1028,8 +1024,8 @@ get_vrFilter( Connection *conn, BerElement *ber, char *last; #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, - "get_vrFilter: conn %d start\n", conn->c_connid )); + LDAP_LOG( FILTER, ENTRY, + "get_vrFilter: conn %d start\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "begin get_vrFilter\n", 0, 0, 0 ); #endif @@ -1058,8 +1054,8 @@ get_vrFilter( Connection *conn, BerElement *ber, *new = NULL; #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, - "get_vrFilter: conn %d exit\n", conn->c_connid )); + LDAP_LOG( FILTER, ENTRY, + "get_vrFilter: conn %d exit\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "end get_vrFilter\n", 0, 0, 0 ); #endif @@ -1109,8 +1105,8 @@ vrFilter_free( ValuesReturnFilter *f ) default: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ERR, - "filter_free: unknown filter type %lu\n", f->f_choice )); + LDAP_LOG( FILTER, ERR, + "filter_free: unknown filter type %lu\n", f->f_choice, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "filter_free: unknown filter type=%lu\n", f->f_choice, 0, 0 ); @@ -1340,8 +1336,8 @@ get_substring_vrFilter( *text = "error decoding filter"; #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, - "get_substring_filter: conn %d begin\n", conn->c_connid )); + LDAP_LOG( FILTER, ENTRY, + "get_substring_filter: conn %d begin\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "begin get_substring_filter\n", 0, 0, 0 ); #endif @@ -1398,9 +1394,9 @@ get_substring_vrFilter( rc = LDAP_PROTOCOL_ERROR; #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ERR, + LDAP_LOG( FILTER, ERR, "get_filter_substring: conn %d unknown substring choice=%ld\n", - conn->c_connid, (long)tag )); + conn->c_connid, (long)tag, 0 ); #else Debug( LDAP_DEBUG_FILTER, " unknown substring choice=%ld\n", @@ -1429,9 +1425,9 @@ get_substring_vrFilter( switch ( tag ) { case LDAP_SUBSTRING_INITIAL: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "get_substring_filter: conn %d INITIAL\n", - conn->c_connid )); + LDAP_LOG( FILTER, DETAIL1, + "get_substring_filter: conn %d INITIAL\n", + conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, " INITIAL\n", 0, 0, 0 ); #endif @@ -1449,9 +1445,8 @@ get_substring_vrFilter( case LDAP_SUBSTRING_ANY: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "get_substring_filter: conn %d ANY\n", - conn->c_connid )); + LDAP_LOG( FILTER, DETAIL1, + "get_substring_filter: conn %d ANY\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, " ANY\n", 0, 0, 0 ); #endif @@ -1466,9 +1461,8 @@ get_substring_vrFilter( case LDAP_SUBSTRING_FINAL: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "get_substring_filter: conn %d FINAL\n", - conn->c_connid )); + LDAP_LOG( FILTER, DETAIL1, + "get_substring_filter: conn %d FINAL\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, " FINAL\n", 0, 0, 0 ); #endif @@ -1483,9 +1477,9 @@ get_substring_vrFilter( default: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_INFO, + LDAP_LOG( FILTER, INFO, "get_substring_filter: conn %d unknown substring type %ld\n", - conn->c_connid, (long)tag )); + conn->c_connid, (long)tag, 0 ); #else Debug( LDAP_DEBUG_FILTER, " unknown substring type=%ld\n", @@ -1496,9 +1490,9 @@ get_substring_vrFilter( return_error: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_INFO, + LDAP_LOG( FILTER, INFO, "get_substring_filter: conn %d error %ld\n", - conn->c_connid, (long)rc )); + conn->c_connid, (long)rc, 0 ); #else Debug( LDAP_DEBUG_FILTER, " error=%ld\n", (long) rc, 0, 0 ); @@ -1512,8 +1506,8 @@ return_error: } #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, - "get_substring_filter: conn %d exit\n", conn->c_connid )); + LDAP_LOG( FILTER, ENTRY, + "get_substring_filter: conn %d exit\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "end get_substring_filter\n", 0, 0, 0 ); #endif diff --git a/servers/slapd/filterentry.c b/servers/slapd/filterentry.c index af513e29c565ca7035d0529a0ca3db57d1ab9c12..672915cb8cde4a6ff3db6717e74d401c4d1592bb 100644 --- a/servers/slapd/filterentry.c +++ b/servers/slapd/filterentry.c @@ -56,8 +56,7 @@ test_filter( int rc; #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, - "test_filter: begin\n" )); + LDAP_LOG( FILTER, ENTRY, "test_filter: begin\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "=> test_filter\n", 0, 0, 0 ); #endif @@ -66,13 +65,12 @@ test_filter( switch ( f->f_choice ) { case SLAPD_FILTER_COMPUTED: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "test_filter: COMPUTED %s (%d)\n", - f->f_result == LDAP_COMPARE_FALSE ? "false" : - f->f_result == LDAP_COMPARE_TRUE ? "true" : - f->f_result == SLAPD_COMPARE_UNDEFINED ? "undefined" : - "error", - f->f_result )); + LDAP_LOG( FILTER, DETAIL1, + "test_filter: COMPUTED %s (%d)\n", + f->f_result == LDAP_COMPARE_FALSE ? "false" : + f->f_result == LDAP_COMPARE_TRUE ? "true" : + f->f_result == SLAPD_COMPARE_UNDEFINED ? "undefined" : + "error", f->f_result, 0 ); #else Debug( LDAP_DEBUG_FILTER, " COMPUTED %s (%d)\n", f->f_result == LDAP_COMPARE_FALSE ? "false" : @@ -86,8 +84,7 @@ test_filter( case LDAP_FILTER_EQUALITY: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "test_filter: EQUALITY\n" )); + LDAP_LOG( FILTER, DETAIL1, "test_filter: EQUALITY\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, " EQUALITY\n", 0, 0, 0 ); #endif @@ -98,8 +95,7 @@ test_filter( case LDAP_FILTER_SUBSTRINGS: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "test_filter SUBSTRINGS\n" )); + LDAP_LOG( FILTER, DETAIL1, "test_filter SUBSTRINGS\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, " SUBSTRINGS\n", 0, 0, 0 ); #endif @@ -119,8 +115,7 @@ test_filter( case LDAP_FILTER_PRESENT: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "test_filter: PRESENT\n" )); + LDAP_LOG( FILTER, DETAIL1, "test_filter: PRESENT\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, " PRESENT\n", 0, 0, 0 ); #endif @@ -130,8 +125,7 @@ test_filter( case LDAP_FILTER_APPROX: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "test_filter: APPROX\n" )); + LDAP_LOG( FILTER, DETAIL1, "test_filter: APPROX\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, " APPROX\n", 0, 0, 0 ); #endif @@ -141,8 +135,7 @@ test_filter( case LDAP_FILTER_AND: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "test_filter: AND\n" )); + LDAP_LOG( FILTER, DETAIL1, "test_filter: AND\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, " AND\n", 0, 0, 0 ); #endif @@ -152,8 +145,7 @@ test_filter( case LDAP_FILTER_OR: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "test_filter: OR\n" )); + LDAP_LOG( FILTER, DETAIL1, "test_filter: OR\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, " OR\n", 0, 0, 0 ); #endif @@ -163,8 +155,7 @@ test_filter( case LDAP_FILTER_NOT: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "test_filter: NOT\n" )); + LDAP_LOG( FILTER, DETAIL1, "test_filter: NOT\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, " NOT\n", 0, 0, 0 ); #endif @@ -186,8 +177,7 @@ test_filter( case LDAP_FILTER_EXT: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "test_filter: EXT\n" )); + LDAP_LOG( FILTER, DETAIL1, "test_filter: EXT\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, " EXT\n", 0, 0, 0 ); #endif @@ -197,9 +187,8 @@ test_filter( default: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_INFO, - "test_filter: unknown filter type %lu\n", - f->f_choice )); + LDAP_LOG( FILTER, INFO, + "test_filter: unknown filter type %lu\n", f->f_choice, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, " unknown filter type %lu\n", f->f_choice, 0, 0 ); @@ -209,8 +198,7 @@ test_filter( } #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, - "test_filter: return=%d\n", rc )); + LDAP_LOG( FILTER, RESULTS, "test_filter: return=%d\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "<= test_filter %d\n", rc, 0, 0 ); #endif @@ -382,8 +370,7 @@ test_filter_and( int rtn = LDAP_COMPARE_TRUE; /* True if empty */ #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, - "test_filter_and: begin\n" )); + LDAP_LOG( FILTER, ENTRY, "test_filter_and: begin\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "=> test_filter_and\n", 0, 0, 0 ); #endif @@ -405,8 +392,7 @@ test_filter_and( } #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, - "test_filter_and: rc=%d\n", rtn )); + LDAP_LOG( FILTER, RESULTS, "test_filter_and: rc=%d\n", rtn, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "<= test_filter_and %d\n", rtn, 0, 0 ); #endif @@ -427,8 +413,7 @@ test_filter_or( int rtn = LDAP_COMPARE_FALSE; /* False if empty */ #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, - "test_filter_or: begin\n" )); + LDAP_LOG( FILTER, ENTRY, "test_filter_or: begin\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "=> test_filter_or\n", 0, 0, 0 ); #endif @@ -450,8 +435,7 @@ test_filter_or( } #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, - "test_filter_or: result=%d\n", rtn )); + LDAP_LOG( FILTER, ENTRY, "test_filter_or: result=%d\n", rtn, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "<= test_filter_or %d\n", rtn, 0, 0 ); #endif @@ -472,8 +456,7 @@ test_substrings_filter( Attribute *a; #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, - "test_substrings_filter: begin\n" )); + LDAP_LOG( FILTER, ENTRY, "test_substrings_filter: begin\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "begin test_substrings_filter\n", 0, 0, 0 ); #endif @@ -516,8 +499,7 @@ test_substrings_filter( } #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, - "test_substrings_filter: return FALSE\n" )); + LDAP_LOG( FILTER, ENTRY, "test_substrings_filter: return FALSE\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "end test_substrings_filter 1\n", 0, 0, 0 ); #endif diff --git a/servers/slapd/init.c b/servers/slapd/init.c index c96040e39238a078aa15826e4bc684b6a4e67ec3..b860b3f673bdce6e7935f3aadc39a00100d44873 100644 --- a/servers/slapd/init.c +++ b/servers/slapd/init.c @@ -75,9 +75,9 @@ slap_init( int mode, const char *name ) if( slapMode != SLAP_UNDEFINED_MODE ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, - "init: %s init called twice (old=%d, new=%d)\n", - name, slapMode, mode )); + LDAP_LOG( OPERATION, CRIT, + "init: %s init called twice (old=%d, new=%d)\n", + name, slapMode, mode ); #else Debug( LDAP_DEBUG_ANY, "%s init: init called twice (old=%d, new=%d)\n", @@ -93,9 +93,10 @@ slap_init( int mode, const char *name ) case SLAP_SERVER_MODE: case SLAP_TOOL_MODE: #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, - "init: %s initiation, initiated %s.\n", - name, (mode & SLAP_MODE) == SLAP_TOOL_MODE ? "tool" : "server" )); + LDAP_LOG( OPERATION, DETAIL1, + "init: %s initiation, initiated %s.\n", + name, (mode & SLAP_MODE) == SLAP_TOOL_MODE ? + "tool" : "server", 0 ); #else Debug( LDAP_DEBUG_TRACE, "%s init: initiated %s.\n", name, @@ -139,8 +140,8 @@ slap_init( int mode, const char *name ) default: #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "init: %s init, undefined mode (%d).\n", name, mode )); + LDAP_LOG( OPERATION, ERR, + "init: %s init, undefined mode (%d).\n", name, mode, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s init: undefined mode (%d).\n", name, mode, 0 ); @@ -158,8 +159,7 @@ int slap_startup( Backend *be ) int rc; #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, - "slap_startup: %s started\n", slap_name )); + LDAP_LOG( OPERATION, CRIT, "slap_startup: %s started\n", slap_name, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "%s startup: initiated.\n", @@ -177,8 +177,8 @@ int slap_shutdown( Backend *be ) int rc; #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, - "slap_shutdown: %s shutdown initiated.\n", slap_name)); + LDAP_LOG( OPERATION, CRIT, + "slap_shutdown: %s shutdown initiated.\n", slap_name, 0, 0); #else Debug( LDAP_DEBUG_TRACE, "%s shutdown: initiated\n", @@ -199,9 +199,8 @@ int slap_destroy(void) int rc; #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, - "slap_destroy: %s freeing system resources.\n", - slap_name )); + LDAP_LOG( OPERATION, INFO, + "slap_destroy: %s freeing system resources.\n", slap_name, 0, 0); #else Debug( LDAP_DEBUG_TRACE, "%s shutdown: freeing system resources.\n", diff --git a/servers/slapd/limits.c b/servers/slapd/limits.c index c33726e71190b011a143de2f8a8eb210618142a3..c34e84882164cf464ffff65fed2ba270e8f16627 100644 --- a/servers/slapd/limits.c +++ b/servers/slapd/limits.c @@ -223,10 +223,9 @@ parse_limits( if ( argc < 3 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s : line %d: missing arg(s) in " - "\"limits <pattern> <limits>\" line.\n", - fname, lineno )); + "\"limits <pattern> <limits>\" line.\n", fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s : line %d: missing arg(s) in " @@ -328,13 +327,11 @@ parse_limits( default: if ( pattern[0] != '=' ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s : line %d: missing '=' in " "\"dn[.{exact|base|one|subtree" - "|children|regex|anonymous}]" - "=<pattern>\" in " - "\"limits <pattern> <limits>\" line.\n", - fname, lineno )); + "|children|regex|anonymous}]" "=<pattern>\" in " + "\"limits <pattern> <limits>\" line.\n", fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s : line %d: missing '=' in " @@ -369,10 +366,10 @@ parse_limits( if ( parse_limit( argv[i], &limit ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s : line %d: unknown limit type \"%s\" in " "\"limits <pattern> <limits>\" line.\n", - fname, lineno, argv[i] )); + fname, lineno, argv[i] ); #else Debug( LDAP_DEBUG_ANY, "%s : line %d: unknown limit type \"%s\" in " diff --git a/servers/slapd/lock.c b/servers/slapd/lock.c index 305fb5b91ce0d346275ad6faf836fbd13d8d4b97..13fe405b14e1583526f4263c620a1748f4549bf6 100644 --- a/servers/slapd/lock.c +++ b/servers/slapd/lock.c @@ -1,48 +1,59 @@ /* lock.c - routines to open and apply an advisory lock to a file */ +/* $OpenLDAP$ */ +/* + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ -#include <stdio.h> -#include <sys/time.h> -#include <sys/types.h> #include "portable.h" -#ifdef USE_LOCKF -#include <unistd.h> -#endif + +#include <stdio.h> + +#include <ac/string.h> +#include <ac/socket.h> +#include <ac/time.h> +#include <ac/unistd.h> + +#ifdef HAVE_SYS_FILE_H #include <sys/file.h> -#include <sys/param.h> -#include <sys/socket.h> +#endif + #include "slap.h" FILE * -lock_fopen( char *fname, char *type, FILE **lfp ) +lock_fopen( const char *fname, const char *type, FILE **lfp ) { FILE *fp; char buf[MAXPATHLEN]; /* open the lock file */ - strcpy( buf, fname ); - strcat( buf, ".lock" ); + strcpy(lutil_strcopy( buf, fname ), ".lock" ); if ( (*lfp = fopen( buf, "w" )) == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG( OPERATION, ERR, + "lock_fopen: could not open lock file \"%s\".\n", buf, 0, 0); +#else Debug( LDAP_DEBUG_ANY, "could not open \"%s\"\n", buf, 0, 0 ); +#endif + return( NULL ); } /* acquire the lock */ -#ifdef USE_LOCKF - while ( lockf( fileno( *lfp ), F_LOCK, 0 ) != 0 ) { -#else - while ( flock( fileno( *lfp ), LOCK_EX ) != 0 ) { -#endif - ; /* NULL */ - } + ldap_lockf( fileno(*lfp) ); /* open the log file */ if ( (fp = fopen( fname, type )) == NULL ) { - Debug( LDAP_DEBUG_ANY, "could not open \"%s\"\n", fname, 0, 0 ); -#ifdef USE_LOCKF - lockf( fileno( *lfp ), F_ULOCK, 0 ); +#ifdef NEW_LOGGING + LDAP_LOG( OPERATION, ERR, + "lock_fopen: could not open log file \"%s\".\n", buf, 0, 0); #else - flock( fileno( *lfp ), LOCK_UN ); + Debug( LDAP_DEBUG_ANY, "could not open \"%s\"\n", fname, 0, 0 ); #endif + + ldap_unlockf( fileno(*lfp) ); + fclose( *lfp ); + *lfp = NULL; return( NULL ); } @@ -53,11 +64,7 @@ int lock_fclose( FILE *fp, FILE *lfp ) { /* unlock */ -#ifdef USE_LOCKF - lockf( fileno( lfp ), F_ULOCK, 0 ); -#else - flock( fileno( lfp ), LOCK_UN ); -#endif + ldap_unlockf( fileno(lfp) ); fclose( lfp ); return( fclose( fp ) ); diff --git a/servers/slapd/main.c b/servers/slapd/main.c index cea889cf7adfc9c38a657b481e40f431b4929b54..de931e49088dd0318cf6b010e6556abb2f6b8520 100644 --- a/servers/slapd/main.c +++ b/servers/slapd/main.c @@ -177,8 +177,10 @@ int main( int argc, char **argv ) { slap_debug = *i; #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, - "main: new debug level from registry is: %d\n", slap_debug )); + lutil_log_initialize( argc, argv ); + LDAP_LOG( SLAPD, INFO, + "main: new debug level from registry is: %d\n", + slap_debug, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "new debug level from registry is: %d\n", slap_debug, 0, 0 ); #endif @@ -192,8 +194,8 @@ int main( int argc, char **argv ) urls = ch_strdup(newUrls); #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, - "main: new urls from registry: %s\n", urls )); + LDAP_LOG( SLAPD, INFO, + "main: new urls from registry: %s\n", urls, 0, 0 ); #else Debug(LDAP_DEBUG_ANY, "new urls from registry: %s\n", urls, 0, 0); @@ -206,8 +208,8 @@ int main( int argc, char **argv ) { configfile = newConfigFile; #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, - "main: new config file from registry is: %s\n", configfile )); + LDAP_LOG( SLAPD, INFO, + "main: new config file from registry is: %s\n", configfile, 0, 0 ); #else Debug ( LDAP_DEBUG_ANY, "new config file from registry is: %s\n", configfile, 0, 0 ); #endif @@ -310,16 +312,15 @@ int main( int argc, char **argv ) #ifdef NEW_LOGGING lutil_log_initialize( argc, argv ); -#endif - +#else lutil_set_debug_level( "slapd", slap_debug ); ber_set_option(NULL, LBER_OPT_DEBUG_LEVEL, &slap_debug); ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, &slap_debug); ldif_debug = slap_debug; +#endif #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, - "%s", Versionstr )); + LDAP_LOG( SLAPD, INFO, "%s", Versionstr, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "%s", Versionstr, 0, 0 ); #endif @@ -384,8 +385,7 @@ int main( int argc, char **argv ) if ( slap_schema_init( ) != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, - "main: schema initialization error\n" )); + LDAP_LOG( OPERATION, CRIT, "main: schema initialization error\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "schema initialization error\n", @@ -424,8 +424,7 @@ int main( int argc, char **argv ) if ( glue_sub_init( ) != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, - "main: subordinate config error\n")); + LDAP_LOG( SLAPD, CRIT, "main: subordinate config error\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "subordinate config error\n", @@ -436,8 +435,7 @@ int main( int argc, char **argv ) if ( slap_schema_check( ) != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, - "main: schema prep error\n")); + LDAP_LOG( SLAPD, CRIT, "main: schema prep error\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "schema prep error\n", @@ -451,8 +449,7 @@ int main( int argc, char **argv ) rc = ldap_pvt_tls_init(); if( rc != 0) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, - "main: tls init failed: %d\n", rc )); + LDAP_LOG( SLAPD, CRIT, "main: tls init failed: %d\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "main: TLS init failed: %d\n", @@ -466,8 +463,7 @@ int main( int argc, char **argv ) rc = ldap_pvt_tls_init_def_ctx(); if( rc != 0) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, - "main: tls init def ctx failed: %d\n", rc )); + LDAP_LOG( SLAPD, CRIT, "main: tls init def ctx failed: %d\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "main: TLS init def ctx failed: %d\n", @@ -516,8 +512,7 @@ int main( int argc, char **argv ) FILE *fp; #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, - "main: slapd starting.\n" )); + LDAP_LOG( SLAPD, INFO, "main: slapd starting.\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "slapd starting\n", 0, 0, 0 ); #endif @@ -575,8 +570,7 @@ stop: #endif #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, - "main: slapd stopped.\n" )); + LDAP_LOG( SLAPD, CRIT, "main: slapd stopped.\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "slapd stopped.\n", 0, 0, 0 ); #endif diff --git a/servers/slapd/matchedValues.c b/servers/slapd/matchedValues.c index 56bd29667b491b59dc3e40bd258be1e43a5266a5..483a14956d225e1f988caa2bf4636202ff340a42 100644 --- a/servers/slapd/matchedValues.c +++ b/servers/slapd/matchedValues.c @@ -73,8 +73,7 @@ filter_matched_values( int rc = LDAP_SUCCESS; #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, - "filter_matched_values: begin\n" )); + LDAP_LOG( FILTER, ENTRY, "filter_matched_values: begin\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "=> filter_matched_values\n", 0, 0, 0 ); #endif @@ -83,13 +82,12 @@ filter_matched_values( switch ( f->f_choice ) { case SLAPD_FILTER_COMPUTED: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, + LDAP_LOG( FILTER, DETAIL1, "test_vrFilter: COMPUTED %s (%d)\n", f->f_result == LDAP_COMPARE_FALSE ? "false" : f->f_result == LDAP_COMPARE_TRUE ? "true" : f->f_result == SLAPD_COMPARE_UNDEFINED ? "undefined" : - "error", - f->f_result )); + "error", f->f_result, 0 ); #else Debug( LDAP_DEBUG_FILTER, " COMPUTED %s (%d)\n", f->f_result == LDAP_COMPARE_FALSE ? "false" : @@ -103,8 +101,7 @@ filter_matched_values( case LDAP_FILTER_EQUALITY: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "test_vrFilter: EQUALITY\n" )); + LDAP_LOG( FILTER, DETAIL1, "test_vrFilter: EQUALITY\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, " EQUALITY\n", 0, 0, 0 ); #endif @@ -117,8 +114,7 @@ filter_matched_values( case LDAP_FILTER_SUBSTRINGS: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "test_vrFilter SUBSTRINGS\n" )); + LDAP_LOG( FILTER, DETAIL1, "test_vrFilter SUBSTRINGS\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, " SUBSTRINGS\n", 0, 0, 0 ); #endif @@ -132,8 +128,7 @@ filter_matched_values( case LDAP_FILTER_PRESENT: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "test_vrFilter: PRESENT\n" )); + LDAP_LOG( FILTER, DETAIL1, "test_vrFilter: PRESENT\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, " PRESENT\n", 0, 0, 0 ); #endif @@ -162,8 +157,7 @@ filter_matched_values( case LDAP_FILTER_EXT: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "test_vrFilter: EXT\n" )); + LDAP_LOG( FILTER, DETAIL1, "test_vrFilter: EXT\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, " EXT\n", 0, 0, 0 ); #endif @@ -176,9 +170,8 @@ filter_matched_values( default: #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_INFO, - "test_vrFilter: unknown filter type %lu\n", - f->f_choice )); + LDAP_LOG( FILTER, INFO, + "test_vrFilter: unknown filter type %lu\n", f->f_choice, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, " unknown filter type %lu\n", f->f_choice, 0, 0 ); @@ -188,8 +181,7 @@ filter_matched_values( } #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, - "filter_matched_values: return=%d\n", rc )); + LDAP_LOG( FILTER, ENTRY, "filter_matched_values: return=%d\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "<= filter_matched_values %d\n", rc, 0, 0 ); #endif diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 5e7440973711638a420d3188ecb89ce473cad5e0..30e9cca497134dd57182051704f1f75d38dc080c 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -50,8 +50,7 @@ do_modify( int manageDSAit; #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, - "do_modify: enter\n" )); + LDAP_LOG( OPERATION, ENTRY, "do_modify: enter\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "do_modify\n", 0, 0, 0 ); #endif @@ -77,8 +76,7 @@ do_modify( if ( ber_scanf( op->o_ber, "{m" /*}*/, &dn ) == LBER_ERROR ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "do_modify: ber_scanf failed\n" )); + LDAP_LOG( OPERATION, ERR, "do_modify: ber_scanf failed\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_modify: ber_scanf failed\n", 0, 0, 0 ); #endif @@ -89,8 +87,7 @@ do_modify( } #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ARGS, - "do_modify: dn (%s)\n", dn.bv_val )); + LDAP_LOG( OPERATION, ARGS, "do_modify: dn (%s)\n", dn.bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_ARGS, "do_modify: dn (%s)\n", dn.bv_val, 0, 0 ); #endif @@ -128,9 +125,9 @@ do_modify( case LDAP_MOD_ADD: if ( mod->sml_bvalues == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + LDAP_LOG( OPERATION, ERR, "do_modify: modify/add operation (%ld) requires values\n", - (long)mop )); + (long)mop, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_modify: modify/add operation (%ld) requires values\n", @@ -152,9 +149,8 @@ do_modify( default: { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "do_modify: invalid modify operation (%ld)\n", - (long)mop )); + LDAP_LOG( OPERATION, ERR, + "do_modify: invalid modify operation (%ld)\n", (long)mop, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_modify: invalid modify operation (%ld)\n", @@ -174,8 +170,7 @@ do_modify( if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "do_modify: get_ctrls failed\n" )); + LDAP_LOG( OPERATION, ERR, "do_modify: get_ctrls failed\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_modify: get_ctrls failed\n", 0, 0, 0 ); #endif @@ -186,9 +181,8 @@ do_modify( rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, - "do_modify: conn %d invalid dn (%s)\n", - conn->c_connid, dn.bv_val )); + LDAP_LOG( OPERATION, INFO, "do_modify: conn %d invalid dn (%s)\n", + conn->c_connid, dn.bv_val, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_modify: invalid dn (%s)\n", dn.bv_val, 0, 0 ); @@ -200,8 +194,8 @@ do_modify( if( ndn.bv_len == 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "do_modify: attempt to modify root DSE.\n" )); + LDAP_LOG( OPERATION, ERR, + "do_modify: attempt to modify root DSE.\n",0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_modify: root dse!\n", 0, 0, 0 ); #endif @@ -213,8 +207,8 @@ do_modify( #if defined( SLAPD_SCHEMA_DN ) } else if ( strcasecmp( ndn.bv_val, SLAPD_SCHEMA_DN ) == 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "do_modify: attempt to modify subschema subentry.\n" )); + LDAP_LOG( OPERATION, ERR, + "do_modify: attempt to modify subschema subentry.\n" , 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_modify: subschema subentry!\n", 0, 0, 0 ); #endif @@ -228,31 +222,26 @@ do_modify( #ifdef LDAP_DEBUG #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, - "do_modify: modifications:\n" )); + LDAP_LOG( OPERATION, DETAIL1, "do_modify: modifications:\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ARGS, "modifications:\n", 0, 0, 0 ); #endif for ( tmp = modlist; tmp != NULL; tmp = tmp->sml_next ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, - "\t%s: %s\n", tmp->sml_op == LDAP_MOD_ADD ? - "add" : (tmp->sml_op == LDAP_MOD_DELETE ? - "delete" : "replace"), tmp->sml_type.bv_val )); + LDAP_LOG( OPERATION, DETAIL1, "\t%s: %s\n", + tmp->sml_op == LDAP_MOD_ADD ? + "add" : (tmp->sml_op == LDAP_MOD_DELETE ? + "delete" : "replace"), tmp->sml_type.bv_val, 0 ); if ( tmp->sml_bvalues == NULL ) { - LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, - "\t\tno values" )); + LDAP_LOG( OPERATION, DETAIL1, "\t\tno values", 0, 0, 0 ); } else if ( tmp->sml_bvalues[0].bv_val == NULL ) { - LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, - "\t\tzero values" )); + LDAP_LOG( OPERATION, DETAIL1, "\t\tzero values", 0, 0, 0 ); } else if ( tmp->sml_bvalues[1].bv_val == NULL ) { - LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, - "\t\tone value" )); + LDAP_LOG( OPERATION, DETAIL1, "\t\tone value", 0, 0, 0 ); } else { - LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, - "\t\tmultiple values" )); + LDAP_LOG( OPERATION, DETAIL1, "\t\tmultiple values", 0, 0, 0 ); } #else @@ -574,7 +563,7 @@ int slap_mods_opattrs( ldap_pvt_thread_mutex_lock( &gmtime_mutex ); ltm = gmtime( &now ); - strftime( timebuf, sizeof(timebuf), "%Y%m%d%H%M%SZ", ltm ); + lutil_gentime( timebuf, sizeof(timebuf), ltm ); csn.bv_len = lutil_csnstr( csnbuf, sizeof( csnbuf ), 0, 0 ); ldap_pvt_thread_mutex_unlock( &gmtime_mutex ); diff --git a/servers/slapd/modrdn.c b/servers/slapd/modrdn.c index eca68cace571f2fd5b35d3499c6d871b367853f2..8cb8a2737de44897807b7ed55f776ce959424073 100644 --- a/servers/slapd/modrdn.c +++ b/servers/slapd/modrdn.c @@ -65,8 +65,7 @@ do_modrdn( int manageDSAit; #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, - "do_modrdn: begin\n" )); + LDAP_LOG( OPERATION, ENTRY, "do_modrdn: begin\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "do_modrdn\n", 0, 0, 0 ); #endif @@ -87,8 +86,7 @@ do_modrdn( == LBER_ERROR ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "do_modrdn: ber_scanf failed\n" )); + LDAP_LOG( OPERATION, ERR, "do_modrdn: ber_scanf failed\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0, 0 ); #endif @@ -106,8 +104,8 @@ do_modrdn( * newSuperior is present: report error. */ #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "do_modrdn: (v2) invalid field newSuperior.\n" )); + LDAP_LOG( OPERATION, ERR, + "do_modrdn: (v2) invalid field newSuperior.\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "modrdn(v2): invalid field newSuperior!\n", @@ -124,8 +122,8 @@ do_modrdn( == LBER_ERROR ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "do_modrdn: ber_scanf(\"m\") failed\n" )); + LDAP_LOG( OPERATION, ERR, + "do_modrdn: ber_scanf(\"m\") failed\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "ber_scanf(\"m\") failed\n", 0, 0, 0 ); @@ -141,10 +139,10 @@ do_modrdn( } #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ARGS, + LDAP_LOG( OPERATION, ARGS, "do_modrdn: dn (%s) newrdn (%s) newsuperior(%s)\n", dn.bv_val, newrdn.bv_val, - newSuperior.bv_len ? newSuperior.bv_val : "" )); + newSuperior.bv_len ? newSuperior.bv_val : "" ); #else Debug( LDAP_DEBUG_ARGS, "do_modrdn: dn (%s) newrdn (%s) newsuperior (%s)\n", @@ -154,8 +152,7 @@ do_modrdn( if ( ber_scanf( op->o_ber, /*{*/ "}") == LBER_ERROR ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "do_modrdn: ber_scanf failed\n" )); + LDAP_LOG( OPERATION, ERR, "do_modrdn: ber_scanf failed\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_modrdn: ber_scanf failed\n", 0, 0, 0 ); #endif @@ -168,8 +165,7 @@ do_modrdn( if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "do_modrdn: get_ctrls failed\n" )); + LDAP_LOG( OPERATION, ERR, "do_modrdn: get_ctrls failed\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_modrdn: get_ctrls failed\n", 0, 0, 0 ); #endif @@ -181,9 +177,9 @@ do_modrdn( rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + LDAP_LOG( OPERATION, INFO, "do_modrdn: conn %d invalid dn (%s)\n", - conn->c_connid, dn.bv_val )); + conn->c_connid, dn.bv_val, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_modrdn: invalid dn (%s)\n", dn.bv_val, 0, 0 ); @@ -195,8 +191,8 @@ do_modrdn( if( ndn.bv_len == 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "do_modrdn: attempt to modify root DSE.\n" )); + LDAP_LOG( OPERATION, ERR, + "do_modrdn: attempt to modify root DSE.\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_modrdn: root dse!\n", 0, 0, 0 ); #endif @@ -208,8 +204,8 @@ do_modrdn( #ifdef SLAPD_SCHEMA_DN } else if ( strcasecmp( ndn.bv_val, SLAPD_SCHEMA_DN ) == 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "do_modrdn: attempt to modify subschema subentry\n" )); + LDAP_LOG( OPERATION, ERR, + "do_modrdn: attempt to modify subschema subentry\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_modrdn: subschema subentry!\n", 0, 0, 0 ); #endif @@ -225,9 +221,9 @@ do_modrdn( rc = dnPrettyNormal( NULL, &newrdn, &pnewrdn, &nnewrdn ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + LDAP_LOG( OPERATION, INFO, "do_modrdn: conn %d invalid newrdn (%s)\n", - conn->c_connid, newrdn.bv_val )); + conn->c_connid, newrdn.bv_val, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_modrdn: invalid newrdn (%s)\n", newrdn.bv_val, 0, 0 ); @@ -239,8 +235,8 @@ do_modrdn( if( rdnValidate( &pnewrdn ) != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "do_modrdn: invalid rdn (%s).\n", pnewrdn.bv_val )); + LDAP_LOG( OPERATION, ERR, + "do_modrdn: invalid rdn (%s).\n", pnewrdn.bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_modrdn: invalid rdn (%s)\n", pnewrdn.bv_val, 0, 0 ); @@ -256,9 +252,9 @@ do_modrdn( &nnewSuperior ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + LDAP_LOG( OPERATION, INFO, "do_modrdn: conn %d invalid newSuperior (%s)\n", - conn->c_connid, newSuperior.bv_val )); + conn->c_connid, newSuperior.bv_val, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_modrdn: invalid newSuperior (%s)\n", diff --git a/servers/slapd/module.c b/servers/slapd/module.c index 4a58714d5f0a20b385f8f1cdbfe53c88a099f73c..12375773cfae4fcb4a7ca8871a0f8d43b7382f39 100644 --- a/servers/slapd/module.c +++ b/servers/slapd/module.c @@ -41,8 +41,8 @@ int module_init (void) if (lt_dlinit()) { const char *error = lt_dlerror(); #ifdef NEW_LOGGING - LDAP_LOG(( "module", LDAP_LEVEL_CRIT, - "module_init: lt_ldinit failed: %s\n", error )); + LDAP_LOG( SLAPD, CRIT, + "module_init: lt_ldinit failed: %s\n", error, 0, 0 ); #else Debug(LDAP_DEBUG_ANY, "lt_dlinit failed: %s\n", error, 0, 0); #endif @@ -62,8 +62,8 @@ int module_kill (void) if (lt_dlexit()) { const char *error = lt_dlerror(); #ifdef NEW_LOGGING - LDAP_LOG(( "module", LDAP_LEVEL_CRIT, - "module_kill: lt_dlexit failed: %s\n", error )); + LDAP_LOG( SLAPD, CRIT, "module_kill: lt_dlexit failed: %s\n", + error, 0, 0 ); #else Debug(LDAP_DEBUG_ANY, "lt_dlexit failed: %s\n", error, 0, 0); #endif @@ -83,8 +83,8 @@ int module_load(const char* file_name, int argc, char *argv[]) module = (module_loaded_t *)ch_calloc(1, sizeof(module_loaded_t)); if (module == NULL) { #ifdef NEW_LOGGING - LDAP_LOG(( "module", LDAP_LEVEL_CRIT, - "module_load: (%s) out of memory.\n", file_name )); + LDAP_LOG( SLAPD, CRIT, + "module_load: (%s) out of memory.\n", file_name, 0, 0 ); #else Debug(LDAP_DEBUG_ANY, "module_load failed: (%s) out of memory\n", file_name, 0, 0); @@ -101,9 +101,9 @@ int module_load(const char* file_name, int argc, char *argv[]) if ((module->lib = lt_dlopen(file_name)) == NULL) { error = lt_dlerror(); #ifdef NEW_LOGGING - LDAP_LOG(( "module", LDAP_LEVEL_CRIT, - "module_load: lt_dlopen failed: (%s) %s.\n", - file_name, error )); + LDAP_LOG( SLAPD, CRIT, + "module_load: lt_dlopen failed: (%s) %s.\n", + file_name, error, 0 ); #else Debug(LDAP_DEBUG_ANY, "lt_dlopen failed: (%s) %s\n", file_name, error, 0); @@ -114,8 +114,7 @@ int module_load(const char* file_name, int argc, char *argv[]) } #ifdef NEW_LOGGING - LDAP_LOG(( "module", LDAP_LEVEL_INFO, - "module_load: loaded module %s\n", file_name )); + LDAP_LOG( SLAPD, INFO, "module_load: loaded module %s\n", file_name, 0, 0 ); #else Debug(LDAP_DEBUG_CONFIG, "loaded module %s\n", file_name, 0, 0); #endif @@ -123,9 +122,9 @@ int module_load(const char* file_name, int argc, char *argv[]) if ((initialize = lt_dlsym(module->lib, "init_module")) == NULL) { #ifdef NEW_LOGGING - LDAP_LOG(( "module", LDAP_LEVEL_ERR, - "module_load: module %s : no init_module() function found\n", - file_name )); + LDAP_LOG( SLAPD, ERR, + "module_load: module %s : no init_module() function found\n", + file_name, 0, 0 ); #else Debug(LDAP_DEBUG_CONFIG, "module %s: no init_module() function found\n", file_name, 0, 0); @@ -154,8 +153,8 @@ int module_load(const char* file_name, int argc, char *argv[]) rc = initialize(argc, argv); if (rc == -1) { #ifdef NEW_LOGGING - LDAP_LOG(( "module", LDAP_LEVEL_ERR, - "module_load: module %s init_module() failed\n", file_name)); + LDAP_LOG( SLAPD, ERR, + "module_load: module %s init_module() failed\n", file_name, 0, 0); #else Debug(LDAP_DEBUG_CONFIG, "module %s: init_module() failed\n", file_name, 0, 0); @@ -170,8 +169,9 @@ int module_load(const char* file_name, int argc, char *argv[]) || module_regtable[rc].proc == NULL) { #ifdef NEW_LOGGING - LDAP_LOG(( "module", LDAP_LEVEL_ERR, - "module_load: module %s: unknown registration type (%d).\n", file_name)); + LDAP_LOG( SLAPD, ERR, + "module_load: module %s: unknown registration type (%d).\n", + file_name, 0); #else Debug(LDAP_DEBUG_CONFIG, "module %s: unknown registration type (%d)\n", file_name, rc, 0); @@ -184,9 +184,9 @@ int module_load(const char* file_name, int argc, char *argv[]) rc = (module_regtable[rc].proc)(module, file_name); if (rc != 0) { #ifdef NEW_LOGGING - LDAP_LOG(( "module", LDAP_LEVEL_ERR, - "module_load: module %s:%s could not be registered.\n", - file_name, module_regtable[rc].type )); + LDAP_LOG( SLAPD, ERR, + "module_load: module %s:%s could not be registered.\n", + file_name, module_regtable[rc].type, 0 ); #else Debug(LDAP_DEBUG_CONFIG, "module %s: %s module could not be registered\n", file_name, module_regtable[rc].type, 0); @@ -200,9 +200,9 @@ int module_load(const char* file_name, int argc, char *argv[]) module_list = module; #ifdef NEW_LOGGING - LDAP_LOG(( "module", LDAP_LEVEL_INFO, - "module_load: module %s:%s registered\n", file_name, - module_regtable[rc].type )); + LDAP_LOG( SLAPD, INFO, + "module_load: module %s:%s registered\n", file_name, + module_regtable[rc].type, 0 ); #else Debug(LDAP_DEBUG_CONFIG, "module %s: %s module registered\n", file_name, module_regtable[rc].type, 0); diff --git a/servers/slapd/mr.c b/servers/slapd/mr.c index f8e788b6e0082d66acd4d2b0676a08588e42c915..dfa34c95d8c34620b6f1b4d194f898bcdf6409a6 100644 --- a/servers/slapd/mr.c +++ b/servers/slapd/mr.c @@ -16,7 +16,6 @@ #include "slap.h" #include "ldap_pvt.h" - struct mindexrec { struct berval mir_name; MatchingRule *mir_mr; @@ -198,8 +197,8 @@ register_matching_rule( if( usage == SLAP_MR_NONE ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "register_matching_rule: %s not usable\n", desc )); + LDAP_LOG( OPERATION, ERR, + "register_matching_rule: %s not usable\n", desc, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "register_matching_rule: not usable %s\n", desc, 0, 0 ); @@ -216,9 +215,9 @@ register_matching_rule( if( amr == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "register_matching_rule: could not locate associated matching rule %s for %s\n", - associated, desc )); + LDAP_LOG( OPERATION, ERR, + "register_matching_rule: could not locate associated " + "matching rule %s for %s\n", associated, desc, 0 ); #else Debug( LDAP_DEBUG_ANY, "register_matching_rule: could not locate " "associated matching rule %s for %s\n", @@ -234,9 +233,9 @@ register_matching_rule( mr = ldap_str2matchingrule( desc, &code, &err, LDAP_SCHEMA_ALLOW_ALL); if ( !mr ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "register_matching_rule: %s before %s in %s.\n", - ldap_scherr2str(code), err, desc )); + LDAP_LOG( OPERATION, ERR, + "register_matching_rule: %s before %s in %s.\n", + ldap_scherr2str(code), err, desc ); #else Debug( LDAP_DEBUG_ANY, "Error in register_matching_rule: %s before %s in %s\n", ldap_scherr2str(code), err, desc ); @@ -253,9 +252,9 @@ register_matching_rule( if ( code ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "register_matching_rule: %s for %s in %s.\n", - scherr2str(code), err, desc )); + LDAP_LOG( OPERATION, ERR, + "register_matching_rule: %s for %s in %s.\n", + scherr2str(code), err, desc ); #else Debug( LDAP_DEBUG_ANY, "Error in register_matching_rule: %s for %s in %s\n", scherr2str(code), err, desc ); diff --git a/servers/slapd/mra.c b/servers/slapd/mra.c index 81db86ae7687473872714cc5460984a353f91f45..eca939b02674fd8b17def10f75c736b76a158c53 100644 --- a/servers/slapd/mra.c +++ b/servers/slapd/mra.c @@ -14,7 +14,6 @@ #include "slap.h" - void mra_free( MatchingRuleAssertion *mra, @@ -53,8 +52,8 @@ get_mra( if( rtag == LBER_ERROR ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "get_mra: ber_scanf (\"{t\") failure\n" )); + LDAP_LOG( OPERATION, ERR, + "get_mra: ber_scanf (\"{t\") failure\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, " get_mra ber_scanf\n", 0, 0, 0 ); #endif @@ -68,8 +67,8 @@ get_mra( rtag = ber_scanf( ber, "m", &ma->ma_rule_text ); if ( rtag == LBER_ERROR ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "get_mra: ber_scanf(\"o\") failure.\n" )); + LDAP_LOG( OPERATION, ERR, + "get_mra: ber_scanf(\"o\") failure.\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, " get_mra ber_scanf for mr\n", 0, 0, 0 ); #endif @@ -82,8 +81,8 @@ get_mra( rtag = ber_scanf( ber, "t", &tag ); if( rtag == LBER_ERROR ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "get_mra: ber_scanf (\"t\") failure\n" )); + LDAP_LOG( OPERATION, ERR, + "get_mra: ber_scanf (\"t\") failure\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, " get_mra ber_scanf\n", 0, 0, 0 ); #endif @@ -98,8 +97,8 @@ get_mra( rtag = ber_scanf( ber, "m", &type ); if ( rtag == LBER_ERROR ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "get_mra: ber_scanf (\"o\") failure.\n" )); + LDAP_LOG( OPERATION, ERR, + "get_mra: ber_scanf (\"o\") failure.\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, " get_mra ber_scanf for ad\n", 0, 0, 0 ); #endif @@ -111,8 +110,8 @@ get_mra( rtag = ber_scanf( ber, "t", &tag ); if( rtag == LBER_ERROR ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "get_mra: ber_scanf (\"t\") failure.\n" )); + LDAP_LOG( OPERATION, ERR, + "get_mra: ber_scanf (\"t\") failure.\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, " get_mra ber_scanf\n", 0, 0, 0 ); #endif @@ -125,8 +124,8 @@ get_mra( if ( tag != LDAP_FILTER_EXT_VALUE ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "get_mra: ber_scanf missing value\n" )); + LDAP_LOG( OPERATION, ERR, + "get_mra: ber_scanf missing value\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, " get_mra ber_scanf missing value\n", 0, 0, 0 ); #endif @@ -140,8 +139,8 @@ get_mra( if( rtag == LBER_ERROR ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "get_mra: ber_scanf (\"o\") failure.\n" )); + LDAP_LOG( OPERATION, ERR, + "get_mra: ber_scanf (\"o\") failure.\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, " get_mra ber_scanf\n", 0, 0, 0 ); #endif @@ -161,8 +160,7 @@ get_mra( if( rtag == LBER_ERROR ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "get_mra: ber_scanf failure\n")); + LDAP_LOG( OPERATION, ERR, "get_mra: ber_scanf failure\n", 0, 0, 0); #else Debug( LDAP_DEBUG_ANY, " get_mra ber_scanf\n", 0, 0, 0 ); #endif diff --git a/servers/slapd/oc.c b/servers/slapd/oc.c index 02f6ea402212c9206dff7f9fcbdb6d69477e64fd..2d7c6ce097274af7dd4b5327a207e25eab7ddd23 100644 --- a/servers/slapd/oc.c +++ b/servers/slapd/oc.c @@ -25,8 +25,14 @@ int is_object_subclass( if( sub == NULL || sup == NULL ) return 0; #if 1 +#ifdef NEW_LOGGING + LDAP_LOG ( OPERATION, ARGS, + "is_object_subclass(%s,%s) %d\n", + sup->soc_oid, sub->soc_oid, sup == sub ); +#else Debug( LDAP_DEBUG_TRACE, "is_object_subclass(%s,%s) %d\n", sup->soc_oid, sub->soc_oid, sup == sub ); +#endif #endif if( sup == sub ) { @@ -72,10 +78,10 @@ int is_entry_objectclass( if( attr == NULL ) { /* no objectClass attribute */ #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, "is_entry_objectclass: " - "dn(%s), oid (%s), no objectClass attribute.\n", - e->e_dn == NULL ? "" : e->e_dn, - oc->soc_oclass.oc_oid )); + LDAP_LOG( OPERATION, ERR, + "is_entry_objectclass: dn(%s), oid (%s), no objectClass " + "attribute.\n", e->e_dn == NULL ? "" : e->e_dn, + oc->soc_oclass.oc_oid, 0 ); #else Debug( LDAP_DEBUG_ANY, "is_entry_objectclass(\"%s\", \"%s\") " "no objectClass attribute\n", diff --git a/servers/slapd/passwd.c b/servers/slapd/passwd.c index 06cc1586a87478d2285866f4d7b2badd4b3d0bf0..f45b974272d4bb57a657a29aea2d56f4c2313c0f 100644 --- a/servers/slapd/passwd.c +++ b/servers/slapd/passwd.c @@ -119,8 +119,8 @@ int slap_passwd_parse( struct berval *reqdata, if( tag == LDAP_TAG_EXOP_MODIFY_PASSWD_ID ) { if( id == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "slap_passwd_parse: ID not allowed.\n")); + LDAP_LOG( OPERATION, ERR, + "slap_passwd_parse: ID not allowed.\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "slap_passwd_parse: ID not allowed.\n", 0, 0, 0 ); @@ -135,8 +135,8 @@ int slap_passwd_parse( struct berval *reqdata, if( tag == LBER_ERROR ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "slap_passwd_parse: ID parse failed.\n")); + LDAP_LOG( OPERATION, ERR, + "slap_passwd_parse: ID parse failed.\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "slap_passwd_parse: ID parse failed.\n", 0, 0, 0 ); @@ -151,8 +151,8 @@ int slap_passwd_parse( struct berval *reqdata, if( tag == LDAP_TAG_EXOP_MODIFY_PASSWD_OLD ) { if( oldpass == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "slap_passwd_parse: OLD not allowed.\n" )); + LDAP_LOG( OPERATION, ERR, + "slap_passwd_parse: OLD not allowed.\n" , 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "slap_passwd_parse: OLD not allowed.\n", 0, 0, 0 ); @@ -167,8 +167,8 @@ int slap_passwd_parse( struct berval *reqdata, if( tag == LBER_ERROR ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "slap_passwd_parse: ID parse failed.\n" )); + LDAP_LOG( OPERATION, ERR, + "slap_passwd_parse: ID parse failed.\n" , 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "slap_passwd_parse: ID parse failed.\n", 0, 0, 0 ); @@ -183,8 +183,8 @@ int slap_passwd_parse( struct berval *reqdata, if( tag == LDAP_TAG_EXOP_MODIFY_PASSWD_NEW ) { if( newpass == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "slap_passwd_parse: NEW not allowed.\n" )); + LDAP_LOG( OPERATION, ERR, + "slap_passwd_parse: NEW not allowed.\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "slap_passwd_parse: NEW not allowed.\n", 0, 0, 0 ); @@ -199,8 +199,8 @@ int slap_passwd_parse( struct berval *reqdata, if( tag == LBER_ERROR ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "slap_passwd_parse: OLD parse failed.\n")); + LDAP_LOG( OPERATION, ERR, + "slap_passwd_parse: OLD parse failed.\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "slap_passwd_parse: OLD parse failed.\n", 0, 0, 0 ); @@ -215,8 +215,8 @@ int slap_passwd_parse( struct berval *reqdata, if( len != 0 ) { decoding_error: #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "slap_passwd_parse: decoding error, len=%ld\n", (long)len )); + LDAP_LOG( OPERATION, ERR, + "slap_passwd_parse: decoding error, len=%ld\n", (long)len, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "slap_passwd_parse: decoding error, len=%ld\n", @@ -243,8 +243,8 @@ struct berval * slap_passwd_return( assert( cred != NULL ); #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, - "slap_passwd_return: %ld\n",(long)cred->bv_len )); + LDAP_LOG( OPERATION, ENTRY, + "slap_passwd_return: %ld\n",(long)cred->bv_len, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "slap_passwd_return: %ld\n", (long) cred->bv_len, 0, 0 ); @@ -302,8 +302,7 @@ slap_passwd_generate( struct berval *pass ) { struct berval *tmp; #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, - "slap_passwd_generate: begin\n" )); + LDAP_LOG( OPERATION, ENTRY, "slap_passwd_generate: begin\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "slap_passwd_generate\n", 0, 0, 0 ); #endif diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 3e75823e0d78d97a1c7cde13915ba00da26370ce..583b09e5b1fbb6af05bbd40df8061fec4988b655 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -267,11 +267,6 @@ LDAP_SLAPD_F (char **) str2charray LDAP_P(( const char *str, const char *brkstr LDAP_SLAPD_F (int) charray_strcmp LDAP_P(( const char **a1, const char **a2 )); LDAP_SLAPD_F (int) charray_strcasecmp LDAP_P(( const char **a1, const char **a2 )); -LDAP_SLAPD_F (char *) slap_strcopy LDAP_P(( - char *dst, const char *src )); -LDAP_SLAPD_F (char *) slap_strncopy LDAP_P(( - char *dst, const char *src, size_t n )); - /* * controls.c */ @@ -857,6 +852,7 @@ LDAP_SLAPD_F (void) slap_sasl2dn LDAP_P(( struct berval *saslname, struct berval *dn )); LDAP_SLAPD_F (int) slap_sasl_authorized LDAP_P(( + Connection *conn, struct berval *authcid, struct berval *authzid )); LDAP_SLAPD_F (int) slap_sasl_regexp_config LDAP_P(( diff --git a/servers/slapd/referral.c b/servers/slapd/referral.c index 53edf251fba585d36abccdac5f419b604b499240..a836657fe1bc18ea74429b2ba47401b545e66d9d 100644 --- a/servers/slapd/referral.c +++ b/servers/slapd/referral.c @@ -152,9 +152,9 @@ int validate_global_referral( const char *url ) default: /* other error, bail */ #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "referral: invalid URL (%s): %s (%d)\n", - url, "" /* ldap_url_error2str(rc) */, rc )); + url, "" /* ldap_url_error2str(rc) */, rc ); #else Debug( LDAP_DEBUG_ANY, "referral: invalid URL (%s): %s (%d)\n", @@ -167,9 +167,7 @@ int validate_global_referral( const char *url ) if( lurl->lud_dn && *lurl->lud_dn ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "referral: URL (%s): contains DN\n", - url )); + LDAP_LOG( CONFIG, CRIT, "referral: URL (%s): contains DN\n", url, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "referral: URL (%s): contains DN\n", @@ -179,9 +177,8 @@ int validate_global_referral( const char *url ) } else if( lurl->lud_attrs ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "referral: URL (%s): requests attributes\n", - url )); + LDAP_LOG( CONFIG, CRIT, + "referral: URL (%s): requests attributes\n", url, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "referral: URL (%s): requests attributes\n", @@ -191,9 +188,8 @@ int validate_global_referral( const char *url ) } else if( lurl->lud_scope != LDAP_SCOPE_DEFAULT ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "referral: URL (%s): contains explicit scope\n", - url )); + LDAP_LOG( CONFIG, CRIT, + "referral: URL (%s): contains explicit scope\n", url, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "referral: URL (%s): contains explicit scope\n", @@ -203,9 +199,8 @@ int validate_global_referral( const char *url ) } else if( lurl->lud_filter ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, - "referral: URL (%s): contains explicit filter\n", - url )); + LDAP_LOG( CONFIG, CRIT, + "referral: URL (%s): contains explicit filter\n", url, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "referral: URL (%s): contains explicit filter\n", diff --git a/servers/slapd/result.c b/servers/slapd/result.c index d2def63547477610f7dab2e16c2fcd3d26729537..96a2ef1337cc44fe3b510cb16f7f0d9bd72f9fff 100644 --- a/servers/slapd/result.c +++ b/servers/slapd/result.c @@ -133,9 +133,9 @@ static long send_ldap_ber( */ #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "send_ldap_ber: conn %lu ber_flush failed err=%d (%s)\n", - conn ? conn->c_connid : 0, err, sock_errstr(err) )); + LDAP_LOG( OPERATION, ERR, + "send_ldap_ber: conn %lu ber_flush failed err=%d (%s)\n", + conn ? conn->c_connid : 0, err, sock_errstr(err) ); #else Debug( LDAP_DEBUG_CONNS, "ber_flush failed errno=%d reason=\"%s\"\n", err, sock_errstr(err), 0 ); @@ -197,9 +197,9 @@ send_ldap_response( ber_init_w_nullc( ber, LBER_USE_DER ); #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, - "send_ldap_response: conn %lu msgid=%d tag=%lu err=%d\n", - conn ? conn->c_connid : 0, msgid, tag, err )); + LDAP_LOG( OPERATION, ENTRY, + "send_ldap_response: msgid=%d tag=%lu err=%d\n", + msgid, tag, err ); #else Debug( LDAP_DEBUG_TRACE, "send_ldap_response: msgid=%d tag=%lu err=%d\n", @@ -208,10 +208,10 @@ send_ldap_response( if( ref ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ARGS, - "send_ldap_response: conn %lu ref=\"%s\"\n", - conn ? conn->c_connid : 0, - ref[0].bv_val ? ref[0].bv_val : "NULL" )); + LDAP_LOG( OPERATION, ARGS, + "send_ldap_response: conn %lu ref=\"%s\"\n", + conn ? conn->c_connid : 0, + ref[0].bv_val ? ref[0].bv_val : "NULL" , 0 ); #else Debug( LDAP_DEBUG_ARGS, "send_ldap_response: ref=\"%s\"\n", ref[0].bv_val ? ref[0].bv_val : "NULL", @@ -225,9 +225,9 @@ send_ldap_response( rc = ber_write(ber, (char *)&op->o_peeraddr, sizeof(struct sockaddr), 0); if (rc != sizeof(struct sockaddr)) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "send_ldap_response: conn %lu ber_write failed\n", - conn ? conn->c_connid : 0 )); + LDAP_LOG( OPERATION, ERR, + "send_ldap_response: conn %lu ber_write failed\n", + conn ? conn->c_connid : 0 , 0, 0); #else Debug( LDAP_DEBUG_ANY, "ber_write failed\n", 0, 0, 0 ); #endif @@ -285,9 +285,9 @@ send_ldap_response( if ( rc == -1 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "send_ldap_response: conn %lu ber_printf failed\n", - conn ? conn->c_connid : 0 )); + LDAP_LOG( OPERATION, ERR, + "send_ldap_response: conn %lu ber_printf failed\n", + conn ? conn->c_connid : 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 ); #endif @@ -302,9 +302,9 @@ send_ldap_response( if ( bytes < 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "send_ldap_response: conn %lu ber write failed\n", - conn ? conn->c_connid : 0 )); + LDAP_LOG( OPERATION, ERR, + "send_ldap_response: conn %lu ber write failed\n", + conn ? conn->c_connid : 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "send_ldap_response: ber write failed\n", @@ -342,9 +342,9 @@ send_ldap_disconnect( assert( LDAP_UNSOLICITED_ERROR( err ) ); #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, - "send_ldap_disconnect: conn %lu %d:%s\n", - conn ? conn->c_connid : 0, err, text ? text : "" )); + LDAP_LOG( OPERATION, ENTRY, + "send_ldap_disconnect: conn %lu %d:%s\n", + conn ? conn->c_connid : 0, err, text ? text : "" ); #else Debug( LDAP_DEBUG_TRACE, "send_ldap_disconnect %d:%s\n", @@ -390,9 +390,9 @@ send_ldap_result( assert( !LDAP_API_ERROR( err ) ); #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, - "send_ldap_result : conn %lu op=%lu p=%d\n", - op->o_connid, op->o_opid, op->o_protocol )); + LDAP_LOG( OPERATION, ENTRY, + "send_ldap_result : conn %lu op=%lu p=%d\n", + op->o_connid, op->o_opid, op->o_protocol ); #else Debug( LDAP_DEBUG_TRACE, "send_ldap_result: conn=%lu op=%lu p=%d\n", @@ -400,9 +400,9 @@ send_ldap_result( #endif #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ARGS, - "send_ldap_result: conn=%lu err=%d matched=\"%s\" text=\"%s\"\n", - op->o_connid, err, matched ? matched : "", text ? text : "" )); + LDAP_LOG( OPERATION, ARGS, + "send_ldap_result: err=%d matched=\"%s\" text=\"%s\"\n", + err, matched ? matched : "", text ? text : "" ); #else Debug( LDAP_DEBUG_ARGS, "send_ldap_result: err=%d matched=\"%s\" text=\"%s\"\n", @@ -412,9 +412,9 @@ send_ldap_result( if( ref ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ARGS, + LDAP_LOG( OPERATION, ARGS, "send_ldap_result: referral=\"%s\"\n", - ref[0].bv_val ? ref[0].bv_val : "NULL" )); + ref[0].bv_val ? ref[0].bv_val : "NULL", 0, 0 ); #else Debug( LDAP_DEBUG_ARGS, "send_ldap_result: referral=\"%s\"\n", @@ -471,9 +471,9 @@ send_ldap_sasl( ber_int_t msgid; #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, - "send_ldap_sasl: conn %lu err=%d len=%lu\n", - op->o_connid, err, cred ? cred->bv_len : -1 )); + LDAP_LOG( OPERATION, ENTRY, + "send_ldap_sasl: conn %lu err=%d len=%lu\n", + op->o_connid, err, cred ? cred->bv_len : -1 ); #else Debug( LDAP_DEBUG_TRACE, "send_ldap_sasl: err=%d len=%ld\n", err, cred ? (long) cred->bv_len : -1, NULL ); @@ -505,10 +505,10 @@ send_ldap_extended( ber_int_t msgid; #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, - "send_ldap_extended: conn %lu err=%d oid=%s len=%ld\n", - op->o_connid, err, rspoid ? rspoid : "", - rspdata != NULL ? rspdata->bv_len : 0 )); + LDAP_LOG( OPERATION, ENTRY, + "send_ldap_extended: err=%d oid=%s len=%ld\n", + err, rspoid ? rspoid : "", + rspdata != NULL ? rspdata->bv_len : 0 ); #else Debug( LDAP_DEBUG_TRACE, "send_ldap_extended err=%d oid=%s len=%ld\n", @@ -552,11 +552,9 @@ send_search_result( } #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, - "send_search_result: conn %lu err=%d " - "matched=\"%s\" text=\"%s\"\n", - op->o_connid, err, matched ? matched : "", - text ? text : "" )); + LDAP_LOG( OPERATION, ENTRY, + "send_search_result: err=%d matched=\"%s\" text=\"%s\"\n", + err, matched ? matched : "", text ? text : "" ); #else Debug( LDAP_DEBUG_TRACE, "send_search_result: err=%d matched=\"%s\" text=\"%s\"\n", @@ -595,7 +593,7 @@ send_search_result( { char nbuf[64]; - sprintf( nbuf, "%d nentries=%d", err, nentries ); + snprintf( nbuf, sizeof nbuf, "%d nentries=%d", err, nentries ); Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu SEARCH RESULT tag=%lu err=%s text=%s\n", @@ -647,10 +645,9 @@ send_search_entry( } #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, - "send_search_entry: conn %lu dn=\"%s\"%s\n", - op->o_connid, e->e_dn, - attrsonly ? " (attrsOnly)" : "" )); + LDAP_LOG( OPERATION, ENTRY, + "send_search_entry: conn %lu dn=\"%s\"%s\n", + op->o_connid, e->e_dn, attrsonly ? " (attrsOnly)" : "" ); #else Debug( LDAP_DEBUG_TRACE, "=> send_search_entry: dn=\"%s\"%s\n", @@ -661,10 +658,9 @@ send_search_entry( ad_entry, NULL, ACL_READ, NULL ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_INFO, - "send_search_entry: conn %lu access " - "to entry (%s) not allowed\n", - op->o_connid, e->e_dn )); + LDAP_LOG( ACL, INFO, + "send_search_entry: conn %lu access to entry (%s) not allowed\n", + op->o_connid, e->e_dn, 0 ); #else Debug( LDAP_DEBUG_ACL, "send_search_entry: access to entry not allowed\n", @@ -683,9 +679,9 @@ send_search_entry( rc = ber_write(ber, (char *)&op->o_peeraddr, sizeof(struct sockaddr), 0); if (rc != sizeof(struct sockaddr)) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "send_search_entry: conn %lu ber_printf failed\n", - conn ? conn->c_connid : 0 )); + LDAP_LOG( OPERATION, ERR, + "send_search_entry: conn %lu ber_printf failed\n", + conn ? conn->c_connid : 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 ); #endif @@ -705,9 +701,9 @@ send_search_entry( if ( rc == -1 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "send_search_entry: conn %lu ber_printf failed\n", - op->o_connid )); + LDAP_LOG( OPERATION, ERR, + "send_search_entry: conn %lu ber_printf failed\n", + op->o_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 ); #endif @@ -753,10 +749,9 @@ send_search_entry( if ( rc == -1 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "send_search_entry: conn %lu " - "matched values filtering failed\n", - conn ? conn->c_connid : 0 )); + LDAP_LOG( OPERATION, ERR, + "send_search_entry: conn %lu matched values filtering failed\n", + conn ? conn->c_connid : 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "matched values filtering failed\n", 0, 0, 0 ); @@ -805,10 +800,9 @@ send_search_entry( ACL_READ, &acl_state ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_INFO, "send_search_entry: " - "conn %lu access to attribute %s " - "not allowed\n", - op->o_connid, desc->ad_cname.bv_val )); + LDAP_LOG( ACL, INFO, + "send_search_entry: conn %lu access to attribute %s not " + "allowed\n", op->o_connid, desc->ad_cname.bv_val, 0 ); #else Debug( LDAP_DEBUG_ACL, "acl: " "access to attribute %s not allowed\n", @@ -819,10 +813,9 @@ send_search_entry( if (( rc = ber_printf( ber, "{O[" /*]}*/ , &desc->ad_cname )) == -1 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "send_search_entry: " - "conn %lu ber_printf failed\n", - op->o_connid )); + LDAP_LOG( OPERATION, ERR, + "send_search_entry: conn %lu ber_printf failed\n", + op->o_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 ); #endif @@ -844,12 +837,10 @@ send_search_entry( desc, &a->a_vals[i], ACL_READ, &acl_state ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_INFO, + LDAP_LOG( ACL, INFO, "send_search_entry: conn %lu " - "access to attribute %s, " - "value %d not allowed\n", - op->o_connid, - desc->ad_cname.bv_val, i )); + "access to attribute %s, value %d not allowed\n", + op->o_connid, desc->ad_cname.bv_val, i ); #else Debug( LDAP_DEBUG_ACL, "acl: access to attribute %s, " @@ -866,10 +857,9 @@ send_search_entry( if (( rc = ber_printf( ber, "O", &a->a_vals[i] )) == -1 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + LDAP_LOG( OPERATION, ERR, "send_search_entry: conn %lu " - "ber_printf failed.\n", - op->o_connid )); + "ber_printf failed.\n", op->o_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 ); @@ -891,10 +881,9 @@ send_search_entry( if (( rc = ber_printf( ber, /*{[*/ "]N}" )) == -1 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "send_search_entry: conn %lu " - "ber_printf failed\n", - op->o_connid )); + LDAP_LOG( OPERATION, ERR, + "send_search_entry: conn %lu ber_printf failed\n", + op->o_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 ); #endif @@ -940,10 +929,10 @@ send_search_entry( if ( rc == -1 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + LDAP_LOG( OPERATION, ERR, "send_search_entry: conn %lu " - "matched values filtering failed\n", - conn ? conn->c_connid : 0 )); + "matched values filtering failed\n", + conn ? conn->c_connid : 0, 0, 0); #else Debug( LDAP_DEBUG_ANY, "matched values filtering failed\n", 0, 0, 0 ); @@ -992,10 +981,10 @@ send_search_entry( ACL_READ, &acl_state ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_INFO, + LDAP_LOG( ACL, INFO, "send_search_entry: conn %lu " "access to attribute %s not allowed\n", - op->o_connid, desc->ad_cname.bv_val )); + op->o_connid, desc->ad_cname.bv_val, 0 ); #else Debug( LDAP_DEBUG_ACL, "acl: access to attribute %s " "not allowed\n", @@ -1008,10 +997,9 @@ send_search_entry( rc = ber_printf( ber, "{O[" /*]}*/ , &desc->ad_cname ); if ( rc == -1 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + LDAP_LOG( OPERATION, ERR, "send_search_entry: conn %lu " - "ber_printf failed\n", - op->o_connid )); + "ber_printf failed\n", op->o_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 ); #endif @@ -1035,12 +1023,10 @@ send_search_entry( desc, &a->a_vals[i], ACL_READ, &acl_state ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_INFO, + LDAP_LOG( ACL, INFO, "send_search_entry: conn %lu " - "access to %s, value %d " - "not allowed\n", - op->o_connid, - desc->ad_cname.bv_val, i )); + "access to %s, value %d not allowed\n", + op->o_connid, desc->ad_cname.bv_val, i ); #else Debug( LDAP_DEBUG_ACL, "acl: access to attribute %s, " @@ -1057,11 +1043,9 @@ send_search_entry( if (( rc = ber_printf( ber, "O", &a->a_vals[i] )) == -1 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "send_search_entry: " - "conn %lu ber_printf " - "failed\n", - op->o_connid )); + LDAP_LOG( OPERATION, ERR, + "send_search_entry: conn %lu ber_printf failed\n", + op->o_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 ); @@ -1085,10 +1069,9 @@ send_search_entry( if (( rc = ber_printf( ber, /*{[*/ "]N}" )) == -1 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "send_search_entry: conn %lu " - "ber_printf failed\n", - op->o_connid )); + LDAP_LOG( OPERATION, ERR, + "send_search_entry: conn %lu ber_printf failed\n", + op->o_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 ); #endif @@ -1122,9 +1105,9 @@ send_search_entry( #endif if ( rc == -1 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "send_search_entry: conn %lu ber_printf failed\n", - op->o_connid )); + LDAP_LOG( OPERATION, ERR, + "send_search_entry: conn %lu ber_printf failed\n", + op->o_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 ); #endif @@ -1140,9 +1123,9 @@ send_search_entry( if ( bytes < 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "send_search_entry: conn %lu ber write failed.\n", - op->o_connid )); + LDAP_LOG( OPERATION, ERR, + "send_search_entry: conn %lu ber write failed.\n", + op->o_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "send_search_entry: ber write failed\n", @@ -1162,9 +1145,8 @@ send_search_entry( conn->c_connid, op->o_opid, e->e_dn, 0, 0 ); #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, - "send_search_entry: conn %lu exit.\n", - op->o_connid )); + LDAP_LOG( OPERATION, ENTRY, + "send_search_entry: conn %lu exit.\n", op->o_connid, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= send_search_entry\n", 0, 0, 0 ); #endif @@ -1195,9 +1177,9 @@ send_search_reference( AttributeDescription *ad_entry = slap_schema.si_ad_entry; #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, - "send_search_reference: conn %lu dn=\"%s\"\n", - op->o_connid, e->e_dn )); + LDAP_LOG( OPERATION, ENTRY, + "send_search_reference: conn %lu dn=\"%s\"\n", + op->o_connid, e->e_dn, 0 ); #else Debug( LDAP_DEBUG_TRACE, "=> send_search_reference: dn=\"%s\"\n", @@ -1209,10 +1191,9 @@ send_search_reference( ad_entry, NULL, ACL_READ, NULL ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_INFO, + LDAP_LOG( ACL, INFO, "send_search_reference: conn %lu " - "access to entry %s not allowed\n", - op->o_connid, e->e_dn )); + "access to entry %s not allowed\n", op->o_connid, e->e_dn, 0 ); #else Debug( LDAP_DEBUG_ACL, "send_search_reference: access to entry not allowed\n", @@ -1226,10 +1207,9 @@ send_search_reference( ad_ref, NULL, ACL_READ, NULL ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "acl", LDAP_LEVEL_INFO, + LDAP_LOG( ACL, INFO, "send_search_reference: conn %lu access " - "to reference not allowed.\n", - op->o_connid )); + "to reference not allowed.\n", op->o_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ACL, "send_search_reference: access " @@ -1242,9 +1222,9 @@ send_search_reference( if( refs == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + LDAP_LOG( OPERATION, ERR, "send_search_reference: conn %lu null ref in (%s).\n", - op->o_connid, e->e_dn )); + op->o_connid, e->e_dn, 0 ); #else Debug( LDAP_DEBUG_ANY, "send_search_reference: null ref in (%s)\n", @@ -1269,10 +1249,9 @@ send_search_reference( if ( rc == -1 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + LDAP_LOG( OPERATION, ERR, "send_search_reference: conn %lu " - "ber_printf failed.\n", - op->o_connid )); + "ber_printf failed.\n", op->o_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "send_search_reference: ber_printf failed\n", 0, 0, 0 ); @@ -1297,8 +1276,8 @@ send_search_reference( conn->c_connid, op->o_opid, e->e_dn, 0, 0 ); #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, - "send_search_reference: conn %lu exit.\n", op->o_connid )); + LDAP_LOG( OPERATION, ENTRY, + "send_search_reference: conn %lu exit.\n", op->o_connid, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= send_search_reference\n", 0, 0, 0 ); #endif @@ -1324,8 +1303,8 @@ str2result( if ( strncasecmp( s, "RESULT", 6 ) != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, - "str2result: (%s), expecting \"RESULT\"\n", s )); + LDAP_LOG( OPERATION, INFO, + "str2result: (%s), expecting \"RESULT\"\n", s, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "str2result (%s) expecting \"RESULT\"\n", s, 0, 0 ); @@ -1358,8 +1337,7 @@ str2result( } } else { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, - "str2result: (%s) unknown.\n", s )); + LDAP_LOG( OPERATION, INFO, "str2result: (%s) unknown.\n", s, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "str2result (%s) unknown\n", s, 0, 0 ); diff --git a/servers/slapd/root_dse.c b/servers/slapd/root_dse.c index e814c5155d648a5768f3dc2c989f8224f6835483..62c2fc7cf05c673f080062a4b4f25f9ddcb6bb14 100644 --- a/servers/slapd/root_dse.c +++ b/servers/slapd/root_dse.c @@ -20,11 +20,11 @@ #include "lber_pvt.h" static struct berval supportedFeatures[] = { - BER_BVC("1.3.6.1.4.1.4203.1.5.1"), /* all Operational Attributes ("+") */ - BER_BVC("1.3.6.1.4.1.4203.1.5.2"), /* OCs in Attributes List */ - BER_BVC("1.3.6.1.4.1.4203.1.5.3"), /* (&) and (|) search filters */ - BER_BVC("1.3.6.1.4.1.4203.1.5.4"), /* Language Tag Options */ - BER_BVC("1.3.6.1.4.1.4203.1.5.5"), /* Language Range Options */ + BER_BVC(LDAP_FEATURE_ALL_OPERATIONAL_ATTRS), /* all Operational Attributes ("+") */ + BER_BVC(LDAP_FEATURE_OBJECTCLASS_ATTRS), /* OCs in Attributes List */ + BER_BVC(LDAP_FEATURE_ABSOLUTE_FILTERS), /* (&) and (|) search filters */ + BER_BVC(LDAP_FEATURE_LANGUAGE_TAG_OPTIONS), /* Language Tag Options */ + BER_BVC(LDAP_FEATURE_LANGUAGE_RANGE_OPTIONS), /* Language Range Options */ {0,NULL} }; @@ -36,7 +36,6 @@ root_dse_info( Entry **entry, const char **text ) { - char buf[BUFSIZ]; Entry *e; struct berval vals[2], *bv; int i, j; @@ -122,13 +121,14 @@ root_dse_info( /* supportedLDAPVersion */ for ( i=LDAP_VERSION_MIN; i<=LDAP_VERSION_MAX; i++ ) { + char buf[BUFSIZ]; if (!( global_allows & SLAP_ALLOW_BIND_V2 ) && ( i < LDAP_VERSION3 ) ) { /* version 2 and lower are disallowed */ continue; } - sprintf(buf,"%d",i); + snprintf(buf, sizeof buf, "%d", i); vals[0].bv_val = buf; vals[0].bv_len = strlen( vals[0].bv_val ); attr_merge( e, ad_supportedLDAPVersion, vals ); diff --git a/servers/slapd/sasl.c b/servers/slapd/sasl.c index 13088088afe0de9f69dfad6fecea924867969f29..be7b1bb51368184bfe5dc8c897e53c0fa3d2ff77 100644 --- a/servers/slapd/sasl.c +++ b/servers/slapd/sasl.c @@ -51,9 +51,9 @@ int slap_sasl_config( int cargc, char **cargv, char *line, if ( strcasecmp( cargv[0], "sasl-authz-policy" ) == 0 ) { if ( cargc != 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: missing policy in \"sasl-authz-policy <policy>\" line\n", - fname, lineno )); + fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing policy in \"sasl-authz-policy <policy>\" line\n", @@ -64,12 +64,12 @@ int slap_sasl_config( int cargc, char **cargv, char *line, } if ( slap_sasl_setpolicy( cargv[1] ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: unable " "to parse value \"%s\" " "in \"sasl-authz-policy " "<policy>\" line.\n", - fname, lineno, cargv[1] )); + fname, lineno, cargv[1] ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: unable " @@ -86,9 +86,9 @@ int slap_sasl_config( int cargc, char **cargv, char *line, } else if ( strcasecmp( cargv[0], "sasl-host" ) == 0 ) { if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: missing host in \"sasl-host <host>\" line\n", - fname, lineno )); + fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing host in \"sasl-host <host>\" line\n", @@ -100,9 +100,9 @@ int slap_sasl_config( int cargc, char **cargv, char *line, if ( global_host != NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: already set sasl-host!\n", - fname, lineno )); + fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: already set sasl-host!\n", @@ -119,9 +119,9 @@ int slap_sasl_config( int cargc, char **cargv, char *line, } else if ( strcasecmp( cargv[0], "sasl-realm" ) == 0 ) { if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: missing realm in \"sasl-realm <realm>\" line.\n", - fname, lineno )); + fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing realm in \"sasl-realm <realm>\" line\n", @@ -133,9 +133,9 @@ int slap_sasl_config( int cargc, char **cargv, char *line, if ( global_realm != NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: already set sasl-realm!\n", - fname, lineno )); + fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: already set sasl-realm!\n", @@ -154,10 +154,10 @@ int slap_sasl_config( int cargc, char **cargv, char *line, int rc; if ( cargc != 3 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: need 2 args in " "\"saslregexp <match> <replace>\"\n", - fname, lineno )); + fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: need 2 args in \"saslregexp <match> <replace>\"\n", @@ -177,10 +177,10 @@ int slap_sasl_config( int cargc, char **cargv, char *line, if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: missing flags in " "\"sasl-secprops <properties>\" line\n", - fname, lineno )); + fname, lineno, 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing flags in \"sasl-secprops <properties>\" line\n", @@ -193,9 +193,9 @@ int slap_sasl_config( int cargc, char **cargv, char *line, txt = slap_sasl_secprops( cargv[1] ); if ( txt != NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d sasl-secprops: %s\n", - fname, lineno, txt )); + fname, lineno, txt ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: sasl-secprops: %s\n", @@ -276,10 +276,8 @@ slap_sasl_log( } #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, - "SASL [conn=%ld] %s: %s\n", - conn ? conn->c_connid : -1, - label, message )); + LDAP_LOG( TRANSPORT, ENTRY, + "SASL [conn=%ld] %s: %s\n", conn ? conn->c_connid : -1, label, message); #else Debug( level, "SASL [conn=%ld] %s: %s\n", conn ? conn->c_connid: -1, @@ -315,10 +313,9 @@ int slap_sasl_getdn( Connection *conn, char *id, int len, struct berval dn2; #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, + LDAP_LOG( TRANSPORT, ENTRY, "slap_sasl_getdn: conn %d id=%s\n", - conn ? conn->c_connid : -1, - id ? (*id ? id : "<empty>") : "NULL" )); + conn ? conn->c_connid : -1, id ? (*id ? id : "<empty>") : "NULL", 0 ); #else Debug( LDAP_DEBUG_ARGS, "slap_sasl_getdn: id=%s\n", id?(*id?id:"<empty>"):"NULL",0,0 ); @@ -403,29 +400,29 @@ int slap_sasl_getdn( Connection *conn, char *id, int len, /* Build the new dn */ c1 = dn->bv_val; dn->bv_val = ch_malloc( len+1 ); - p = slap_strcopy( dn->bv_val, "uid=" ); - p = slap_strncopy( p, c1, dn->bv_len ); + p = lutil_strcopy( dn->bv_val, "uid=" ); + p = lutil_strncopy( p, c1, dn->bv_len ); if( realm ) { int rlen = dn->bv_len - ( realm - c1 ); - p = slap_strcopy( p, ",cn=" ); - p = slap_strncopy( p, realm, rlen ); + p = lutil_strcopy( p, ",cn=" ); + p = lutil_strncopy( p, realm, rlen ); realm[-1] = '@'; } else if( user_realm && *user_realm ) { - p = slap_strcopy( p, ",cn=" ); - p = slap_strcopy( p, user_realm ); + p = lutil_strcopy( p, ",cn=" ); + p = lutil_strcopy( p, user_realm ); } if( conn->c_sasl_bind_mech.bv_len ) { - p = slap_strcopy( p, ",cn=" ); - p = slap_strcopy( p, conn->c_sasl_bind_mech.bv_val ); + p = lutil_strcopy( p, ",cn=" ); + p = lutil_strcopy( p, conn->c_sasl_bind_mech.bv_val ); } - p = slap_strcopy( p, ",cn=auth" ); + p = lutil_strcopy( p, ",cn=auth" ); dn->bv_len = p - dn->bv_val; #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, - "slap_sasl_getdn: u:id converted to %s.\n", dn->bv_val )); + LDAP_LOG( TRANSPORT, ENTRY, + "slap_sasl_getdn: u:id converted to %s.\n", dn->bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "getdn: u:id converted to %s\n", dn->bv_val,0,0 ); #endif @@ -453,8 +450,8 @@ int slap_sasl_getdn( Connection *conn, char *id, int len, ch_free( dn->bv_val ); *dn = dn2; #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, - "slap_sasl_getdn: dn:id converted to %s.\n", dn->bv_val )); + LDAP_LOG( TRANSPORT, ENTRY, + "slap_sasl_getdn: dn:id converted to %s.\n", dn->bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "getdn: dn:id converted to %s\n", dn->bv_val, 0, 0 ); @@ -523,8 +520,8 @@ slap_auxprop_lookup( rc = slap_str2ad( name, &ad, &text ); if ( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_DETAIL1, - "slap_auxprop: str2ad(%s): %s\n", name, text )); + LDAP_LOG( TRANSPORT, DETAIL1, + "slap_auxprop: str2ad(%s): %s\n", name, text, 0 ); #else Debug( LDAP_DEBUG_TRACE, "slap_auxprop: str2ad(%s): %s\n", name, text, 0 ); @@ -664,11 +661,10 @@ slap_sasl_canonicalize( *out_len = 0; #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, + LDAP_LOG( TRANSPORT, ENTRY, "slap_sasl_canonicalize: conn %d %s=\"%s\"\n", - conn ? conn->c_connid : -1, - (flags & SASL_CU_AUTHID) ? "authcid" : "authzid", - in ? in : "<empty>" )); + conn ? conn->c_connid : -1, + (flags & SASL_CU_AUTHID) ? "authcid" : "authzid", in ? in : "<empty>"); #else Debug( LDAP_DEBUG_ARGS, "SASL Canonicalize [conn=%ld]: " "%s=\"%s\"\n", @@ -723,10 +719,9 @@ slap_sasl_canonicalize( prop_set( props, names[0], (char *)&dn, sizeof( dn ) ); #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, + LDAP_LOG( TRANSPORT, ENTRY, "slap_sasl_canonicalize: conn %d %s=\"%s\"\n", - conn ? conn->c_connid : -1, - names[0]+1, dn.bv_val )); + conn ? conn->c_connid : -1, names[0]+1, dn.bv_val ); #else Debug( LDAP_DEBUG_ARGS, "SASL Canonicalize [conn=%ld]: " "%s=\"%s\"\n", @@ -759,9 +754,9 @@ slap_sasl_authorize( int rc; #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, + LDAP_LOG( TRANSPORT, ENTRY, "slap_sasl_authorize: conn %d authcid=\"%s\" authzid=\"%s\"\n", - conn ? conn->c_connid : -1, auth_identity, requested_user)); + conn ? conn->c_connid : -1, auth_identity, requested_user); #else Debug( LDAP_DEBUG_ARGS, "SASL Authorize [conn=%ld]: " "authcid=\"%s\" authzid=\"%s\"\n", @@ -785,13 +780,13 @@ slap_sasl_authorize( AC_MEMCPY( &authzDN, auxvals[1].values[0], sizeof(authzDN) ); - rc = slap_sasl_authorized( &authcDN, &authzDN ); + rc = slap_sasl_authorized( conn, &authcDN, &authzDN ); ch_free( authcDN.bv_val ); if ( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_INFO, - "slap_sasl_authorize: conn %ld authorization disallowed (%d)\n", - (long)(conn ? conn->c_connid : -1), rc )); + LDAP_LOG( TRANSPORT, INFO, + "slap_sasl_authorize: conn %ld authorization disallowed (%d)\n", + (long)(conn ? conn->c_connid : -1), rc, 0 ); #else Debug( LDAP_DEBUG_TRACE, "SASL Authorize [conn=%ld]: " " authorization disallowed (%d)\n", @@ -806,9 +801,9 @@ slap_sasl_authorize( conn->c_sasl_dn = authzDN; #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, - "slap_sasl_authorize: conn %d authorization allowed\n", - (long)(conn ? conn->c_connid : -1 ) )); + LDAP_LOG( TRANSPORT, ENTRY, + "slap_sasl_authorize: conn %d authorization allowed\n", + (long)(conn ? conn->c_connid : -1), 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "SASL Authorize [conn=%ld]: " " authorization allowed\n", @@ -838,11 +833,10 @@ slap_sasl_authorize( } #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, - "slap_sasl_authorize: conn %d authcid=\"%s\" authzid=\"%s\"\n", - conn ? conn->c_connid : -1, - authcid ? authcid : "<empty>", - authzid ? authzid : "<empty>" )); + LDAP_LOG( TRANSPORT, ENTRY, + "slap_sasl_authorize: conn %d authcid=\"%s\" authzid=\"%s\"\n", + conn ? conn->c_connid : -1, authcid ? authcid : "<empty>", + authzid ? authzid : "<empty>" ); #else Debug( LDAP_DEBUG_ARGS, "SASL Authorize [conn=%ld]: " "authcid=\"%s\" authzid=\"%s\"\n", @@ -855,8 +849,8 @@ slap_sasl_authorize( rc = sasl_getprop( conn->c_sasl_context, SASL_REALM, (void **)&realm ); if( rc != SASL_OK && rc != SASL_NOTDONE ) { #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_ERR, - "slap_sasl_authorize: getprop(REALM) failed.\n" )); + LDAP_LOG( TRANSPORT, ERR, + "slap_sasl_authorize: getprop(REALM) failed.\n", 0, 0, 0 ); #else Debug(LDAP_DEBUG_TRACE, "authorize: getprop(REALM) failed!\n", 0,0,0); @@ -874,9 +868,9 @@ slap_sasl_authorize( } if( ( authzid == NULL ) || !strcmp( authcid,authzid ) ) { #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, - "slap_sasl_authorize: conn %d Using authcDN=%s\n", - conn ? conn->c_connid : -1, authcDN.bv_val )); + LDAP_LOG( TRANSPORT, ENTRY, + "slap_sasl_authorize: conn %d Using authcDN=%s\n", + conn ? conn->c_connid : -1, authcDN.bv_val, 0 ); #else Debug( LDAP_DEBUG_TRACE, "SASL Authorize [conn=%ld]: " "Using authcDN=%s\n", (long) (conn ? conn->c_connid : -1), authcDN.bv_val,0 ); @@ -893,13 +887,13 @@ slap_sasl_authorize( return SASL_NOAUTHZ; } - rc = slap_sasl_authorized( &authcDN, &authzDN ); + rc = slap_sasl_authorized(conn, &authcDN, &authzDN ); ch_free( authcDN.bv_val ); if( rc ) { #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_INFO, - "slap_sasl_authorize: conn %ld authorization disallowed (%d)\n", - (long)(conn ? conn->c_connid : -1), rc )); + LDAP_LOG( TRANSPORT, INFO, + "slap_sasl_authorize: conn %ld authorization disallowed (%d)\n", + (long)(conn ? conn->c_connid : -1), rc, 0 ); #else Debug( LDAP_DEBUG_TRACE, "SASL Authorize [conn=%ld]: " " authorization disallowed (%d)\n", @@ -912,9 +906,9 @@ slap_sasl_authorize( } #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, - "slap_sasl_authorize: conn %d authorization allowed\n", - (long)(conn ? conn->c_connid : -1 ) )); + LDAP_LOG( TRANSPORT, RESULTS, + "slap_sasl_authorize: conn %d authorization allowed\n", + (long)(conn ? conn->c_connid : -1 ), 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "SASL Authorize [conn=%ld]: " " authorization allowed\n", @@ -995,8 +989,7 @@ int slap_sasl_init( void ) if( rc != SASL_OK ) { #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_INFO, - "slap_sasl_init: init failed.\n" )); + LDAP_LOG( TRANSPORT, INFO, "slap_sasl_init: init failed.\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "sasl_server_init failed\n", 0, 0, 0 ); @@ -1006,8 +999,7 @@ int slap_sasl_init( void ) } #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_INFO, - "slap_sasl_init: initialized!\n")); + LDAP_LOG( TRANSPORT, INFO, "slap_sasl_init: initialized!\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "slap_sasl_init: initialized!\n", 0, 0, 0 ); @@ -1129,8 +1121,8 @@ int slap_sasl_open( Connection *conn ) if( sc != SASL_OK ) { #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_ERR, - "slap_sasl_open: sasl_server_new failed: %d\n", sc )); + LDAP_LOG( TRANSPORT, ERR, + "slap_sasl_open: sasl_server_new failed: %d\n", sc, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "sasl_server_new failed: %d\n", sc, 0, 0 ); @@ -1147,8 +1139,8 @@ int slap_sasl_open( Connection *conn ) if( sc != SASL_OK ) { #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_ERR, - "slap_sasl_open: sasl_setprop failed: %d \n", sc )); + LDAP_LOG( TRANSPORT, ERR, + "slap_sasl_open: sasl_setprop failed: %d \n", sc, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "sasl_setprop failed: %d\n", sc, 0, 0 ); @@ -1242,8 +1234,8 @@ char ** slap_sasl_mechs( Connection *conn ) if( sc != SASL_OK ) { #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_ERR, - "slap_sasl_mechs: sasl_listmech failed: %d\n", sc )); + LDAP_LOG( TRANSPORT, ERR, + "slap_sasl_mechs: sasl_listmech failed: %d\n", sc, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "slap_sasl_listmech failed: %d\n", sc, 0, 0 ); @@ -1300,12 +1292,12 @@ int slap_sasl_bind( int sc; #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, - "sasl_bind: conn %ld dn=\"%s\" mech=%s datalen=%ld\n", - conn->c_connid, + LDAP_LOG( TRANSPORT, ENTRY, + "sasl_bind: dn=\"%s\" mech=%s datalen=%ld\n", dn->bv_len ? dn->bv_val : "", - conn->c_sasl_bind_in_progress ? "<continuing>" : conn->c_sasl_bind_mech.bv_val, - cred ? cred->bv_len : 0 )); + conn->c_sasl_bind_in_progress ? "<continuing>" : + conn->c_sasl_bind_mech.bv_val, + cred ? cred->bv_len : 0 ); #else Debug(LDAP_DEBUG_ARGS, "==> sasl_bind: dn=\"%s\" mech=%s datalen=%ld\n", @@ -1389,8 +1381,7 @@ int slap_sasl_bind( #endif #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, - "slap_sasl_bind: rc=%d\n", rc )); + LDAP_LOG( TRANSPORT, RESULTS, "slap_sasl_bind: rc=%d\n", rc, 0, 0 ); #else Debug(LDAP_DEBUG_TRACE, "<== slap_sasl_bind: rc=%d\n", rc, 0, 0); #endif @@ -1445,11 +1436,11 @@ slap_sasl_setpass( } #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY, + LDAP_LOG( BACKEND, ENTRY, "slap_sasl_setpass: \"%s\"\n", - id.bv_val ? id.bv_val : "" )); + id.bv_val ? id.bv_val : "", 0, 0); #else - Debug( LDAP_DEBUG_ARGS, "==> ldbm_back_exop_passwd: \"%s\"\n", + Debug( LDAP_DEBUG_ARGS, "==> slap_sasl_setpass: \"%s\"\n", id.bv_val ? id.bv_val : "", 0, 0 ); #endif @@ -1477,7 +1468,7 @@ slap_sasl_setpass( id.bv_val, new.bv_val, new.bv_len, 0, text ); #else rc = sasl_setpass( conn->c_sasl_context, id.bv_val, - old.bv_val, old.bv_len, new.bv_val, new.bv_len, 0 ); + new.bv_val, new.bv_len, old.bv_val, old.bv_len, 0 ); if( rc != SASL_OK ) { *text = sasl_errdetail( conn->c_sasl_context ); } diff --git a/servers/slapd/saslauthz.c b/servers/slapd/saslauthz.c index 601d0245c8481102d6792be533e960c3f3d9ca06..22e6894bcf9e2f8e8ac97806cad5233165a46f24 100644 --- a/servers/slapd/saslauthz.c +++ b/servers/slapd/saslauthz.c @@ -1,3 +1,7 @@ +/* + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ /* * Copyright (c) 2000, Mark Adamson, Carnegie Mellon. All rights reserved. * This software is not subject to any license of Carnegie Mellon University. @@ -96,8 +100,8 @@ static int slap_parseURI( struct berval *uri, } #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, - "slap_parseURI: parsing %s\n", uri->bv_val )); + LDAP_LOG( TRANSPORT, ENTRY, + "slap_parseURI: parsing %s\n", uri->bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "slap_parseURI: parsing %s\n", uri->bv_val, 0, 0 ); #endif @@ -170,10 +174,9 @@ static int slap_sasl_rx_off(char *rep, int *off) if ( *c == '$' ) { if ( n == SASLREGEX_REPLACE ) { #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_ERR, + LDAP_LOG( TRANSPORT, ERR, "slap_sasl_regexp_config: \"%s\" has too many $n " - "placeholders (max %d)\n", - rep, SASLREGEX_REPLACE )); + "placeholders (max %d)\n", rep, SASLREGEX_REPLACE, 0 ); #else Debug( LDAP_DEBUG_ANY, "SASL replace pattern %s has too many $n " @@ -194,11 +197,9 @@ static int slap_sasl_rx_off(char *rep, int *off) off[n] = -1; return( LDAP_SUCCESS ); } -#endif /* HAVE_CYRUS_SASL */ int slap_sasl_regexp_config( const char *match, const char *replace ) { -#ifdef HAVE_CYRUS_SASL const char *c; int rc, n; SaslRegexp_t *reg; @@ -212,9 +213,9 @@ int slap_sasl_regexp_config( const char *match, const char *replace ) rc = dnNormalize2( NULL, &bv, &nbv ); if ( rc ) { #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_ERR, - "slap_sasl_regexp_config: \"%s\" could not be normalized.\n", - match )); + LDAP_LOG( TRANSPORT, ERR, + "slap_sasl_regexp_config: \"%s\" could not be normalized.\n", + match, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "SASL match pattern %s could not be normalized.\n", @@ -230,9 +231,9 @@ int slap_sasl_regexp_config( const char *match, const char *replace ) if ( filter ) filter_free( filter ); if ( rc ) { #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_ERR, - "slap_sasl_regexp_config: \"%s\" could not be parsed.\n", - replace )); + LDAP_LOG( TRANSPORT, ERR, + "slap_sasl_regexp_config: \"%s\" could not be parsed.\n", + replace, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "SASL replace pattern %s could not be parsed.\n", @@ -245,9 +246,9 @@ int slap_sasl_regexp_config( const char *match, const char *replace ) rc = regcomp( ®->sr_workspace, reg->sr_match, REG_EXTENDED|REG_ICASE ); if ( rc ) { #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_ERR, - "slap_sasl_regexp_config: \"%s\" could not be compiled.\n", - reg->sr_match )); + LDAP_LOG( TRANSPORT, ERR, + "slap_sasl_regexp_config: \"%s\" could not be compiled.\n", + reg->sr_match, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "SASL match pattern %s could not be compiled by regexp engine\n", @@ -266,13 +267,10 @@ int slap_sasl_regexp_config( const char *match, const char *replace ) } nSaslRegexp++; -#endif return( LDAP_SUCCESS ); } -#ifdef HAVE_CYRUS_SASL - /* Perform replacement on regexp matches */ static void slap_sasl_rx_exp( char *rep, int *off, regmatch_t *str, char *saslname, struct berval *out ) @@ -334,8 +332,8 @@ static int slap_sasl_regexp( struct berval *in, SaslUri_t *out ) memset( out, 0, sizeof( *out ) ); #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, - "slap_sasl_regexp: converting SASL name %s\n", saslname )); + LDAP_LOG( TRANSPORT, ENTRY, + "slap_sasl_regexp: converting SASL name %s\n", saslname, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "slap_sasl_regexp: converting SASL name %s\n", saslname, 0, 0 ); @@ -369,10 +367,10 @@ static int slap_sasl_regexp( struct berval *in, SaslUri_t *out ) out->scope = reg->sr_replace.scope; #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, + LDAP_LOG( TRANSPORT, ENTRY, "slap_sasl_regexp: converted SASL name to ldap:///%s??%s?%s\n", out->dn.bv_val, scope[out->scope], out->filter.bv_val ? - out->filter.bv_val : "" )); + out->filter.bv_val : "" ); #else Debug( LDAP_DEBUG_TRACE, "slap_sasl_regexp: converted SASL name to ldap:///%s??%s?%s\n", @@ -409,8 +407,8 @@ static int sasl_sc_sasl2dn( BackendDB *be, Connection *conn, Operation *o, ndn->bv_val = NULL; #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_DETAIL1, - "slap_sasl2dn: search DN returned more than 1 entry\n" )); + LDAP_LOG( TRANSPORT, DETAIL1, + "slap_sasl2dn: search DN returned more than 1 entry\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "slap_sasl2dn: search DN returned more than 1 entry\n", 0,0,0 ); @@ -441,8 +439,8 @@ void slap_sasl2dn( Connection *conn, struct berval *saslname, struct berval *dn SaslUri_t uri; #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, - "slap_sasl2dn: converting SASL name %s to DN.\n", saslname->bv_val )); + LDAP_LOG( TRANSPORT, ENTRY, + "slap_sasl2dn: converting SASL name %s to DN.\n", saslname->bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "==>slap_sasl2dn: " "converting SASL name %s to a DN\n", saslname->bv_val, 0,0 ); @@ -472,9 +470,9 @@ void slap_sasl2dn( Connection *conn, struct berval *saslname, struct berval *dn } #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_DETAIL1, + LDAP_LOG( TRANSPORT, DETAIL1, "slap_sasl2dn: performing internal search (base=%s, scope=%d)\n", - uri.dn.bv_val, uri.scope )); + uri.dn.bv_val, uri.scope, 0 ); #else Debug( LDAP_DEBUG_TRACE, "slap_sasl2dn: performing internal search (base=%s, scope=%d)\n", @@ -491,24 +489,24 @@ void slap_sasl2dn( Connection *conn, struct berval *saslname, struct berval *dn op.o_ndn = *saslname; op.o_callback = &cb; op.o_time = slap_get_time(); + op.o_do_not_cache = 1; - (*be->be_search)( be, NULL, &op, NULL, &uri.dn, + (*be->be_search)( be, conn, &op, NULL, &uri.dn, uri.scope, LDAP_DEREF_NEVER, 1, 0, filter, NULL, NULL, 1 ); +FINISHED: if( dn->bv_len ) { conn->c_authz_backend = be; } - -FINISHED: if( uri.dn.bv_len ) ch_free( uri.dn.bv_val ); if( uri.filter.bv_len ) ch_free( uri.filter.bv_val ); if( filter ) filter_free( filter ); #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, + LDAP_LOG( TRANSPORT, ENTRY, "slap_sasl2dn: Converted SASL name to %s\n", - dn->bv_len ? dn->bv_val : "<nothing>" )); + dn->bv_len ? dn->bv_val : "<nothing>", 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<==slap_sasl2dn: Converted SASL name to %s\n", dn->bv_len ? dn->bv_val : "<nothing>", 0, 0 ); @@ -545,7 +543,7 @@ static int sasl_sc_smatch( BackendDB *be, Connection *conn, Operation *o, */ static -int slap_sasl_match( struct berval *rule, struct berval *assertDN, struct berval *authc ) +int slap_sasl_match(Connection *conn, struct berval *rule, struct berval *assertDN, struct berval *authc ) { struct berval searchbase = {0, NULL}; int rc, scope; @@ -557,8 +555,9 @@ int slap_sasl_match( struct berval *rule, struct berval *assertDN, struct berval Operation op = {0}; #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, - "slap_sasl_match: comparing DN %s to rule %s\n", assertDN->bv_val, rule->bv_val )); + LDAP_LOG( TRANSPORT, ENTRY, + "slap_sasl_match: comparing DN %s to rule %s\n", + assertDN->bv_val, rule->bv_val,0 ); #else Debug( LDAP_DEBUG_TRACE, "===>slap_sasl_match: comparing DN %s to rule %s\n", assertDN->bv_val, rule->bv_val, 0 ); @@ -586,9 +585,9 @@ int slap_sasl_match( struct berval *rule, struct berval *assertDN, struct berval /* Must run an internal search. */ #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_DETAIL1, + LDAP_LOG( TRANSPORT, DETAIL1, "slap_sasl_match: performing internal search (base=%s, scope=%d)\n", - searchbase.bv_val, scope )); + searchbase.bv_val, scope,0 ); #else Debug( LDAP_DEBUG_TRACE, "slap_sasl_match: performing internal search (base=%s, scope=%d)\n", @@ -611,8 +610,9 @@ int slap_sasl_match( struct berval *rule, struct berval *assertDN, struct berval op.o_ndn = *authc; op.o_callback = &cb; op.o_time = slap_get_time(); + op.o_do_not_cache = 1; - (*be->be_search)( be, /*conn=*/NULL, &op, /*base=*/NULL, &searchbase, + (*be->be_search)( be, conn, &op, /*base=*/NULL, &searchbase, scope, /*deref=*/1, /*sizelimit=*/0, /*time=*/0, filter, /*fstr=*/NULL, /*attrs=*/NULL, /*attrsonly=*/0 ); @@ -625,8 +625,8 @@ CONCLUDED: if( searchbase.bv_len ) ch_free( searchbase.bv_val ); if( filter ) filter_free( filter ); #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, - "slap_sasl_match: comparison returned %d\n", rc )); + LDAP_LOG( TRANSPORT, ENTRY, + "slap_sasl_match: comparison returned %d\n", rc, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<===slap_sasl_match: comparison returned %d\n", rc, 0, 0); @@ -645,15 +645,19 @@ CONCLUDED: * The DNs should not have the dn: prefix */ static int -slap_sasl_check_authz(struct berval *searchDN, struct berval *assertDN, AttributeDescription *ad, struct berval *authc) +slap_sasl_check_authz( Connection *conn, + struct berval *searchDN, + struct berval *assertDN, + AttributeDescription *ad, + struct berval *authc ) { int i, rc; BerVarray vals=NULL; #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, + LDAP_LOG( TRANSPORT, ENTRY, "slap_sasl_check_authz: does %s match %s rule in %s?\n", - assertDN->bv_val, ad->ad_cname.bv_val, searchDN->bv_val )); + assertDN->bv_val, ad->ad_cname.bv_val, searchDN->bv_val); #else Debug( LDAP_DEBUG_TRACE, "==>slap_sasl_check_authz: does %s match %s rule in %s?\n", @@ -666,7 +670,7 @@ slap_sasl_check_authz(struct berval *searchDN, struct berval *assertDN, Attribut /* Check if the *assertDN matches any **vals */ for( i=0; vals[i].bv_val != NULL; i++ ) { - rc = slap_sasl_match( &vals[i], assertDN, authc ); + rc = slap_sasl_match( conn, &vals[i], assertDN, authc ); if ( rc == LDAP_SUCCESS ) goto COMPLETE; } @@ -676,8 +680,9 @@ COMPLETE: if( vals ) ber_bvarray_free( vals ); #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, - "slap_sasl_check_authz: %s check returning %s\n", ad->ad_cname.bv_val, rc )); + LDAP_LOG( TRANSPORT, RESULTS, + "slap_sasl_check_authz: %s check returning %s\n", + ad->ad_cname.bv_val, rc, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<==slap_sasl_check_authz: %s check returning %d\n", ad->ad_cname.bv_val, rc, 0); @@ -692,7 +697,8 @@ COMPLETE: * The DNs should not have the dn: prefix */ -int slap_sasl_authorized( struct berval *authcDN, struct berval *authzDN ) +int slap_sasl_authorized( Connection *conn, + struct berval *authcDN, struct berval *authzDN ) { int rc = LDAP_INAPPROPRIATE_AUTH; @@ -704,8 +710,9 @@ int slap_sasl_authorized( struct berval *authcDN, struct berval *authzDN ) } #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, - "slap_sasl_authorized: can %s become %s?\n", authcDN->bv_val, authzDN->bv_val )); + LDAP_LOG( TRANSPORT, ENTRY, + "slap_sasl_authorized: can %s become %s?\n", + authcDN->bv_val, authzDN->bv_val, 0 ); #else Debug( LDAP_DEBUG_TRACE, "==>slap_sasl_authorized: can %s become %s?\n", authcDN->bv_val, authzDN->bv_val, 0 ); @@ -719,7 +726,7 @@ int slap_sasl_authorized( struct berval *authcDN, struct berval *authzDN ) /* Check source rules */ if( authz_policy & SASL_AUTHZ_TO ) { - rc = slap_sasl_check_authz( authcDN, authzDN, + rc = slap_sasl_check_authz( conn, authcDN, authzDN, slap_schema.si_ad_saslAuthzTo, authcDN ); if( rc == LDAP_SUCCESS ) { goto DONE; @@ -728,7 +735,7 @@ int slap_sasl_authorized( struct berval *authcDN, struct berval *authzDN ) /* Check destination rules */ if( authz_policy & SASL_AUTHZ_FROM ) { - rc = slap_sasl_check_authz( authzDN, authcDN, + rc = slap_sasl_check_authz( conn, authzDN, authcDN, slap_schema.si_ad_saslAuthzFrom, authcDN ); if( rc == LDAP_SUCCESS ) { goto DONE; @@ -741,8 +748,7 @@ DONE: #endif #ifdef NEW_LOGGING - LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, - "slap_sasl_authorized: return %d\n", rc )); + LDAP_LOG( TRANSPORT, RESULTS, "slap_sasl_authorized: return %d\n", rc,0,0 ); #else Debug( LDAP_DEBUG_TRACE, "<== slap_sasl_authorized: return %d\n", rc, 0, 0 ); diff --git a/servers/slapd/schema_check.c b/servers/slapd/schema_check.c index ec1def4308b4488ef9c224b2daf2324d157ab94f..a2a3e6455e23f49fc9f963f1cc7aa9b611bde583 100644 --- a/servers/slapd/schema_check.c +++ b/servers/slapd/schema_check.c @@ -86,9 +86,8 @@ entry_schema_check( type ); #ifdef NEW_LOGGING - LDAP_LOG(( "schema", LDAP_LEVEL_INFO, - "entry_schema_check: dn=\"%s\" %s\n", - e->e_dn, textbuf )); + LDAP_LOG( OPERATION, INFO, + "entry_schema_check: dn=\"%s\" %s\n", e->e_dn, textbuf, 0 ); #else Debug( LDAP_DEBUG_ANY, "Entry (%s), %s\n", @@ -106,9 +105,9 @@ entry_schema_check( asc = attr_find( e->e_attrs, ad_structuralObjectClass ); if ( asc == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "schema", LDAP_LEVEL_INFO, "entry_schema_check: " - "No structuralObjectClass for entry (%s)\n", - e->e_dn )); + LDAP_LOG( OPERATION, INFO, + "entry_schema_check: No structuralObjectClass for entry (%s)\n", + e->e_dn, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "No structuralObjectClass for entry (%s)\n", @@ -130,9 +129,8 @@ entry_schema_check( asc->a_vals[0].bv_val ); #ifdef NEW_LOGGING - LDAP_LOG(( "schema", LDAP_LEVEL_INFO, - "entry_schema_check: dn (%s), %s\n", - e->e_dn, textbuf )); + LDAP_LOG( OPERATION, INFO, + "entry_schema_check: dn (%s), %s\n", e->e_dn, textbuf, 0 ); #else Debug( LDAP_DEBUG_ANY, "entry_check_schema(%s): %s\n", @@ -148,9 +146,8 @@ entry_schema_check( asc->a_vals[0].bv_val ); #ifdef NEW_LOGGING - LDAP_LOG(( "schema", LDAP_LEVEL_INFO, - "entry_schema_check: dn (%s), %s\n", - e->e_dn, textbuf )); + LDAP_LOG( OPERATION, INFO, + "entry_schema_check: dn (%s), %s\n", e->e_dn, textbuf, 0 ); #else Debug( LDAP_DEBUG_ANY, "entry_check_schema(%s): %s\n", @@ -164,9 +161,9 @@ entry_schema_check( aoc = attr_find( e->e_attrs, ad_objectClass ); if ( aoc == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG(( "schema", LDAP_LEVEL_INFO, - "entry_schema_check: No objectClass for entry (%s).\n", - e->e_dn )); + LDAP_LOG( OPERATION, INFO, + "entry_schema_check: No objectClass for entry (%s).\n", + e->e_dn, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "No objectClass for entry (%s)\n", e->e_dn, 0, 0 ); @@ -209,9 +206,8 @@ entry_schema_check( aoc->a_vals[i].bv_val ); #ifdef NEW_LOGGING - LDAP_LOG(( "schema", LDAP_LEVEL_INFO, - "entry_schema_check: dn (%s), %s\n", - e->e_dn, textbuf )); + LDAP_LOG( OPERATION, INFO, + "entry_schema_check: dn (%s), %s\n", e->e_dn, textbuf, 0 ); #else Debug( LDAP_DEBUG_ANY, "entry_check_schema(%s): %s\n", @@ -245,9 +241,9 @@ entry_schema_check( aoc->a_vals[i].bv_val ); #ifdef NEW_LOGGING - LDAP_LOG(( "schema", LDAP_LEVEL_INFO, + LDAP_LOG( OPERATION, INFO, "entry_schema_check: dn (%s), %s\n", - e->e_dn, textbuf )); + e->e_dn, textbuf, 0 ); #else Debug( LDAP_DEBUG_ANY, "entry_check_schema(%s): %s\n", @@ -279,9 +275,9 @@ entry_schema_check( aoc->a_vals[i].bv_val ); #ifdef NEW_LOGGING - LDAP_LOG(( "schema", LDAP_LEVEL_INFO, - "entry_schema_check: dn (%s), %s\n", - e->e_dn, textbuf )); + LDAP_LOG( OPERATION, INFO, + "entry_schema_check: dn (%s), %s\n", + e->e_dn, textbuf, 0 ); #else Debug( LDAP_DEBUG_ANY, "entry_check_schema(%s): %s\n", @@ -301,9 +297,8 @@ entry_schema_check( aoc->a_vals[i].bv_val, s ); #ifdef NEW_LOGGING - LDAP_LOG(( "schema", LDAP_LEVEL_INFO, - "entry_schema_check: dn=\"%s\" %s", - e->e_dn, textbuf )); + LDAP_LOG( OPERATION, INFO, + "entry_schema_check: dn=\"%s\" %s", e->e_dn, textbuf, 0 ); #else Debug( LDAP_DEBUG_ANY, "Entry (%s): %s\n", @@ -334,9 +329,8 @@ entry_schema_check( type ); #ifdef NEW_LOGGING - LDAP_LOG(( "schema", LDAP_LEVEL_INFO, - "entry_schema_check: dn=\"%s\" %s\n", - e->e_dn, textbuf )); + LDAP_LOG( OPERATION, INFO, + "entry_schema_check: dn=\"%s\" %s\n", e->e_dn, textbuf, 0); #else Debug( LDAP_DEBUG_ANY, "Entry (%s), %s\n", @@ -361,9 +355,9 @@ oc_check_required( Attribute *a; #ifdef NEW_LOGGING - LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY, - "oc_check_required: dn (%s), objectClass \"%s\"\n", - e->e_dn, ocname->bv_val )); + LDAP_LOG( OPERATION, ENTRY, + "oc_check_required: dn (%s), objectClass \"%s\"\n", + e->e_dn, ocname->bv_val, 0 ); #else Debug( LDAP_DEBUG_TRACE, "oc_check_required entry (%s), objectClass \"%s\"\n", @@ -402,8 +396,8 @@ int oc_check_allowed( int i, j; #ifdef NEW_LOGGING - LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY, - "oc_check_allowed: type \"%s\"\n", at->sat_cname.bv_val )); + LDAP_LOG( OPERATION, ENTRY, + "oc_check_allowed: type \"%s\"\n", at->sat_cname.bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "oc_check_allowed type \"%s\"\n", diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index f0ad77cb51a3daab777728a7a8a8e0c6735e00a0..4e8ac815f89ddbca06df111e1f86e83718c8cfd8 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -3367,9 +3367,9 @@ objectIdentifierFirstComponentMatch( } #ifdef NEW_LOGGING - LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY, - "objectIdentifierFirstComponentMatch: %d\n %s\n %s\n", - match, value->bv_val, asserted->bv_val )); + LDAP_LOG( CONFIG, ENTRY, + "objectIdentifierFirstComponentMatch: %d\n %s\n %s\n", + match, value->bv_val, asserted->bv_val ); #else Debug( LDAP_DEBUG_ARGS, "objectIdentifierFirstComponentMatch " "%d\n\t\"%s\"\n\t\"%s\"\n", @@ -3516,9 +3516,9 @@ certificateExactConvert( xcert = d2i_X509(NULL, &p, in->bv_len); if ( !xcert ) { #ifdef NEW_LOGGING - LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY, - "certificateExactConvert: error parsing cert: %s\n", - ERR_error_string(ERR_get_error(),NULL))); + LDAP_LOG( CONFIG, ENTRY, + "certificateExactConvert: error parsing cert: %s\n", + ERR_error_string(ERR_get_error(),NULL), 0, 0 ); #else Debug( LDAP_DEBUG_ARGS, "certificateExactConvert: " "error parsing cert: %s\n", @@ -3551,9 +3551,8 @@ certificateExactConvert( *p++ = '\0'; #ifdef NEW_LOGGING - LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY, - "certificateExactConvert: \n %s\n", - out->bv_val)); + LDAP_LOG( CONFIG, ARGS, + "certificateExactConvert: \n %s\n", out->bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_ARGS, "certificateExactConvert " "\n\t\"%s\"\n", @@ -3633,9 +3632,9 @@ certificateExactMatch( xcert = d2i_X509(NULL, &p, value->bv_len); if ( !xcert ) { #ifdef NEW_LOGGING - LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY, - "certificateExactMatch: error parsing cert: %s\n", - ERR_error_string(ERR_get_error(),NULL))); + LDAP_LOG( CONFIG, ENTRY, + "certificateExactMatch: error parsing cert: %s\n", + ERR_error_string(ERR_get_error(),NULL), 0, 0 ); #else Debug( LDAP_DEBUG_ARGS, "certificateExactMatch: " "error parsing cert: %s\n", @@ -3674,10 +3673,12 @@ certificateExactMatch( } #ifdef NEW_LOGGING - LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY, - "certificateExactMatch: %d\n %s $ %s\n %s $ %s\n", - *matchp, serial.bv_val, issuer_dn.bv_val, - asserted_serial.bv_val, asserted_issuer_dn.bv_val)); + LDAP_LOG( CONFIG, ARGS, "certificateExactMatch " + "%d\n\t\"%s $ %s\"\n", + *matchp, serial.bv_val, issuer_dn.bv_val ); + LDAP_LOG( CONFIG, ARGS, "\t\"%s $ %s\"\n", + asserted_serial.bv_val, asserted_issuer_dn.bv_val, + 0 ); #else Debug( LDAP_DEBUG_ARGS, "certificateExactMatch " "%d\n\t\"%s $ %s\"\n", @@ -3729,9 +3730,9 @@ static int certificateExactIndexer( xcert = d2i_X509(NULL, &p, values[i].bv_len); if ( !xcert ) { #ifdef NEW_LOGGING - LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY, - "certificateExactIndexer: error parsing cert: %s\n", - ERR_error_string(ERR_get_error(),NULL))); + LDAP_LOG( CONFIG, ENTRY, + "certificateExactIndexer: error parsing cert: %s\n", + ERR_error_string(ERR_get_error(),NULL), 0, 0); #else Debug( LDAP_DEBUG_ARGS, "certificateExactIndexer: " "error parsing cert: %s\n", @@ -3749,9 +3750,8 @@ static int certificateExactIndexer( &keys[i] ); ber_memfree(serial.bv_val); #ifdef NEW_LOGGING - LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY, - "certificateExactIndexer: returning: %s\n", - keys[i].bv_val)); + LDAP_LOG( CONFIG, ENTRY, + "certificateExactIndexer: returning: %s\n", keys[i].bv_val, 0, 0); #else Debug( LDAP_DEBUG_ARGS, "certificateExactIndexer: " "returning: %s\n", @@ -4060,7 +4060,7 @@ nisNetgroupTripleValidate( return LDAP_INVALID_SYNTAX; } - } else if ( !ATTR_CHAR( *p ) ) { + } else if ( !AD_CHAR( *p ) ) { return LDAP_INVALID_SYNTAX; } } @@ -4094,7 +4094,7 @@ bootParameterValidate( /* key */ for (; ( p < e ) && ( *p != '=' ); p++ ) { - if ( !ATTR_CHAR( *p ) ) { + if ( !AD_CHAR( *p ) ) { return LDAP_INVALID_SYNTAX; } } @@ -4105,7 +4105,7 @@ bootParameterValidate( /* server */ for ( p++; ( p < e ) && ( *p != ':' ); p++ ) { - if ( !ATTR_CHAR( *p ) ) { + if ( !AD_CHAR( *p ) ) { return LDAP_INVALID_SYNTAX; } } @@ -4116,7 +4116,7 @@ bootParameterValidate( /* path */ for ( p++; p < e; p++ ) { - if ( !ATTR_CHAR( *p ) ) { + if ( !SLAP_PRINTABLE( *p ) ) { return LDAP_INVALID_SYNTAX; } } @@ -4627,7 +4627,7 @@ int slap_schema_init( void ) { int res; - int i; + int i = 0; /* we should only be called once (from main) */ assert( schema_init_done == 0 ); diff --git a/servers/slapd/schema_prep.c b/servers/slapd/schema_prep.c index 28dca9ccb0a8e0fee88bbcc9b6385d2bd014fd57..15bf1e3c8f5d894b9623ec51e454d28ce129f2f8 100644 --- a/servers/slapd/schema_prep.c +++ b/servers/slapd/schema_prep.c @@ -36,9 +36,8 @@ objectClassMatch( #if 1 #ifdef NEW_LOGGING - LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY, - "> objectClassMatch(%s, %s)\n", - value->bv_val, a->bv_val )); + LDAP_LOG( CONFIG, ENTRY, + "> objectClassMatch(%s, %s)\n", value->bv_val, a->bv_val, 0 ); #else Debug( LDAP_DEBUG_TRACE, "> objectClassMatch(%s,%s)\n", value->bv_val, a->bv_val, 0 ); @@ -69,9 +68,9 @@ objectClassMatch( #if 1 #ifdef NEW_LOGGING - LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY, - "< objectClassMatch(%s, %s) = %d\n", - value->bv_val, a->bv_val, *matchp )); + LDAP_LOG( CONFIG, ENTRY, + "< objectClassMatch(%s, %s) = %d\n", + value->bv_val, a->bv_val, *matchp ); #else Debug( LDAP_DEBUG_TRACE, "< objectClassMatch(%s,%s) = %d\n", value->bv_val, a->bv_val, *matchp ); @@ -99,9 +98,8 @@ structuralObjectClassMatch( #if 1 #ifdef NEW_LOGGING - LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY, - "> structuralObjectClassMatch(%s, %s)\n", - value->bv_val, a->bv_val )); + LDAP_LOG( CONFIG, ENTRY, + "> structuralObjectClassMatch(%s, %s)\n", value->bv_val, a->bv_val, 0 ); #else Debug( LDAP_DEBUG_TRACE, "> structuralObjectClassMatch(%s,%s)\n", value->bv_val, a->bv_val, 0 ); @@ -128,9 +126,9 @@ structuralObjectClassMatch( #if 1 #ifdef NEW_LOGGING - LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY, - "< structuralObjectClassMatch( %s, %s ) = %d\n", - value->bv_val, a->bv_val, *matchp )); + LDAP_LOG( CONFIG, ENTRY, + "< structuralObjectClassMatch( %s, %s ) = %d\n", + value->bv_val, a->bv_val, *matchp ); #else Debug( LDAP_DEBUG_TRACE, "< structuralObjectClassMatch(%s,%s) = %d\n", value->bv_val, a->bv_val, *matchp ); diff --git a/servers/slapd/schemaparse.c b/servers/slapd/schemaparse.c index 1f9138753b38459864de403b687d815e669c37f7..ffbf47dc22d3f2d2ff26c5c1c7e8d4f9da4eb03c 100644 --- a/servers/slapd/schemaparse.c +++ b/servers/slapd/schemaparse.c @@ -25,8 +25,8 @@ static char *const err2text[] = { "Success", "Out of memory", "ObjectClass not found", - "ObjectClass inappropriate SUPerior", - "ObjectClass operational", + "user-defined ObjectClass has inappropriate SUPerior", + "user-defined ObjectClass includes operational attributes", "Duplicate objectClass", "AttributeType not found", "AttributeType inappropriate USAGE", diff --git a/servers/slapd/search.c b/servers/slapd/search.c index c4db3e52e664bb210845a9949a740ca3bc33b156..7e36a3d7483b3b0ddf990689eca751577ac6d692 100644 --- a/servers/slapd/search.c +++ b/servers/slapd/search.c @@ -45,8 +45,7 @@ do_search( int manageDSAit; #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, - "do_search: conn %d\n", conn->c_connid )); + LDAP_LOG( OPERATION, ENTRY, "do_search: conn %d\n", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "do_search\n", 0, 0, 0 ); #endif @@ -112,9 +111,9 @@ do_search( rc = dnPrettyNormal( NULL, &base, &pbase, &nbase ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + LDAP_LOG( OPERATION, ERR, "do_search: conn %d invalid dn (%s)\n", - conn->c_connid, base.bv_val )); + conn->c_connid, base.bv_val, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_search: invalid dn (%s)\n", base.bv_val, 0, 0 ); @@ -125,9 +124,10 @@ do_search( } #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ARGS, - "do_search \"%s\" %d %d %d %d %d\n", base.bv_val, scope, - deref, sizelimit, timelimit, attrsonly )); + LDAP_LOG( OPERATION, ARGS, "SRCH \"%s\" %d %d", + base.bv_val, scope, deref ); + LDAP_LOG( OPERATION, ARGS, " %d %d %d\n", + sizelimit, timelimit, attrsonly); #else Debug( LDAP_DEBUG_ARGS, "SRCH \"%s\" %d %d", base.bv_val, scope, deref ); @@ -152,9 +152,9 @@ do_search( } #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ARGS, - "do_search: conn %d filter: %s\n", conn->c_connid, - fstr.bv_len ? fstr.bv_val : "empty" )); + LDAP_LOG( OPERATION, ARGS, + "do_search: conn %d filter: %s\n", + conn->c_connid, fstr.bv_len ? fstr.bv_val : "empty", 0 ); #else Debug( LDAP_DEBUG_ARGS, " filter: %s\n", fstr.bv_len ? fstr.bv_val : "empty", 0, 0 ); @@ -177,9 +177,9 @@ do_search( if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + LDAP_LOG( OPERATION, INFO, "do_search: conn %d get_ctrls failed (%d)\n", - conn->c_connid, rc )); + conn->c_connid, rc, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_search: get_ctrls failed\n", 0, 0, 0 ); #endif @@ -188,8 +188,8 @@ do_search( } #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ARGS, - "do_search: conn %d attrs:", conn->c_connid )); + LDAP_LOG( OPERATION, ARGS, + "do_search: conn %d attrs:", conn->c_connid, 0, 0 ); #else Debug( LDAP_DEBUG_ARGS, " attrs:", 0, 0, 0 ); #endif @@ -197,8 +197,8 @@ do_search( if ( siz != 0 ) { for ( i = 0; i<siz; i++ ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ARGS, - "do_search: %s", an[i].an_name.bv_val )); + LDAP_LOG( OPERATION, ARGS, + "do_search: %s", an[i].an_name.bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_ARGS, " %s", an[i].an_name.bv_val, 0, 0 ); #endif @@ -206,7 +206,7 @@ do_search( } #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ARGS, "\n" )); + LDAP_LOG( OPERATION, ARGS, "\n" , 0, 0, 0 ); #else Debug( LDAP_DEBUG_ARGS, "\n", 0, 0, 0 ); #endif diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 4284b9dfdd0dd8ef05193a7b874d302f955825c2..188e6104228d88dd97f9dfab92662082f5e0a084 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -1482,6 +1482,8 @@ typedef struct slap_op { volatile sig_atomic_t o_abandon; /* abandon flag */ + char o_do_not_cache; /* don't cache from this op */ + #define SLAP_NO_CONTROL 0 #define SLAP_NONCRITICAL_CONTROL 1 #define SLAP_CRITICAL_CONTROL 2 diff --git a/servers/slapd/str2filter.c b/servers/slapd/str2filter.c index 45a42ad60034e5c883520f39f5a859ed9bc6d6bb..ff7cd450adfc7eea72d5e479af5fd74831697131 100644 --- a/servers/slapd/str2filter.c +++ b/servers/slapd/str2filter.c @@ -33,8 +33,7 @@ str2filter( const char *str ) const char *text = NULL; #ifdef NEW_LOGGING - LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, - "str2filter: \"%s\"\n", str )); + LDAP_LOG( FILTER, ENTRY, "str2filter: \"%s\"\n", str, 0, 0 ); #else Debug( LDAP_DEBUG_FILTER, "str2filter \"%s\"\n", str, 0, 0 ); #endif diff --git a/servers/slapd/suffixalias.c b/servers/slapd/suffixalias.c index faf68b95b4ce3ffecc4a170bbfcf4d8802cf491e..78a1a18cb32816087284a2fa68608227d7bc4107 100644 --- a/servers/slapd/suffixalias.c +++ b/servers/slapd/suffixalias.c @@ -65,9 +65,9 @@ void suffix_alias( strncpy( dn->bv_val, oldDN, diff ); strcpy( &dn->bv_val[diff], be->be_suffixAlias[i+1].bv_val ); #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_INFO, - "suffix_alias: converted \"%s\" to \"%s\"\n", - oldDN, dn->bv_val )); + LDAP_LOG( OPERATION, INFO, + "suffix_alias: converted \"%s\" to \"%s\"\n", + oldDN, dn->bv_val, 0 ); #else Debug( LDAP_DEBUG_ARGS, "suffix_alias: converted \"%s\" to \"%s\"\n", diff --git a/servers/slapd/syntax.c b/servers/slapd/syntax.c index eea2e1b1108ce59c5aa59244bf7d030fb6e7142d..98f53d433bfc5f8de8c7dcd8c13436246b74d3db 100644 --- a/servers/slapd/syntax.c +++ b/servers/slapd/syntax.c @@ -16,7 +16,6 @@ #include "slap.h" #include "ldap_pvt.h" - struct sindexrec { char *sir_name; Syntax *sir_syn; @@ -164,9 +163,9 @@ register_syntax( syn = ldap_str2syntax( desc, &code, &err, LDAP_SCHEMA_ALLOW_ALL); if ( !syn ) { #ifdef NEW_LOGGING - LDAP_LOG(( "schema", LDAP_LEVEL_ERR, - "register_syntax: Error - %s before %s in %s.\n", - ldap_scherr2str(code), err, desc )); + LDAP_LOG( CONFIG, ERR, + "register_syntax: Error - %s before %s in %s.\n", + ldap_scherr2str(code), err, desc ); #else Debug( LDAP_DEBUG_ANY, "Error in register_syntax: %s before %s in %s\n", ldap_scherr2str(code), err, desc ); @@ -181,9 +180,9 @@ register_syntax( if ( code ) { #ifdef NEW_LOGGING - LDAP_LOG(( "schema", LDAP_LEVEL_ERR, - "register_syntax: Error - %s %s in %s\n", - scherr2str(code), err, desc )); + LDAP_LOG( CONFIG, ERR, + "register_syntax: Error - %s %s in %s\n", + scherr2str(code), err, desc ); #else Debug( LDAP_DEBUG_ANY, "Error in register_syntax: %s %s in %s\n", scherr2str(code), err, desc ); @@ -222,9 +221,9 @@ syn_schema_info( Entry *e ) } #if 0 #ifdef NEW_LOGGING - LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY, + LDAP_LOG( config, ENTRY, "syn_schema_info: Merging syn [%ld] %s\n", - (long)vals[0].bv_len, vals[0].bv_val )); + (long)vals[0].bv_len, vals[0].bv_val, 0 ); #else Debug( LDAP_DEBUG_TRACE, "Merging syn [%ld] %s\n", (long) vals[0].bv_len, vals[0].bv_val, 0 ); diff --git a/servers/slapd/unbind.c b/servers/slapd/unbind.c index 40457cfe9ace176af24e749075d2b23bba5f3eb4..c4c4f18542368b2dd8a69e9da4827b9c4e21db87 100644 --- a/servers/slapd/unbind.c +++ b/servers/slapd/unbind.c @@ -26,7 +26,6 @@ #include "slap.h" - int do_unbind( Connection *conn, @@ -34,8 +33,8 @@ do_unbind( ) { #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, - "do_unbind: conn %d\n", conn ? conn->c_connid : -1 )); + LDAP_LOG( OPERATION, ENTRY, + "do_unbind: conn %d\n", conn ? conn->c_connid : -1, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "do_unbind\n", 0, 0, 0 ); #endif diff --git a/servers/slapd/user.c b/servers/slapd/user.c new file mode 100644 index 0000000000000000000000000000000000000000..8df425bc38573407022c1944ceaa3c8e8177a344 --- /dev/null +++ b/servers/slapd/user.c @@ -0,0 +1,198 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* user.c - set user id, group id and group access list + * + * Copyright 1999 by PM Lashley. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. +*/ + +#include "portable.h" + +#if defined(HAVE_SETUID) && defined(HAVE_SETGID) + +#include <stdio.h> + +#include <ac/stdlib.h> + +#ifdef HAVE_PWD_H +#include <pwd.h> +#endif +#ifdef HAVE_GRP_H +#include <grp.h> +#endif + +#include <ac/ctype.h> +#include <ac/unistd.h> + +#include "slap.h" + +/* + * Set real and effective user id and group id, and group access list + * The user and group arguments are freed. + */ + +void +slap_init_user( char *user, char *group ) +{ + uid_t uid = 0; + gid_t gid = 0; + int got_uid = 0, got_gid = 0; + + if ( user ) { + struct passwd *pwd; + if ( isdigit( (unsigned char) *user )) { + got_uid = 1; + uid = atoi( user ); +#ifdef HAVE_GETPWUID + pwd = getpwuid( uid ); + goto did_getpw; +#else + free( user ); + user = NULL; +#endif + } else { + pwd = getpwnam( user ); + did_getpw: + if ( pwd == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG( OPERATION, INFO, + "slap_init_user: No passwd entry for user %s\n", user, 0, 0 ); +#else + Debug( LDAP_DEBUG_ANY, "No passwd entry for user %s\n", + user, 0, 0 ); +#endif + + exit( EXIT_FAILURE ); + } + if ( got_uid ) { + free( user ); + user = (pwd != NULL ? ch_strdup( pwd->pw_name ) : NULL); + } else { + got_uid = 1; + uid = pwd->pw_uid; + } + got_gid = 1; + gid = pwd->pw_gid; +#ifdef HAVE_ENDPWENT + endpwent(); +#endif + } + } + + if ( group ) { + struct group *grp; + if ( isdigit( (unsigned char) *group )) { + gid = atoi( group ); +#ifdef HAVE_GETGRGID + grp = getgrgid( gid ); + goto did_group; +#endif + } else { + grp = getgrnam( group ); + if ( grp != NULL ) + gid = grp->gr_gid; + did_group: + if ( grp == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG( OPERATION, INFO, + "slap_init_user: No group entry for group %s\n", group, 0, 0 ); +#else + Debug( LDAP_DEBUG_ANY, "No group entry for group %s\n", + group, 0, 0 ); +#endif + + exit( EXIT_FAILURE ); + } + } + free( group ); + got_gid = 1; + } + + if ( user ) { + if ( getuid() == 0 && initgroups( user, gid ) != 0 ) { +#ifdef NEW_LOGGING + LDAP_LOG( OPERATION, INFO, + "slap_init_user: Could not set the group access (gid) list.\n", + 0, 0, 0 ); +#else + Debug( LDAP_DEBUG_ANY, + "Could not set the group access (gid) list\n", 0, 0, 0 ); +#endif + + exit( EXIT_FAILURE ); + } + free( user ); + } + +#ifdef HAVE_ENDGRENT + endgrent(); +#endif + + if ( got_gid ) { + if ( setgid( gid ) != 0 ) { +#ifdef NEW_LOGGING + LDAP_LOG( OPERATION, INFO, + "slap_init_user: could not set real group id to %d\n", + (int)gid, 0, 0); +#else + Debug( LDAP_DEBUG_ANY, "Could not set real group id to %d\n", + (int) gid, 0, 0 ); +#endif + + exit( EXIT_FAILURE ); + } +#ifdef HAVE_SETEGID + if ( setegid( gid ) != 0 ) { +#ifdef NEW_LOGGING + LDAP_LOG( OPERATION, INFO, + "slap_init_user: Could not set effective group id to %d\n", + (int)gid, 0, 0); +#else + Debug( LDAP_DEBUG_ANY, "Could not set effective group id to %d\n", + (int) gid, 0, 0 ); +#endif + + exit( EXIT_FAILURE ); + } +#endif + } + + if ( got_uid ) { + if ( setuid( uid ) != 0 ) { +#ifdef NEW_LOGGING + LDAP_LOG( OPERATION, INFO, + "slap_init_user: Could not set real user id to %d\n", + (int)uid, 0, 0 ); +#else + Debug( LDAP_DEBUG_ANY, "Could not set real user id to %d\n", + (int) uid, 0, 0 ); +#endif + + exit( EXIT_FAILURE ); + } +#ifdef HAVE_SETEUID + if ( seteuid( uid ) != 0 ) { +#ifdef NEW_LOGGING + LDAP_LOG( OPERATION, INFO, + "slap_init_user: Could not set effective user id to %d\n", + (int)uid, 0, 0 ); +#else + Debug( LDAP_DEBUG_ANY, "Could not set effective user id to %d\n", + (int) uid, 0, 0 ); +#endif + + exit( EXIT_FAILURE ); + } +#endif + } +} + +#endif /* HAVE_PWD_H && HAVE_GRP_H */