X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Faclparse.c;h=b433196837ff97e3894c0955a64c4d5c62212de3;hb=c2df36c86f70fb671aaf9c87469ff37a34f29427;hp=188aa0b6d23ddb9034ca04deb330df398d978be3;hpb=5354f2d4e6a8226bef82655026c645f0c5be00e2;p=openldap
diff --git a/servers/slapd/aclparse.c b/servers/slapd/aclparse.c
index 188aa0b6d2..b433196837 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-2006 The OpenLDAP Foundation.
+ * Copyright 1998-2011 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -39,7 +39,7 @@
#include "lutil.h"
static const char style_base[] = "base";
-char *style_strings[] = {
+const char *style_strings[] = {
"regex",
"expand",
"exact",
@@ -52,12 +52,17 @@ char *style_strings[] = {
"users",
"self",
"ip",
+ "ipv6",
"path",
NULL
};
+#define ACLBUF_CHUNKSIZE 8192
+static struct berval aclbuf;
+
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);
@@ -327,12 +332,11 @@ parse_acl(
int i;
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,9 +344,10 @@ 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) );
+ a->acl_attrval_style = ACL_STYLE_NONE;
for ( ++i; i < argc; i++ ) {
if ( strcasecmp( argv[i], "by" ) == 0 ) {
i--;
@@ -357,7 +362,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 +376,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 +387,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 +445,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 +456,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,7 +476,7 @@ 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 ) {
@@ -482,14 +487,14 @@ parse_acl(
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, 0, &bv );
@@ -505,7 +510,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 ) )
@@ -520,14 +525,14 @@ 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, bv.bv_val,
- REG_EXTENDED | REG_ICASE | REG_NOSUB );
+ REG_EXTENDED | REG_ICASE );
if ( e ) {
char err[SLAP_TEXT_BUFLEN],
buf[ SLAP_TEXT_BUFLEN ];
@@ -540,7 +545,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;
@@ -571,25 +576,16 @@ parse_acl(
} else {
char buf[ SLAP_TEXT_BUFLEN ];
- /* FIXME: should be an error */
-
snprintf( buf, sizeof( buf ),
- "unknown val.