X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Faclparse.c;h=b1760206ffa8092121459363cd1a52cedb4aa798;hb=46fab059977aed107f53c96ced0f35cfff8c7836;hp=5a7184a25ee60a748f6f5445f66d59d546f920e7;hpb=b5ef8ea6f404e4c7d6e288a55ec3156959cec744;p=openldap diff --git a/servers/slapd/aclparse.c b/servers/slapd/aclparse.c index 5a7184a25e..b1760206ff 100644 --- a/servers/slapd/aclparse.c +++ b/servers/slapd/aclparse.c @@ -38,10 +38,11 @@ #include "lber_pvt.h" #include "lutil.h" -static char *style_strings[] = { +static const char style_base[] = "base"; +char *style_strings[] = { "regex", "expand", - "base", + "exact", "one", "subtree", "children", @@ -438,8 +439,9 @@ parse_acl( acl_usage(); } - } else if ( strcasecmp( left, "attr" ) == 0 - || strcasecmp( left, "attrs" ) == 0 ) { + } else if ( strcasecmp( left, "attr" ) == 0 /* TOLERATED */ + || strcasecmp( left, "attrs" ) == 0 ) /* DOCUMENTED */ + { a->acl_attrs = str2anlist( a->acl_attrs, right, "," ); if ( a->acl_attrs == NULL ) { @@ -450,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", @@ -463,62 +467,121 @@ parse_acl( fname, lineno ); acl_usage(); } + ber_str2bv( right, 0, 1, &a->acl_attrval ); - if ( style && strcasecmp( style, "regex" ) == 0 ) { - 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) ); + 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: " - "regular expression \"%s\" bad because of %s\n", - fname, lineno, right, buf ); + "invalid matching rule \"%s\".\n", + fname, lineno, mr ); acl_usage(); } - a->acl_attrval_style = ACL_STYLE_REGEX; - } else { - /* FIXME: if the attribute has DN syntax, we might - * allow one, subtree and children styles as well */ - if ( !strcasecmp( style, "exact" ) ) { - a->acl_attrval_style = ACL_STYLE_BASE; - } else if ( a->acl_attrs[0].an_desc->ad_type-> - sat_syntax == slap_schema.si_syn_distinguishedName ) + if( !mr_usable_with_at( a->acl_attrval_mr, a->acl_attrs[ 0 ].an_desc->ad_type ) ) { - if ( !strcasecmp( style, "baseObject" ) || - !strcasecmp( style, "base" ) ) - { + 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, + 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 ); + acl_usage(); + } + a->acl_attrval_style = ACL_STYLE_REGEX; + + } else { + /* FIXME: if the attribute has DN syntax, we might + * allow one, subtree and children styles as well */ + if ( !strcasecmp( style, "base" ) || + !strcasecmp( style, "exact" ) ) { a->acl_attrval_style = ACL_STYLE_BASE; - } else if ( !strcasecmp( style, "onelevel" ) || - !strcasecmp( style, "one" ) ) - { - a->acl_attrval_style = ACL_STYLE_ONE; - } else if ( !strcasecmp( style, "subtree" ) || - !strcasecmp( style, "sub" ) ) + + } else if ( a->acl_attrs[0].an_desc->ad_type-> + sat_syntax == slap_schema.si_syn_distinguishedName ) { - a->acl_attrval_style = ACL_STYLE_SUBTREE; - } else if ( !strcasecmp( style, "children" ) ) { - a->acl_attrval_style = ACL_STYLE_CHILDREN; + struct berval bv; + + if ( !strcasecmp( style, "baseObject" ) || + !strcasecmp( style, "base" ) ) + { + a->acl_attrval_style = ACL_STYLE_BASE; + } else if ( !strcasecmp( style, "onelevel" ) || + !strcasecmp( style, "one" ) ) + { + a->acl_attrval_style = ACL_STYLE_ONE; + } else if ( !strcasecmp( style, "subtree" ) || + !strcasecmp( style, "sub" ) ) + { + a->acl_attrval_style = ACL_STYLE_SUBTREE; + } else if ( !strcasecmp( style, "children" ) ) { + a->acl_attrval_style = ACL_STYLE_CHILDREN; + } else { + fprintf( stderr, + "%s: line %d: unknown val.