mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-03-13 14:27:59 +08:00
fix further ITS#3830 issues; allow to specify a matching rule for non-DN match
This commit is contained in:
parent
54fa643a9b
commit
deec44b89a
@ -82,7 +82,7 @@ It can have the forms
|
||||
.nf
|
||||
[dn[.<dnstyle>]=]<dnpattern>
|
||||
filter=<ldapfilter>
|
||||
attrs=<attrlist>[ val[.<attrstyle>]=<attrval>]
|
||||
attrs=<attrlist>[ val[/matchingRule][.<attrstyle>]=<attrval>]
|
||||
.fi
|
||||
.LP
|
||||
with
|
||||
@ -190,13 +190,13 @@ form is given,
|
||||
is implied, i.e. all attributes are addressed.
|
||||
.LP
|
||||
Using the form
|
||||
.B attrs=<attr> val[.<attrstyle>]=<attrval>
|
||||
.B attrs=<attr> val[/matchingRule][.<attrstyle>]=<attrval>
|
||||
specifies access to a particular value of a single attribute.
|
||||
In this case, only a single attribute type may be given. The
|
||||
.B <attrstyle>
|
||||
.B exact
|
||||
(the default) uses the attribute's equality matching rule to compare the
|
||||
value. If the
|
||||
value, unless a different (and compatible) matching rule is specified. If the
|
||||
.B <attrstyle>
|
||||
is
|
||||
.BR regex ,
|
||||
|
@ -906,7 +906,7 @@ slap_acl_get(
|
||||
|
||||
if ( a->acl_attrs[0].an_desc->ad_type->sat_syntax != slap_schema.si_syn_distinguishedName ) {
|
||||
if (value_match( &match, desc,
|
||||
desc->ad_type->sat_equality, 0,
|
||||
/* desc->ad_type->sat_equality */ a->acl_attrval_mr, 0,
|
||||
val, &a->acl_attrval, &text ) != LDAP_SUCCESS ||
|
||||
match )
|
||||
continue;
|
||||
|
@ -452,6 +452,8 @@ parse_acl(
|
||||
}
|
||||
|
||||
} else if ( strncasecmp( left, "val", 3 ) == 0 ) {
|
||||
char *mr;
|
||||
|
||||
if ( !BER_BVISEMPTY( &a->acl_attrval ) ) {
|
||||
fprintf( stderr,
|
||||
"%s: line %d: attr val already specified in to clause.\n",
|
||||
@ -465,8 +467,34 @@ parse_acl(
|
||||
fname, lineno );
|
||||
acl_usage();
|
||||
}
|
||||
|
||||
ber_str2bv( right, 0, 1, &a->acl_attrval );
|
||||
a->acl_attrval_style = ACL_STYLE_BASE;
|
||||
|
||||
mr = strchr( left, '/' );
|
||||
if ( mr != NULL ) {
|
||||
mr[ 0 ] = '\0';
|
||||
mr++;
|
||||
|
||||
a->acl_attrval_mr = mr_find( mr );
|
||||
if ( a->acl_attrval_mr == NULL ) {
|
||||
fprintf( stderr, "%s: line %d: "
|
||||
"invalid matching rule \"%s\".\n",
|
||||
fname, lineno, mr );
|
||||
acl_usage();
|
||||
}
|
||||
|
||||
if( !mr_usable_with_at( a->acl_attrval_mr, a->acl_attrs[ 0 ].an_desc->ad_type ) )
|
||||
{
|
||||
fprintf( stderr, "%s: line %d: "
|
||||
"matching rule \"%s\" use "
|
||||
"with attr \"%s\" not appropriate.\n",
|
||||
fname, lineno, mr,
|
||||
a->acl_attrs[ 0 ].an_name.bv_val );
|
||||
acl_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if ( style != NULL ) {
|
||||
if ( strcasecmp( style, "regex" ) == 0 ) {
|
||||
int e = regcomp( &a->acl_attrval_re, a->acl_attrval.bv_val,
|
||||
@ -491,6 +519,8 @@ parse_acl(
|
||||
} else if ( a->acl_attrs[0].an_desc->ad_type->
|
||||
sat_syntax == slap_schema.si_syn_distinguishedName )
|
||||
{
|
||||
struct berval bv;
|
||||
|
||||
if ( !strcasecmp( style, "baseObject" ) ||
|
||||
!strcasecmp( style, "base" ) )
|
||||
{
|
||||
@ -515,6 +545,18 @@ parse_acl(
|
||||
a->acl_attrval_style = ACL_STYLE_BASE;
|
||||
}
|
||||
|
||||
bv = a->acl_attrval;
|
||||
rc = dnNormalize( 0, NULL, NULL, &bv, &a->acl_attrval, NULL );
|
||||
if ( rc != LDAP_SUCCESS ) {
|
||||
fprintf( stderr,
|
||||
"%s: line %d: unable to normalize DN \"%s\" "
|
||||
"for attributeType \"%s\" (%d).\n",
|
||||
fname, lineno, bv.bv_val,
|
||||
a->acl_attrs[0].an_desc->ad_cname.bv_val, rc );
|
||||
acl_usage();
|
||||
}
|
||||
ber_memfree( bv.bv_val );
|
||||
|
||||
} else {
|
||||
fprintf( stderr,
|
||||
"%s: line %d: unknown val.<style> \"%s\" "
|
||||
@ -525,7 +567,21 @@ parse_acl(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Check for appropriate matching rule */
|
||||
if ( a->acl_attrval_style != ACL_STYLE_REGEX ) {
|
||||
if ( a->acl_attrval_mr == NULL ) {
|
||||
a->acl_attrval_mr = a->acl_attrs[ 0 ].an_desc->ad_type->sat_equality;
|
||||
}
|
||||
|
||||
if ( a->acl_attrval_mr == NULL ) {
|
||||
fprintf( stderr, "%s: line %d: "
|
||||
"attr \"%s\" must have an EQUALITY matching rule.\n",
|
||||
fname, lineno, a->acl_attrs[ 0 ].an_name.bv_val );
|
||||
acl_usage();
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
fprintf( stderr,
|
||||
"%s: line %d: expecting <what> got \"%s\"\n",
|
||||
@ -2053,7 +2109,7 @@ acl_usage( void )
|
||||
"<access clause> ::= access to <what> "
|
||||
"[ by <who> <access> [ <control> ] ]+ \n"
|
||||
"<what> ::= * | [dn[.<dnstyle>]=<DN>] [filter=<filter>] [attrs=<attrlist>]\n"
|
||||
"<attrlist> ::= <attr> [val[.<attrstyle>]=<value>] | <attr> , <attrlist>\n"
|
||||
"<attrlist> ::= <attr> [val[/matchingRule][.<attrstyle>]=<value>] | <attr> , <attrlist>\n"
|
||||
"<attr> ::= <attrname> | entry | children\n",
|
||||
"<who> ::= [ * | anonymous | users | self | dn[.<dnstyle>]=<DN> ]\n"
|
||||
"\t[ realanonymous | realusers | realself | realdn[.<dnstyle>]=<DN> ]\n"
|
||||
|
@ -1440,6 +1440,7 @@ typedef struct slap_acl {
|
||||
regex_t acl_dn_re;
|
||||
struct berval acl_dn_pat;
|
||||
AttributeName *acl_attrs;
|
||||
MatchingRule *acl_attrval_mr;
|
||||
slap_style_t acl_attrval_style;
|
||||
regex_t acl_attrval_re;
|
||||
struct berval acl_attrval;
|
||||
|
Loading…
Reference in New Issue
Block a user