-/* acl.c - routines to parse and check acl's */
+/* aclparse.c - routines to parse and check acl's */
/* $OpenLDAP$ */
/*
- * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
char *left, *right;
AccessControl *a;
Access *b;
+#ifdef SLAPD_SCHEMA_NOT_COMPAT
+ int rc;
+ char *text;
+ static AttributeDescription *member = NULL;
+ static AttributeDescription *aci = NULL;
+#endif
a = NULL;
for ( i = 1; i < argc; i++ ) {
pat = ch_strdup( "anonymous" );
} else if ( strcmp( right, "*" ) == 0 ) {
- /* dn=* /
+ /* dn=* */
/* any or users? any for now */
pat = ch_strdup( "users" );
}
if ( strcasecmp( left, "dnattr" ) == 0 ) {
- if( b->a_dn_pat != NULL ) {
+ if( b->a_dn_at != NULL ) {
fprintf( stderr,
- "%s: line %d: dnaddr already specified.\n",
+ "%s: line %d: dnattr already specified.\n",
fname, lineno );
acl_usage();
}
+#ifdef SLAPD_SCHEMA_NOT_COMPAT
+ rc = slap_str2ad( right, &b->a_dn_at, &text );
+
+ if( rc != LDAP_SUCCESS ) {
+ fprintf( stderr,
+ "%s: line %d: dnattr \"%s\": %s\n",
+ fname, lineno, right, text );
+ acl_usage();
+ }
+
+#ifdef SLAPD_OID_DN_SYNTAX
+ if( strcmp( b->a_dn_at->ad_type->sat_syntax_oid,
+ SLAPD_OID_DN_SYNTAX ) != 0 )
+ {
+ fprintf( stderr,
+ "%s: line %d: dnattr attribute type not of DN syntax.\n",
+ fname, lineno );
+ acl_usage();
+ }
+#endif
+#else
b->a_dn_at = ch_strdup( right );
+#endif
continue;
}
/* format of string is "group/objectClassValue/groupAttrName" */
if ((value = strchr(left, '/')) != NULL) {
*value++ = '\0';
- if (value && *value
+ if (*value
&& (name = strchr(value, '/')) != NULL)
{
*name++ = '\0';
*--value = '/';
} else {
b->a_group_oc = ch_strdup("groupOfNames");
+ }
- if (name && *name) {
- b->a_group_at = ch_strdup(name);
- *--name = '/';
+ if (name && *name) {
+#ifdef SLAPD_SCHEMA_NOT_COMPAT
+ rc = slap_str2ad( right, &b->a_group_at, &text );
- } else {
- b->a_group_at = ch_strdup("member");
+ if( rc != LDAP_SUCCESS ) {
+ fprintf( stderr,
+ "%s: line %d: group \"%s\": %s\n",
+ fname, lineno, right, text );
+ acl_usage();
}
+#else
+ b->a_group_at = ch_strdup(name);
+#endif
+ *--name = '/';
+
+ } else {
+#ifdef SLAPD_SCHEMA_NOT_COMPAT
+ b->a_group_at = member;
+#else
+ b->a_group_at = ch_strdup("member");
+#endif
}
+
+#ifdef SLAPD_SCHEMA_NOT_COMPAT
+ if( b->a_group_at == NULL ) {
+ fprintf( stderr,
+ "%s: line %d: group attribute type undefined.\n",
+ fname, lineno );
+ acl_usage();
+ }
+
+#ifdef SLAPD_OID_DN_SYNTAX
+ if( strcmp( b->a_group_at->ad_type->sat_syntax_oid,
+ SLAPD_OID_DN_SYNTAX ) != 0 )
+ {
+ fprintf( stderr,
+ "%s: line %d: group attribute type not of DN syntax.\n",
+ fname, lineno );
+ acl_usage();
+ }
+#endif /* SLAPD_OID_DN_SYNTAX */
+#endif /* SLAPD_SCHEMA_NOT_COMPAT */
continue;
}
acl_usage();
}
- if ( right != NULL && *right != '\0' )
+#ifdef SLAPD_SCHEMA_NOT_COMPAT
+ if ( right != NULL && *right != '\0' ) {
+ rc = slap_str2ad( right, &b->a_aci_at, &text );
+
+ if( rc != LDAP_SUCCESS ) {
+ fprintf( stderr,
+ "%s: line %d: aci \"%s\": %s\n",
+ fname, lineno, right, text );
+ acl_usage();
+ }
+ } else {
+ b->a_aci_at = aci;
+ }
+
+ if( b->a_aci_at == NULL ) {
+ fprintf( stderr,
+ "%s: line %d: aci attribute type undefined.\n",
+ fname, lineno );
+ acl_usage();
+ }
+
+ if( strcmp( b->a_aci_at->ad_type->sat_syntax_oid,
+ SLAPD_OID_ACI_SYNTAX ) != 0 )
+ {
+ fprintf( stderr,
+ "%s: line %d: aci attribute type not of ACI syntax.\n",
+ fname, lineno );
+ acl_usage();
+ }
+#else
+ if ( right != NULL && *right != '\0' ) {
b->a_aci_at = ch_strdup( right );
- else
+ } else {
b->a_aci_at = ch_strdup( SLAPD_ACI_DEFAULT_ATTR );
+ }
+#endif
continue;
}
-#endif
+#endif /* SLAPD_ACI_ENABLED */
if( right != NULL ) {
/* unsplit */