]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/schema_init.c
More system schema checks
[openldap] / servers / slapd / schema_init.c
index 968dc443a30a982635d830a4c6ceb999e7d3e0c1..cfd141b2fcba882a814eb77db8dc1ce76c30d46d 100644 (file)
@@ -1,7 +1,7 @@
 /* schema_init.c - init builtin schema */
 /* $OpenLDAP$ */
 /*
- * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 
@@ -222,38 +222,38 @@ nameUIDValidate(
        struct berval *in )
 {
        int rc;
-       struct berval *dn;
+       struct berval dn;
 
        if( in->bv_len == 0 ) return LDAP_SUCCESS;
 
-       dn = ber_bvdup( in );
-       if( !dn ) return LDAP_OTHER;
+       ber_dupbv( &dn, in );
+       if( !dn.bv_val ) return LDAP_OTHER;
 
-       if( dn->bv_val[dn->bv_len-1] == 'B'
-               && dn->bv_val[dn->bv_len-2] == '\'' )
+       if( dn.bv_val[dn.bv_len-1] == 'B'
+               && dn.bv_val[dn.bv_len-2] == '\'' )
        {
                /* assume presence of optional UID */
                ber_len_t i;
 
-               for(i=dn->bv_len-3; i>1; i--) {
-                       if( dn->bv_val[i] != '0' &&     dn->bv_val[i] != '1' ) {
+               for(i=dn.bv_len-3; i>1; i--) {
+                       if( dn.bv_val[i] != '0' &&      dn.bv_val[i] != '1' ) {
                                break;
                        }
                }
-               if( dn->bv_val[i] != '\'' ||
-                   dn->bv_val[i-1] != '#' ) {
-                       ber_bvfree( dn );
+               if( dn.bv_val[i] != '\'' ||
+                   dn.bv_val[i-1] != '#' ) {
+                       ber_memfree( dn.bv_val );
                        return LDAP_INVALID_SYNTAX;
                }
 
                /* trim the UID to allow use of dnValidate */
-               dn->bv_val[i-1] = '\0';
-               dn->bv_len = i-1;
+               dn.bv_val[i-1] = '\0';
+               dn.bv_len = i-1;
        }
 
-       rc = dnValidate( NULL, dn );
+       rc = dnValidate( NULL, &dn );
 
-       ber_bvfree( dn );
+       ber_memfree( &dn );
        return rc;
 }
 
@@ -3575,7 +3575,7 @@ serial_and_issuer_parse(
 
        bv.bv_len = end-begin+1;
        bv.bv_val = begin;
-       *serial = ber_bvdup(&bv);
+       *serial = ber_dupbv(NULL, &bv);
 
        /* now extract the issuer, remember p was at the dollar sign */
        begin = p+1;
@@ -4113,15 +4113,18 @@ static struct syntax_defs_rec {
        slap_syntax_transform_func *sd_str2ber;
 #endif
 } syntax_defs[] = {
-       {"( 1.3.6.1.4.1.1466.115.121.1.1 DESC 'ACI Item' " X_BINARY X_NOT_H_R ")",
+       {"( 1.3.6.1.4.1.1466.115.121.1.1 DESC 'ACI Item' "
+               X_BINARY X_NOT_H_R ")",
                SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, NULL, NULL, NULL},
        {"( 1.3.6.1.4.1.1466.115.121.1.2 DESC 'Access Point' " X_NOT_H_R ")",
                0, NULL, NULL, NULL},
        {"( 1.3.6.1.4.1.1466.115.121.1.3 DESC 'Attribute Type Description' )",
                0, NULL, NULL, NULL},
-       {"( 1.3.6.1.4.1.1466.115.121.1.4 DESC 'Audio' " X_NOT_H_R ")",
+       {"( 1.3.6.1.4.1.1466.115.121.1.4 DESC 'Audio' "
+               X_NOT_H_R ")",
                SLAP_SYNTAX_BLOB, blobValidate, NULL, NULL},
-       {"( 1.3.6.1.4.1.1466.115.121.1.5 DESC 'Binary' " X_NOT_H_R ")",
+       {"( 1.3.6.1.4.1.1466.115.121.1.5 DESC 'Binary' "
+               X_NOT_H_R ")",
                SLAP_SYNTAX_BER, berValidate, NULL, NULL},
        {"( 1.3.6.1.4.1.1466.115.121.1.6 DESC 'Bit String' )",
                0, bitStringValidate, bitStringNormalize, NULL },
@@ -4202,6 +4205,9 @@ static struct syntax_defs_rec {
                0, NULL, NULL, NULL},
        {"( 1.3.6.1.4.1.1466.115.121.1.44 DESC 'Printable String' )",
                0, printableStringValidate, IA5StringNormalize, NULL},
+       {"( 1.3.6.1.4.1.1466.115.121.1.45 DESC 'SubtreeSpecification' "
+               X_BINARY X_NOT_H_R ")",
+               SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, NULL, NULL, NULL},
        {"( 1.3.6.1.4.1.1466.115.121.1.49 DESC 'Supported Algorithm' "
                X_BINARY X_NOT_H_R ")",
                SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
@@ -4246,9 +4252,11 @@ static struct syntax_defs_rec {
                UTF8StringValidate /* THIS WILL CHANGE FOR NEW ACI SYNTAX */,
                NULL, NULL},
 
+#ifdef SLAPD_AUTHPASSWD
        /* needs updating */
        {"( 1.3.6.1.4.1.4203.666.2.2 DESC 'OpenLDAP authPassword' )",
                SLAP_SYNTAX_HIDE, NULL, NULL, NULL},
+#endif
 
        /* OpenLDAP Void Syntax */
        {"( 1.3.6.1.4.1.4203.1.1.1 DESC 'OpenLDAP void' )" ,
@@ -4296,7 +4304,7 @@ static struct mrule_defs_rec {
         */
        {"( " directoryStringApproxMatchOID " NAME 'directoryStringApproxMatch' "
                "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
-               SLAP_MR_EQUALITY_APPROX | SLAP_MR_EXT,
+               SLAP_MR_HIDE | SLAP_MR_EQUALITY_APPROX | SLAP_MR_EXT,
                NULL, NULL,
                directoryStringApproxMatch,
                directoryStringApproxIndexer, 
@@ -4305,7 +4313,7 @@ static struct mrule_defs_rec {
 
        {"( " IA5StringApproxMatchOID " NAME 'IA5StringApproxMatch' "
                "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
-               SLAP_MR_EQUALITY_APPROX | SLAP_MR_EXT,
+               SLAP_MR_HIDE | SLAP_MR_EQUALITY_APPROX | SLAP_MR_EXT,
                NULL, NULL,
                IA5StringApproxMatch,
                IA5StringApproxIndexer, 
@@ -4545,6 +4553,7 @@ static struct mrule_defs_rec {
                caseExactIA5SubstringsFilter,
                NULL},
 
+#ifdef SLAPD_AUTHPASSWD
        /* needs updating */
        {"( 1.3.6.1.4.1.4203.666.4.1 NAME 'authPasswordMatch' "
                "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )",
@@ -4552,6 +4561,7 @@ static struct mrule_defs_rec {
                NULL, NULL,
                authPasswordMatch, NULL, NULL,
                NULL},
+#endif
 
        {"( 1.3.6.1.4.1.4203.666.4.2 NAME 'OpenLDAPaciMatch' "
                "SYNTAX 1.3.6.1.4.1.4203.666.2.1 )",
@@ -4578,7 +4588,7 @@ static struct mrule_defs_rec {
 };
 
 int
-schema_init( void )
+slap_schema_init( void )
 {
        int             res;
        int             i;
@@ -4600,7 +4610,7 @@ schema_init( void )
                );
 
                if ( res ) {
-                       fprintf( stderr, "schema_init: Error registering syntax %s\n",
+                       fprintf( stderr, "slap_schema_init: Error registering syntax %s\n",
                                 syntax_defs[i].sd_desc );
                        return LDAP_OTHER;
                }
@@ -4609,7 +4619,7 @@ schema_init( void )
        for ( i=0; mrule_defs[i].mrd_desc != NULL; i++ ) {
                if( mrule_defs[i].mrd_usage == SLAP_MR_NONE ) {
                        fprintf( stderr,
-                               "schema_init: Ingoring unusable matching rule %s\n",
+                               "slap_schema_init: Ingoring unusable matching rule %s\n",
                                 mrule_defs[i].mrd_desc );
                        continue;
                }
@@ -4626,13 +4636,15 @@ schema_init( void )
 
                if ( res ) {
                        fprintf( stderr,
-                               "schema_init: Error registering matching rule %s\n",
+                               "slap_schema_init: Error registering matching rule %s\n",
                                 mrule_defs[i].mrd_desc );
                        return LDAP_OTHER;
                }
        }
+
+       res = slap_schema_load();
        schema_init_done = 1;
-       return LDAP_SUCCESS;
+       return res;
 }
 
 void