From: Pierangelo Masarati Date: Sat, 10 Sep 2005 18:42:33 +0000 (+0000) Subject: put logging under Debug(); silence warnings; s/warnings/errors/ #ifdef'd X-Git-Tag: OPENLDAP_REL_ENG_2_2_MP~442 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ceb9c15bdd1d0e1cbe8d17f6101897863856e8c2;p=openldap put logging under Debug(); silence warnings; s/warnings/errors/ #ifdef'd --- diff --git a/servers/slapd/aclparse.c b/servers/slapd/aclparse.c index 258917a639..339bc6a582 100644 --- a/servers/slapd/aclparse.c +++ b/servers/slapd/aclparse.c @@ -84,7 +84,7 @@ slap_dynacl_config( for ( da = b->a_dynacl; da; da = da->da_next ) { if ( strcasecmp( da->da_name, name ) == 0 ) { - fprintf( stderr, + Debug( LDAP_DEBUG_ANY, "%s: line %d: dynacl \"%s\" already specified.\n", fname, lineno, name ); acl_usage(); @@ -119,8 +119,8 @@ regtest(const char *fname, int lineno, char *pat) { int e; regex_t re; - char buf[512]; - unsigned size; + char buf[ SLAP_TEXT_BUFLEN ]; + unsigned size; char *sp; char *dp; @@ -151,18 +151,23 @@ regtest(const char *fname, int lineno, char *pat) { *dp = '\0'; if ( size >= (sizeof(buf) - 1) ) { - fprintf( stderr, + Debug( LDAP_DEBUG_ANY, "%s: line %d: regular expression \"%s\" too large\n", fname, lineno, pat ); acl_usage(); } if ((e = regcomp(&re, buf, REG_EXTENDED|REG_ICASE))) { - char error[512]; + char error[ SLAP_TEXT_BUFLEN ]; + regerror(e, &re, error, sizeof(error)); - fprintf( stderr, - "%s: line %d: regular expression \"%s\" bad because of %s\n", - fname, lineno, pat, error ); + + snprintf( buf, sizeof( buf ), + "regular expression \"%s\" bad because of %s", + pat, error ); + Debug( LDAP_DEBUG_ANY, + "%s: line %d: %s\n", + fname, lineno, buf ); acl_usage(); } regfree(&re); @@ -183,7 +188,7 @@ regtest(const char *fname, int lineno, char *pat) { static int check_scope( BackendDB *be, AccessControl *a ) { - int patlen; + ber_len_t patlen; struct berval dn; dn = be->be_nsuffix[0]; @@ -252,7 +257,8 @@ regex_done:; * more than one level between the suffix * and the pattern */ if ( style == ACL_STYLE_ONE ) { - int rdnlen = -1, sep = 0; + ber_len_t rdnlen = 0; + int sep = 0; if ( patlen > 0 ) { if ( !DN_SEPARATOR( dn.bv_val[dn.bv_len - patlen - 1] )) { @@ -261,7 +267,7 @@ regex_done:; sep = 1; } - rdnlen = dn_rdnlen( NULL, &dn ); + rdnlen = (ber_len_t)dn_rdnlen( NULL, &dn ); if ( rdnlen != dn.bv_len - patlen - sep ) return ACL_SCOPE_ERR; } @@ -329,9 +335,9 @@ parse_acl( /* to clause - select which entries are protected */ if ( strcasecmp( argv[i], "to" ) == 0 ) { if ( a != NULL ) { - fprintf( stderr, "%s: line %d: " + Debug( LDAP_DEBUG_ANY, "%s: line %d: " "only one to clause allowed in access line\n", - fname, lineno ); + fname, lineno, 0 ); acl_usage(); } a = (AccessControl *) ch_calloc( 1, sizeof(AccessControl) ); @@ -345,10 +351,10 @@ parse_acl( if ( !BER_BVISEMPTY( &a->acl_dn_pat ) || a->acl_dn_style != ACL_STYLE_REGEX ) { - fprintf( stderr, + Debug( LDAP_DEBUG_ANY, "%s: line %d: dn pattern" " already specified in to clause.\n", - fname, lineno ); + fname, lineno, 0 ); acl_usage(); } @@ -360,7 +366,7 @@ parse_acl( split( left, '.', &left, &style ); if ( right == NULL ) { - fprintf( stderr, "%s: line %d: " + Debug( LDAP_DEBUG_ANY, "%s: line %d: " "missing \"=\" in \"%s\" in to clause\n", fname, lineno, left ); acl_usage(); @@ -370,10 +376,10 @@ parse_acl( if ( !BER_BVISEMPTY( &a->acl_dn_pat ) || a->acl_dn_style != ACL_STYLE_REGEX ) { - fprintf( stderr, + Debug( LDAP_DEBUG_ANY, "%s: line %d: dn pattern" " already specified in to clause.\n", - fname, lineno ); + fname, lineno, 0 ); acl_usage(); } @@ -429,7 +435,7 @@ parse_acl( } } else { - fprintf( stderr, "%s: line %d: " + Debug( LDAP_DEBUG_ANY, "%s: line %d: " "unknown dn style \"%s\" in to clause\n", fname, lineno, style ); acl_usage(); @@ -440,7 +446,7 @@ parse_acl( if ( strcasecmp( left, "filter" ) == 0 ) { if ( (a->acl_filter = str2filter( right )) == NULL ) { - fprintf( stderr, + Debug( LDAP_DEBUG_ANY, "%s: line %d: bad filter \"%s\" in to clause\n", fname, lineno, right ); acl_usage(); @@ -452,7 +458,7 @@ parse_acl( a->acl_attrs = str2anlist( a->acl_attrs, right, "," ); if ( a->acl_attrs == NULL ) { - fprintf( stderr, + Debug( LDAP_DEBUG_ANY, "%s: line %d: unknown attr \"%s\" in to clause\n", fname, lineno, right ); acl_usage(); @@ -462,16 +468,16 @@ parse_acl( char *mr; if ( !BER_BVISEMPTY( &a->acl_attrval ) ) { - fprintf( stderr, + Debug( LDAP_DEBUG_ANY, "%s: line %d: attr val already specified in to clause.\n", - fname, lineno ); + fname, lineno, 0 ); acl_usage(); } if ( a->acl_attrs == NULL || !BER_BVISEMPTY( &a->acl_attrs[1].an_name ) ) { - fprintf( stderr, + Debug( LDAP_DEBUG_ANY, "%s: line %d: attr val requires a single attribute.\n", - fname, lineno ); + fname, lineno, 0 ); acl_usage(); } @@ -485,7 +491,7 @@ parse_acl( a->acl_attrval_mr = mr_find( mr ); if ( a->acl_attrval_mr == NULL ) { - fprintf( stderr, "%s: line %d: " + Debug( LDAP_DEBUG_ANY, "%s: line %d: " "invalid matching rule \"%s\".\n", fname, lineno, mr ); acl_usage(); @@ -493,11 +499,16 @@ parse_acl( if( !mr_usable_with_at( a->acl_attrval_mr, a->acl_attrs[ 0 ].an_desc->ad_type ) ) { - fprintf( stderr, "%s: line %d: " + char buf[ SLAP_TEXT_BUFLEN ]; + + snprintf( buf, sizeof( buf ), "matching rule \"%s\" use " - "with attr \"%s\" not appropriate.\n", - fname, lineno, mr, - a->acl_attrs[ 0 ].an_name.bv_val ); + "with attr \"%s\" not appropriate.", + mr, a->acl_attrs[ 0 ].an_name.bv_val ); + + + Debug( LDAP_DEBUG_ANY, "%s: line %d: %s\n", + fname, lineno, buf ); acl_usage(); } } @@ -507,11 +518,17 @@ parse_acl( int e = regcomp( &a->acl_attrval_re, a->acl_attrval.bv_val, REG_EXTENDED | REG_ICASE | REG_NOSUB ); if ( e ) { - char buf[512]; - regerror( e, &a->acl_attrval_re, buf, sizeof(buf) ); - fprintf( stderr, "%s: line %d: " - "regular expression \"%s\" bad because of %s\n", - fname, lineno, right, buf ); + char err[SLAP_TEXT_BUFLEN], + buf[ SLAP_TEXT_BUFLEN ]; + + regerror( e, &a->acl_attrval_re, err, sizeof( err ) ); + + snprintf( buf, sizeof( buf ), + "regular expression \"%s\" bad because of %s", + right, err ); + + Debug( LDAP_DEBUG_ANY, "%s: line %d: %s\n", + fname, lineno, buf ); acl_usage(); } a->acl_attrval_style = ACL_STYLE_REGEX; @@ -543,33 +560,61 @@ parse_acl( } else if ( !strcasecmp( style, "children" ) ) { a->acl_attrval_style = ACL_STYLE_CHILDREN; } else { - fprintf( stderr, - "%s: line %d: unknown val.