]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/schema_prep.c
ITS#5376,ITS#5378
[openldap] / servers / slapd / schema_prep.c
index e6d66910cae7891aa3acea3198a863ca2136a557..9105b66e40c9085554dd3e0b6187752ecad5daf5 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2005 The OpenLDAP Foundation.
+ * Copyright 1998-2008 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -297,8 +297,8 @@ static int objectSubClassIndexer(
 
                                ocvalues[noc] = sup->soc_cname;
 
-                               assert( ocvalues[noc].bv_val );
-                               assert( ocvalues[noc].bv_len );
+                               assert( ocvalues[noc].bv_val != NULL );
+                               assert( ocvalues[noc].bv_len != 0 );
 
                                noc++;
 
@@ -321,7 +321,9 @@ static ObjectClassSchemaCheckFN rootDseObjectClass;
 static ObjectClassSchemaCheckFN aliasObjectClass;
 static ObjectClassSchemaCheckFN referralObjectClass;
 static ObjectClassSchemaCheckFN subentryObjectClass;
+#ifdef LDAP_DYNAMIC_OBJECTS
 static ObjectClassSchemaCheckFN dynamicObjectClass;
+#endif
 
 static struct slap_schema_oc_map {
        char *ssom_name;
@@ -365,7 +367,7 @@ static struct slap_schema_oc_map {
        { "subschema", "( 2.5.20.1 NAME 'subschema' "
                "DESC 'RFC2252: controlling subschema (sub)entry' "
                "AUXILIARY "
-               "MAY ( dITStructureRules $ nameForms $ ditContentRules $ "
+               "MAY ( dITStructureRules $ nameForms $ dITContentRules $ "
                        "objectClasses $ attributeTypes $ matchingRules $ "
                        "matchingRuleUse ) )",
                subentryObjectClass, SLAP_OC_OPERATIONAL,
@@ -417,7 +419,9 @@ static AttributeTypeSchemaCheckFN aliasAttribute;
 static AttributeTypeSchemaCheckFN referralAttribute;
 static AttributeTypeSchemaCheckFN subentryAttribute;
 static AttributeTypeSchemaCheckFN administrativeRoleAttribute;
+#ifdef LDAP_DYNAMIC_OBJECTS
 static AttributeTypeSchemaCheckFN dynamicAttribute;
+#endif
 
 static struct slap_schema_ad_map {
        char *ssam_name;
@@ -541,13 +545,13 @@ static struct slap_schema_ad_map {
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_entryDN) },
-       { "entryUUID", "( 1.3.6.1.4.1.4203.666.1.6 NAME 'entryUUID' "   
+       { "entryUUID", "( 1.3.6.1.1.16.4 NAME 'entryUUID' "   
                        "DESC 'UUID of the entry' "
                        "EQUALITY UUIDMatch "
                        "ORDERING UUIDOrderingMatch "
-                       "SYNTAX 1.3.6.1.4.1.4203.666.2.6 "
+                       "SYNTAX 1.3.6.1.1.16.1 "
                        "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
-               NULL, SLAP_AT_HIDE,
+               NULL, SLAP_AT_MANAGEABLE,
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_entryUUID) },
@@ -575,8 +579,9 @@ static struct slap_schema_ad_map {
 #ifdef LDAP_SUPERIOR_UUID
        { "superiorUUID", "( 1.3.6.1.4.1.4203.666.1.11 NAME 'superiorUUID' "   
                        "DESC 'UUID of the superior entry' "
-                       "EQUALITY octetStringMatch "
-                       "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{64} "
+                       "EQUALITY UUIDMatch "
+                       "ORDERING UUIDOrderingMatch "
+                       "SYNTAX 1.3.6.1.1.16.1 "
                        "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
                NULL, SLAP_AT_HIDE,
                NULL, NULL,
@@ -739,7 +744,7 @@ static struct slap_schema_ad_map {
                offsetof(struct slap_internal_schema, si_ad_subtreeSpecification) },
 
        /* subschema subentry attributes */
-       { "ditStructureRules", "( 2.5.21.1 NAME 'dITStructureRules' "
+       { "dITStructureRules", "( 2.5.21.1 NAME 'dITStructureRules' "
                        "DESC 'RFC2252: DIT structure rules' "
                        "EQUALITY integerFirstComponentMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.17 "
@@ -748,7 +753,7 @@ static struct slap_schema_ad_map {
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_ditStructureRules) },
-       { "ditContentRules", "( 2.5.21.2 NAME 'dITContentRules' "
+       { "dITContentRules", "( 2.5.21.2 NAME 'dITContentRules' "
                        "DESC 'RFC2252: DIT content rules' "
                        "EQUALITY objectIdentifierFirstComponentMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.16 USAGE directoryOperation )",
@@ -850,8 +855,16 @@ static struct slap_schema_ad_map {
        { "authzTo", "( 1.3.6.1.4.1.4203.666.1.8 "
                        "NAME ( 'authzTo' 'saslAuthzTo' ) "
                        "DESC 'proxy authorization targets' "
+#ifdef SLAP_AUTHZ_SYNTAX
+                       "EQUALITY authzMatch "
+                       "SYNTAX 1.3.6.1.4.1.4203.666.2.7 "
+#else /* ! SLAP_AUTHZ_SYNTAX */
                        "EQUALITY caseExactMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 "
+#endif /* ! SLAP_AUTHZ_SYNTAX */
+#ifdef SLAP_ORDERED_PRETTYNORM
+                       "X-ORDERED 'VALUES' "
+#endif /* SLAP_ORDERED_PRETTYNORM */
                        "USAGE distributedOperation )",
                NULL, SLAP_AT_HIDE,
                NULL, NULL,
@@ -860,25 +873,21 @@ static struct slap_schema_ad_map {
        { "authzFrom", "( 1.3.6.1.4.1.4203.666.1.9 "
                        "NAME ( 'authzFrom' 'saslAuthzFrom' ) "
                        "DESC 'proxy authorization sources' "
+#ifdef SLAP_AUTHZ_SYNTAX
+                       "EQUALITY authzMatch "
+                       "SYNTAX 1.3.6.1.4.1.4203.666.2.7 "
+#else /* ! SLAP_AUTHZ_SYNTAX */
                        "EQUALITY caseExactMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 "
+#endif /* ! SLAP_AUTHZ_SYNTAX */
+#ifdef SLAP_ORDERED_PRETTYNORM
+                       "X-ORDERED 'VALUES' "
+#endif /* SLAP_ORDERED_PRETTYNORM */
                        "USAGE distributedOperation )",
                NULL, SLAP_AT_HIDE,
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_saslAuthzFrom) },
-#ifdef SLAPD_ACI_ENABLED
-       { "OpenLDAPaci", "( 1.3.6.1.4.1.4203.666.1.5 "
-                       "NAME 'OpenLDAPaci' "
-                       "DESC 'OpenLDAP access control information (experimental)' "
-                       "EQUALITY OpenLDAPaciMatch "
-                       "SYNTAX 1.3.6.1.4.1.4203.666.2.1 "
-                       "USAGE directoryOperation )",
-               NULL, SLAP_AT_HIDE,
-               NULL, NULL,
-               NULL, NULL, NULL, NULL, NULL,
-               offsetof(struct slap_internal_schema, si_ad_aci) },
-#endif
 
 #ifdef LDAP_DYNAMIC_OBJECTS
        { "entryTtl", "( 1.3.6.1.4.1.1466.101.119.3 NAME 'entryTtl' "
@@ -934,6 +943,26 @@ static struct slap_schema_ad_map {
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_uid) },
+       { "uidNumber", /* for ldapi:// */
+               "( 1.3.6.1.1.1.1.0 NAME 'uidNumber' "
+               "DESC 'An integer uniquely identifying a user "
+                               "in an administrative domain' "
+               "EQUALITY integerMatch "
+               "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )",
+               NULL, 0,
+               NULL, NULL,
+               NULL, NULL, NULL, NULL, NULL,
+               offsetof(struct slap_internal_schema, si_ad_uidNumber) },
+       { "gidNumber", /* for ldapi:// */
+               "( 1.3.6.1.1.1.1.1 NAME 'gidNumber' "
+               "DESC 'An integer uniquely identifying a group "
+                               "in an administrative domain' "
+               "EQUALITY integerMatch "
+               "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )",
+               NULL, 0,
+               NULL, NULL,
+               NULL, NULL, NULL, NULL, NULL,
+               offsetof(struct slap_internal_schema, si_ad_gidNumber) },
        { "userPassword", "( 2.5.4.35 NAME 'userPassword' "
                        "DESC 'RFC2256/2307: password of user' "
                        "EQUALITY octetStringMatch "
@@ -1008,14 +1037,31 @@ static struct slap_schema_ad_map {
 };
 
 static AttributeType slap_at_undefined = {
-       { "1.1.1", NULL, NULL, 1, NULL,
+       { "1.1.1", NULL, "Catchall for undefined attribute types", 1, NULL,
                NULL, NULL, NULL, NULL,
-               0, 0, 0, 1, 3, NULL }, /* LDAPAttributeType */
+               0, 0, 0, 1, LDAP_SCHEMA_DSA_OPERATION, NULL }, /* LDAPAttributeType */
        BER_BVC("UNDEFINED"), /* cname */
        NULL, /* sup */
        NULL, /* subtypes */
        NULL, NULL, NULL, NULL, /* matching rules routines */
-       NULL, /* syntax (this may need to be defined) */
+       NULL, /* syntax (will be set later to "octetString") */
+       NULL, /* schema check function */
+       NULL, /* oidmacro */
+       SLAP_AT_ABSTRACT|SLAP_AT_FINAL, /* mask */
+       { NULL }, /* next */
+       NULL /* attribute description */
+       /* mutex (don't know how to initialize it :) */
+};
+
+static AttributeType slap_at_proxied = {
+       { "1.1.1", NULL, "Catchall for undefined proxied attribute types", 1, NULL,
+               NULL, NULL, NULL, NULL,
+               0, 0, 0, 0, LDAP_SCHEMA_USER_APPLICATIONS, NULL }, /* LDAPAttributeType */
+       BER_BVC("PROXIED"), /* cname */
+       NULL, /* sup */
+       NULL, /* subtypes */
+       NULL, NULL, NULL, NULL, /* matching rules routines (will be set later) */
+       NULL, /* syntax (will be set later to "octetString") */
        NULL, /* schema check function */
        NULL, /* oidmacro */
        SLAP_AT_ABSTRACT|SLAP_AT_FINAL, /* mask */
@@ -1123,6 +1169,19 @@ slap_schema_load( void )
                }
        }
 
+       slap_at_undefined.sat_syntax = slap_schema.si_syn_octetString;
+       slap_schema.si_at_undefined = &slap_at_undefined;
+
+       slap_at_proxied.sat_equality = mr_find( "octetStringMatch" );
+       slap_at_proxied.sat_approx = mr_find( "octetStringMatch" );
+       slap_at_proxied.sat_ordering = mr_find( "octetStringOrderingMatch" );
+       slap_at_proxied.sat_substr = mr_find( "octetStringSubstringsMatch" );
+       slap_at_proxied.sat_syntax = slap_schema.si_syn_octetString;
+       slap_schema.si_at_proxied = &slap_at_proxied;
+
+       ldap_pvt_thread_mutex_init( &ad_undef_mutex );
+       ldap_pvt_thread_mutex_init( &oc_undef_mutex );
+
        for( i=0; ad_map[i].ssam_name; i++ ) {
                assert( ad_map[i].ssam_defn != NULL );
                {
@@ -1148,6 +1207,7 @@ slap_schema_load( void )
 
                        code = at_add( at, 0, NULL, &err );
                        if ( code ) {
+                               ldap_attributetype_free( at );
                                fprintf( stderr, "slap_schema_load: AttributeType "
                                        "\"%s\": %s: \"%s\"\n",
                                         ad_map[i].ssam_name, scherr2str(code), err );
@@ -1231,6 +1291,7 @@ slap_schema_load( void )
                                        mr->smr_filter = ad_map[i].ssam_mr_filter;
                                }
 
+                               /* FIXME: no-one will free this at exit */
                                (*adp)->ad_type->sat_equality = mr;
                        }
                }
@@ -1292,9 +1353,6 @@ slap_schema_load( void )
                }
        }
 
-       slap_at_undefined.sat_syntax = slap_schema.si_syn_octetString;
-       slap_schema.si_at_undefined = &slap_at_undefined;
-
        return LDAP_SUCCESS;
 }
 
@@ -1400,6 +1458,7 @@ static int subentryObjectClass (
        return LDAP_SUCCESS;
 }
 
+#ifdef LDAP_DYNAMIC_OBJECTS
 static int dynamicObjectClass (
        Backend *be,
        Entry *e,
@@ -1418,6 +1477,7 @@ static int dynamicObjectClass (
 
        return LDAP_SUCCESS;
 }
+#endif /* LDAP_DYNAMIC_OBJECTS */
 
 static int rootDseAttribute (
        Backend *be,
@@ -1540,6 +1600,7 @@ static int administrativeRoleAttribute (
        return LDAP_OBJECT_CLASS_VIOLATION;
 }
 
+#ifdef LDAP_DYNAMIC_OBJECTS
 static int dynamicAttribute (
        Backend *be,
        Entry *e,
@@ -1565,3 +1626,4 @@ static int dynamicAttribute (
 
        return LDAP_SUCCESS;
 }
+#endif /* LDAP_DYNAMIC_OBJECTS */