#include "lutil.h"
static const char style_base[] = "base";
-static char *style_strings[] = {
+char *style_strings[] = {
"regex",
"expand",
"exact",
}
} 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",
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,
} 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" ) )
{
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\" "
}
}
}
-
+
+ /* 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",
{
free( a->acl_dn_pat.bv_val );
BER_BVZERO( &a->acl_dn_pat );
+ a->acl_dn_style = ACL_STYLE_REGEX;
}
if ( !BER_BVISEMPTY( &a->acl_dn_pat ) ||
fprintf( stderr,
"%s: line %d: \"onelevel\" should be used "
"instead of \"level{1}\" in by DN clause\n",
- fname, lineno, 0 );
+ fname, lineno );
} else if ( level == 0 && sty == ACL_STYLE_LEVEL ) {
fprintf( stderr,
"%s: line %d: \"base\" should be used "
"instead of \"level{0}\" in by DN clause\n",
- fname, lineno, 0 );
+ fname, lineno );
}
bdn->a_level = level;
fprintf( stderr, "%s: line %d: "
"deprecated group style \"regex\"; "
"use \"expand\" instead\n",
- fname, lineno, style );
+ fname, lineno );
sty = ACL_STYLE_EXPAND;
break;
"<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"