/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
#include <ac/socket.h>
#include "slap.h"
-#include "ldap_pvt.h"
-#include "ldap_pvt_uc.h"
#define OCDEBUG 0
struct slap_internal_schema slap_schema;
+static int
+oidValidate(
+ Syntax *syntax,
+ struct berval *in )
+{
+ struct berval val = *in;
+
+ if( val.bv_len == 0 ) {
+ /* disallow empty strings */
+ return LDAP_INVALID_SYNTAX;
+ }
+
+ if( DESC_LEADCHAR( val.bv_val[0] ) ) {
+ val.bv_val++;
+ val.bv_len--;
+ if ( val.bv_len == 0 ) return LDAP_SUCCESS;
+
+ while( DESC_CHAR( val.bv_val[0] ) ) {
+ val.bv_val++;
+ val.bv_len--;
+
+ if ( val.bv_len == 0 ) return LDAP_SUCCESS;
+ }
+
+ } else {
+ int sep = 0;
+ while( OID_LEADCHAR( val.bv_val[0] ) ) {
+ val.bv_val++;
+ val.bv_len--;
+
+ if ( val.bv_val[-1] != '0' ) {
+ while ( OID_LEADCHAR( val.bv_val[0] )) {
+ val.bv_val++;
+ val.bv_len--;
+ }
+ }
+
+ if( val.bv_len == 0 ) {
+ if( sep == 0 ) break;
+ return LDAP_SUCCESS;
+ }
+
+ if( !OID_SEPARATOR( val.bv_val[0] )) break;
+
+ sep++;
+ val.bv_val++;
+ val.bv_len--;
+ }
+ }
+
+ return LDAP_INVALID_SYNTAX;
+}
+
+
static int objectClassPretty(
struct slap_syntax *syntax,
struct berval * in,
struct berval * out,
void *ctx )
{
- ObjectClass *oc = oc_bvfind( in );
+ ObjectClass *oc;
- if( oc != NULL ) {
- ber_dupbv_x( out, &oc->soc_cname, ctx );
- } else {
- ber_dupbv_x( out, in, ctx );
+ if( oidValidate( NULL, in )) return LDAP_INVALID_SYNTAX;
+
+ oc = oc_bvfind( in );
+ if( oc == NULL ) return LDAP_INVALID_SYNTAX;
+
+ ber_dupbv_x( out, &oc->soc_cname, ctx );
+ return LDAP_SUCCESS;
+}
+
+static int
+attributeTypeMatch(
+ int *matchp,
+ slap_mask_t flags,
+ Syntax *syntax,
+ MatchingRule *mr,
+ struct berval *value,
+ void *assertedValue )
+{
+ struct berval *a = (struct berval *) assertedValue;
+ AttributeType *at = at_bvfind( value );
+ AttributeType *asserted = at_bvfind( a );
+
+ if( asserted == NULL ) {
+ if( OID_LEADCHAR( *a->bv_val ) ) {
+ /* OID form, return FALSE */
+ *matchp = 1;
+ return LDAP_SUCCESS;
+ }
+
+ /* desc form, return undefined */
+ return LDAP_INVALID_SYNTAX;
+ }
+
+ if ( at == NULL ) {
+ /* unrecognized stored value */
+ return LDAP_INVALID_SYNTAX;
+ }
+
+ *matchp = ( asserted != at );
+ return LDAP_SUCCESS;
+}
+
+static int
+matchingRuleMatch(
+ int *matchp,
+ slap_mask_t flags,
+ Syntax *syntax,
+ MatchingRule *mr,
+ struct berval *value,
+ void *assertedValue )
+{
+ struct berval *a = (struct berval *) assertedValue;
+ MatchingRule *mrv = mr_bvfind( value );
+ MatchingRule *asserted = mr_bvfind( a );
+
+ if( asserted == NULL ) {
+ if( OID_LEADCHAR( *a->bv_val ) ) {
+ /* OID form, return FALSE */
+ *matchp = 1;
+ return LDAP_SUCCESS;
+ }
+
+ /* desc form, return undefined */
+ return LDAP_INVALID_SYNTAX;
}
+ if ( mrv == NULL ) {
+ /* unrecognized stored value */
+ return LDAP_INVALID_SYNTAX;
+ }
+
+ *matchp = ( asserted != mrv );
+ return LDAP_SUCCESS;
+}
+
+static int
+objectClassMatch(
+ int *matchp,
+ slap_mask_t flags,
+ Syntax *syntax,
+ MatchingRule *mr,
+ struct berval *value,
+ void *assertedValue )
+{
+ struct berval *a = (struct berval *) assertedValue;
+ ObjectClass *oc = oc_bvfind( value );
+ ObjectClass *asserted = oc_bvfind( a );
+
+ if( asserted == NULL ) {
+ if( OID_LEADCHAR( *a->bv_val ) ) {
+ /* OID form, return FALSE */
+ *matchp = 1;
+ return LDAP_SUCCESS;
+ }
+
+ /* desc form, return undefined */
+ return LDAP_INVALID_SYNTAX;
+ }
+
+ if ( oc == NULL ) {
+ /* unrecognized stored value */
+ return LDAP_INVALID_SYNTAX;
+ }
+
+ *matchp = ( asserted != oc );
return LDAP_SUCCESS;
}
}
/* desc form, return undefined */
- return SLAPD_COMPARE_UNDEFINED;
+ return LDAP_INVALID_SYNTAX;
}
if ( oc == NULL ) {
/* unrecognized stored value */
- return SLAPD_COMPARE_UNDEFINED;
+ return LDAP_INVALID_SYNTAX;
}
if( SLAP_MR_IS_VALUE_OF_ATTRIBUTE_SYNTAX( flags ) ) {
}
/* over allocate */
- ocvalues = sl_malloc( sizeof( struct berval ) * (noc+16), ctx );
+ ocvalues = slap_sl_malloc( sizeof( struct berval ) * (noc+16), ctx );
/* copy listed values (and termination) */
for( i=0; i<noc; i++ ) {
}
if( !found ) {
- ocvalues = sl_realloc( ocvalues,
+ ocvalues = slap_sl_realloc( ocvalues,
sizeof( struct berval ) * (noc+2), ctx );
assert( k == noc );
rc = octetStringIndexer( use, mask, syntax, mr,
prefix, ocvalues, keysp, ctx );
- sl_free( ocvalues, ctx );
+ slap_sl_free( ocvalues, ctx );
return rc;
}
"matchingRuleUse ) )",
subentryObjectClass, SLAP_OC_OPERATIONAL,
offsetof(struct slap_internal_schema, si_oc_subschema) },
-#ifdef LDAP_DEVEL
+#ifdef LDAP_COLLECTIVE_ATTRIBUTES
{ "collectiveAttributeSubentry", "( 2.5.17.2 "
"NAME 'collectiveAttributeSubentry' "
+ "DESC 'RFC3671: collective attribute subentry' "
"AUXILIARY )",
subentryObjectClass,
SLAP_OC_COLLECTIVEATTRIBUTESUBENTRY|SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
- offsetof(struct slap_internal_schema, si_oc_collectiveAttributeSubentry) },
+ offsetof( struct slap_internal_schema,
+ si_oc_collectiveAttributeSubentry) },
+#endif
+#ifdef LDAP_DYNAMIC_OBJECTS
{ "dynamicObject", "( 1.3.6.1.4.1.1466.101.119.2 "
"NAME 'dynamicObject' "
"DESC 'RFC2589: Dynamic Object' "
"EQUALITY objectIdentifierMatch "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
NULL, SLAP_AT_FINAL,
- NULL, objectClassPretty,
+ oidValidate, objectClassPretty,
NULL, NULL, objectSubClassMatch,
objectSubClassIndexer, objectSubClassFilter,
offsetof(struct slap_internal_schema, si_ad_objectClass) },
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 "
"SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
NULL, 0,
- NULL, objectClassPretty,
+ oidValidate, objectClassPretty,
NULL, NULL, objectSubClassMatch,
objectSubClassIndexer, objectSubClassFilter,
offsetof(struct slap_internal_schema, si_ad_structuralObjectClass) },
"EQUALITY booleanMatch "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 "
"SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
- NULL, 0,
+ NULL, SLAP_AT_DYNAMIC,
NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
offsetof(struct slap_internal_schema, si_ad_hasSubordinates) },
"EQUALITY distinguishedNameMatch "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE "
"NO-USER-MODIFICATION USAGE directoryOperation )",
- NULL, 0,
+ NULL, SLAP_AT_DYNAMIC,
NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
offsetof(struct slap_internal_schema, si_ad_subschemaSubentry) },
-#ifdef LDAP_DEVEL
+#ifdef LDAP_COLLECTIVE_ATTRIBUTES
{ "collectiveAttributeSubentries", "( 2.5.18.12 "
"NAME 'collectiveAttributeSubentries' "
+ "DESC 'RFC3671: collective attribute subentries' "
"EQUALITY distinguishedNameMatch "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
"NO-USER-MODIFICATION USAGE directoryOperation )",
NULL, NULL, NULL, NULL, NULL,
offsetof(struct slap_internal_schema, si_ad_collectiveSubentries) },
{ "collectiveExclusions", "( 2.5.18.7 NAME 'collectiveExclusions' "
+ "DESC 'RFC3671: collective attribute exclusions' "
"EQUALITY objectIdentifierMatch "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 "
"USAGE directoryOperation )",
offsetof(struct slap_internal_schema, si_ad_collectiveExclusions) },
#endif
+ { "entryDN", "( 1.3.6.1.4.1.4203.666.1.33 NAME 'entryDN' "
+ "DESC 'DN of the entry' "
+ "EQUALITY distinguishedNameMatch "
+ "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
+ "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
+ NULL, SLAP_AT_HIDE|SLAP_AT_DYNAMIC,
+ NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL,
+ offsetof(struct slap_internal_schema, si_ad_entryDN) },
{ "entryUUID", "( 1.3.6.1.4.1.4203.666.1.6 NAME 'entryUUID' "
"DESC 'UUID of the entry' "
"EQUALITY UUIDMatch "
offsetof(struct slap_internal_schema, si_ad_entryUUID) },
{ "entryCSN", "( 1.3.6.1.4.1.4203.666.1.7 NAME 'entryCSN' "
"DESC 'change sequence number of the entry content' "
- "EQUALITY octetStringMatch "
- "ORDERING octetStringOrderingMatch "
- "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{64} "
+ "EQUALITY CSNMatch "
+ "ORDERING CSNOrderingMatch "
+ "SYNTAX 1.3.6.1.4.1.4203.666.11.2.1{64} "
"SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
NULL, SLAP_AT_HIDE,
NULL, NULL,
offsetof(struct slap_internal_schema, si_ad_entryCSN) },
{ "namingCSN", "( 1.3.6.1.4.1.4203.666.1.13 NAME 'namingCSN' "
"DESC 'change sequence number of the entry naming (RDN)' "
- "EQUALITY octetStringMatch "
- "ORDERING octetStringOrderingMatch "
- "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{64} "
+ "EQUALITY CSNMatch "
+ "ORDERING CSNOrderingMatch "
+ "SYNTAX 1.3.6.1.4.1.4203.666.11.2.1{64} "
"SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
NULL, SLAP_AT_HIDE,
NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
offsetof(struct slap_internal_schema, si_ad_namingCSN) },
+#ifdef LDAP_SUPERIOR_UUID
{ "superiorUUID", "( 1.3.6.1.4.1.4203.666.1.11 NAME 'superiorUUID' "
"DESC 'UUID of the superior entry' "
"EQUALITY octetStringMatch "
NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
offsetof(struct slap_internal_schema, si_ad_superiorUUID) },
+#endif
{ "syncreplCookie", "( 1.3.6.1.4.1.4203.666.1.23 "
"NAME 'syncreplCookie' "
{ "contextCSN", "( 1.3.6.1.4.1.4203.666.1.25 "
"NAME 'contextCSN' "
"DESC 'the largest committed CSN of a context' "
- "EQUALITY octetStringMatch "
- "ORDERING octetStringOrderingMatch "
- "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 "
+ "EQUALITY CSNMatch "
+ "ORDERING CSNOrderingMatch "
+ "SYNTAX 1.3.6.1.4.1.4203.666.11.2.1{64} "
"SINGLE-VALUE NO-USER-MODIFICATION USAGE dSAOperation )",
NULL, SLAP_AT_HIDE,
NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
offsetof(struct slap_internal_schema, si_ad_contextCSN) },
-#ifdef LDAP_DEVEL
+#ifdef LDAP_SYNC_TIMESTAMP
{ "syncTimestamp", "( 1.3.6.1.4.1.4203.666.1.26 NAME 'syncTimestamp' "
"DESC 'Time which object was replicated' "
"EQUALITY generalizedTimeMatch "
"EQUALITY objectIdentifierFirstComponentMatch "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.16 USAGE directoryOperation )",
subentryAttribute, SLAP_AT_HIDE,
- NULL, NULL,
- NULL, NULL, NULL, NULL, NULL,
+ oidValidate, NULL,
+ NULL, NULL, objectClassMatch, NULL, NULL,
offsetof(struct slap_internal_schema, si_ad_ditContentRules) },
{ "matchingRules", "( 2.5.21.4 NAME 'matchingRules' "
"DESC 'RFC2252: matching rules' "
"EQUALITY objectIdentifierFirstComponentMatch "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.30 USAGE directoryOperation )",
subentryAttribute, 0,
- NULL, NULL,
- NULL, NULL, NULL, NULL, NULL,
+ oidValidate, NULL,
+ NULL, NULL, matchingRuleMatch, NULL, NULL,
offsetof(struct slap_internal_schema, si_ad_matchingRules) },
{ "attributeTypes", "( 2.5.21.5 NAME 'attributeTypes' "
"DESC 'RFC2252: attribute types' "
"EQUALITY objectIdentifierFirstComponentMatch "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.3 USAGE directoryOperation )",
subentryAttribute, 0,
- NULL, NULL,
- NULL, NULL, NULL, NULL, NULL,
+ oidValidate, NULL,
+ NULL, NULL, attributeTypeMatch, NULL, NULL,
offsetof(struct slap_internal_schema, si_ad_attributeTypes) },
{ "objectClasses", "( 2.5.21.6 NAME 'objectClasses' "
"DESC 'RFC2252: object classes' "
"EQUALITY objectIdentifierFirstComponentMatch "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.37 USAGE directoryOperation )",
subentryAttribute, 0,
- NULL, NULL,
- NULL, NULL, NULL, NULL, NULL,
+ oidValidate, NULL,
+ NULL, NULL, objectClassMatch, NULL, NULL,
offsetof(struct slap_internal_schema, si_ad_objectClasses) },
{ "nameForms", "( 2.5.21.7 NAME 'nameForms' "
"DESC 'RFC2252: name forms ' "
"EQUALITY objectIdentifierFirstComponentMatch "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.31 USAGE directoryOperation )",
subentryAttribute, 0,
- NULL, NULL,
- NULL, NULL, NULL, NULL, NULL,
+ oidValidate, NULL,
+ NULL, NULL, matchingRuleMatch, NULL, NULL,
offsetof(struct slap_internal_schema, si_ad_matchingRuleUse) },
{ "ldapSyntaxes", "( 1.3.6.1.4.1.1466.101.120.16 NAME 'ldapSyntaxes' "
offsetof(struct slap_internal_schema, si_ad_aci) },
#endif
-#ifdef LDAP_DEVEL
+#ifdef LDAP_DYNAMIC_OBJECTS
{ "entryTtl", "( 1.3.6.1.4.1.1466.101.119.3 NAME 'entryTtl' "
"DESC 'RFC2589: entry time-to-live' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE "
NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
offsetof(struct slap_internal_schema, si_ad_cn) },
+ { "uid", "( 0.9.2342.19200300.100.1.1 NAME ( 'uid' 'userid' ) "
+ "DESC 'RFC1274: user identifier' "
+ "EQUALITY caseIgnoreMatch "
+ "SUBSTR caseIgnoreSubstringsMatch "
+ "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{256} )",
+ NULL, 0,
+ NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL,
+ offsetof(struct slap_internal_schema, si_ad_uid) },
{ "userPassword", "( 2.5.4.35 NAME 'userPassword' "
"DESC 'RFC2256/2307: password of user' "
"EQUALITY octetStringMatch "
offsetof(struct slap_internal_schema, si_mr_caseExactSubstringsMatch) },
{ "distinguishedNameMatch",
offsetof(struct slap_internal_schema, si_mr_distinguishedNameMatch) },
+ { "dnSubtreeMatch",
+ offsetof(struct slap_internal_schema, si_mr_dnSubtreeMatch) },
+ { "dnOneLevelMatch",
+ offsetof(struct slap_internal_schema, si_mr_dnOneLevelMatch) },
+ { "dnSubordinateMatch",
+ offsetof(struct slap_internal_schema, si_mr_dnSubordinateMatch) },
+ { "dnSuperiorMatch",
+ offsetof(struct slap_internal_schema, si_mr_dnSuperiorMatch) },
{ "integerMatch",
offsetof(struct slap_internal_schema, si_mr_integerMatch) },
{ "integerFirstComponentMatch",
offsetof(struct slap_internal_schema, si_syn_integer) },
{ "1.3.6.1.4.1.1466.115.121.1.40",
offsetof(struct slap_internal_schema, si_syn_octetString) },
+ { "1.3.6.1.4.1.1466.115.121.1.3",
+ offsetof(struct slap_internal_schema, si_syn_attributeTypeDesc) },
+ { "1.3.6.1.4.1.1466.115.121.1.16",
+ offsetof(struct slap_internal_schema, si_syn_ditContentRuleDesc) },
+ { "1.3.6.1.4.1.1466.115.121.1.54",
+ offsetof(struct slap_internal_schema, si_syn_ldapSyntaxDesc) },
+ { "1.3.6.1.4.1.1466.115.121.1.30",
+ offsetof(struct slap_internal_schema, si_syn_matchingRuleDesc) },
+ { "1.3.6.1.4.1.1466.115.121.1.31",
+ offsetof(struct slap_internal_schema, si_syn_matchingRuleUseDesc) },
+ { "1.3.6.1.4.1.1466.115.121.1.35",
+ offsetof(struct slap_internal_schema, si_syn_nameFormDesc) },
+ { "1.3.6.1.4.1.1466.115.121.1.37",
+ offsetof(struct slap_internal_schema, si_syn_objectClassDesc) },
+ { "1.3.6.1.4.1.1466.115.121.1.17",
+ offsetof(struct slap_internal_schema, si_syn_ditStructureRuleDesc) },
{ NULL, 0 }
};
}
/* install custom rule routines */
- if( ( (*adp)->ad_type->sat_equality != NULL &&
- syntax == (*adp)->ad_type->sat_equality->smr_syntax ) ||
+ if( syntax != NULL ||
ad_map[i].ssam_mr_convert ||
ad_map[i].ssam_mr_normalize ||
ad_map[i].ssam_mr_match ||
MatchingRule *mr = ch_malloc( sizeof( MatchingRule ) );
*mr = *(*adp)->ad_type->sat_equality;
- if ( syntax == mr->smr_syntax ) {
+ if ( syntax != NULL ) {
mr->smr_syntax = (*adp)->ad_type->sat_syntax;
}
if ( ad_map[i].ssam_mr_convert ) {
}
}
- slap_at_undefined.sat_syntax = slap_schema.si_syn_distinguishedName;
+ slap_at_undefined.sat_syntax = slap_schema.si_syn_octetString;
slap_schema.si_at_undefined = &slap_at_undefined;
return LDAP_SUCCESS;