From: Greg Burd Date: Thu, 10 Aug 2023 16:39:15 +0000 (-0400) Subject: ITS#10089 - convert Debug to use config args X-Git-Tag: OPENLDAP_REL_ENG_2_5_17~48 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7b693aadc1572982886c719ce1ef477f4f815951;p=thirdparty%2Fopenldap.git ITS#10089 - convert Debug to use config args --- diff --git a/servers/slapd/aclparse.c b/servers/slapd/aclparse.c index bd53e9c27d..5f63ec1520 100644 --- a/servers/slapd/aclparse.c +++ b/servers/slapd/aclparse.c @@ -121,7 +121,7 @@ slap_dynacl_config( #endif /* SLAP_DYNACL */ static int -regtest(const char *fname, int lineno, char *pat) { +regtest(struct config_args_s *c, char *pat) { int e; regex_t re; @@ -157,21 +157,21 @@ regtest(const char *fname, int lineno, char *pat) { *dp = '\0'; if ( size >= (sizeof(buf) - 1) ) { - Debug( LDAP_DEBUG_ANY, - "%s: line %d: regular expression \"%s\" too large\n", - fname, lineno, pat ); + snprintf( c->cr_msg, sizeof( c->cr_msg), + "regular expression too large \"%s\"", pat); + Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); (void)acl_usage(); return -1; } - if ((e = regcomp(&re, buf, REG_EXTENDED|REG_ICASE))) { + if ( (e = regcomp(&re, buf, REG_EXTENDED|REG_ICASE)) ) { char error[ SLAP_TEXT_BUFLEN ]; regerror(e, &re, error, sizeof(error)); - Debug(LDAP_DEBUG_ANY, - "%s: line %d: regular expression \"%s\" bad because of %s\n", - fname, lineno, pat, error ); + snprintf( c->cr_msg, sizeof ( c->cr_msg ), + "regular expression \"%s\" bad because of %s", pat, error); + Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); acl_usage(); regfree(&re); return -1; @@ -215,7 +215,7 @@ check_scope( BackendDB *be, AccessControl *a ) ber_len_t rebuflen; regex_t re; int rc; - + /* add trailing '$' to database suffix to form * a simple trial regex pattern "$" */ AC_MEMCPY( dnbuf, be->be_nsuffix[0].bv_val, @@ -359,10 +359,9 @@ parse_acl( if ( !BER_BVISEMPTY( &a->acl_dn_pat ) || a->acl_dn_style != ACL_STYLE_REGEX ) { - Debug( LDAP_DEBUG_ANY, - "%s: line %d: dn pattern" - " already specified in to clause.\n", - fname, lineno ); + snprintf( c->cr_msg, sizeof( c->cr_msg ), + "dn pattern already specified in to clause." ); + Debug( LDAP_DEBUG_ANY, "%s: %s.", c->log, c->cr_msg ); goto fail; } @@ -374,9 +373,9 @@ parse_acl( split( left, '.', &left, &style ); if ( right == NULL ) { - Debug( LDAP_DEBUG_ANY, "%s: line %d: " - "missing \"=\" in \"%s\" in to clause\n", - fname, lineno, left ); + snprintf( c->cr_msg, sizeof( c->cr_msg ), + "missing \"=\" in \"%s\" in to clause", left ); + Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); goto fail; } @@ -384,10 +383,9 @@ parse_acl( if ( !BER_BVISEMPTY( &a->acl_dn_pat ) || a->acl_dn_style != ACL_STYLE_REGEX ) { - Debug( LDAP_DEBUG_ANY, - "%s: line %d: dn pattern" - " already specified in to clause.\n", - fname, lineno ); + snprintf( c->cr_msg, sizeof( c->cr_msg), + "dn pattern already specified in to clause" ); + Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); goto fail; } @@ -428,12 +426,12 @@ parse_acl( a->acl_dn_style = ACL_STYLE_BASE; ber_str2bv( right, 0, 1, &a->acl_dn_pat ); - } else if ( strcmp(right, "*") == 0 - || strcmp(right, ".*") == 0 - || strcmp(right, ".*$") == 0 - || strcmp(right, "^.*") == 0 + } else if ( strcmp(right, "*") == 0 + || strcmp(right, ".*") == 0 + || strcmp(right, ".*$") == 0 + || strcmp(right, "^.*") == 0 || strcmp(right, "^.*$") == 0 - || strcmp(right, ".*$$") == 0 + || strcmp(right, ".*$$") == 0 || strcmp(right, "^.*$$") == 0 ) { ber_str2bv( "*", STRLENOF("*"), 1, &a->acl_dn_pat ); @@ -443,9 +441,9 @@ parse_acl( } } else { - Debug( LDAP_DEBUG_ANY, "%s: line %d: " - "unknown dn style \"%s\" in to clause\n", - fname, lineno, style ); + snprintf( c->cr_msg, sizeof( c->cr_msg ), + "unknown dn style \"%s\" in to clause", style ); + Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); goto fail; } @@ -454,9 +452,9 @@ parse_acl( if ( strcasecmp( left, "filter" ) == 0 ) { if ( (a->acl_filter = str2filter( right )) == NULL ) { - Debug( LDAP_DEBUG_ANY, - "%s: line %d: bad filter \"%s\" in to clause\n", - fname, lineno, right ); + snprintf( c->cr_msg, sizeof( c->cr_msg ), + "bad filter \"%s\" in to clause", right ); + Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); goto fail; } @@ -464,37 +462,36 @@ parse_acl( || strcasecmp( left, "attrs" ) == 0 ) /* DOCUMENTED */ { if ( strcasecmp( left, "attr" ) == 0 ) { - Debug( LDAP_DEBUG_ANY, - "%s: line %d: \"attr\" " - "is deprecated (and undocumented); " - "use \"attrs\" instead.\n", - fname, lineno ); + snprintf( c->cr_msg, sizeof( c->cr_msg ), + "\"attr\" is deprecated (and undocumented); " + "use \"attrs\" instead"); + Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); } a->acl_attrs = str2anlist( a->acl_attrs, right, "," ); if ( a->acl_attrs == NULL ) { - Debug( LDAP_DEBUG_ANY, - "%s: line %d: unknown attr \"%s\" in to clause\n", - fname, lineno, right ); + snprintf( c->cr_msg, sizeof( c->cr_msg ), + "unknown attr \"%s\" in to clause", right ); + Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); goto fail; } } else if ( strncasecmp( left, "val", 3 ) == 0 ) { struct berval bv; char *mr; - + if ( !BER_BVISEMPTY( &a->acl_attrval ) ) { - Debug( LDAP_DEBUG_ANY, - "%s: line %d: attr val already specified in to clause.\n", - fname, lineno ); + snprintf( c->cr_msg, sizeof( c->cr_msg ), + "attr val already specified in to clause" ); + Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); goto fail; } if ( a->acl_attrs == NULL || !BER_BVISEMPTY( &a->acl_attrs[1].an_name ) ) { - Debug( LDAP_DEBUG_ANY, - "%s: line %d: attr val requires a single attribute.\n", - fname, lineno ); + snprintf( c->cr_msg, sizeof( c->cr_msg ), + "attr val requires a single attribute"); + Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); goto fail; } @@ -508,23 +505,23 @@ parse_acl( a->acl_attrval_mr = mr_find( mr ); if ( a->acl_attrval_mr == NULL ) { - Debug( LDAP_DEBUG_ANY, "%s: line %d: " - "invalid matching rule \"%s\".\n", - fname, lineno, mr ); + snprintf( c->cr_msg, sizeof( c->cr_msg ), + "invalid matching rule \"%s\"", mr); + Debug( LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->cr_msg ); goto fail; } if( !mr_usable_with_at( a->acl_attrval_mr, a->acl_attrs[ 0 ].an_desc->ad_type ) ) { - Debug(LDAP_DEBUG_ANY, - "%s: line %d: matching rule \"%s\" use " "with attr \"%s\" not appropriate.\n", - fname, lineno, - mr, - a->acl_attrs[0].an_name.bv_val ); + snprintf( c->cr_msg, sizeof( c->cr_msg ), + "matching rule \"%s\" use " "with attr \"%s\" not appropriate", + mr, + a->acl_attrs[0].an_name.bv_val ); + Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c-> log, c->cr_msg ); goto fail; } } - + if ( style != NULL ) { if ( strcasecmp( style, "regex" ) == 0 ) { int e = regcomp( &a->acl_attrval_re, bv.bv_val, @@ -533,9 +530,10 @@ parse_acl( char err[SLAP_TEXT_BUFLEN]; regerror( e, &a->acl_attrval_re, err, sizeof( err ) ); - Debug(LDAP_DEBUG_ANY, - "%s: line %d: regular expression \"%s\" bad because of %s\n", - fname, lineno, right, err ); + snprintf( c->cr_msg, sizeof( c->cr_msg ), + "regular expression \"%s\" bad because of %s", + right, err ); + Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); goto fail; } a->acl_attrval_style = ACL_STYLE_REGEX; @@ -565,34 +563,31 @@ parse_acl( } else if ( !strcasecmp( style, "children" ) ) { a->acl_attrval_style = ACL_STYLE_CHILDREN; } else { - Debug(LDAP_DEBUG_CONFIG | LDAP_DEBUG_ACL, - "%s: line %d: unknown val.