Commit 741f9ea3 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Add initial dnSubtreeMatch.

Should reuse other DN routines.
Need to add various other DN matching rule functions.
This commit, combined with entryDN and slapcat -a, should
fully address ITS#3112.
parent f1f18f7b
......@@ -958,7 +958,54 @@ dnMatch(
match, value->bv_val, asserted->bv_val );
*matchp = match;
return( LDAP_SUCCESS );
return LDAP_SUCCESS;
}
/*
* dnRelativeMatch routine
*/
int
dnRelativeMatch(
int *matchp,
slap_mask_t flags,
Syntax *syntax,
MatchingRule *mr,
struct berval *value,
void *assertedValue )
{
int match;
struct berval *asserted = (struct berval *) assertedValue;
assert( matchp );
assert( value );
assert( assertedValue );
assert( !BER_BVISNULL( value ) );
assert( !BER_BVISNULL( asserted ) );
if( mr == slap_schema.si_mr_dnSubtreeMatch ) {
if( asserted->bv_len > value->bv_len ) {
match = -1;
} else if ( asserted->bv_len == value->bv_len ) {
match = memcmp( value->bv_val, asserted->bv_val,
value->bv_len );
} else {
if( DN_SEPARATOR(
value->bv_val[value->bv_len - asserted->bv_len - 1] ))
{
match = memcmp(
&value->bv_val[value->bv_len - asserted->bv_len],
asserted->bv_val,
asserted->bv_len );
} else {
return 1;
}
}
*matchp = match;
return LDAP_SUCCESS;
}
return LDAP_OTHER;
}
int
......@@ -988,8 +1035,7 @@ rdnMatch(
match, value->bv_val, asserted->bv_val );
*matchp = match;
return( LDAP_SUCCESS );
return LDAP_SUCCESS;
}
......@@ -1046,14 +1092,11 @@ dnExtractRdn(
return rc;
}
rc = ldap_rdn2bv_x( tmpRDN, rdn, LDAP_DN_FORMAT_LDAPV3 | LDAP_DN_PRETTY, ctx );
rc = ldap_rdn2bv_x( tmpRDN, rdn, LDAP_DN_FORMAT_LDAPV3 | LDAP_DN_PRETTY,
ctx );
ldap_rdnfree_x( tmpRDN, ctx );
if ( rc != LDAP_SUCCESS ) {
return rc;
}
return LDAP_SUCCESS;
return rc;
}
/*
......@@ -1253,7 +1296,6 @@ dnX509normalize( void *x509_name, struct berval *out )
int
dnX509peerNormalize( void *ssl, struct berval *dn )
{
return ldap_pvt_tls_get_peer_dn( ssl, dn,
(LDAPDN_rewrite_dummy *)LDAPDN_rewrite, 0 );
}
......
......@@ -506,6 +506,14 @@ LDAP_SLAPD_F (int) dnMatch LDAP_P((
struct berval *value,
void *assertedValue ));
LDAP_SLAPD_F (int) dnRelativeMatch LDAP_P((
int *matchp,
slap_mask_t flags,
Syntax *syntax,
MatchingRule *mr,
struct berval *value,
void *assertedValue ));
LDAP_SLAPD_F (int) rdnMatch LDAP_P((
int *matchp,
slap_mask_t flags,
......
......@@ -3210,6 +3210,36 @@ static slap_mrule_defs_rec mrule_defs[] = {
octetStringIndexer, octetStringFilter,
NULL },
{"( 1.3.6.1.4.1.4203.666.4.9 NAME 'dnSubtreeMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )",
SLAP_MR_HIDE | SLAP_MR_EXT, NULL,
NULL, dnNormalize, dnRelativeMatch,
NULL, NULL,
NULL },
#if 0
{"( 1.3.6.1.4.1.4203.666.4.8 NAME 'dnOneLevelMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )",
SLAP_MR_HIDE | SLAP_MR_EXT, NULL,
NULL, dnNormalize, dnRelativeMatch,
NULL, NULL,
NULL },
{"( 1.3.6.1.4.1.4203.666.4.10 NAME 'dnSubordinateMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )",
SLAP_MR_HIDE | SLAP_MR_EXT, NULL,
NULL, dnNormalize, dnRelativeMatch,
NULL, NULL,
NULL },
{"( 1.3.6.1.4.1.4203.666.4.11 NAME 'dnSuperiorMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )",
SLAP_MR_HIDE | SLAP_MR_EXT, NULL,
NULL, dnNormalize, dnRelativeMatch,
NULL, NULL,
NULL },
#endif
{"( 1.2.36.79672281.1.13.3 NAME 'rdnMatch' "
"SYNTAX 1.2.36.79672281.1.5.0 )",
SLAP_MR_EQUALITY | SLAP_MR_EXT, NULL,
......
......@@ -991,6 +991,18 @@ static struct slap_schema_mr_map {
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) },
#if 0
{ "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) },
#endif
{ "integerMatch",
offsetof(struct slap_internal_schema, si_mr_integerMatch) },
{ "integerFirstComponentMatch",
......
......@@ -868,6 +868,12 @@ struct slap_internal_schema {
/* Matching Rules */
MatchingRule *si_mr_distinguishedNameMatch;
MatchingRule *si_mr_dnSubtreeMatch;
#if 0
MatchingRule *si_mr_dnOneLevelMatch;
MatchingRule *si_mr_dnSubordinateMatch;
MatchingRule *si_mr_dnSuperiorMatch;
#endif
MatchingRule *si_mr_caseExactMatch;
MatchingRule *si_mr_caseExactSubstringsMatch;
MatchingRule *si_mr_caseExactIA5Match;
......
Supports Markdown
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