1 /* schema_init.c - init builtin schema */
4 * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
13 #include <ac/string.h>
14 #include <ac/socket.h>
18 #include "lutil_md5.h"
29 int match = value->bv_len - ((struct berval *) assertedValue)->bv_len;
32 match = memcmp( value->bv_val,
33 ((struct berval *) assertedValue)->bv_val,
41 /* Index generation function */
42 int octetStringIndexer(
46 struct berval *prefix,
47 struct berval **values,
48 struct berval ***keysp )
53 lutil_MD5_CTX MD5context;
54 unsigned char MD5digest[16];
56 digest.bv_val = MD5digest;
57 digest.bv_len = sizeof(MD5digest);
59 for( i=0; values[i] != NULL; i++ ) {
65 keys = ch_malloc( sizeof( struct berval * ) * (i+1) );
67 slen = strlen( syntax->ssyn_oid );
68 mlen = strlen( mr->smr_oid );
70 for( i=0; values[i] != NULL; i++ ) {
71 lutil_MD5Init( &MD5context );
72 if( prefix != NULL && prefix->bv_len > 0 ) {
73 lutil_MD5Update( &MD5context,
74 prefix->bv_val, prefix->bv_len );
76 lutil_MD5Update( &MD5context,
77 syntax->ssyn_oid, slen );
78 lutil_MD5Update( &MD5context,
80 lutil_MD5Update( &MD5context,
81 values[i]->bv_val, values[i]->bv_len );
82 lutil_MD5Final( MD5digest, &MD5context );
84 keys[i] = ber_bvdup( &digest );
94 /* Index generation function */
95 int octetStringFilter(
99 struct berval *prefix,
101 struct berval ***keysp )
104 struct berval **keys;
105 lutil_MD5_CTX MD5context;
106 unsigned char MD5digest[LUTIL_MD5_BYTES];
107 struct berval *value = (struct berval *) assertValue;
108 struct berval digest;
109 digest.bv_val = MD5digest;
110 digest.bv_len = sizeof(MD5digest);
112 slen = strlen( syntax->ssyn_oid );
113 mlen = strlen( mr->smr_oid );
115 keys = ch_malloc( sizeof( struct berval * ) * 2 );
117 lutil_MD5Init( &MD5context );
118 if( prefix != NULL && prefix->bv_len > 0 ) {
119 lutil_MD5Update( &MD5context,
120 prefix->bv_val, prefix->bv_len );
122 lutil_MD5Update( &MD5context,
123 syntax->ssyn_oid, slen );
124 lutil_MD5Update( &MD5context,
126 lutil_MD5Update( &MD5context,
127 value->bv_val, value->bv_len );
128 lutil_MD5Final( MD5digest, &MD5context );
130 keys[0] = ber_bvdup( &digest );
146 if( in->bv_len == 0 ) return LDAP_SUCCESS;
148 dn = ch_strdup( in->bv_val );
150 rc = dn_validate( dn ) == NULL
151 ? LDAP_INVALID_SYNTAX : LDAP_SUCCESS;
161 struct berval **normalized )
163 struct berval *out = ber_bvdup( val );
165 if( out->bv_len != 0 ) {
167 #ifdef USE_DN_NORMALIZE
168 dn = dn_normalize( out->bv_val );
170 dn = dn_validate( out->bv_val );
175 return LDAP_INVALID_SYNTAX;
179 out->bv_len = strlen( dn );
192 struct berval *value,
193 void *assertedValue )
196 struct berval *asserted = (struct berval *) assertedValue;
198 match = value->bv_len - asserted->bv_len;
201 #ifdef USE_DN_NORMALIZE
202 match = strcmp( value->bv_val, asserted->bv_val );
204 match = strcasecmp( value->bv_val, asserted->bv_val );
208 Debug( LDAP_DEBUG_ARGS, "dnMatch %d\n\t\"%s\"\n\t\"%s\"\n",
209 match, value->bv_val, asserted->bv_val );
220 /* any value allowed */
229 /* any value allowed */
233 #define berValidate blobValidate
242 unsigned char *u = in->bv_val;
244 for( count = in->bv_len; count > 0; count-=len, u+=len ) {
245 /* get the length indicated by the first byte */
246 len = LDAP_UTF8_CHARLEN( u );
248 /* should not be zero */
249 if( len == 0 ) return LDAP_INVALID_SYNTAX;
251 /* make sure len corresponds with the offset
252 to the next character */
253 if( LDAP_UTF8_OFFSET( u ) != len ) return LDAP_INVALID_SYNTAX;
256 if( count != 0 ) return LDAP_INVALID_SYNTAX;
265 struct berval **normalized )
267 struct berval *newval;
270 newval = ch_malloc( sizeof( struct berval ) );
274 /* Ignore initial whitespace */
275 while ( ldap_utf8_isspace( p ) ) {
281 return LDAP_INVALID_SYNTAX;
284 newval->bv_val = ch_strdup( p );
285 p = q = newval->bv_val;
291 if ( ldap_utf8_isspace( p ) ) {
292 len = LDAP_UTF8_COPY(q,p);
297 /* Ignore the extra whitespace */
298 while ( ldap_utf8_isspace( p ) ) {
302 len = LDAP_UTF8_COPY(q,p);
309 assert( *newval->bv_val );
310 assert( newval->bv_val < p );
313 /* cannot start with a space */
314 assert( !ldap_utf8_isspace(newval->bv_val) );
317 * If the string ended in space, backup the pointer one
318 * position. One is enough because the above loop collapsed
319 * all whitespace to a single space.
326 /* cannot end with a space */
327 assert( !ldap_utf8_isspace( LDAP_UTF8_PREV(q) ) );
332 newval->bv_len = q - newval->bv_val;
333 *normalized = newval;
345 if( val->bv_len == 0 ) return 0;
347 if( isdigit(val->bv_val[0]) ) {
349 for(i=1; i < val->bv_len; i++) {
350 if( val->bv_val[i] == '.' ) {
351 if( dot++ ) return 1;
352 } else if ( isdigit(val->bv_val[i]) ) {
355 return LDAP_INVALID_SYNTAX;
359 return !dot ? LDAP_SUCCESS : LDAP_INVALID_SYNTAX;
361 } else if( isalpha(val->bv_val[0]) ) {
362 for(i=1; i < val->bv_len; i++) {
363 if( !isalpha(val->bv_val[i] ) ) {
364 return LDAP_INVALID_SYNTAX;
371 return LDAP_INVALID_SYNTAX;
381 for(i=0; i < val->bv_len; i++) {
382 if( !isdigit(val->bv_val[i]) ) return LDAP_INVALID_SYNTAX;
389 printableStringValidate(
395 for(i=0; i < val->bv_len; i++) {
396 if( !isprint(val->bv_val[i]) ) return LDAP_INVALID_SYNTAX;
409 for(i=0; i < val->bv_len; i++) {
410 if( !isascii(val->bv_val[i]) ) return LDAP_INVALID_SYNTAX;
420 struct berval **out )
423 ber_len_t i, len = in->bv_len;
424 struct berval *bv = ch_malloc( sizeof(struct berval) );
426 bv->bv_len = len * sizeof( ldap_unicode_t );
427 bv->bv_val = (char *) u = ch_malloc( bv->bv_len + sizeof( ldap_unicode_t ) );;
429 for(i=0; i < len; i++ ) {
431 * IA5StringValidate should have been called to ensure
432 * input is limited to IA5.
434 u[i] = in->bv_val[i];
446 struct berval **normalized )
448 struct berval *newval;
451 newval = ch_malloc( sizeof( struct berval ) );
455 /* Ignore initial whitespace */
456 while ( isspace( *p++ ) ) {
462 return LDAP_INVALID_SYNTAX;
465 newval->bv_val = ch_strdup( p );
466 p = q = newval->bv_val;
469 if ( isspace( *p ) ) {
472 /* Ignore the extra whitespace */
473 while ( isspace( *p++ ) ) {
481 assert( *newval->bv_val );
482 assert( newval->bv_val < p );
485 /* cannot start with a space */
486 assert( !isspace(*newval->bv_val) );
489 * If the string ended in space, backup the pointer one
490 * position. One is enough because the above loop collapsed
491 * all whitespace to a single space.
494 if ( isspace( q[-1] ) ) {
498 /* cannot end with a space */
499 assert( !isspace( q[-1] ) );
504 newval->bv_len = q - newval->bv_val;
505 *normalized = newval;
516 struct berval *value,
517 void *assertedValue )
519 *match = strcmp( value->bv_val,
520 ((struct berval *) assertedValue)->bv_val );
525 caseExactIA5SubstringsMatch(
530 struct berval *value,
531 void *assertedValue )
534 SubstringsAssertion *sub = assertedValue;
535 struct berval left = *value;
539 if( sub->sa_initial ) {
540 inlen += sub->sa_initial->bv_len;
543 for(i=0; sub->sa_any[i]; i++) {
544 inlen += sub->sa_final->bv_len;
547 if( sub->sa_final ) {
548 inlen += sub->sa_final->bv_len;
551 if( inlen > value->bv_len ) {
556 if( sub->sa_initial ) {
557 match = strncmp( sub->sa_initial->bv_val, left.bv_val,
558 sub->sa_initial->bv_len );
564 left.bv_val += sub->sa_initial->bv_len;
565 left.bv_len -= sub->sa_initial->bv_len;
566 inlen -= sub->sa_initial->bv_len;
569 if( sub->sa_final ) {
570 match = strncmp( sub->sa_final->bv_val,
571 &left.bv_val[left.bv_len - sub->sa_final->bv_len],
572 sub->sa_final->bv_len );
578 left.bv_len -= sub->sa_final->bv_len;
579 inlen -= sub->sa_initial->bv_len;
583 for(i=0; sub->sa_any[i]; i++) {
588 if( inlen < left.bv_len ) {
589 /* not enough length */
594 if( sub->sa_any[i]->bv_len == 0 ) {
598 p = strchr( left.bv_val, *sub->sa_any[i]->bv_val );
605 idx = p - left.bv_val;
606 assert( idx < left.bv_len );
608 if( idx >= left.bv_len ) {
609 /* this shouldn't happen */
616 if( sub->sa_any[i]->bv_len > left.bv_len ) {
617 /* not enough left */
622 match = strncmp( left.bv_val,
623 sub->sa_any[i]->bv_val,
624 sub->sa_any[i]->bv_len );
631 left.bv_val += sub->sa_any[i]->bv_len;
632 left.bv_len -= sub->sa_any[i]->bv_len;
647 struct berval *value,
648 void *assertedValue )
650 *match = strcasecmp( value->bv_val,
651 ((struct berval *) assertedValue)->bv_val );
655 static char *strcasechr( const char *str, int c )
657 char *lower = strchr( str, TOLOWER(c) );
658 char *upper = strchr( str, TOUPPER(c) );
660 if( lower && upper ) {
661 return lower < upper ? lower : upper;
662 } else if ( lower ) {
670 caseIgnoreIA5SubstringsMatch(
675 struct berval *value,
676 void *assertedValue )
679 SubstringsAssertion *sub = assertedValue;
680 struct berval left = *value;
684 if( sub->sa_initial ) {
685 inlen += sub->sa_initial->bv_len;
688 for(i=0; sub->sa_any[i]; i++) {
689 inlen += sub->sa_final->bv_len;
692 if( sub->sa_final ) {
693 inlen += sub->sa_final->bv_len;
696 if( inlen > value->bv_len ) {
701 if( sub->sa_initial ) {
702 match = strncasecmp( sub->sa_initial->bv_val, left.bv_val,
703 sub->sa_initial->bv_len );
709 left.bv_val += sub->sa_initial->bv_len;
710 left.bv_len -= sub->sa_initial->bv_len;
713 if( sub->sa_final ) {
714 match = strncasecmp( sub->sa_final->bv_val,
715 &left.bv_val[left.bv_len - sub->sa_final->bv_len],
716 sub->sa_final->bv_len );
722 left.bv_len -= sub->sa_final->bv_len;
726 for(i=0; sub->sa_any[i]; i++) {
731 if( inlen < left.bv_len ) {
732 /* not enough length */
737 if( sub->sa_any[i]->bv_len == 0 ) {
741 p = strcasechr( left.bv_val, *sub->sa_any[i]->bv_val );
748 idx = p - left.bv_val;
749 assert( idx < left.bv_len );
751 if( idx >= left.bv_len ) {
752 /* this shouldn't happen */
759 if( sub->sa_any[i]->bv_len > left.bv_len ) {
760 /* not enough left */
765 match = strncasecmp( left.bv_val,
766 sub->sa_any[i]->bv_val,
767 sub->sa_any[i]->bv_len );
774 left.bv_val += sub->sa_any[i]->bv_len;
775 left.bv_len -= sub->sa_any[i]->bv_len;
784 /* Index generation function */
785 int caseIgnoreIA5Indexer(
789 struct berval *prefix,
790 struct berval **values,
791 struct berval ***keysp )
795 struct berval **keys;
796 lutil_MD5_CTX MD5context;
797 unsigned char MD5digest[16];
798 struct berval digest;
799 digest.bv_val = MD5digest;
800 digest.bv_len = sizeof(MD5digest);
802 for( i=0; values[i] != NULL; i++ ) {
803 /* just count them */
808 keys = ch_malloc( sizeof( struct berval * ) * (i+1) );
810 slen = strlen( syntax->ssyn_oid );
811 mlen = strlen( mr->smr_oid );
813 for( i=0; values[i] != NULL; i++ ) {
814 struct berval *value = ber_bvdup( values[i] );
815 ldap_pvt_str2upper( value->bv_val );
817 lutil_MD5Init( &MD5context );
818 if( prefix != NULL && prefix->bv_len > 0 ) {
819 lutil_MD5Update( &MD5context,
820 prefix->bv_val, prefix->bv_len );
822 lutil_MD5Update( &MD5context,
823 syntax->ssyn_oid, slen );
824 lutil_MD5Update( &MD5context,
826 lutil_MD5Update( &MD5context,
827 value->bv_val, value->bv_len );
828 lutil_MD5Final( MD5digest, &MD5context );
832 keys[i] = ber_bvdup( &digest );
840 /* Index generation function */
841 int caseIgnoreIA5Filter(
845 struct berval *prefix,
847 struct berval ***keysp )
850 struct berval **keys;
851 lutil_MD5_CTX MD5context;
852 unsigned char MD5digest[LUTIL_MD5_BYTES];
853 struct berval *value;
854 struct berval digest;
855 digest.bv_val = MD5digest;
856 digest.bv_len = sizeof(MD5digest);
858 slen = strlen( syntax->ssyn_oid );
859 mlen = strlen( mr->smr_oid );
861 value = ber_bvdup( (struct berval *) assertValue );
862 ldap_pvt_str2upper( value->bv_val );
864 keys = ch_malloc( sizeof( struct berval * ) * 2 );
866 lutil_MD5Init( &MD5context );
867 if( prefix != NULL && prefix->bv_len > 0 ) {
868 lutil_MD5Update( &MD5context,
869 prefix->bv_val, prefix->bv_len );
871 lutil_MD5Update( &MD5context,
872 syntax->ssyn_oid, slen );
873 lutil_MD5Update( &MD5context,
875 lutil_MD5Update( &MD5context,
876 value->bv_val, value->bv_len );
877 lutil_MD5Final( MD5digest, &MD5context );
879 keys[0] = ber_bvdup( &digest );
889 NumericStringNormalize(
892 struct berval **normalized )
894 /* similiar to IA5StringNormalize except removes all spaces */
895 struct berval *newval;
898 newval = ch_malloc( sizeof( struct berval ) );
902 /* Ignore initial whitespace */
903 while ( isspace( *p++ ) ) {
909 return LDAP_INVALID_SYNTAX;
912 newval->bv_val = ch_strdup( p );
913 p = q = newval->bv_val;
916 if ( isspace( *p ) ) {
917 /* Ignore whitespace */
924 assert( *newval->bv_val );
925 assert( newval->bv_val < p );
928 /* cannot start with a space */
929 assert( !isspace(*newval->bv_val) );
931 /* cannot end with a space */
932 assert( !isspace( q[-1] ) );
937 newval->bv_len = q - newval->bv_val;
938 *normalized = newval;
943 struct syntax_defs_rec {
946 slap_syntax_validate_func *sd_validate;
947 slap_syntax_transform_func *sd_normalize;
948 slap_syntax_transform_func *sd_pretty;
949 #ifdef SLAPD_BINARY_CONVERSION
950 slap_syntax_transform_func *sd_ber2str;
951 slap_syntax_transform_func *sd_str2ber;
955 #define X_HIDE "X-HIDE 'TRUE' "
956 #define X_BINARY "X-BINARY-TRANSFER-REQUIRED 'TRUE' "
957 #define X_NOT_H_R "X-NOT-HUMAN-READABLE 'TRUE' "
959 struct syntax_defs_rec syntax_defs[] = {
960 {"( 1.3.6.1.4.1.1466.115.121.1.1 DESC 'ACI Item' " X_BINARY X_NOT_H_R ")",
961 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, NULL, NULL, NULL},
962 {"( 1.3.6.1.4.1.1466.115.121.1.2 DESC 'Access Point' " X_NOT_H_R ")",
963 0, NULL, NULL, NULL},
964 {"( 1.3.6.1.4.1.1466.115.121.1.3 DESC 'Attribute Type Description' )",
965 0, NULL, NULL, NULL},
966 {"( 1.3.6.1.4.1.1466.115.121.1.4 DESC 'Audio' " X_NOT_H_R ")",
967 SLAP_SYNTAX_BLOB, blobValidate, NULL, NULL},
968 {"( 1.3.6.1.4.1.1466.115.121.1.5 DESC 'Binary' " X_BINARY X_NOT_H_R ")",
969 SLAP_SYNTAX_BER, berValidate, NULL, NULL},
970 {"( 1.3.6.1.4.1.1466.115.121.1.6 DESC 'Bit String' )",
971 0, NULL, NULL, NULL},
972 {"( 1.3.6.1.4.1.1466.115.121.1.7 DESC 'Boolean' )",
973 0, NULL, NULL, NULL},
974 {"( 1.3.6.1.4.1.1466.115.121.1.8 DESC 'Certificate' "
975 X_BINARY X_NOT_H_R ")",
976 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
977 {"( 1.3.6.1.4.1.1466.115.121.1.9 DESC 'Certificate List' "
978 X_BINARY X_NOT_H_R ")",
979 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
980 {"( 1.3.6.1.4.1.1466.115.121.1.10 DESC 'Certificate Pair' "
981 X_BINARY X_NOT_H_R ")",
982 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
983 {"( 1.3.6.1.4.1.1466.115.121.1.11 DESC 'Country String' )",
984 0, NULL, NULL, NULL},
985 {"( 1.3.6.1.4.1.1466.115.121.1.12 DESC 'Distinguished Name' )",
986 0, dnValidate, dnNormalize, NULL},
987 {"( 1.3.6.1.4.1.1466.115.121.1.13 DESC 'Data Quality' )",
988 0, NULL, NULL, NULL},
989 {"( 1.3.6.1.4.1.1466.115.121.1.14 DESC 'Delivery Method' )",
990 0, NULL, NULL, NULL},
991 {"( 1.3.6.1.4.1.1466.115.121.1.15 DESC 'Directory String' )",
992 0, UTF8StringValidate, UTF8StringNormalize, NULL},
993 {"( 1.3.6.1.4.1.1466.115.121.1.16 DESC 'DIT Content Rule Description' )",
994 0, NULL, NULL, NULL},
995 {"( 1.3.6.1.4.1.1466.115.121.1.17 DESC 'DIT Structure Rule Description' )",
996 0, NULL, NULL, NULL},
997 {"( 1.3.6.1.4.1.1466.115.121.1.19 DESC 'DSA Quality' )",
998 0, NULL, NULL, NULL},
999 {"( 1.3.6.1.4.1.1466.115.121.1.20 DESC 'DSE Type' )",
1000 0, NULL, NULL, NULL},
1001 {"( 1.3.6.1.4.1.1466.115.121.1.21 DESC 'Enhanced Guide' )",
1002 0, NULL, NULL, NULL},
1003 {"( 1.3.6.1.4.1.1466.115.121.1.22 DESC 'Facsimile Telephone Number' )",
1004 0, blobValidate, NULL, NULL},
1005 {"( 1.3.6.1.4.1.1466.115.121.1.23 DESC 'Fax' " X_NOT_H_R ")",
1006 SLAP_SYNTAX_BLOB, NULL, NULL, NULL},
1007 {"( 1.3.6.1.4.1.1466.115.121.1.24 DESC 'Generalized Time' )",
1008 0, NULL, NULL, NULL},
1009 {"( 1.3.6.1.4.1.1466.115.121.1.25 DESC 'Guide' )",
1010 0, NULL, NULL, NULL},
1011 {"( 1.3.6.1.4.1.1466.115.121.1.26 DESC 'IA5 String' )",
1012 0, IA5StringValidate, IA5StringNormalize, NULL},
1013 {"( 1.3.6.1.4.1.1466.115.121.1.27 DESC 'Integer' )",
1014 0, integerValidate, NULL, NULL},
1015 {"( 1.3.6.1.4.1.1466.115.121.1.28 DESC 'JPEG' " X_NOT_H_R ")",
1016 SLAP_SYNTAX_BLOB, NULL, NULL, NULL},
1017 {"( 1.3.6.1.4.1.1466.115.121.1.29 DESC 'Master And Shadow Access Points' )",
1018 0, NULL, NULL, NULL},
1019 {"( 1.3.6.1.4.1.1466.115.121.1.30 DESC 'Matching Rule Description' )",
1020 0, NULL, NULL, NULL},
1021 {"( 1.3.6.1.4.1.1466.115.121.1.31 DESC 'Matching Rule Use Description' )",
1022 0, NULL, NULL, NULL},
1023 {"( 1.3.6.1.4.1.1466.115.121.1.32 DESC 'Mail Preference' )",
1024 0, NULL, NULL, NULL},
1025 {"( 1.3.6.1.4.1.1466.115.121.1.33 DESC 'MHS OR Address' )",
1026 0, NULL, NULL, NULL},
1027 {"( 1.3.6.1.4.1.1466.115.121.1.34 DESC 'Name And Optional UID' )",
1028 0, NULL, NULL, NULL},
1029 {"( 1.3.6.1.4.1.1466.115.121.1.35 DESC 'Name Form Description' )",
1030 0, NULL, NULL, NULL},
1031 {"( 1.3.6.1.4.1.1466.115.121.1.36 DESC 'Numeric String' )",
1032 0, IA5StringValidate, NumericStringNormalize, NULL},
1033 {"( 1.3.6.1.4.1.1466.115.121.1.37 DESC 'Object Class Description' )",
1034 0, NULL, NULL, NULL},
1035 {"( 1.3.6.1.4.1.1466.115.121.1.38 DESC 'OID' )",
1036 0, oidValidate, NULL, NULL},
1037 {"( 1.3.6.1.4.1.1466.115.121.1.39 DESC 'Other Mailbox' )",
1038 0, NULL, NULL, NULL},
1039 {"( 1.3.6.1.4.1.1466.115.121.1.40 DESC 'Octet String' )",
1040 0, blobValidate, NULL, NULL},
1041 {"( 1.3.6.1.4.1.1466.115.121.1.41 DESC 'Postal Address' )",
1042 0, blobValidate, NULL, NULL},
1043 {"( 1.3.6.1.4.1.1466.115.121.1.42 DESC 'Protocol Information' )",
1044 0, NULL, NULL, NULL},
1045 {"( 1.3.6.1.4.1.1466.115.121.1.43 DESC 'Presentation Address' )",
1046 0, NULL, NULL, NULL},
1047 {"( 1.3.6.1.4.1.1466.115.121.1.44 DESC 'Printable String' )",
1048 0, printableStringValidate, NULL, NULL},
1049 {"( 1.3.6.1.4.1.1466.115.121.1.49 DESC 'Supported Algorithm' "
1050 X_BINARY X_NOT_H_R ")",
1051 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
1052 {"( 1.3.6.1.4.1.1466.115.121.1.50 DESC 'Telephone Number' )",
1053 0, blobValidate, NULL, NULL},
1054 {"( 1.3.6.1.4.1.1466.115.121.1.51 DESC 'Teletex Terminal Identifier' )",
1055 0, NULL, NULL, NULL},
1056 {"( 1.3.6.1.4.1.1466.115.121.1.52 DESC 'Telex Number' )",
1057 0, NULL, NULL, NULL},
1058 {"( 1.3.6.1.4.1.1466.115.121.1.53 DESC 'UTC Time' )",
1059 0, NULL, NULL, NULL},
1060 {"( 1.3.6.1.4.1.1466.115.121.1.54 DESC 'LDAP Syntax Description' )",
1061 0, NULL, NULL, NULL},
1062 {"( 1.3.6.1.4.1.1466.115.121.1.55 DESC 'Modify Rights' )",
1063 0, NULL, NULL, NULL},
1064 {"( 1.3.6.1.4.1.1466.115.121.1.56 DESC 'LDAP Schema Definition' )",
1065 0, NULL, NULL, NULL},
1066 {"( 1.3.6.1.4.1.1466.115.121.1.57 DESC 'LDAP Schema Description' )",
1067 0, NULL, NULL, NULL},
1068 {"( 1.3.6.1.4.1.1466.115.121.1.58 DESC 'Substring Assertion' )",
1069 0, NULL, NULL, NULL},
1071 /* OpenLDAP Experimental Syntaxes */
1072 {"( 1.3.6.1.4.1.4203.666.2.1 DESC 'OpenLDAP Experimental ACI' )",
1073 0, NULL, NULL, NULL},
1074 {"( 1.3.6.1.4.1.4203.666.2.2 DESC 'OpenLDAP authPassword' )",
1075 0, NULL, NULL, NULL},
1076 {"( 1.3.6.1.4.1.4203.666.2.3 DESC 'OpenLDAP void' " X_HIDE ")" ,
1077 SLAP_SYNTAX_HIDE, inValidate, NULL, NULL},
1078 #if 0 /* not needed */
1079 {"( 1.3.6.1.4.1.4203.666.2.4 DESC 'OpenLDAP DN' " X_HIDE ")" ,
1080 SLAP_SYNTAX_HIDE, inValidate, NULL, NULL},
1083 {NULL, 0, NULL, NULL, NULL}
1086 struct mrule_defs_rec {
1089 slap_mr_convert_func * mrd_convert;
1090 slap_mr_normalize_func * mrd_normalize;
1091 slap_mr_match_func * mrd_match;
1092 slap_mr_indexer_func * mrd_indexer;
1093 slap_mr_filter_func * mrd_filter;
1097 * Other matching rules in X.520 that we do not use:
1099 * 2.5.13.9 numericStringOrderingMatch
1100 * 2.5.13.13 booleanMatch
1101 * 2.5.13.15 integerOrderingMatch
1102 * 2.5.13.18 octetStringOrderingMatch
1103 * 2.5.13.19 octetStringSubstringsMatch
1104 * 2.5.13.25 uTCTimeMatch
1105 * 2.5.13.26 uTCTimeOrderingMatch
1106 * 2.5.13.31 directoryStringFirstComponentMatch
1107 * 2.5.13.32 wordMatch
1108 * 2.5.13.33 keywordMatch
1109 * 2.5.13.34 certificateExactMatch
1110 * 2.5.13.35 certificateMatch
1111 * 2.5.13.36 certificatePairExactMatch
1112 * 2.5.13.37 certificatePairMatch
1113 * 2.5.13.38 certificateListExactMatch
1114 * 2.5.13.39 certificateListMatch
1115 * 2.5.13.40 algorithmIdentifierMatch
1116 * 2.5.13.41 storedPrefixMatch
1117 * 2.5.13.42 attributeCertificateMatch
1118 * 2.5.13.43 readerAndKeyIDMatch
1119 * 2.5.13.44 attributeIntegrityMatch
1123 /* recycled matching functions */
1124 #define caseIgnoreMatch caseIgnoreIA5Match
1125 #define caseIgnoreOrderingMatch caseIgnoreMatch
1126 #define caseIgnoreSubstringsMatch caseIgnoreIA5SubstringsMatch
1127 #define caseExactMatch caseExactIA5Match
1128 #define caseExactOrderingMatch caseExactMatch
1129 #define caseExactSubstringsMatch caseExactIA5SubstringsMatch
1131 /* unimplemented matching functions */
1132 #define objectIdentifierMatch NULL
1133 #define caseIgnoreListMatch NULL
1134 #define caseIgnoreListSubstringsMatch NULL
1135 #define integerMatch NULL
1136 #define bitStringMatch NULL
1137 #define octetStringMatch NULL
1138 #define telephoneNumberMatch NULL
1139 #define telephoneNumberSubstringsMatch NULL
1140 #define presentationAddressMatch NULL
1141 #define uniqueMemberMatch NULL
1142 #define protocolInformationMatch NULL
1143 #define generalizedTimeMatch NULL
1144 #define generalizedTimeOrderingMatch NULL
1145 #define integerFirstComponentMatch NULL
1146 #define objectIdentifierFirstComponentMatch NULL
1148 #define OpenLDAPaciMatch NULL
1149 #define authPasswordMatch NULL
1151 /* unimplied indexer/filter routines */
1152 #define dnIndexer NULL
1153 #define dnFilter NULL
1155 #define caseIgnoreIndexer caseIgnoreIA5Indexer
1156 #define caseIgnoreFilter caseIgnoreIA5Filter
1157 #define caseExactIndexer caseExactIA5Indexer
1158 #define caseExactFilter caseExactIA5Filter
1159 #define caseExactIA5Indexer caseIgnoreIA5Indexer
1160 #define caseExactIA5Filter caseIgnoreIA5Filter
1162 struct mrule_defs_rec mrule_defs[] = {
1163 {"( 2.5.13.0 NAME 'objectIdentifierMatch' "
1164 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
1165 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1166 NULL, NULL, objectIdentifierMatch,
1167 caseIgnoreIA5Indexer, caseIgnoreIA5Filter},
1169 {"( 2.5.13.1 NAME 'distinguishedNameMatch' "
1170 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )",
1171 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1172 NULL, NULL, dnMatch, dnIndexer, dnFilter},
1174 {"( 2.5.13.2 NAME 'caseIgnoreMatch' "
1175 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
1176 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1177 NULL, NULL, caseIgnoreMatch, caseIgnoreIndexer, caseIgnoreFilter},
1179 {"( 2.5.13.3 NAME 'caseIgnoreOrderingMatch' "
1180 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
1182 NULL, NULL, caseIgnoreOrderingMatch, NULL, NULL},
1184 {"( 2.5.13.4 NAME 'caseIgnoreSubstringsMatch' "
1185 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
1186 SLAP_MR_SUBSTR | SLAP_MR_EXT,
1187 NULL, NULL, caseIgnoreSubstringsMatch, NULL, NULL},
1189 /* Next three are not in the RFC's, but are needed for compatibility */
1190 {"( 2.5.13.5 NAME 'caseExactMatch' "
1191 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
1192 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1193 NULL, NULL, caseExactMatch, caseExactIndexer, caseExactFilter},
1195 {"( 2.5.13.6 NAME 'caseExactOrderingMatch' "
1196 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
1198 NULL, NULL, caseExactOrderingMatch, NULL, NULL},
1200 {"( 2.5.13.7 NAME 'caseExactSubstringsMatch' "
1201 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
1202 SLAP_MR_SUBSTR | SLAP_MR_EXT,
1203 NULL, NULL, caseExactSubstringsMatch, NULL, NULL},
1205 {"( 2.5.13.8 NAME 'numericStringMatch' "
1206 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.36 )",
1207 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1208 NULL, NULL, caseIgnoreIA5Match, NULL, NULL},
1210 {"( 2.5.13.10 NAME 'numericStringSubstringsMatch' "
1211 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
1212 SLAP_MR_SUBSTR | SLAP_MR_EXT,
1213 NULL, NULL, caseIgnoreIA5SubstringsMatch, NULL, NULL},
1215 {"( 2.5.13.11 NAME 'caseIgnoreListMatch' "
1216 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.41 )",
1217 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1218 NULL, NULL, caseIgnoreListMatch, NULL, NULL},
1220 {"( 2.5.13.12 NAME 'caseIgnoreListSubstringsMatch' "
1221 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
1222 SLAP_MR_SUBSTR | SLAP_MR_EXT,
1223 NULL, NULL, caseIgnoreListSubstringsMatch, NULL, NULL},
1225 {"( 2.5.13.14 NAME 'integerMatch' "
1226 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )",
1227 SLAP_MR_NONE | SLAP_MR_EXT,
1228 NULL, NULL, integerMatch, NULL, NULL},
1230 {"( 2.5.13.16 NAME 'bitStringMatch' "
1231 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.6 )",
1232 SLAP_MR_NONE | SLAP_MR_EXT,
1233 NULL, NULL, bitStringMatch, NULL, NULL},
1235 {"( 2.5.13.17 NAME 'octetStringMatch' "
1236 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )",
1237 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1238 NULL, NULL, octetStringMatch, octetStringIndexer, octetStringFilter},
1240 {"( 2.5.13.20 NAME 'telephoneNumberMatch' "
1241 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.50 )",
1242 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1243 NULL, NULL, telephoneNumberMatch, NULL, NULL},
1245 {"( 2.5.13.21 NAME 'telephoneNumberSubstringsMatch' "
1246 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
1247 SLAP_MR_SUBSTR | SLAP_MR_EXT,
1248 NULL, NULL, telephoneNumberSubstringsMatch, NULL, NULL},
1250 {"( 2.5.13.22 NAME 'presentationAddressMatch' "
1251 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.43 )",
1252 SLAP_MR_NONE | SLAP_MR_EXT,
1253 NULL, NULL, presentationAddressMatch, NULL, NULL},
1255 {"( 2.5.13.23 NAME 'uniqueMemberMatch' "
1256 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.34 )",
1257 SLAP_MR_NONE | SLAP_MR_EXT,
1258 NULL, NULL, uniqueMemberMatch, NULL, NULL},
1260 {"( 2.5.13.24 NAME 'protocolInformationMatch' "
1261 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.42 )",
1262 SLAP_MR_NONE | SLAP_MR_EXT,
1263 NULL, NULL, protocolInformationMatch, NULL, NULL},
1265 {"( 2.5.13.27 NAME 'generalizedTimeMatch' "
1266 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )",
1267 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1268 NULL, NULL, generalizedTimeMatch, NULL, NULL},
1270 {"( 2.5.13.28 NAME 'generalizedTimeOrderingMatch' "
1271 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )",
1273 NULL, NULL, generalizedTimeOrderingMatch, NULL, NULL},
1275 {"( 2.5.13.29 NAME 'integerFirstComponentMatch' "
1276 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )",
1277 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1278 NULL, NULL, integerFirstComponentMatch, NULL, NULL},
1280 {"( 2.5.13.30 NAME 'objectIdentifierFirstComponentMatch' "
1281 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
1282 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1283 NULL, NULL, objectIdentifierFirstComponentMatch, NULL, NULL},
1285 {"( 1.3.6.1.4.1.1466.109.114.1 NAME 'caseExactIA5Match' "
1286 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
1287 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1288 NULL, NULL, caseExactIA5Match, caseExactIA5Indexer, caseExactIA5Filter},
1290 {"( 1.3.6.1.4.1.1466.109.114.2 NAME 'caseIgnoreIA5Match' "
1291 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
1292 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1293 NULL, NULL, caseIgnoreIA5Match, caseExactIA5Indexer, caseExactIA5Filter},
1295 {"( 1.3.6.1.4.1.1466.109.114.3 NAME 'caseIgnoreIA5SubstringsMatch' "
1296 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
1298 NULL, NULL, caseIgnoreIA5SubstringsMatch, NULL, NULL},
1300 {"( 1.3.6.1.4.1.4203.666.4.1 NAME 'authPasswordMatch' "
1301 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )",
1303 NULL, NULL, authPasswordMatch, NULL, NULL},
1305 {"( 1.3.6.1.4.1.4203.666.4.2 NAME 'OpenLDAPaciMatch' "
1306 "SYNTAX 1.3.6.1.4.1.4203.666.2.1 )",
1308 NULL, NULL, OpenLDAPaciMatch, NULL, NULL},
1310 {NULL, SLAP_MR_NONE, NULL, NULL, NULL}
1319 /* we should only be called once (from main) */
1320 assert( schema_init_done == 0 );
1322 for ( i=0; syntax_defs[i].sd_desc != NULL; i++ ) {
1323 res = register_syntax( syntax_defs[i].sd_desc,
1324 syntax_defs[i].sd_flags,
1325 syntax_defs[i].sd_validate,
1326 syntax_defs[i].sd_normalize,
1327 syntax_defs[i].sd_pretty
1328 #ifdef SLAPD_BINARY_CONVERSION
1330 syntax_defs[i].sd_ber2str,
1331 syntax_defs[i].sd_str2ber
1336 fprintf( stderr, "schema_init: Error registering syntax %s\n",
1337 syntax_defs[i].sd_desc );
1342 for ( i=0; mrule_defs[i].mrd_desc != NULL; i++ ) {
1343 if( mrule_defs[i].mrd_usage == SLAP_MR_NONE ) {
1345 "schema_init: Ingoring unusable matching rule %s\n",
1346 mrule_defs[i].mrd_desc );
1350 res = register_matching_rule(
1351 mrule_defs[i].mrd_desc,
1352 mrule_defs[i].mrd_usage,
1353 mrule_defs[i].mrd_convert,
1354 mrule_defs[i].mrd_normalize,
1355 mrule_defs[i].mrd_match,
1356 mrule_defs[i].mrd_indexer,
1357 mrule_defs[i].mrd_filter );
1361 "schema_init: Error registering matching rule %s\n",
1362 mrule_defs[i].mrd_desc );
1366 schema_init_done = 1;
1367 return LDAP_SUCCESS;