X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Faclparse.c;h=051e4a6fb4ace6f12a3614915d89552ae188d208;hb=c3960b98d3b5fbd6ebeb200ca7799ece7b766d50;hp=3c52759f7033aa55afc9b13438d3c3ac99913ec7;hpb=ea0047295cb73510c49f398fd8347cd762b876f6;p=openldap diff --git a/servers/slapd/aclparse.c b/servers/slapd/aclparse.c index 3c52759f70..051e4a6fb4 100644 --- a/servers/slapd/aclparse.c +++ b/servers/slapd/aclparse.c @@ -2,7 +2,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2005 The OpenLDAP Foundation. + * Copyright 1998-2006 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,12 +52,14 @@ char *style_strings[] = { "users", "self", "ip", + "ipv6", "path", NULL }; static void split(char *line, int splitchar, char **left, char **right); static void access_append(Access **l, Access *a); +static void access_free( Access *a ); static int acl_usage(void); static void acl_regex_normalized_dn(const char *src, struct berval *pat); @@ -325,14 +327,13 @@ parse_acl( int pos ) { int i; - char *left, *right, *style, *next; + char *left, *right, *style; struct berval bv; - AccessControl *a; - Access *b; + AccessControl *a = NULL; + Access *b = NULL; int rc; const char *text; - a = NULL; for ( i = 1; i < argc; i++ ) { /* to clause - select which entries are protected */ if ( strcasecmp( argv[i], "to" ) == 0 ) { @@ -340,7 +341,7 @@ parse_acl( Debug( LDAP_DEBUG_ANY, "%s: line %d: " "only one to clause allowed in access line\n", fname, lineno, 0 ); - return acl_usage(); + goto fail; } a = (AccessControl *) ch_calloc( 1, sizeof(AccessControl) ); for ( ++i; i < argc; i++ ) { @@ -357,7 +358,7 @@ parse_acl( "%s: line %d: dn pattern" " already specified in to clause.\n", fname, lineno, 0 ); - return acl_usage(); + goto fail; } ber_str2bv( "*", STRLENOF( "*" ), 1, &a->acl_dn_pat ); @@ -371,7 +372,7 @@ parse_acl( Debug( LDAP_DEBUG_ANY, "%s: line %d: " "missing \"=\" in \"%s\" in to clause\n", fname, lineno, left ); - return acl_usage(); + goto fail; } if ( strcasecmp( left, "dn" ) == 0 ) { @@ -382,7 +383,7 @@ parse_acl( "%s: line %d: dn pattern" " already specified in to clause.\n", fname, lineno, 0 ); - return acl_usage(); + goto fail; } if ( style == NULL || *style == '\0' || @@ -440,7 +441,7 @@ parse_acl( Debug( LDAP_DEBUG_ANY, "%s: line %d: " "unknown dn style \"%s\" in to clause\n", fname, lineno, style ); - return acl_usage(); + goto fail; } continue; @@ -451,7 +452,7 @@ parse_acl( Debug( LDAP_DEBUG_ANY, "%s: line %d: bad filter \"%s\" in to clause\n", fname, lineno, right ); - return acl_usage(); + goto fail; } } else if ( strcasecmp( left, "attr" ) == 0 /* TOLERATED */ @@ -471,27 +472,28 @@ parse_acl( Debug( LDAP_DEBUG_ANY, "%s: line %d: unknown attr \"%s\" in to clause\n", fname, lineno, right ); - return acl_usage(); + goto fail; } } else if ( strncasecmp( left, "val", 3 ) == 0 ) { - char *mr; + struct berval bv; + char *mr; if ( !BER_BVISEMPTY( &a->acl_attrval ) ) { Debug( LDAP_DEBUG_ANY, "%s: line %d: attr val already specified in to clause.\n", fname, lineno, 0 ); - return acl_usage(); + goto fail; } if ( a->acl_attrs == NULL || !BER_BVISEMPTY( &a->acl_attrs[1].an_name ) ) { Debug( LDAP_DEBUG_ANY, "%s: line %d: attr val requires a single attribute.\n", fname, lineno, 0 ); - return acl_usage(); + goto fail; } - ber_str2bv( right, 0, 1, &a->acl_attrval ); + ber_str2bv( right, 0, 0, &bv ); a->acl_attrval_style = ACL_STYLE_BASE; mr = strchr( left, '/' ); @@ -504,7 +506,7 @@ parse_acl( Debug( LDAP_DEBUG_ANY, "%s: line %d: " "invalid matching rule \"%s\".\n", fname, lineno, mr ); - return acl_usage(); + goto fail; } if( !mr_usable_with_at( a->acl_attrval_mr, a->acl_attrs[ 0 ].an_desc->ad_type ) ) @@ -519,13 +521,13 @@ parse_acl( Debug( LDAP_DEBUG_ANY, "%s: line %d: %s\n", fname, lineno, buf ); - return acl_usage(); + goto fail; } } if ( style != NULL ) { if ( strcasecmp( style, "regex" ) == 0 ) { - int e = regcomp( &a->acl_attrval_re, a->acl_attrval.bv_val, + int e = regcomp( &a->acl_attrval_re, bv.bv_val, REG_EXTENDED | REG_ICASE | REG_NOSUB ); if ( e ) { char err[SLAP_TEXT_BUFLEN], @@ -539,7 +541,7 @@ parse_acl( Debug( LDAP_DEBUG_ANY, "%s: line %d: %s\n", fname, lineno, buf ); - return acl_usage(); + goto fail; } a->acl_attrval_style = ACL_STYLE_REGEX; @@ -553,8 +555,6 @@ 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" ) ) { @@ -572,26 +572,18 @@ parse_acl( } else { char buf[ SLAP_TEXT_BUFLEN ]; - /* FIXME: should be an error */ - snprintf( buf, sizeof( buf ), - "unknown val.