From c8c384710376c8cf1b5dfa15d91fa92bbd12beab Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Wed, 2 Jun 2010 00:18:32 +0000 Subject: [PATCH] ITS#6566 use Debug, not fprintf(stderr) --- servers/slapd/overlays/ppolicy.c | 6 ++-- servers/slapd/overlays/rwm.c | 28 +++++++++---------- servers/slapd/overlays/rwmconf.c | 48 ++++++++++++++++++-------------- servers/slapd/overlays/sssvlv.c | 4 +-- servers/slapd/overlays/valsort.c | 2 +- 5 files changed, 47 insertions(+), 41 deletions(-) diff --git a/servers/slapd/overlays/ppolicy.c b/servers/slapd/overlays/ppolicy.c index ec5992b82c..924071255c 100644 --- a/servers/slapd/overlays/ppolicy.c +++ b/servers/slapd/overlays/ppolicy.c @@ -2234,7 +2234,7 @@ ppolicy_db_init( if ( cr ){ snprintf( cr->msg, sizeof(cr->msg), "slapo-ppolicy cannot be global" ); - fprintf( stderr, "%s\n", cr->msg ); + Debug( LDAP_DEBUG_ANY, "%s\n", cr->msg, 0, 0 ); } return 1; } @@ -2251,7 +2251,7 @@ ppolicy_db_init( snprintf( cr->msg, sizeof(cr->msg), "User Schema load failed for attribute \"%s\". Error code %d: %s", pwd_UsSchema[i].def, code, err ); - fprintf( stderr, "%s\n", cr->msg ); + Debug( LDAP_DEBUG_ANY, "%s\n", cr->msg, 0, 0 ); } return code; } @@ -2344,7 +2344,7 @@ int ppolicy_initialize() SLAP_CTRL_ADD|SLAP_CTRL_BIND|SLAP_CTRL_MODIFY|SLAP_CTRL_HIDE, extops, ppolicy_parseCtrl, &ppolicy_cid ); if ( code != LDAP_SUCCESS ) { - fprintf( stderr, "Failed to register control %d\n", code ); + Debug( LDAP_DEBUG_ANY, "Failed to register control %d\n", code, 0, 0 ); return code; } diff --git a/servers/slapd/overlays/rwm.c b/servers/slapd/overlays/rwm.c index 1c1acc819b..46c2b73940 100644 --- a/servers/slapd/overlays/rwm.c +++ b/servers/slapd/overlays/rwm.c @@ -122,7 +122,7 @@ rwm_op_rollback( Operation *op, SlapReply *rs, rwm_op_state *ros ) #if 0 ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex ); /* too late, c_mutex released */ - fprintf( stderr, "*** DN: \"%s\" => \"%s\"\n", + Debug( LDAP_DEBUG_ANY, "*** DN: \"%s\" => \"%s\"\n", op->o_conn->c_ndn.bv_val, op->o_req_ndn.bv_val ); ber_bvreplace( &op->o_conn->c_ndn, @@ -1626,12 +1626,12 @@ rwm_suffixmassage_config( */ if ( argc == 2 ) { if ( be->be_suffix == NULL ) { - fprintf( stderr, "%s: line %d: " + Debug( LDAP_DEBUG_ANY, "%s: line %d: " " \"suffixMassage []" " \" without " " part requires database " "suffix be defined first.\n", - fname, lineno ); + fname, lineno, 0 ); return 1; } bvnc = be->be_suffix[ 0 ]; @@ -1642,22 +1642,22 @@ rwm_suffixmassage_config( massaged = 2; } else { - fprintf( stderr, "%s: line %d: syntax is" + Debug( LDAP_DEBUG_ANY, "%s: line %d: syntax is" " \"suffixMassage []" " \"\n", - fname, lineno ); + fname, lineno, 0 ); return 1; } if ( dnPrettyNormal( NULL, &bvnc, &pvnc, &nvnc, NULL ) != LDAP_SUCCESS ) { - fprintf( stderr, "%s: line %d: suffix DN %s is invalid\n", + Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix DN %s is invalid\n", fname, lineno, bvnc.bv_val ); return 1; } ber_str2bv( argv[ massaged ], 0, 0, &brnc ); if ( dnPrettyNormal( NULL, &brnc, &prnc, &nrnc, NULL ) != LDAP_SUCCESS ) { - fprintf( stderr, "%s: line %d: suffix DN %s is invalid\n", + Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix DN %s is invalid\n", fname, lineno, brnc.bv_val ); free( nvnc.bv_val ); free( pvnc.bv_val ); @@ -1776,9 +1776,9 @@ rwm_db_config( } else if ( strcasecmp( argv[0], "t-f-support" ) == 0 ) { if ( argc != 2 ) { - fprintf( stderr, + Debug( LDAP_DEBUG_ANY, "%s: line %d: \"t-f-support {no|yes|discover}\" needs 1 argument.\n", - fname, lineno ); + fname, lineno, 0 ); return( 1 ); } @@ -1790,17 +1790,17 @@ rwm_db_config( /* TODO: not implemented yet */ } else if ( strcasecmp( argv[ 1 ], "discover" ) == 0 ) { - fprintf( stderr, + Debug( LDAP_DEBUG_ANY, "%s: line %d: \"discover\" not supported yet " "in \"t-f-support {no|yes|discover}\".\n", - fname, lineno ); + fname, lineno, 0 ); return( 1 ); #if 0 rwmap->rwm_flags |= RWM_F_SUPPORT_T_F_DISCOVER; #endif } else { - fprintf( stderr, + Debug( LDAP_DEBUG_ANY, "%s: line %d: unknown value \"%s\" for \"t-f-support {no|yes|discover}\".\n", fname, lineno, argv[ 1 ] ); return 1; @@ -1808,9 +1808,9 @@ rwm_db_config( } else if ( strcasecmp( argv[0], "normalize-mapped-attrs" ) == 0 ) { if ( argc !=2 ) { - fprintf( stderr, + Debug( LDAP_DEBUG_ANY, "%s: line %d: \"normalize-mapped-attrs {no|yes}\" needs 1 argument.\n", - fname, lineno ); + fname, lineno, 0 ); return( 1 ); } diff --git a/servers/slapd/overlays/rwmconf.c b/servers/slapd/overlays/rwmconf.c index bc9fe8114c..c39ed65f56 100644 --- a/servers/slapd/overlays/rwmconf.c +++ b/servers/slapd/overlays/rwmconf.c @@ -50,9 +50,9 @@ rwm_map_config( int rc = 0; if ( argc < 3 || argc > 4 ) { - fprintf( stderr, + Debug( LDAP_DEBUG_ANY, "%s: line %d: syntax is \"map {objectclass | attribute} [ | *] { | *}\"\n", - fname, lineno ); + fname, lineno, 0 ); return 1; } @@ -64,10 +64,10 @@ rwm_map_config( map = at_map; } else { - fprintf( stderr, "%s: line %d: syntax is " + Debug( LDAP_DEBUG_ANY, "%s: line %d: syntax is " "\"map {objectclass | attribute} [ | *] " "{ | *}\"\n", - fname, lineno ); + fname, lineno, 0 ); return 1; } @@ -98,18 +98,18 @@ rwm_map_config( && ( strcasecmp( src, "objectclass" ) == 0 || strcasecmp( dst, "objectclass" ) == 0 ) ) { - fprintf( stderr, + Debug( LDAP_DEBUG_ANY, "%s: line %d: objectclass attribute cannot be mapped\n", - fname, lineno ); + fname, lineno, 0 ); return 1; } mapping = (struct ldapmapping *)ch_calloc( 2, sizeof(struct ldapmapping) ); if ( mapping == NULL ) { - fprintf( stderr, + Debug( LDAP_DEBUG_ANY, "%s: line %d: out of memory\n", - fname, lineno ); + fname, lineno, 0 ); return 1; } ber_str2bv( src, 0, 1, &mapping[0].m_src ); @@ -127,7 +127,7 @@ rwm_map_config( if ( src[0] != '\0' ) { mapping[0].m_src_oc = oc_bvfind( &mapping[0].m_src ); if ( mapping[0].m_src_oc == NULL ) { - fprintf( stderr, + Debug( LDAP_DEBUG_ANY, "%s: line %d: warning, source objectClass '%s' " "should be defined in schema\n", fname, lineno, src ); @@ -145,14 +145,14 @@ rwm_map_config( mapping[0].m_dst_oc = oc_bvfind( &mapping[0].m_dst ); if ( mapping[0].m_dst_oc == NULL ) { - fprintf( stderr, + Debug( LDAP_DEBUG_ANY, "%s: line %d: warning, destination objectClass '%s' " "is not defined in schema\n", fname, lineno, dst ); mapping[0].m_dst_oc = oc_bvfind_undef( &mapping[0].m_dst ); if ( mapping[0].m_dst_oc == NULL ) { - fprintf( stderr, "%s: line %d: unable to mimic destination objectClass '%s'\n", + Debug( LDAP_DEBUG_ANY, "%s: line %d: unable to mimic destination objectClass '%s'\n", fname, lineno, dst ); goto error_return; } @@ -170,7 +170,7 @@ rwm_map_config( rc = slap_bv2ad( &mapping[0].m_src, &mapping[0].m_src_ad, &text ); if ( rc != LDAP_SUCCESS ) { - fprintf( stderr, + Debug( LDAP_DEBUG_ANY, "%s: line %d: warning, source attributeType '%s' " "should be defined in schema\n", fname, lineno, src ); @@ -184,9 +184,12 @@ rwm_map_config( &mapping[0].m_src_ad, &text, SLAP_AD_PROXIED ); if ( rc != LDAP_SUCCESS ) { - fprintf( stderr, - "%s: line %d: source attributeType '%s': %d (%s)\n", - fname, lineno, src, rc, text ? text : "null" ); + char prefix[1024]; + snprintf( prefix, sizeof(prefix), + "%s: line %d: source attributeType '%s': %d", + fname, lineno, src, rc ); + Debug( LDAP_DEBUG_ANY, "%s (%s)\n", + prefix, text ? text : "null", 0 ); goto error_return; } @@ -196,7 +199,7 @@ rwm_map_config( rc = slap_bv2ad( &mapping[0].m_dst, &mapping[0].m_dst_ad, &text ); if ( rc != LDAP_SUCCESS ) { - fprintf( stderr, + Debug( LDAP_DEBUG_ANY, "%s: line %d: warning, destination attributeType '%s' " "is not defined in schema\n", fname, lineno, dst ); @@ -205,9 +208,12 @@ rwm_map_config( &mapping[0].m_dst_ad, &text, SLAP_AD_PROXIED ); if ( rc != LDAP_SUCCESS ) { - fprintf( stderr, - "%s: line %d: destination attributeType '%s': %d (%s)\n", - fname, lineno, dst, rc, text ? text : "null" ); + char prefix[1024]; + snprintf( prefix, sizeof(prefix), + "%s: line %d: destination attributeType '%s': %d", + fname, lineno, dst, rc ); + Debug( LDAP_DEBUG_ANY, "%s (%s)\n", + prefix, text ? text : "null", 0 ); goto error_return; } } @@ -217,9 +223,9 @@ rwm_map_config( if ( ( src[0] != '\0' && avl_find( map->map, (caddr_t)mapping, rwm_mapping_cmp ) != NULL) || avl_find( map->remap, (caddr_t)&mapping[1], rwm_mapping_cmp ) != NULL) { - fprintf( stderr, + Debug( LDAP_DEBUG_ANY, "%s: line %d: duplicate mapping found.\n", - fname, lineno ); + fname, lineno, 0 ); /* FIXME: free stuff */ goto error_return; } diff --git a/servers/slapd/overlays/sssvlv.c b/servers/slapd/overlays/sssvlv.c index a024db2cc0..10dde1f249 100644 --- a/servers/slapd/overlays/sssvlv.c +++ b/servers/slapd/overlays/sssvlv.c @@ -1236,11 +1236,11 @@ int sssvlv_initialize() if ( rc == LDAP_SUCCESS ) { rc = overlay_register( &sssvlv ); if ( rc != LDAP_SUCCESS ) { - fprintf( stderr, "Failed to register server side sort overlay\n" ); + Debug( LDAP_DEBUG_ANY, "Failed to register server side sort overlay\n", 0, 0, 0 ); } } else { - fprintf( stderr, "Failed to register control %d\n", rc ); + Debug( LDAP_DEBUG_ANY, "Failed to register control %d\n", rc, 0, 0 ); } return rc; diff --git a/servers/slapd/overlays/valsort.c b/servers/slapd/overlays/valsort.c index 5f5c2e10bc..9f57ece910 100644 --- a/servers/slapd/overlays/valsort.c +++ b/servers/slapd/overlays/valsort.c @@ -568,7 +568,7 @@ int valsort_initialize( void ) SLAP_CTRL_SEARCH | SLAP_CTRL_HIDE, NULL, valsort_parseCtrl, &valsort_cid ); if ( rc != LDAP_SUCCESS ) { - fprintf( stderr, "Failed to register control %d\n", rc ); + Debug( LDAP_DEBUG_ANY, "Failed to register control %d\n", rc, 0, 0 ); return rc; } -- 2.39.5