]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/aclparse.c
Y2k copyright update
[openldap] / servers / slapd / aclparse.c
index 73bb669c006f0cc8dfbf92e65e524f2e5ca31b21..ced1c95c69b64cbe9c048f15925254443885b37e 100644 (file)
@@ -1,7 +1,7 @@
-/* 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
  */
 
@@ -95,6 +95,12 @@ parse_acl(
        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++ ) {
@@ -269,7 +275,7 @@ parse_acl(
                                                pat = ch_strdup( "anonymous" );
 
                                        } else if ( strcmp( right, "*" ) == 0 ) {
-                                               /* dn=* /
+                                               /* dn=* */
                                                /* any or users?  any for now */
                                                pat = ch_strdup( "users" );
 
@@ -313,14 +319,36 @@ parse_acl(
                                }
 
                                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;
                                }
 
@@ -338,7 +366,7 @@ parse_acl(
                                        /* 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';
@@ -353,15 +381,50 @@ parse_acl(
                                                *--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;
                                }
 
@@ -426,13 +489,45 @@ parse_acl(
                                                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 */