]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/schema_init.c
add logs; fix bug in group/dn selection logic
[openldap] / servers / slapd / schema_init.c
index 8a70eaefbb68530ea2a8269412e2726fbccd897c..499935beed43b870e1e0d94b28d0b5824958dd32 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2003 The OpenLDAP Foundation.
+ * Copyright 1998-2004 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -804,7 +804,7 @@ nameUIDPretty(
        } else {
                int rc;
                struct berval dnval = *val;
-               struct berval uidval = { 0, NULL };
+               struct berval uidval = BER_BVNULL;
 
                if( val->bv_val[val->bv_len-1] == 'B'
                        && val->bv_val[val->bv_len-2] == '\'' )
@@ -875,7 +875,7 @@ uniqueMemberNormalize(
 
        ber_dupbv( &out, val );
        if( out.bv_len != 0 ) {
-               struct berval uid = { 0, NULL };
+               struct berval uid = BER_BVNULL;
 
                if( out.bv_val[out.bv_len-1] == 'B'
                        && out.bv_val[out.bv_len-2] == '\'' )
@@ -935,10 +935,10 @@ uniqueMemberMatch(
 {
        int match;
        struct berval *asserted = (struct berval *) assertedValue;
-       struct berval assertedDN = { 0, NULL };
-       struct berval assertedUID = { 0, NULL };
-       struct berval valueDN = { 0, NULL };
-       struct berval valueUID = { 0, NULL };
+       struct berval assertedDN = BER_BVNULL;
+       struct berval assertedUID = BER_BVNULL;
+       struct berval valueDN = BER_BVNULL;
+       struct berval valueUID = BER_BVNULL;
 
        if( asserted->bv_len != 0 ) {
                assertedDN = *asserted;
@@ -1372,7 +1372,7 @@ approxIndexer(
        BerVarray keys=NULL;
 
        for( j=0; values[j].bv_val != NULL; j++ ) {
-               struct berval val = { 0, NULL };
+               struct berval val = BER_BVNULL;
                /* Yes, this is necessary */
                UTF8bvnormalize( &values[j], &val, LDAP_UTF8_APPROX, NULL );
                assert( val.bv_val != NULL );
@@ -2210,7 +2210,7 @@ certificateExactNormalize(
        unsigned char *p;
        char *serial = NULL;
        ber_len_t seriallen;
-       struct berval issuer_dn = { 0, NULL };
+       struct berval issuer_dn = BER_BVNULL;
        X509_NAME *name = NULL;
        ASN1_INTEGER *sn = NULL;
        X509 *xcert = NULL;
@@ -2557,6 +2557,139 @@ generalizedTimeOrderingMatch(
        return LDAP_SUCCESS;
 }
 
+static int
+deliveryMethodValidate(
+       Syntax *syntax,
+       struct berval *val )
+{
+#undef LENOF
+#define LENOF(s) (sizeof(s)-1)
+       struct berval tmp = *val;
+       /*
+     * DeliveryMethod = pdm *( WSP DOLLAR WSP DeliveryMethod )
+        *      pdm = "any" / "mhs" / "physical" / "telex" / "teletex" /
+        *              "g3fax" / "g4fax" / "ia5" / "videotex" / "telephone"
+        */
+again:
+       if( tmp.bv_len < 3 ) return LDAP_INVALID_SYNTAX;
+
+       switch( tmp.bv_val[0] ) {
+       case 'a':
+       case 'A':
+               if(( tmp.bv_len >= LENOF("any") ) &&
+                       ( strncasecmp(tmp.bv_val, "any", LENOF("any")) == 0 ))
+               {
+                       tmp.bv_len -= LENOF("any");
+                       tmp.bv_val += LENOF("any");
+                       break;
+               }
+               return LDAP_INVALID_SYNTAX;
+
+       case 'm':
+       case 'M':
+               if(( tmp.bv_len >= LENOF("mhs") ) &&
+                       ( strncasecmp(tmp.bv_val, "mhs", LENOF("mhs")) == 0 ))
+               {
+                       tmp.bv_len -= LENOF("mhs");
+                       tmp.bv_val += LENOF("mhs");
+                       break;
+               }
+               return LDAP_INVALID_SYNTAX;
+
+       case 'p':
+       case 'P':
+               if(( tmp.bv_len >= LENOF("physical") ) &&
+                       ( strncasecmp(tmp.bv_val, "physical", LENOF("physical")) == 0 ))
+               {
+                       tmp.bv_len -= LENOF("physical");
+                       tmp.bv_val += LENOF("physical");
+                       break;
+               }
+               return LDAP_INVALID_SYNTAX;
+
+       case 't':
+       case 'T': /* telex or teletex or telephone */
+               if(( tmp.bv_len >= LENOF("telex") ) &&
+                       ( strncasecmp(tmp.bv_val, "telex", LENOF("telex")) == 0 ))
+               {
+                       tmp.bv_len -= LENOF("telex");
+                       tmp.bv_val += LENOF("telex");
+                       break;
+               }
+               if(( tmp.bv_len >= LENOF("teletex") ) &&
+                       ( strncasecmp(tmp.bv_val, "teletex", LENOF("teletex")) == 0 ))
+               {
+                       tmp.bv_len -= LENOF("teletex");
+                       tmp.bv_val += LENOF("teletex");
+                       break;
+               }
+               if(( tmp.bv_len >= LENOF("telephone") ) &&
+                       ( strncasecmp(tmp.bv_val, "telephone", LENOF("telephone")) == 0 ))
+               {
+                       tmp.bv_len -= LENOF("telephone");
+                       tmp.bv_val += LENOF("telephone");
+                       break;
+               }
+               return LDAP_INVALID_SYNTAX;
+
+       case 'g':
+       case 'G': /* g3fax or g4fax */
+               if(( tmp.bv_len >= LENOF("g3fax") ) && (
+                       ( strncasecmp(tmp.bv_val, "g3fax", LENOF("g3fax")) == 0 ) ||
+                       ( strncasecmp(tmp.bv_val, "g4fax", LENOF("g4fax")) == 0 )))
+               {
+                       tmp.bv_len -= LENOF("g3fax");
+                       tmp.bv_val += LENOF("g3fax");
+                       break;
+               }
+               return LDAP_INVALID_SYNTAX;
+
+       case 'i':
+       case 'I':
+               if(( tmp.bv_len >= LENOF("ia5") ) &&
+                       ( strncasecmp(tmp.bv_val, "ia5", LENOF("ia5")) == 0 ))
+               {
+                       tmp.bv_len -= LENOF("ia5");
+                       tmp.bv_val += LENOF("ia5");
+                       break;
+               }
+               return LDAP_INVALID_SYNTAX;
+
+       case 'v':
+       case 'V':
+               if(( tmp.bv_len >= LENOF("videotex") ) &&
+                       ( strncasecmp(tmp.bv_val, "videotex", LENOF("videotex")) == 0 ))
+               {
+                       tmp.bv_len -= LENOF("videotex");
+                       tmp.bv_val += LENOF("videotex");
+                       break;
+               }
+               return LDAP_INVALID_SYNTAX;
+
+       default:
+               return LDAP_INVALID_SYNTAX;
+       }
+
+       if( tmp.bv_len == 0 ) return LDAP_SUCCESS;
+
+       while( tmp.bv_len && ( tmp.bv_val[0] == ' ' )) {
+               tmp.bv_len++;
+               tmp.bv_val--;
+       }
+       if( tmp.bv_len && ( tmp.bv_val[0] == '$' )) {
+               tmp.bv_len++;
+               tmp.bv_val--;
+       } else {
+               return LDAP_INVALID_SYNTAX;
+       }
+       while( tmp.bv_len && ( tmp.bv_val[0] == ' ' )) {
+               tmp.bv_len++;
+               tmp.bv_val--;
+       }
+
+       goto again;
+}
+
 static int
 nisNetgroupTripleValidate(
        Syntax *syntax,
@@ -2740,7 +2873,7 @@ static slap_syntax_defs_rec syntax_defs[] = {
        {"( 1.3.6.1.4.1.1466.115.121.1.13 DESC 'Data Quality' )",
                0, NULL, NULL},
        {"( 1.3.6.1.4.1.1466.115.121.1.14 DESC 'Delivery Method' )",
-               0, NULL, NULL},
+               0, deliveryMethodValidate, NULL},
        {"( 1.3.6.1.4.1.1466.115.121.1.15 DESC 'Directory String' )",
                0, UTF8StringValidate, NULL},
        {"( 1.3.6.1.4.1.1466.115.121.1.16 DESC 'DIT Content Rule Description' )",
@@ -2889,21 +3022,22 @@ char *objectIdentifierFirstComponentMatchSyntaxes[] = {
 /*
  * Other matching rules in X.520 that we do not use (yet):
  *
- * 2.5.13.9            numericStringOrderingMatch
  * 2.5.13.25   uTCTimeMatch
  * 2.5.13.26   uTCTimeOrderingMatch
- * 2.5.13.31   directoryStringFirstComponentMatch
- * 2.5.13.32   wordMatch
- * 2.5.13.33   keywordMatch
+ * 2.5.13.31*  directoryStringFirstComponentMatch
+ * 2.5.13.32*  wordMatch
+ * 2.5.13.33*  keywordMatch
  * 2.5.13.36   certificatePairExactMatch
  * 2.5.13.37   certificatePairMatch
  * 2.5.13.38   certificateListExactMatch
  * 2.5.13.39   certificateListMatch
  * 2.5.13.40   algorithmIdentifierMatch
- * 2.5.13.41   storedPrefixMatch
+ * 2.5.13.41*  storedPrefixMatch
  * 2.5.13.42   attributeCertificateMatch
  * 2.5.13.43   readerAndKeyIDMatch
  * 2.5.13.44   attributeIntegrityMatch
+ *
+ * (*) described in RFC 3698 (LDAP: Additional Matching Rules)
  */
 static slap_mrule_defs_rec mrule_defs[] = {
        /*
@@ -2958,7 +3092,7 @@ static slap_mrule_defs_rec mrule_defs[] = {
 
        {"( 2.5.13.4 NAME 'caseIgnoreSubstringsMatch' "
                "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
-               SLAP_MR_SUBSTR, NULL,
+               SLAP_MR_SUBSTR, directoryStringSyntaxes,
                NULL, UTF8StringNormalize, octetStringSubstringsMatch,
                octetStringSubstringsIndexer, octetStringSubstringsFilter,
                "caseIgnoreMatch" },
@@ -2987,10 +3121,17 @@ static slap_mrule_defs_rec mrule_defs[] = {
        {"( 2.5.13.8 NAME 'numericStringMatch' "
                "SYNTAX 1.3.6.1.4.1.1466.115.121.1.36 )",
                SLAP_MR_EQUALITY | SLAP_MR_EXT, NULL,
-               NULL, numericStringNormalize, octetStringSubstringsMatch,
-               octetStringSubstringsIndexer, octetStringSubstringsFilter,
+               NULL, numericStringNormalize, octetStringMatch,
+               octetStringIndexer, octetStringFilter,
                NULL },
 
+       {"( 2.5.13.9 NAME 'numericStringOrderingMatch' "
+               "SYNTAX 1.3.6.1.4.1.1466.115.121.1.36 )",
+               SLAP_MR_ORDERING, NULL,
+               NULL, numericStringNormalize, octetStringOrderingMatch,
+               NULL, NULL,
+               "numericStringMatch" },
+
        {"( 2.5.13.10 NAME 'numericStringSubstringsMatch' "
                "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
                SLAP_MR_SUBSTR, NULL,