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 );
524 #ifdef SLAPD_SCHEMA_NOT_COMPAT
526 caseExactIA5SubstringsMatch(
531 struct berval *value,
532 void *assertedValue )
535 SubstringsAssertion *sub = assertedValue;
536 struct berval left = *value;
540 if( sub->sa_initial ) {
541 inlen += sub->sa_initial->bv_len;
544 for(i=0; sub->sa_any[i]; i++) {
545 inlen += sub->sa_final->bv_len;
548 if( sub->sa_final ) {
549 inlen += sub->sa_final->bv_len;
552 if( inlen > value->bv_len ) {
557 if( sub->sa_initial ) {
558 match = strncmp( sub->sa_initial->bv_val, left.bv_val,
559 sub->sa_initial->bv_len );
565 left.bv_val += sub->sa_initial->bv_len;
566 left.bv_len -= sub->sa_initial->bv_len;
567 inlen -= sub->sa_initial->bv_len;
570 if( sub->sa_final ) {
571 match = strncmp( sub->sa_final->bv_val,
572 &left.bv_val[left.bv_len - sub->sa_final->bv_len],
573 sub->sa_final->bv_len );
579 left.bv_len -= sub->sa_final->bv_len;
580 inlen -= sub->sa_initial->bv_len;
584 for(i=0; sub->sa_any[i]; i++) {
589 if( inlen < left.bv_len ) {
590 /* not enough length */
595 if( sub->sa_any[i]->bv_len == 0 ) {
599 p = strchr( left.bv_val, *sub->sa_any[i]->bv_val );
606 idx = p - left.bv_val;
607 assert( idx < left.bv_len );
609 if( idx >= left.bv_len ) {
610 /* this shouldn't happen */
617 if( sub->sa_any[i]->bv_len > left.bv_len ) {
618 /* not enough left */
623 match = strncmp( left.bv_val,
624 sub->sa_any[i]->bv_val,
625 sub->sa_any[i]->bv_len );
632 left.bv_val += sub->sa_any[i]->bv_len;
633 left.bv_len -= sub->sa_any[i]->bv_len;
649 struct berval *value,
650 void *assertedValue )
652 *match = strcasecmp( value->bv_val,
653 ((struct berval *) assertedValue)->bv_val );
657 #ifdef SLAPD_SCHEMA_NOT_COMPAT
658 static char *strcasechr( const char *str, int c )
660 char *lower = strchr( str, TOLOWER(c) );
661 char *upper = strchr( str, TOUPPER(c) );
663 if( lower && upper ) {
664 return lower < upper ? lower : upper;
665 } else if ( lower ) {
673 caseIgnoreIA5SubstringsMatch(
678 struct berval *value,
679 void *assertedValue )
682 SubstringsAssertion *sub = assertedValue;
683 struct berval left = *value;
687 if( sub->sa_initial ) {
688 inlen += sub->sa_initial->bv_len;
691 for(i=0; sub->sa_any[i]; i++) {
692 inlen += sub->sa_final->bv_len;
695 if( sub->sa_final ) {
696 inlen += sub->sa_final->bv_len;
699 if( inlen > value->bv_len ) {
704 if( sub->sa_initial ) {
705 match = strncasecmp( sub->sa_initial->bv_val, left.bv_val,
706 sub->sa_initial->bv_len );
712 left.bv_val += sub->sa_initial->bv_len;
713 left.bv_len -= sub->sa_initial->bv_len;
716 if( sub->sa_final ) {
717 match = strncasecmp( sub->sa_final->bv_val,
718 &left.bv_val[left.bv_len - sub->sa_final->bv_len],
719 sub->sa_final->bv_len );
725 left.bv_len -= sub->sa_final->bv_len;
729 for(i=0; sub->sa_any[i]; i++) {
734 if( inlen < left.bv_len ) {
735 /* not enough length */
740 if( sub->sa_any[i]->bv_len == 0 ) {
744 p = strcasechr( left.bv_val, *sub->sa_any[i]->bv_val );
751 idx = p - left.bv_val;
752 assert( idx < left.bv_len );
754 if( idx >= left.bv_len ) {
755 /* this shouldn't happen */
762 if( sub->sa_any[i]->bv_len > left.bv_len ) {
763 /* not enough left */
768 match = strncasecmp( left.bv_val,
769 sub->sa_any[i]->bv_val,
770 sub->sa_any[i]->bv_len );
777 left.bv_val += sub->sa_any[i]->bv_len;
778 left.bv_len -= sub->sa_any[i]->bv_len;
788 /* Index generation function */
789 int caseIgnoreIA5Indexer(
793 struct berval *prefix,
794 struct berval **values,
795 struct berval ***keysp )
799 struct berval **keys;
800 lutil_MD5_CTX MD5context;
801 unsigned char MD5digest[16];
802 struct berval digest;
803 digest.bv_val = MD5digest;
804 digest.bv_len = sizeof(MD5digest);
806 for( i=0; values[i] != NULL; i++ ) {
807 /* just count them */
812 keys = ch_malloc( sizeof( struct berval * ) * (i+1) );
814 slen = strlen( syntax->ssyn_oid );
815 mlen = strlen( mr->smr_oid );
817 for( i=0; values[i] != NULL; i++ ) {
818 struct berval *value = ber_bvdup( values[i] );
819 ldap_pvt_str2upper( value->bv_val );
821 lutil_MD5Init( &MD5context );
822 if( prefix != NULL && prefix->bv_len > 0 ) {
823 lutil_MD5Update( &MD5context,
824 prefix->bv_val, prefix->bv_len );
826 lutil_MD5Update( &MD5context,
827 syntax->ssyn_oid, slen );
828 lutil_MD5Update( &MD5context,
830 lutil_MD5Update( &MD5context,
831 value->bv_val, value->bv_len );
832 lutil_MD5Final( MD5digest, &MD5context );
836 keys[i] = ber_bvdup( &digest );
844 /* Index generation function */
845 int caseIgnoreIA5Filter(
849 struct berval *prefix,
851 struct berval ***keysp )
854 struct berval **keys;
855 lutil_MD5_CTX MD5context;
856 unsigned char MD5digest[LUTIL_MD5_BYTES];
857 struct berval *value;
858 struct berval digest;
859 digest.bv_val = MD5digest;
860 digest.bv_len = sizeof(MD5digest);
862 slen = strlen( syntax->ssyn_oid );
863 mlen = strlen( mr->smr_oid );
865 value = ber_bvdup( (struct berval *) assertValue );
866 ldap_pvt_str2upper( value->bv_val );
868 keys = ch_malloc( sizeof( struct berval * ) * 2 );
870 lutil_MD5Init( &MD5context );
871 if( prefix != NULL && prefix->bv_len > 0 ) {
872 lutil_MD5Update( &MD5context,
873 prefix->bv_val, prefix->bv_len );
875 lutil_MD5Update( &MD5context,
876 syntax->ssyn_oid, slen );
877 lutil_MD5Update( &MD5context,
879 lutil_MD5Update( &MD5context,
880 value->bv_val, value->bv_len );
881 lutil_MD5Final( MD5digest, &MD5context );
883 keys[0] = ber_bvdup( &digest );
893 NumericStringNormalize(
896 struct berval **normalized )
898 /* similiar to IA5StringNormalize except removes all spaces */
899 struct berval *newval;
902 newval = ch_malloc( sizeof( struct berval ) );
906 /* Ignore initial whitespace */
907 while ( isspace( *p++ ) ) {
913 return LDAP_INVALID_SYNTAX;
916 newval->bv_val = ch_strdup( p );
917 p = q = newval->bv_val;
920 if ( isspace( *p ) ) {
921 /* Ignore whitespace */
928 assert( *newval->bv_val );
929 assert( newval->bv_val < p );
932 /* cannot start with a space */
933 assert( !isspace(*newval->bv_val) );
935 /* cannot end with a space */
936 assert( !isspace( q[-1] ) );
941 newval->bv_len = q - newval->bv_val;
942 *normalized = newval;
947 struct syntax_defs_rec {
950 slap_syntax_validate_func *sd_validate;
951 slap_syntax_transform_func *sd_normalize;
952 slap_syntax_transform_func *sd_pretty;
953 #ifdef SLAPD_BINARY_CONVERSION
954 slap_syntax_transform_func *sd_ber2str;
955 slap_syntax_transform_func *sd_str2ber;
959 #define X_HIDE "X-HIDE 'TRUE' "
960 #define X_BINARY "X-BINARY-TRANSFER-REQUIRED 'TRUE' "
961 #define X_NOT_H_R "X-NOT-HUMAN-READABLE 'TRUE' "
963 struct syntax_defs_rec syntax_defs[] = {
964 {"( 1.3.6.1.4.1.1466.115.121.1.1 DESC 'ACI Item' " X_BINARY X_NOT_H_R ")",
965 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, NULL, NULL, NULL},
966 {"( 1.3.6.1.4.1.1466.115.121.1.2 DESC 'Access Point' " X_NOT_H_R ")",
967 0, NULL, NULL, NULL},
968 {"( 1.3.6.1.4.1.1466.115.121.1.3 DESC 'Attribute Type Description' )",
969 0, NULL, NULL, NULL},
970 {"( 1.3.6.1.4.1.1466.115.121.1.4 DESC 'Audio' " X_NOT_H_R ")",
971 SLAP_SYNTAX_BLOB, blobValidate, NULL, NULL},
972 {"( 1.3.6.1.4.1.1466.115.121.1.5 DESC 'Binary' " X_BINARY X_NOT_H_R ")",
973 SLAP_SYNTAX_BER, berValidate, NULL, NULL},
974 {"( 1.3.6.1.4.1.1466.115.121.1.6 DESC 'Bit String' )",
975 0, NULL, NULL, NULL},
976 {"( 1.3.6.1.4.1.1466.115.121.1.7 DESC 'Boolean' )",
977 0, NULL, NULL, NULL},
978 {"( 1.3.6.1.4.1.1466.115.121.1.8 DESC 'Certificate' "
979 X_BINARY X_NOT_H_R ")",
980 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
981 {"( 1.3.6.1.4.1.1466.115.121.1.9 DESC 'Certificate List' "
982 X_BINARY X_NOT_H_R ")",
983 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
984 {"( 1.3.6.1.4.1.1466.115.121.1.10 DESC 'Certificate Pair' "
985 X_BINARY X_NOT_H_R ")",
986 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
987 {"( 1.3.6.1.4.1.1466.115.121.1.11 DESC 'Country String' )",
988 0, NULL, NULL, NULL},
989 {"( 1.3.6.1.4.1.1466.115.121.1.12 DESC 'Distinguished Name' )",
990 0, dnValidate, dnNormalize, NULL},
991 {"( 1.3.6.1.4.1.1466.115.121.1.13 DESC 'Data Quality' )",
992 0, NULL, NULL, NULL},
993 {"( 1.3.6.1.4.1.1466.115.121.1.14 DESC 'Delivery Method' )",
994 0, NULL, NULL, NULL},
995 {"( 1.3.6.1.4.1.1466.115.121.1.15 DESC 'Directory String' )",
996 0, UTF8StringValidate, UTF8StringNormalize, NULL},
997 {"( 1.3.6.1.4.1.1466.115.121.1.16 DESC 'DIT Content Rule Description' )",
998 0, NULL, NULL, NULL},
999 {"( 1.3.6.1.4.1.1466.115.121.1.17 DESC 'DIT Structure Rule Description' )",
1000 0, NULL, NULL, NULL},
1001 {"( 1.3.6.1.4.1.1466.115.121.1.19 DESC 'DSA Quality' )",
1002 0, NULL, NULL, NULL},
1003 {"( 1.3.6.1.4.1.1466.115.121.1.20 DESC 'DSE Type' )",
1004 0, NULL, NULL, NULL},
1005 {"( 1.3.6.1.4.1.1466.115.121.1.21 DESC 'Enhanced Guide' )",
1006 0, NULL, NULL, NULL},
1007 {"( 1.3.6.1.4.1.1466.115.121.1.22 DESC 'Facsimile Telephone Number' )",
1008 0, blobValidate, NULL, NULL},
1009 {"( 1.3.6.1.4.1.1466.115.121.1.23 DESC 'Fax' " X_NOT_H_R ")",
1010 SLAP_SYNTAX_BLOB, NULL, NULL, NULL},
1011 {"( 1.3.6.1.4.1.1466.115.121.1.24 DESC 'Generalized Time' )",
1012 0, NULL, NULL, NULL},
1013 {"( 1.3.6.1.4.1.1466.115.121.1.25 DESC 'Guide' )",
1014 0, NULL, NULL, NULL},
1015 {"( 1.3.6.1.4.1.1466.115.121.1.26 DESC 'IA5 String' )",
1016 0, IA5StringValidate, IA5StringNormalize, NULL},
1017 {"( 1.3.6.1.4.1.1466.115.121.1.27 DESC 'Integer' )",
1018 0, integerValidate, NULL, NULL},
1019 {"( 1.3.6.1.4.1.1466.115.121.1.28 DESC 'JPEG' " X_NOT_H_R ")",
1020 SLAP_SYNTAX_BLOB, NULL, NULL, NULL},
1021 {"( 1.3.6.1.4.1.1466.115.121.1.29 DESC 'Master And Shadow Access Points' )",
1022 0, NULL, NULL, NULL},
1023 {"( 1.3.6.1.4.1.1466.115.121.1.30 DESC 'Matching Rule Description' )",
1024 0, NULL, NULL, NULL},
1025 {"( 1.3.6.1.4.1.1466.115.121.1.31 DESC 'Matching Rule Use Description' )",
1026 0, NULL, NULL, NULL},
1027 {"( 1.3.6.1.4.1.1466.115.121.1.32 DESC 'Mail Preference' )",
1028 0, NULL, NULL, NULL},
1029 {"( 1.3.6.1.4.1.1466.115.121.1.33 DESC 'MHS OR Address' )",
1030 0, NULL, NULL, NULL},
1031 {"( 1.3.6.1.4.1.1466.115.121.1.34 DESC 'Name And Optional UID' )",
1032 0, NULL, NULL, NULL},
1033 {"( 1.3.6.1.4.1.1466.115.121.1.35 DESC 'Name Form Description' )",
1034 0, NULL, NULL, NULL},
1035 {"( 1.3.6.1.4.1.1466.115.121.1.36 DESC 'Numeric String' )",
1036 0, IA5StringValidate, NumericStringNormalize, NULL},
1037 {"( 1.3.6.1.4.1.1466.115.121.1.37 DESC 'Object Class Description' )",
1038 0, NULL, NULL, NULL},
1039 {"( 1.3.6.1.4.1.1466.115.121.1.38 DESC 'OID' )",
1040 0, oidValidate, NULL, NULL},
1041 {"( 1.3.6.1.4.1.1466.115.121.1.39 DESC 'Other Mailbox' )",
1042 0, NULL, NULL, NULL},
1043 {"( 1.3.6.1.4.1.1466.115.121.1.40 DESC 'Octet String' )",
1044 0, blobValidate, NULL, NULL},
1045 {"( 1.3.6.1.4.1.1466.115.121.1.41 DESC 'Postal Address' )",
1046 0, blobValidate, NULL, NULL},
1047 {"( 1.3.6.1.4.1.1466.115.121.1.42 DESC 'Protocol Information' )",
1048 0, NULL, NULL, NULL},
1049 {"( 1.3.6.1.4.1.1466.115.121.1.43 DESC 'Presentation Address' )",
1050 0, NULL, NULL, NULL},
1051 {"( 1.3.6.1.4.1.1466.115.121.1.44 DESC 'Printable String' )",
1052 0, printableStringValidate, NULL, NULL},
1053 {"( 1.3.6.1.4.1.1466.115.121.1.49 DESC 'Supported Algorithm' "
1054 X_BINARY X_NOT_H_R ")",
1055 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
1056 {"( 1.3.6.1.4.1.1466.115.121.1.50 DESC 'Telephone Number' )",
1057 0, blobValidate, NULL, NULL},
1058 {"( 1.3.6.1.4.1.1466.115.121.1.51 DESC 'Teletex Terminal Identifier' )",
1059 0, NULL, NULL, NULL},
1060 {"( 1.3.6.1.4.1.1466.115.121.1.52 DESC 'Telex Number' )",
1061 0, NULL, NULL, NULL},
1062 {"( 1.3.6.1.4.1.1466.115.121.1.53 DESC 'UTC Time' )",
1063 0, NULL, NULL, NULL},
1064 {"( 1.3.6.1.4.1.1466.115.121.1.54 DESC 'LDAP Syntax Description' )",
1065 0, NULL, NULL, NULL},
1066 {"( 1.3.6.1.4.1.1466.115.121.1.55 DESC 'Modify Rights' )",
1067 0, NULL, NULL, NULL},
1068 {"( 1.3.6.1.4.1.1466.115.121.1.56 DESC 'LDAP Schema Definition' )",
1069 0, NULL, NULL, NULL},
1070 {"( 1.3.6.1.4.1.1466.115.121.1.57 DESC 'LDAP Schema Description' )",
1071 0, NULL, NULL, NULL},
1072 {"( 1.3.6.1.4.1.1466.115.121.1.58 DESC 'Substring Assertion' )",
1073 0, NULL, NULL, NULL},
1075 /* OpenLDAP Experimental Syntaxes */
1076 {"( 1.3.6.1.4.1.4203.666.2.1 DESC 'OpenLDAP Experimental ACI' )",
1077 0, NULL, NULL, NULL},
1078 {"( 1.3.6.1.4.1.4203.666.2.2 DESC 'OpenLDAP authPassword' )",
1079 0, NULL, NULL, NULL},
1080 {"( 1.3.6.1.4.1.4203.666.2.3 DESC 'OpenLDAP void' " X_HIDE ")" ,
1081 SLAP_SYNTAX_HIDE, inValidate, NULL, NULL},
1082 #if 0 /* not needed */
1083 {"( 1.3.6.1.4.1.4203.666.2.4 DESC 'OpenLDAP DN' " X_HIDE ")" ,
1084 SLAP_SYNTAX_HIDE, inValidate, NULL, NULL},
1087 {NULL, 0, NULL, NULL, NULL}
1090 struct mrule_defs_rec {
1093 slap_mr_convert_func * mrd_convert;
1094 slap_mr_normalize_func * mrd_normalize;
1095 slap_mr_match_func * mrd_match;
1096 slap_mr_indexer_func * mrd_indexer;
1097 slap_mr_filter_func * mrd_filter;
1101 * Other matching rules in X.520 that we do not use:
1103 * 2.5.13.9 numericStringOrderingMatch
1104 * 2.5.13.13 booleanMatch
1105 * 2.5.13.15 integerOrderingMatch
1106 * 2.5.13.18 octetStringOrderingMatch
1107 * 2.5.13.19 octetStringSubstringsMatch
1108 * 2.5.13.25 uTCTimeMatch
1109 * 2.5.13.26 uTCTimeOrderingMatch
1110 * 2.5.13.31 directoryStringFirstComponentMatch
1111 * 2.5.13.32 wordMatch
1112 * 2.5.13.33 keywordMatch
1113 * 2.5.13.34 certificateExactMatch
1114 * 2.5.13.35 certificateMatch
1115 * 2.5.13.36 certificatePairExactMatch
1116 * 2.5.13.37 certificatePairMatch
1117 * 2.5.13.38 certificateListExactMatch
1118 * 2.5.13.39 certificateListMatch
1119 * 2.5.13.40 algorithmIdentifierMatch
1120 * 2.5.13.41 storedPrefixMatch
1121 * 2.5.13.42 attributeCertificateMatch
1122 * 2.5.13.43 readerAndKeyIDMatch
1123 * 2.5.13.44 attributeIntegrityMatch
1126 #ifndef SLAPD_SCHEMA_NOT_COMPAT
1127 #define caseIgnoreIA5SubstringsMatch NULL
1128 #define caseExactIA5SubstringsMatch NULL
1131 /* recycled matching functions */
1132 #define caseIgnoreMatch caseIgnoreIA5Match
1133 #define caseIgnoreOrderingMatch caseIgnoreMatch
1134 #define caseIgnoreSubstringsMatch caseIgnoreIA5SubstringsMatch
1135 #define caseExactMatch caseExactIA5Match
1136 #define caseExactOrderingMatch caseExactMatch
1137 #define caseExactSubstringsMatch caseExactIA5SubstringsMatch
1139 /* unimplemented matching functions */
1140 #define objectIdentifierMatch NULL
1141 #define caseIgnoreListMatch NULL
1142 #define caseIgnoreListSubstringsMatch NULL
1143 #define integerMatch NULL
1144 #define bitStringMatch NULL
1145 #define octetStringMatch NULL
1146 #define telephoneNumberMatch NULL
1147 #define telephoneNumberSubstringsMatch NULL
1148 #define presentationAddressMatch NULL
1149 #define uniqueMemberMatch NULL
1150 #define protocolInformationMatch NULL
1151 #define generalizedTimeMatch NULL
1152 #define generalizedTimeOrderingMatch NULL
1153 #define integerFirstComponentMatch NULL
1154 #define objectIdentifierFirstComponentMatch NULL
1156 #define OpenLDAPaciMatch NULL
1157 #define authPasswordMatch NULL
1159 /* unimplied indexer/filter routines */
1160 #define dnIndexer NULL
1161 #define dnFilter NULL
1163 #define caseIgnoreIndexer caseIgnoreIA5Indexer
1164 #define caseIgnoreFilter caseIgnoreIA5Filter
1165 #define caseExactIndexer caseExactIA5Indexer
1166 #define caseExactFilter caseExactIA5Filter
1167 #define caseExactIA5Indexer caseIgnoreIA5Indexer
1168 #define caseExactIA5Filter caseIgnoreIA5Filter
1170 struct mrule_defs_rec mrule_defs[] = {
1171 {"( 2.5.13.0 NAME 'objectIdentifierMatch' "
1172 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
1173 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1174 NULL, NULL, objectIdentifierMatch,
1175 caseIgnoreIA5Indexer, caseIgnoreIA5Filter},
1177 {"( 2.5.13.1 NAME 'distinguishedNameMatch' "
1178 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )",
1179 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1180 NULL, NULL, dnMatch, dnIndexer, dnFilter},
1182 {"( 2.5.13.2 NAME 'caseIgnoreMatch' "
1183 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
1184 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1185 NULL, NULL, caseIgnoreMatch, caseIgnoreIndexer, caseIgnoreFilter},
1187 {"( 2.5.13.3 NAME 'caseIgnoreOrderingMatch' "
1188 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
1190 NULL, NULL, caseIgnoreOrderingMatch, NULL, NULL},
1192 {"( 2.5.13.4 NAME 'caseIgnoreSubstringsMatch' "
1193 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
1194 SLAP_MR_SUBSTR | SLAP_MR_EXT,
1195 NULL, NULL, caseIgnoreSubstringsMatch, NULL, NULL},
1197 /* Next three are not in the RFC's, but are needed for compatibility */
1198 {"( 2.5.13.5 NAME 'caseExactMatch' "
1199 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
1200 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1201 NULL, NULL, caseExactMatch, caseExactIndexer, caseExactFilter},
1203 {"( 2.5.13.6 NAME 'caseExactOrderingMatch' "
1204 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
1206 NULL, NULL, caseExactOrderingMatch, NULL, NULL},
1208 {"( 2.5.13.7 NAME 'caseExactSubstringsMatch' "
1209 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
1210 SLAP_MR_SUBSTR | SLAP_MR_EXT,
1211 NULL, NULL, caseExactSubstringsMatch, NULL, NULL},
1213 {"( 2.5.13.8 NAME 'numericStringMatch' "
1214 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.36 )",
1215 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1216 NULL, NULL, caseIgnoreIA5Match, NULL, NULL},
1218 {"( 2.5.13.10 NAME 'numericStringSubstringsMatch' "
1219 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
1220 SLAP_MR_SUBSTR | SLAP_MR_EXT,
1221 NULL, NULL, caseIgnoreIA5SubstringsMatch, NULL, NULL},
1223 {"( 2.5.13.11 NAME 'caseIgnoreListMatch' "
1224 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.41 )",
1225 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1226 NULL, NULL, caseIgnoreListMatch, NULL, NULL},
1228 {"( 2.5.13.12 NAME 'caseIgnoreListSubstringsMatch' "
1229 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
1230 SLAP_MR_SUBSTR | SLAP_MR_EXT,
1231 NULL, NULL, caseIgnoreListSubstringsMatch, NULL, NULL},
1233 {"( 2.5.13.14 NAME 'integerMatch' "
1234 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )",
1235 SLAP_MR_NONE | SLAP_MR_EXT,
1236 NULL, NULL, integerMatch, NULL, NULL},
1238 {"( 2.5.13.16 NAME 'bitStringMatch' "
1239 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.6 )",
1240 SLAP_MR_NONE | SLAP_MR_EXT,
1241 NULL, NULL, bitStringMatch, NULL, NULL},
1243 {"( 2.5.13.17 NAME 'octetStringMatch' "
1244 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )",
1245 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1246 NULL, NULL, octetStringMatch, octetStringIndexer, octetStringFilter},
1248 {"( 2.5.13.20 NAME 'telephoneNumberMatch' "
1249 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.50 )",
1250 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1251 NULL, NULL, telephoneNumberMatch, NULL, NULL},
1253 {"( 2.5.13.21 NAME 'telephoneNumberSubstringsMatch' "
1254 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
1255 SLAP_MR_SUBSTR | SLAP_MR_EXT,
1256 NULL, NULL, telephoneNumberSubstringsMatch, NULL, NULL},
1258 {"( 2.5.13.22 NAME 'presentationAddressMatch' "
1259 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.43 )",
1260 SLAP_MR_NONE | SLAP_MR_EXT,
1261 NULL, NULL, presentationAddressMatch, NULL, NULL},
1263 {"( 2.5.13.23 NAME 'uniqueMemberMatch' "
1264 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.34 )",
1265 SLAP_MR_NONE | SLAP_MR_EXT,
1266 NULL, NULL, uniqueMemberMatch, NULL, NULL},
1268 {"( 2.5.13.24 NAME 'protocolInformationMatch' "
1269 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.42 )",
1270 SLAP_MR_NONE | SLAP_MR_EXT,
1271 NULL, NULL, protocolInformationMatch, NULL, NULL},
1273 {"( 2.5.13.27 NAME 'generalizedTimeMatch' "
1274 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )",
1275 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1276 NULL, NULL, generalizedTimeMatch, NULL, NULL},
1278 {"( 2.5.13.28 NAME 'generalizedTimeOrderingMatch' "
1279 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )",
1281 NULL, NULL, generalizedTimeOrderingMatch, NULL, NULL},
1283 {"( 2.5.13.29 NAME 'integerFirstComponentMatch' "
1284 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )",
1285 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1286 NULL, NULL, integerFirstComponentMatch, NULL, NULL},
1288 {"( 2.5.13.30 NAME 'objectIdentifierFirstComponentMatch' "
1289 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
1290 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1291 NULL, NULL, objectIdentifierFirstComponentMatch, NULL, NULL},
1293 {"( 1.3.6.1.4.1.1466.109.114.1 NAME 'caseExactIA5Match' "
1294 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
1295 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1296 NULL, NULL, caseExactIA5Match, caseExactIA5Indexer, caseExactIA5Filter},
1298 {"( 1.3.6.1.4.1.1466.109.114.2 NAME 'caseIgnoreIA5Match' "
1299 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
1300 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1301 NULL, NULL, caseIgnoreIA5Match, caseExactIA5Indexer, caseExactIA5Filter},
1303 {"( 1.3.6.1.4.1.1466.109.114.3 NAME 'caseIgnoreIA5SubstringsMatch' "
1304 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
1306 NULL, NULL, caseIgnoreIA5SubstringsMatch, NULL, NULL},
1308 {"( 1.3.6.1.4.1.4203.666.4.1 NAME 'authPasswordMatch' "
1309 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )",
1311 NULL, NULL, authPasswordMatch, NULL, NULL},
1313 {"( 1.3.6.1.4.1.4203.666.4.2 NAME 'OpenLDAPaciMatch' "
1314 "SYNTAX 1.3.6.1.4.1.4203.666.2.1 )",
1316 NULL, NULL, OpenLDAPaciMatch, NULL, NULL},
1318 {NULL, SLAP_MR_NONE, NULL, NULL, NULL}
1327 /* we should only be called once (from main) */
1328 assert( schema_init_done == 0 );
1330 for ( i=0; syntax_defs[i].sd_desc != NULL; i++ ) {
1331 res = register_syntax( syntax_defs[i].sd_desc,
1332 syntax_defs[i].sd_flags,
1333 syntax_defs[i].sd_validate,
1334 syntax_defs[i].sd_normalize,
1335 syntax_defs[i].sd_pretty
1336 #ifdef SLAPD_BINARY_CONVERSION
1338 syntax_defs[i].sd_ber2str,
1339 syntax_defs[i].sd_str2ber
1344 fprintf( stderr, "schema_init: Error registering syntax %s\n",
1345 syntax_defs[i].sd_desc );
1350 for ( i=0; mrule_defs[i].mrd_desc != NULL; i++ ) {
1351 if( mrule_defs[i].mrd_usage == SLAP_MR_NONE ) {
1353 "schema_init: Ingoring unusable matching rule %s\n",
1354 mrule_defs[i].mrd_desc );
1358 res = register_matching_rule(
1359 mrule_defs[i].mrd_desc,
1360 mrule_defs[i].mrd_usage,
1361 mrule_defs[i].mrd_convert,
1362 mrule_defs[i].mrd_normalize,
1363 mrule_defs[i].mrd_match,
1364 mrule_defs[i].mrd_indexer,
1365 mrule_defs[i].mrd_filter );
1369 "schema_init: Error registering matching rule %s\n",
1370 mrule_defs[i].mrd_desc );
1374 schema_init_done = 1;
1375 return LDAP_SUCCESS;