X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=sidebyside;f=servers%2Fslapd%2Faclparse.c;h=b433196837ff97e3894c0955a64c4d5c62212de3;hb=c2df36c86f70fb671aaf9c87469ff37a34f29427;hp=fd9a339ee7209237f6612bc1dec7eba5544c5378;hpb=a2a587c6caa2550e7b2a69642aae36b350245835;p=openldap
diff --git a/servers/slapd/aclparse.c b/servers/slapd/aclparse.c
index fd9a339ee7..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-2005 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,13 +52,18 @@ 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 acl_usage(void) LDAP_GCCATTR((noreturn));
+static void access_free( Access *a );
+static int acl_usage(void);
static void acl_regex_normalized_dn(const char *src, struct berval *pat);
@@ -87,7 +92,7 @@ slap_dynacl_config(
Debug( LDAP_DEBUG_ANY,
"%s: line %d: dynacl \"%s\" already specified.\n",
fname, lineno, name );
- acl_usage();
+ return acl_usage();
}
}
@@ -154,7 +159,8 @@ regtest(const char *fname, int lineno, char *pat) {
Debug( LDAP_DEBUG_ANY,
"%s: line %d: regular expression \"%s\" too large\n",
fname, lineno, pat );
- acl_usage();
+ (void)acl_usage();
+ exit( EXIT_FAILURE );
}
if ((e = regcomp(&re, buf, REG_EXTENDED|REG_ICASE))) {
@@ -169,6 +175,7 @@ regtest(const char *fname, int lineno, char *pat) {
"%s: line %d: %s\n",
fname, lineno, buf );
acl_usage();
+ exit( EXIT_FAILURE );
}
regfree(&re);
}
@@ -313,24 +320,23 @@ regex_done:;
return ACL_SCOPE_UNKNOWN;
}
-void
+int
parse_acl(
- Backend *be,
- const char *fname,
- int lineno,
- int argc,
- char **argv,
+ Backend *be,
+ const char *fname,
+ int lineno,
+ int argc,
+ char **argv,
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 ) {
@@ -338,9 +344,10 @@ parse_acl(
Debug( LDAP_DEBUG_ANY, "%s: line %d: "
"only one to clause allowed in access line\n",
fname, lineno, 0 );
- 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--;
@@ -355,7 +362,7 @@ parse_acl(
"%s: line %d: dn pattern"
" already specified in to clause.\n",
fname, lineno, 0 );
- acl_usage();
+ goto fail;
}
ber_str2bv( "*", STRLENOF( "*" ), 1, &a->acl_dn_pat );
@@ -369,7 +376,7 @@ parse_acl(
Debug( LDAP_DEBUG_ANY, "%s: line %d: "
"missing \"=\" in \"%s\" in to clause\n",
fname, lineno, left );
- acl_usage();
+ goto fail;
}
if ( strcasecmp( left, "dn" ) == 0 ) {
@@ -380,7 +387,7 @@ parse_acl(
"%s: line %d: dn pattern"
" already specified in to clause.\n",
fname, lineno, 0 );
- acl_usage();
+ goto fail;
}
if ( style == NULL || *style == '\0' ||
@@ -438,7 +445,7 @@ parse_acl(
Debug( LDAP_DEBUG_ANY, "%s: line %d: "
"unknown dn style \"%s\" in to clause\n",
fname, lineno, style );
- acl_usage();
+ goto fail;
}
continue;
@@ -449,39 +456,48 @@ parse_acl(
Debug( LDAP_DEBUG_ANY,
"%s: line %d: bad filter \"%s\" in to clause\n",
fname, lineno, right );
- acl_usage();
+ goto fail;
}
} else if ( strcasecmp( left, "attr" ) == 0 /* TOLERATED */
|| strcasecmp( left, "attrs" ) == 0 ) /* DOCUMENTED */
{
+ if ( strcasecmp( left, "attr" ) == 0 ) {
+ Debug( LDAP_DEBUG_ANY,
+ "%s: line %d: \"attr\" "
+ "is deprecated (and undocumented); "
+ "use \"attrs\" instead.\n",
+ fname, lineno, 0 );
+ }
+
a->acl_attrs = str2anlist( a->acl_attrs,
right, "," );
if ( a->acl_attrs == NULL ) {
Debug( LDAP_DEBUG_ANY,
"%s: line %d: unknown attr \"%s\" in to clause\n",
fname, lineno, right );
- 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 );
- 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 );
- 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, '/' );
@@ -494,7 +510,7 @@ parse_acl(
Debug( LDAP_DEBUG_ANY, "%s: line %d: "
"invalid matching rule \"%s\".\n",
fname, lineno, mr );
- acl_usage();
+ goto fail;
}
if( !mr_usable_with_at( a->acl_attrval_mr, a->acl_attrs[ 0 ].an_desc->ad_type ) )
@@ -509,14 +525,14 @@ parse_acl(
Debug( LDAP_DEBUG_ANY, "%s: line %d: %s\n",
fname, lineno, buf );
- acl_usage();
+ goto fail;
}
}
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 );
+ int e = regcomp( &a->acl_attrval_re, bv.bv_val,
+ REG_EXTENDED | REG_ICASE );
if ( e ) {
char err[SLAP_TEXT_BUFLEN],
buf[ SLAP_TEXT_BUFLEN ];
@@ -529,7 +545,7 @@ parse_acl(
Debug( LDAP_DEBUG_ANY, "%s: line %d: %s\n",
fname, lineno, buf );
- acl_usage();
+ goto fail;
}
a->acl_attrval_style = ACL_STYLE_REGEX;
@@ -543,8 +559,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" ) )
{
@@ -562,26 +576,18 @@ parse_acl(
} else {
char buf[ SLAP_TEXT_BUFLEN ];
- /* FIXME: should be an error */
-
snprintf( buf, sizeof( buf ),
- "unknown val.