mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-26 09:39:45 -05:00
ITS#10048 Improve regex config error handling
This commit is contained in:
parent
72837dd74c
commit
f0d3f31d9a
3 changed files with 36 additions and 6 deletions
|
|
@ -0,0 +1,4 @@
|
|||
dn: name={3}regex,olcOverlay={0}variant,olcDatabase={1}mdb,cn=config
|
||||
changetype: modify
|
||||
replace: olcVariantEntryRegex
|
||||
olcVariantEntryRegex: (.*),(ou=.*technology.*)(,)dc=example,dc=com
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
dn: name=regex,olcOverlay={0}variant,olcDatabase={1}@BACKEND@,cn=config
|
||||
changetype: add
|
||||
objectclass: olcVariantRegex
|
||||
olcVariantEntryRegex: .*
|
||||
|
|
@ -864,6 +864,9 @@ variant_set_dn( ConfigArgs *ca )
|
|||
|
||||
dnMatch( &diff, 0, NULL, NULL, &vei->dn, &vei2->dn );
|
||||
if ( !diff ) {
|
||||
snprintf( ca->cr_msg, sizeof(ca->cr_msg),
|
||||
"duplicate variant dn: %s", ca->value_ndn.bv_val );
|
||||
Debug( LDAP_DEBUG_ANY, "%s: %s\n", ca->log, ca->cr_msg );
|
||||
return LDAP_CONSTRAINT_VIOLATION;
|
||||
}
|
||||
}
|
||||
|
|
@ -884,7 +887,11 @@ variant_set_regex( ConfigArgs *ca )
|
|||
} else if ( ca->op == LDAP_MOD_DELETE ) {
|
||||
ber_memfree( vei->dn.bv_val );
|
||||
BER_BVZERO( &vei->dn );
|
||||
regfree( vei->regex );
|
||||
if ( vei->regex ) {
|
||||
regfree( vei->regex );
|
||||
ch_free( vei->regex );
|
||||
vei->regex = NULL;
|
||||
}
|
||||
return LDAP_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
@ -905,8 +912,9 @@ variant_set_regex( ConfigArgs *ca )
|
|||
if ( vei == vei2 ) continue;
|
||||
|
||||
if ( !ber_bvcmp( &ca->value_bv, &vei2->dn ) ) {
|
||||
ch_free( vei );
|
||||
ca->ca_private = NULL;
|
||||
snprintf( ca->cr_msg, sizeof(ca->cr_msg),
|
||||
"duplicate variant regex: %s", ca->value_dn.bv_val );
|
||||
Debug( LDAP_DEBUG_ANY, "%s: %s\n", ca->log, ca->cr_msg );
|
||||
return LDAP_CONSTRAINT_VIOLATION;
|
||||
}
|
||||
}
|
||||
|
|
@ -914,7 +922,10 @@ variant_set_regex( ConfigArgs *ca )
|
|||
vei->regex = ch_calloc( 1, sizeof(regex_t) );
|
||||
if ( regcomp( vei->regex, vei->dn.bv_val, REG_EXTENDED ) ) {
|
||||
ch_free( vei->regex );
|
||||
ch_free( vei->dn.bv_val );
|
||||
vei->regex = NULL;
|
||||
snprintf( ca->cr_msg, sizeof(ca->cr_msg),
|
||||
"cannot process regex: %s", vei->dn.bv_val );
|
||||
Debug( LDAP_DEBUG_ANY, "%s: %s\n", ca->log, ca->cr_msg );
|
||||
return LDAP_CONSTRAINT_VIOLATION;
|
||||
}
|
||||
|
||||
|
|
@ -963,9 +974,10 @@ variant_set_alt_pattern( ConfigArgs *ca )
|
|||
if ( ( ( *p >= '0' ) && ( *p <= '9' ) ) || ( *p == '$' ) ) {
|
||||
p += 1;
|
||||
} else {
|
||||
Debug( LDAP_DEBUG_ANY, "variant_set_alt_pattern: "
|
||||
"invalid replacement pattern supplied '%s'\n",
|
||||
snprintf( ca->cr_msg, sizeof(ca->cr_msg),
|
||||
"invalid replacement pattern supplied '%s'",
|
||||
ca->value_bv.bv_val );
|
||||
Debug( LDAP_DEBUG_ANY, "%s: %s\n", ca->log, ca->cr_msg );
|
||||
return LDAP_CONSTRAINT_VIOLATION;
|
||||
}
|
||||
}
|
||||
|
|
@ -1009,6 +1021,9 @@ variant_set_attribute( ConfigArgs *ca )
|
|||
rc = slap_str2ad( s, ad, &text );
|
||||
ber_memfree( ca->value_string );
|
||||
if ( rc ) {
|
||||
snprintf( ca->cr_msg, sizeof(ca->cr_msg),
|
||||
"attribute %s invalid: %s", s, text );
|
||||
Debug( LDAP_DEBUG_ANY, "%s: %s\n", ca->log, ca->cr_msg );
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
@ -1016,6 +1031,10 @@ variant_set_attribute( ConfigArgs *ca )
|
|||
if ( vai->attr && vai->alternative &&
|
||||
vai->attr->ad_type->sat_syntax !=
|
||||
vai->alternative->ad_type->sat_syntax ) {
|
||||
snprintf( ca->cr_msg, sizeof(ca->cr_msg),
|
||||
"attribute '%s' syntax doesn't match alternative attribute '%s'",
|
||||
vai->attr->ad_cname.bv_val, vai->alternative->ad_cname.bv_val );
|
||||
Debug( LDAP_DEBUG_ANY, "%s: %s\n", ca->log, ca->cr_msg );
|
||||
return LDAP_CONSTRAINT_VIOLATION;
|
||||
}
|
||||
|
||||
|
|
@ -1024,6 +1043,9 @@ variant_set_attribute( ConfigArgs *ca )
|
|||
LDAP_SLIST_FOREACH( vai2, &vai->variant->attributes, next ) {
|
||||
if ( vai == vai2 ) continue;
|
||||
if ( vai->attr == vai2->attr ) {
|
||||
snprintf( ca->cr_msg, sizeof(ca->cr_msg),
|
||||
"duplicate attribute '%s'", vai->attr->ad_cname.bv_val );
|
||||
Debug( LDAP_DEBUG_ANY, "%s: %s\n", ca->log, ca->cr_msg );
|
||||
return LDAP_CONSTRAINT_VIOLATION;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue