]> git.sur5r.net Git - openldap/commitdiff
Add abstract/final system attribute types.
authorKurt Zeilenga <kurt@openldap.org>
Fri, 31 May 2002 20:24:26 +0000 (20:24 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Fri, 31 May 2002 20:24:26 +0000 (20:24 +0000)
clean up error code macros

servers/slapd/at.c
servers/slapd/mr.c
servers/slapd/oc.c
servers/slapd/schema_prep.c
servers/slapd/schemaparse.c
servers/slapd/slap.h
servers/slapd/syntax.c

index b12d25eb28a17bb7c5093eb8a89da186aa14aba8..911c46f8702d5a993233951d8e443d1abbd2d1c8 100644 (file)
@@ -235,7 +235,7 @@ at_insert(
                                 (AVL_DUP) avl_dup_error ) ) {
                        *err = sat->sat_oid;
                        ldap_memfree(air);
-                       return SLAP_SCHERR_DUP_ATTR;
+                       return SLAP_SCHERR_ATTR_DUP;
                }
                /* FIX: temporal consistency check */
                at_bvfind(&air->air_name);
@@ -253,7 +253,7 @@ at_insert(
                                         (AVL_DUP) avl_dup_error ) ) {
                                *err = *names;
                                ldap_memfree(air);
-                               return SLAP_SCHERR_DUP_ATTR;
+                               return SLAP_SCHERR_ATTR_DUP;
                        }
                        /* FIX: temporal consistency check */
                        at_bvfind(&air->air_name);
@@ -368,6 +368,11 @@ at_add(
                        /* subtypes must have same usage as their SUP */
                        return SLAP_SCHERR_ATTR_BAD_USAGE;
                }
+
+               if ( sat->sat_flags & SLAP_AT_FINAL ) {
+                       /* cannot subtype a "final" attribute type */
+                       return SLAP_SCHERR_ATTR_BAD_SUP;
+               }
        }
 
        /*
index e1af29d0c88fbee2205347a255571b63422f67a5..f8e788b6e0082d66acd4d2b0676a08588e42c915 100644 (file)
@@ -108,7 +108,7 @@ mr_insert(
                                 (AVL_DUP) avl_dup_error ) ) {
                        *err = smr->smr_oid;
                        ldap_memfree(mir);
-                       return SLAP_SCHERR_DUP_RULE;
+                       return SLAP_SCHERR_MR_DUP;
                }
                /* FIX: temporal consistency check */
                mr_bvfind(&mir->mir_name);
@@ -125,7 +125,7 @@ mr_insert(
                                         (AVL_DUP) avl_dup_error ) ) {
                                *err = *names;
                                ldap_memfree(mir);
-                               return SLAP_SCHERR_DUP_RULE;
+                               return SLAP_SCHERR_MR_DUP;
                        }
                        /* FIX: temporal consistency check */
                        mr_bvfind(&mir->mir_name);
index ca7a0d45aa2cb8a7e3c913296ee9b07be807c608..02f6ea402212c9206dff7f9fcbdb6d69477e64fd 100644 (file)
@@ -354,7 +354,7 @@ oc_insert(
                {
                        *err = soc->soc_oid;
                        ldap_memfree(oir);
-                       return SLAP_SCHERR_DUP_CLASS;
+                       return SLAP_SCHERR_CLASS_DUP;
                }
 
                /* FIX: temporal consistency check */
@@ -378,7 +378,7 @@ oc_insert(
                        {
                                *err = *names;
                                ldap_memfree(oir);
-                               return SLAP_SCHERR_DUP_CLASS;
+                               return SLAP_SCHERR_CLASS_DUP;
                        }
 
                        /* FIX: temporal consistency check */
@@ -446,7 +446,7 @@ oc_add(
        code = oc_create_allowed( soc, soc->soc_at_oids_may, &op, err );
        if ( code != 0 ) return code;
 
-       if( user && op ) return SLAP_SCHERR_CLASS_OPERATIONAL;
+       if( user && op ) return SLAP_SCHERR_CLASS_BAD_SUP;
 
        code = oc_insert(soc,err);
        return code;
index 73c36a7170273720df7b57ce1ef20107fff02f58..6ef84a90e9a655557e4689fc44c1dc70b33749d8 100644 (file)
@@ -236,7 +236,7 @@ static struct slap_schema_ad_map {
                        "DESC 'RFC2256: object classes of the entity' "
                        "EQUALITY objectIdentifierMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
-               NULL, 0, objectClassMatch, NULL, NULL,
+               NULL, SLAP_AT_FINAL, objectClassMatch, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_objectClass) },
 
        /* user entry operational attributes */
@@ -453,7 +453,7 @@ static struct slap_schema_ad_map {
                        "DESC 'RFC2256: name of aliased object' "
                        "EQUALITY distinguishedNameMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE )",
-               aliasAttribute, 0, NULL, NULL, NULL,
+               aliasAttribute, SLAP_AT_FINAL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_aliasedObjectName) },
        { "ref", "( 2.16.840.1.113730.3.1.34 NAME 'ref' "
                        "DESC 'namedref: subordinate referral URL' "
@@ -508,14 +508,14 @@ static struct slap_schema_ad_map {
                        "DESC 'RFC2256: common supertype of DN attributes' "
                        "EQUALITY distinguishedNameMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )",
-               NULL, 0, NULL, NULL, NULL,
+               NULL, SLAP_AT_ABSTRACT, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_distinguishedName) },
        { "name", "( 2.5.4.41 NAME 'name' "
                        "DESC 'RFC2256: common supertype of name attributes' "
                        "EQUALITY caseIgnoreMatch "
                        "SUBSTR caseIgnoreSubstringsMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} )",
-               NULL, 0, NULL, NULL, NULL,
+               NULL, SLAP_AT_ABSTRACT, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_name) },
        { "cn", "( 2.5.4.3 NAME ( 'cn' 'commonName' ) "
                        "DESC 'RFC2256: common name(s) for which the entity is known by' "
@@ -526,7 +526,7 @@ static struct slap_schema_ad_map {
                        "DESC 'RFC2256/2307: password of user' "
                        "EQUALITY octetStringMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{128} )",
-               NULL, 0, NULL, NULL, NULL,
+               NULL, SLAP_AT_FINAL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_userPassword) },
 
 #ifdef SLAPD_AUTHPASSWD
@@ -535,7 +535,7 @@ static struct slap_schema_ad_map {
                        "DESC 'RFC3112: authentication password attribute' "
                        "EQUALITY 1.3.6.1.4.1.4203.1.2.2 "
                        "SYNTAX 1.3.6.1.4.1.4203.1.1.2 )",
-               NULL, 0,
+               NULL, SLAP_AT_FINAL,
                NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_authPassword) },
        { "supportedAuthPasswordSchemes", "( 1.3.6.1.4.1.4203.1.3.3 "
@@ -549,7 +549,7 @@ static struct slap_schema_ad_map {
 #endif
 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
        { "krbName", NULL,
-               NULL, 0, NULL, NULL, NULL,
+               NULL, SLAP_AT_FINAL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_krbName) },
 #endif
 
@@ -565,7 +565,8 @@ static AttributeType slap_at_undefined = {
        NULL, /* subtypes */
        NULL, NULL, NULL, NULL, /* matching rules */
        NULL, /* syntax (this may need to be defined) */
-       (AttributeTypeSchemaCheckFN *) 0, 0, /* schema check function/mask */
+       (AttributeTypeSchemaCheckFN *) 0, /* schema check function */
+       SLAP_AT_ABSTRACT|SLAP_AT_FINAL, /* mask */
        NULL, /* next */
        NULL /* attribute description */
        /* mutex (don't know how to initialize it :) */
index bc9dbd7dd922cded0e670320ecaa8c98eec01f33..10e92f827cb260fa4a791324a507b29323094ab2 100644 (file)
@@ -21,23 +21,23 @@ int global_schemacheck = 1; /* schemacheck ON is default */
 static void            oc_usage(void); 
 static void            at_usage(void);
 
-static char *const err2text[SLAP_SCHERR_LAST+1] = {
-       "Success",
+static char *const err2text[] = {
        "Out of memory",
        "ObjectClass not found",
        "ObjectClass inappropriate SUPerior",
        "ObjectClass operational",
+       "Duplicate objectClass",
        "AttributeType not found",
        "AttributeType inappropriate USAGE",
-       "Duplicate objectClass",
+       "AttributeType inappropriate SUPerior",
+       "AttributeType SYNTAX or SUPerior required",
        "Duplicate attributeType",
-       "Duplicate ldapSyntax",
-       "Duplicate matchingRule",
-       "OID or name required",
-       "SYNTAX or SUPerior required",
        "MatchingRule not found",
+       "Duplicate matchingRule",
        "Syntax not found",
        "Syntax required",
+       "Duplicate ldapSyntax",
+       "OID or name required",
        "Qualifier not supported",
        "Invalid NAME",
        "OID could not be expanded"
@@ -46,7 +46,7 @@ static char *const err2text[SLAP_SCHERR_LAST+1] = {
 char *
 scherr2str(int code)
 {
-       if ( code < 0 || code >= (int)(sizeof(err2text)/sizeof(char *)) ) {
+       if ( code < 0 || SLAP_SCHERR_LAST < code ) {
                return "Unknown error";
        } else {
                return err2text[code];
index a8efb056e8807d0b20785add3b20c8b4ea6e8309..949a01441c56a7896d9d168f943b4e08daf2bf95 100644 (file)
@@ -218,25 +218,26 @@ typedef struct slap_ssf_set {
 /*
  * represents schema information for a database
  */
-#define SLAP_SCHERR_OUTOFMEM           1
-#define SLAP_SCHERR_CLASS_NOT_FOUND    2
-#define SLAP_SCHERR_CLASS_BAD_USAGE    3
-#define SLAP_SCHERR_CLASS_OPERATIONAL 4
-#define SLAP_SCHERR_ATTR_NOT_FOUND     5
-#define SLAP_SCHERR_ATTR_BAD_USAGE     6
-#define SLAP_SCHERR_DUP_CLASS          7
-#define SLAP_SCHERR_DUP_ATTR           8
-#define SLAP_SCHERR_DUP_SYNTAX         9
-#define SLAP_SCHERR_DUP_RULE           10
-#define SLAP_SCHERR_NO_NAME                    11
-#define SLAP_SCHERR_ATTR_INCOMPLETE    12
-#define SLAP_SCHERR_MR_NOT_FOUND       13
-#define SLAP_SCHERR_SYN_NOT_FOUND      14
-#define SLAP_SCHERR_MR_INCOMPLETE      15
-#define SLAP_SCHERR_NOT_SUPPORTED      16
-#define SLAP_SCHERR_BAD_DESCR          17
-#define SLAP_SCHERR_OIDM                       18
-#define SLAP_SCHERR_LAST                       SLAP_SCHERR_OIDM
+#define SLAP_SCHERR_OUTOFMEM                   1
+#define SLAP_SCHERR_CLASS_NOT_FOUND            2
+#define SLAP_SCHERR_CLASS_BAD_USAGE            3
+#define SLAP_SCHERR_CLASS_BAD_SUP              4
+#define SLAP_SCHERR_CLASS_DUP                  5
+#define SLAP_SCHERR_ATTR_NOT_FOUND             6
+#define SLAP_SCHERR_ATTR_BAD_USAGE             7
+#define SLAP_SCHERR_ATTR_BAD_SUP               8
+#define SLAP_SCHERR_ATTR_INCOMPLETE            9
+#define SLAP_SCHERR_ATTR_DUP                   10
+#define SLAP_SCHERR_MR_NOT_FOUND               11
+#define SLAP_SCHERR_MR_INCOMPLETE              12
+#define SLAP_SCHERR_MR_DUP                             13
+#define SLAP_SCHERR_SYN_NOT_FOUND              14
+#define SLAP_SCHERR_SYN_DUP                            15
+#define SLAP_SCHERR_NO_NAME                            16
+#define SLAP_SCHERR_NOT_SUPPORTED              17
+#define SLAP_SCHERR_BAD_DESCR                  18
+#define SLAP_SCHERR_OIDM                               19
+#define SLAP_SCHERR_LAST                               SLAP_SCHERR_OIDM
 
 typedef union slap_sockaddr {
        struct sockaddr sa_addr;
@@ -433,8 +434,10 @@ typedef struct slap_attribute_type {
 
        AttributeTypeSchemaCheckFN      *sat_check;
 
-#define SLAP_AT_NONE   0x0000U
-#define SLAP_AT_HIDE   0x0001U /* hide attribute */
+#define SLAP_AT_NONE           0x0000U
+#define SLAP_AT_ABSTRACT       0x0100U /* cannot be instantiated */
+#define SLAP_AT_FINAL          0x0200U /* cannot be subtyped */
+#define SLAP_AT_HIDE           0x8000U /* hide attribute */
        slap_mask_t                                     sat_flags;
 
        struct slap_attribute_type      *sat_next;
index 2155eb20f5b1c438893ad6933c33a89c208e1a08..eea2e1b1108ce59c5aa59244bf7d030fb6e7142d 100644 (file)
@@ -103,7 +103,7 @@ syn_insert(
                                 (AVL_DUP) avl_dup_error ) ) {
                        *err = ssyn->ssyn_oid;
                        ldap_memfree(sir);
-                       return SLAP_SCHERR_DUP_SYNTAX;
+                       return SLAP_SCHERR_SYN_DUP;
                }
                /* FIX: temporal consistency check */
                syn_find(sir->sir_name);