]> git.sur5r.net Git - openldap/commitdiff
Add initial dnSubtreeMatch.
authorKurt Zeilenga <kurt@openldap.org>
Thu, 9 Sep 2004 02:07:27 +0000 (02:07 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Thu, 9 Sep 2004 02:07:27 +0000 (02:07 +0000)
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.

servers/slapd/dn.c
servers/slapd/proto-slap.h
servers/slapd/schema_init.c
servers/slapd/schema_prep.c
servers/slapd/slap.h

index a74aa428326eab569c3bda3f14e67f33e905b075..9b6edbcf680b5f82ae8ae6e0ec42732b186a4f14 100644 (file)
@@ -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 );
 }
index f05259524bc9a482faefe4f6ca397d19e8fea08e..988952ba50550ac3ec3adce3f35f1edad2225167 100644 (file)
@@ -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, 
index d99591787095bf93f05f991f704c38788a668906..07d3ceccacca0ecb0829f774632dd05a611ffbef 100644 (file)
@@ -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,
index 0af3fde49e39300466180040a3d061e67adb5814..82ab93dea1cf98630fcea777da7595108306674c 100644 (file)
@@ -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",
index 8cc963126a1eb1505f4bd000a1d55208c0aaf99e..e22a503e093b0d734f2f4b899bf2dca11a52bbe5 100644 (file)
@@ -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;