]> git.sur5r.net Git - openldap/commitdiff
A few changes to the handling of operational attributes.
authorKurt Zeilenga <kurt@openldap.org>
Tue, 8 Jan 2002 20:22:41 +0000 (20:22 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Tue, 8 Jan 2002 20:22:41 +0000 (20:22 +0000)
Small preparation for applying tighter semantics to operational attributes.

servers/slapd/at.c
servers/slapd/schemaparse.c

index 29cc14df25152151f9cd77fe1b05cc92ddf8b6ac..90c58551c25d1ad3bf6e0cd2ccb99c69ded1a1e1 100644 (file)
@@ -281,6 +281,7 @@ at_add(
 
                for( i=0; at->at_names[i]; i++ ) {
                        if( !slap_valid_descr( at->at_names[i] ) ) {
+                               *err = at->at_names[i];
                                return SLAP_SCHERR_BAD_DESCR;
                        }
                }
@@ -289,12 +290,32 @@ at_add(
 
        } else if ( at->at_oid ) {
                cname = at->at_oid;
+
        } else {
+               *err = "";
                return SLAP_SCHERR_ATTR_INCOMPLETE;
        }
 
+       *err = cname;
+
+       if ( !at->at_usage && at->at_no_user_mod ) {
+               /* user attribute must be modifable */
+               return SLAP_SCHERR_ATTR_BAD_USAGE;
+       }
+
        if ( at->at_collective ) {
+#ifdef SLAP_COLLECTIVE
+               if( at->at_usage ) {
+                       /* collective attributes cannot be operational */
+                       return SLAP_SCHERR_NOT_SUPPORTED;
+               }
+               if( at->at_single_value ) {
+                       /* collective attributes cannot be single-valued */
+                       return SLAP_SCHERR_NOT_SUPPORTED;
+               }
+#else
                return SLAP_SCHERR_NOT_SUPPORTED;
+#endif
        }
 
        sat = (AttributeType *) ch_calloc( 1, sizeof(AttributeType) );
@@ -315,9 +336,13 @@ at_add(
                sat->sat_sup = supsat;
 
                if ( at_append_to_list(sat, &supsat->sat_subtypes) ) {
-                       *err = cname;
                        return SLAP_SCHERR_OUTOFMEM;
                }
+
+               if ( sat->sat_usage != supsat->sat_usage ) {
+                       /* subtypes must have same usage as their SUP */
+                       return SLAP_SCHERR_ATTR_BAD_USAGE;
+               }
        }
 
        /*
index b77db304a9320f235f962a27641316ffffce2be1..4517b78647ed41e3aa2bb062e0fb7f57f397d511 100644 (file)
@@ -322,6 +322,15 @@ parse_at(
                return 1;
        }
 
+#if 0
+       /* operational attributes should be defined internally */
+       if ( at->at_usage ) {
+               fprintf( stderr, "%s: line %d: attribute type \"%s\" is operational\n",
+                        fname, lineno, at->at_oid );
+               return 1;
+       }
+#endif
+
        if ( !OID_LEADCHAR( at->at_oid[0] )) {
                /* Expand OID macros */
                oid = find_oidm( at->at_oid );
@@ -352,6 +361,7 @@ parse_at(
                }
 
        }
+
        code = at_add(at,&err);
        if ( code ) {
                fprintf( stderr, "%s: line %d: %s: \"%s\"\n",