From: Kurt Zeilenga Date: Mon, 11 Jul 2005 07:55:29 +0000 (+0000) Subject: Sync with HEAD X-Git-Tag: OPENLDAP_REL_ENG_2_3_5~32 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=332fcf809a076531205c9c633b1b0178af38f1cd;p=openldap Sync with HEAD --- diff --git a/servers/slapd/acl.c b/servers/slapd/acl.c index 0276f35075..40de548d29 100644 --- a/servers/slapd/acl.c +++ b/servers/slapd/acl.c @@ -88,7 +88,7 @@ typedef enum slap_aci_scope_t { SLAP_ACI_SCOPE_SUBTREE = ( SLAP_ACI_SCOPE_ENTRY | SLAP_ACI_SCOPE_CHILDREN ) } slap_aci_scope_t; -static AccessControl * acl_get( +static AccessControl * slap_acl_get( AccessControl *ac, int *count, Operation *op, Entry *e, AttributeDescription *desc, @@ -96,7 +96,7 @@ static AccessControl * acl_get( int nmatch, regmatch_t *matches, AccessControlState *state ); -static slap_control_t acl_mask( +static slap_control_t slap_acl_mask( AccessControl *ac, slap_mask_t *mask, Operation *op, Entry *e, AttributeDescription *desc, @@ -142,7 +142,7 @@ static int aci_match_set ( struct berval *subj, Operation *op, * the whole attribute is assumed (all values). * * This routine loops through all access controls and calls - * acl_mask() on each applicable access control. + * slap_acl_mask() on each applicable access control. * The loop exits when a definitive answer is reached or * or no more controls remain. * @@ -281,7 +281,7 @@ slap_access_allowed( memset( matches, '\0', sizeof( matches ) ); } - while ( ( a = acl_get( a, &count, op, e, desc, val, + while ( ( a = slap_acl_get( a, &count, op, e, desc, val, MAXREMATCHES, matches, state ) ) != NULL ) { int i; @@ -315,7 +315,7 @@ slap_access_allowed( } vd_access: - control = acl_mask( a, &mask, op, + control = slap_acl_mask( a, &mask, op, e, desc, val, MAXREMATCHES, matches, count, state ); if ( control != ACL_BREAK ) { @@ -683,7 +683,7 @@ access_allowed_mask( memset( matches, '\0', sizeof(matches) ); } - while ( ( a = acl_get( a, &count, op, e, desc, val, + while ( ( a = slap_acl_get( a, &count, op, e, desc, val, MAXREMATCHES, matches, state ) ) != NULL ) { int i; @@ -717,7 +717,7 @@ access_allowed_mask( } vd_access: - control = acl_mask( a, &mask, op, + control = slap_acl_mask( a, &mask, op, e, desc, val, MAXREMATCHES, matches, count, state ); if ( control != ACL_BREAK ) { @@ -765,13 +765,13 @@ done: #endif /* SLAP_OVERLAY_ACCESS */ /* - * acl_get - return the acl applicable to entry e, attribute + * slap_acl_get - return the acl applicable to entry e, attribute * attr. the acl returned is suitable for use in subsequent calls to * acl_access_allowed(). */ static AccessControl * -acl_get( +slap_acl_get( AccessControl *a, int *count, Operation *op, @@ -881,7 +881,7 @@ acl_get( if( state && !( state->as_recorded & ACL_STATE_RECORDED_VD )) { state->as_recorded |= ACL_STATE_RECORDED_VD; - state->as_vd_acl = prev; + state->as_vd_acl = a; state->as_vd_acl_count = *count; state->as_vd_access = a->acl_access; state->as_vd_access_count = 1; @@ -906,7 +906,7 @@ 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; @@ -1353,7 +1353,7 @@ acl_mask_dnattr( /* - * acl_mask - modifies mask based upon the given acl and the + * slap_acl_mask - modifies mask based upon the given acl and the * requested access to entry e, attribute attr, value val. if val * is null, access to the whole attribute is assumed (all values). * @@ -1362,7 +1362,7 @@ acl_mask_dnattr( */ static slap_control_t -acl_mask( +slap_acl_mask( AccessControl *a, slap_mask_t *mask, Operation *op, @@ -1978,7 +1978,7 @@ acl_mask( continue; } - /* this could be improved by changing acl_mask so that it can deal with + /* this could be improved by changing slap_acl_mask so that it can deal with * by clauses that return grant/deny pairs. Right now, it does either * additive or subtractive rights, but not both at the same time. So, * we need to combine the grant/deny pair into a single rights mask in @@ -2131,7 +2131,7 @@ acl_mask( continue; } - /* this could be improved by changing acl_mask so that it can deal with + /* this could be improved by changing slap_acl_mask so that it can deal with * by clauses that return grant/deny pairs. Right now, it does either * additive or subtractive rights, but not both at the same time. So, * we need to combine the grant/deny pair into a single rights mask in @@ -3173,7 +3173,7 @@ dynacl_aci_parse( const char *fname, int lineno, slap_style_t sty, const char *r if ( sty != ACL_STYLE_REGEX && sty != ACL_STYLE_BASE ) { fprintf( stderr, "%s: line %d: " "inappropriate style \"%s\" in \"aci\" by clause\n", - fname, lineno, sty ); + fname, lineno, style_strings[sty] ); return -1; } diff --git a/servers/slapd/aclparse.c b/servers/slapd/aclparse.c index 01688dcb8d..b1760206ff 100644 --- a/servers/slapd/aclparse.c +++ b/servers/slapd/aclparse.c @@ -39,7 +39,7 @@ #include "lutil.h" static const char style_base[] = "base"; -static char *style_strings[] = { +char *style_strings[] = { "regex", "expand", "exact", @@ -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.