Commit d298e355 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Add SLAP_SYNTAX_BINARY flag to indicate binary storage is used for

attributes of the syntax.  Such attribute values be transferred
using binary syntax unless ber2str/str2ber routines are provided.
Used in conjunction with ";binary" attribute description option
and/or the Binary syntax.
parent e0f7614a
......@@ -75,7 +75,9 @@ Attribute *attr_dup( Attribute *a )
}
tmp->a_type = ch_strdup( a->a_type );
#ifdef SLAPD_SCHEMA_COMPAT
#ifdef SLAPD_SCHEMA_NOT_COMPAT
tmp->a_at = a->a_at;
#else
tmp->a_syntax = a->a_syntax;
#endif
tmp->a_next = NULL;
......
......@@ -197,7 +197,7 @@ int ldbm_tool_index_attr(
char* type )
{
static DBCache *db = NULL;
int indexmask, syntaxmask;
int indexmask;
char * at_cn;
#ifndef SLAPD_SCHEMA_COMPAT
AttributeType *at;
......
......@@ -468,7 +468,7 @@ LIBSLAPD_F (int) oc_add LDAP_P((LDAP_OBJECT_CLASS *oc, const char **err));
LIBSLAPD_F (Syntax *) syn_find LDAP_P((const char *synname));
LIBSLAPD_F (Syntax *) syn_find_desc LDAP_P((const char *syndesc, int *slen));
LIBSLAPD_F (int) syn_add LDAP_P((LDAP_SYNTAX *syn,
LIBSLAPD_F (int) syn_add LDAP_P((LDAP_SYNTAX *syn, int flags,
slap_syntax_validate_func *validate,
slap_syntax_transform_func *ber2str,
slap_syntax_transform_func *str2ber,
......@@ -479,9 +479,11 @@ LIBSLAPD_F (int) mr_add LDAP_P((LDAP_MATCHING_RULE *mr,
slap_mr_convert_func *convert,
slap_mr_normalize_func *normalize,
slap_mr_match_func *match,
slap_mr_indexer_func *indexer,
slap_mr_filter_func *filter,
const char **err));
LIBSLAPD_F (int) register_syntax LDAP_P((char *desc,
LIBSLAPD_F (int) register_syntax LDAP_P((char *desc, int flags,
slap_syntax_validate_func *validate,
slap_syntax_transform_func *ber2str,
slap_syntax_transform_func *str2ber ));
......@@ -489,11 +491,12 @@ LIBSLAPD_F (int) register_syntax LDAP_P((char *desc,
LIBSLAPD_F (int) register_matching_rule LDAP_P((char * desc,
slap_mr_convert_func *convert,
slap_mr_normalize_func *normalize,
slap_mr_match_func *match ));
slap_mr_match_func *match,
slap_mr_indexer_func *indexer,
slap_mr_filter_func *filter ));
LIBSLAPD_F (void) schema_info LDAP_P((Connection *conn, Operation *op,
char **attrs, int attrsonly));
LIBSLAPD_F (int) schema_init LDAP_P((void));
LIBSLAPD_F (int) is_entry_objectclass LDAP_P((
Entry *, const char* objectclass ));
......@@ -501,6 +504,12 @@ LIBSLAPD_F (int) is_entry_objectclass LDAP_P((
#define is_entry_referral(e) is_entry_objectclass((e), "REFERRAL")
/*
* schema_init.c
*/
LIBSLAPD_F (int) schema_init LDAP_P((void));
/*
* schemaparse.c
*/
......
......@@ -677,6 +677,7 @@ syn_insert(
int
syn_add(
LDAP_SYNTAX *syn,
int flags,
slap_syntax_validate_func *validate,
slap_syntax_transform_func *ber2str,
slap_syntax_transform_func *str2ber,
......@@ -689,6 +690,7 @@ syn_add(
ssyn = (Syntax *) ch_calloc( 1, sizeof(Syntax) );
memcpy( &ssyn->ssyn_syn, syn, sizeof(LDAP_SYNTAX));
ssyn->ssyn_flags = flags;
ssyn->ssyn_validate = validate;
ssyn->ssyn_ber2str = ber2str;
ssyn->ssyn_str2ber = str2ber;
......@@ -793,6 +795,8 @@ mr_add(
slap_mr_convert_func *convert,
slap_mr_normalize_func *normalize,
slap_mr_match_func *match,
slap_mr_indexer_func *indexer,
slap_mr_filter_func *filter,
const char **err
)
{
......@@ -806,6 +810,8 @@ mr_add(
smr->smr_convert = convert;
smr->smr_normalize = normalize;
smr->smr_match = match;
smr->smr_indexer = indexer;
smr->smr_filter = filter;
if ( smr->smr_syntax_oid ) {
if ( (syn = syn_find(smr->smr_syntax_oid)) ) {
......@@ -824,7 +830,7 @@ mr_add(
int
register_syntax(
char * desc,
char * desc, int flags,
slap_syntax_validate_func *validate,
slap_syntax_transform_func *ber2str,
slap_syntax_transform_func *str2ber )
......@@ -840,7 +846,7 @@ register_syntax(
return( -1 );
}
code = syn_add( syn, validate, ber2str, str2ber, &err );
code = syn_add( syn, flags, validate, ber2str, str2ber, &err );
if ( code ) {
Debug( LDAP_DEBUG_ANY, "Error in register_syntax: %s %s in %s\n",
scherr2str(code), err, desc );
......@@ -855,7 +861,9 @@ register_matching_rule(
char * desc,
slap_mr_convert_func *convert,
slap_mr_normalize_func *normalize,
slap_mr_match_func *match )
slap_mr_match_func *match,
slap_mr_indexer_func *indexer,
slap_mr_filter_func *filter )
{
LDAP_MATCHING_RULE *mr;
int code;
......@@ -868,7 +876,7 @@ register_matching_rule(
return( -1 );
}
code = mr_add( mr, convert, normalize, match, &err );
code = mr_add( mr, convert, normalize, match, indexer, filter, &err );
if ( code ) {
Debug( LDAP_DEBUG_ANY, "Error in register_syntax: %s for %s in %s\n",
scherr2str(code), err, desc );
......
......@@ -257,6 +257,7 @@ caseIgnoreIA5Match(
struct syntax_defs_rec {
char *sd_desc;
int sd_flags;
slap_syntax_validate_func *sd_validate;
slap_syntax_transform_func *sd_ber2str;
slap_syntax_transform_func *sd_str2ber;
......@@ -264,96 +265,102 @@ struct syntax_defs_rec {
struct syntax_defs_rec syntax_defs[] = {
{"( 1.3.6.1.4.1.1466.115.121.1.3 DESC 'AttributeTypeDescription' )",
NULL, NULL, NULL},
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.4 DESC 'Audio' )",
NULL, NULL, NULL},
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.5 DESC 'Binary' )",
SLAP_SYNTAX_BINARY,
NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.6 DESC 'BitString' )",
NULL, NULL, NULL},
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.7 DESC 'Boolean' )",
NULL, NULL, NULL},
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.8 DESC 'Certificate' )",
SLAP_SYNTAX_BINARY,
NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.9 DESC 'CertificateList' )",
SLAP_SYNTAX_BINARY,
NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.10 DESC 'CertificatePair' )",
SLAP_SYNTAX_BINARY,
NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.12 DESC 'DN' )",
NULL, NULL, NULL},
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.14 DESC 'DeliveryMethod' )",
NULL, NULL, NULL},
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.15 DESC 'DirectoryString' )",
UTF8StringValidate, NULL, NULL},
0, UTF8StringValidate, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.16 DESC 'DITContentRuleDescription' )",
NULL, NULL, NULL},
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.17 DESC 'DITStructureRuleDescription' )",
NULL, NULL, NULL},
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.21 DESC 'EnhancedGuide' )",
NULL, NULL, NULL},
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.22 DESC 'FacsimileTelephoneNumber' )",
NULL, NULL, NULL},
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.24 DESC 'GeneralizedTime' )",
NULL, NULL, NULL},
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.25 DESC 'Guide' )",
NULL, NULL, NULL},
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.26 DESC 'IA5String' )",
IA5StringValidate, NULL, NULL},
0, IA5StringValidate, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.27 DESC 'Integer' )",
NULL, NULL, NULL},
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.28 DESC 'JPEG' )",
NULL, NULL, NULL},
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.30 DESC 'MatchingRuleDescription' )",
NULL, NULL, NULL},
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.31 DESC 'MatchingRuleUseDescription' )",
NULL, NULL, NULL},
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.32 DESC 'MailPreference' )",
NULL, NULL, NULL},
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.34 DESC 'NameAndOptionalUID' )",
NULL, NULL, NULL},
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.35 DESC 'NameFormDescription' )",
NULL, NULL, NULL},
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.36 DESC 'NumericString' )",
NULL, NULL, NULL},
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.37 DESC 'ObjectClassDescription' )",
NULL, NULL, NULL},
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.38 DESC 'OID' )",
NULL, NULL, NULL},
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.39 DESC 'OtherMailbox' )",
NULL, NULL, NULL},
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.40 DESC 'OctetString' )",
octetStringValidate, NULL, NULL},
0, octetStringValidate, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.41 DESC 'PostalAddress' )",
NULL, NULL, NULL},
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.42 DESC 'ProtocolInformation' )",
NULL, NULL, NULL},
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.43 DESC 'PresentationAddress' )",
NULL, NULL, NULL},
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.44 DESC 'PrintableString' )",
NULL, NULL, NULL},
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.49 DESC 'SupportedAlgorithm' )",
NULL, NULL, NULL},
SLAP_SYNTAX_BINARY, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.50 DESC 'TelephoneNumber' )",
NULL, NULL, NULL},
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.51 DESC 'TeletexTerminalIdentifier' )",
NULL, NULL, NULL},
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.52 DESC 'TelexNumber' )",
NULL, NULL, NULL},
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.53 DESC 'UTCTime' )",
NULL, NULL, NULL},
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.54 DESC 'LDAPSyntaxDescription' )",
NULL, NULL, NULL},
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.58 DESC 'SubstringAssertion' )",
NULL, NULL, NULL},
0, NULL, NULL, NULL},
{NULL, NULL, NULL}
{NULL, 0, NULL, NULL, NULL}
};
struct mrule_defs_rec {
char *mrd_desc;
slap_mr_convert_func *mrd_convert;
slap_mr_normalize_func *mrd_normalize;
slap_mr_match_func *mrd_match;
char * mrd_desc;
slap_mr_convert_func * mrd_convert;
slap_mr_normalize_func * mrd_normalize;
slap_mr_match_func * mrd_match;
slap_mr_indexer_func * mrd_indexer;
slap_mr_filter_func * mrd_filter;
};
/*
......@@ -414,108 +421,108 @@ struct mrule_defs_rec {
struct mrule_defs_rec mrule_defs[] = {
{"( 2.5.13.0 NAME 'objectIdentifierMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
NULL, NULL, objectIdentifierMatch},
NULL, NULL, objectIdentifierMatch, NULL, NULL},
{"( 2.5.13.1 NAME 'distinguishedNameMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )",
NULL, NULL, distinguishedNameMatch},
NULL, NULL, distinguishedNameMatch, NULL, NULL},
{"( 2.5.13.2 NAME 'caseIgnoreMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
NULL, UTF8StringNormalize, caseIgnoreMatch},
NULL, UTF8StringNormalize, caseIgnoreMatch, NULL, NULL},
{"( 2.5.13.3 NAME 'caseIgnoreOrderingMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
NULL, UTF8StringNormalize, caseIgnoreOrderingMatch},
NULL, UTF8StringNormalize, caseIgnoreOrderingMatch, NULL, NULL},
{"( 2.5.13.4 NAME 'caseIgnoreSubstringsMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
NULL, UTF8StringNormalize, caseIgnoreSubstringsMatch},
NULL, UTF8StringNormalize, caseIgnoreSubstringsMatch, NULL, NULL},
/* Next three are not in the RFC's, but are needed for compatibility */
{"( 2.5.13.5 NAME 'caseExactMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
NULL, UTF8StringNormalize, caseExactMatch},
NULL, UTF8StringNormalize, caseExactMatch, NULL, NULL},
{"( 2.5.13.6 NAME 'caseExactOrderingMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
NULL, UTF8StringNormalize, caseExactOrderingMatch},
NULL, UTF8StringNormalize, caseExactOrderingMatch, NULL, NULL},
{"( 2.5.13.7 NAME 'caseExactSubstringsMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
NULL, UTF8StringNormalize, caseExactSubstringsMatch},
NULL, UTF8StringNormalize, caseExactSubstringsMatch, NULL, NULL},
{"( 2.5.13.8 NAME 'numericStringMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.36 )",
NULL, NULL, numericStringMatch},
NULL, NULL, numericStringMatch, NULL, NULL},
{"( 2.5.13.10 NAME 'numericStringSubstringsMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
NULL, NULL, numericStringSubstringsMatch},
NULL, NULL, numericStringSubstringsMatch, NULL, NULL},
{"( 2.5.13.11 NAME 'caseIgnoreListMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.41 )",
NULL, NULL, caseIgnoreListMatch},
NULL, NULL, caseIgnoreListMatch, NULL, NULL},
{"( 2.5.13.14 NAME 'integerMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )",
NULL, NULL, integerMatch},
NULL, NULL, integerMatch, NULL, NULL},
{"( 2.5.13.16 NAME 'bitStringMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.6 )",
NULL, NULL, bitStringMatch},
NULL, NULL, bitStringMatch, NULL, NULL},
{"( 2.5.13.17 NAME 'octetStringMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )",
NULL, NULL, octetStringMatch},
NULL, NULL, octetStringMatch, NULL, NULL},
{"( 2.5.13.20 NAME 'telephoneNumberMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.50 )",
NULL, NULL, telephoneNumberMatch},
NULL, NULL, telephoneNumberMatch, NULL, NULL},
{"( 2.5.13.21 NAME 'telephoneNumberSubstringsMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
NULL, NULL, telephoneNumberSubstringsMatch},
NULL, NULL, telephoneNumberSubstringsMatch, NULL, NULL},
{"( 2.5.13.22 NAME 'presentationAddressMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.43 )",
NULL, NULL, presentationAddressMatch},
NULL, NULL, presentationAddressMatch, NULL, NULL},
{"( 2.5.13.23 NAME 'uniqueMemberMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.34 )",
NULL, NULL, uniqueMemberMatch},
NULL, NULL, uniqueMemberMatch, NULL, NULL},
{"( 2.5.13.24 NAME 'protocolInformationMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.42 )",
NULL, NULL, protocolInformationMatch},
NULL, NULL, protocolInformationMatch, NULL, NULL},
{"( 2.5.13.27 NAME 'generalizedTimeMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )",
NULL, NULL, generalizedTimeMatch},
NULL, NULL, generalizedTimeMatch, NULL, NULL},
{"( 2.5.13.28 NAME 'generalizedTimeOrderingMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )",
NULL, NULL, generalizedTimeOrderingMatch},
NULL, NULL, generalizedTimeOrderingMatch, NULL, NULL},
{"( 2.5.13.29 NAME 'integerFirstComponentMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )",
NULL, NULL, integerFirstComponentMatch},
NULL, NULL, integerFirstComponentMatch, NULL, NULL},
{"( 2.5.13.30 NAME 'objectIdentifierFirstComponentMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
NULL, NULL, objectIdentifierFirstComponentMatch},
NULL, NULL, objectIdentifierFirstComponentMatch, NULL, NULL},
{"( 1.3.6.1.4.1.1466.109.114.1 NAME 'caseExactIA5Match' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
NULL, IA5StringNormalize, caseExactIA5Match},
NULL, IA5StringNormalize, caseExactIA5Match, NULL, NULL},
{"( 1.3.6.1.4.1.1466.109.114.2 NAME 'caseIgnoreIA5Match' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
NULL, IA5StringNormalize, caseIgnoreIA5Match},
NULL, IA5StringNormalize, caseIgnoreIA5Match, NULL, NULL},
{"( 1.3.6.1.4.1.1466.109.114.3 NAME 'caseIgnoreIA5SubstringsMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
NULL, IA5StringNormalize, caseIgnoreIA5SubstringsMatch},
NULL, IA5StringNormalize, caseIgnoreIA5SubstringsMatch, NULL, NULL},
{NULL, NULL, NULL, NULL}
};
......@@ -533,6 +540,7 @@ schema_init( void )
for ( i=0; syntax_defs[i].sd_desc != NULL; i++ ) {
res = register_syntax( syntax_defs[i].sd_desc,
syntax_defs[i].sd_flags,
syntax_defs[i].sd_validate,
syntax_defs[i].sd_ber2str,
syntax_defs[i].sd_str2ber );
......@@ -549,7 +557,9 @@ schema_init( void )
mrule_defs[i].mrd_desc,
mrule_defs[i].mrd_convert,
mrule_defs[i].mrd_normalize,
mrule_defs[i].mrd_match );
mrule_defs[i].mrd_match,
mrule_defs[i].mrd_indexer,
mrule_defs[i].mrd_filter );
if ( res ) {
fprintf( stderr,
......
......@@ -148,6 +148,9 @@ typedef struct slap_syntax {
LDAP_SYNTAX ssyn_syn;
int ssyn_flags;
#define SLAP_SYNTAX_NONE 0
#define SLAP_SYNTAX_BINARY 1
slap_syntax_validate_func *ssyn_validate;
/* convert to and from binary */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment