]> git.sur5r.net Git - openldap/commitdiff
SLAPD_SCHEMA_NOT_COMPAT: working modify? need additional match
authorKurt Zeilenga <kurt@openldap.org>
Sun, 28 May 2000 23:51:39 +0000 (23:51 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Sun, 28 May 2000 23:51:39 +0000 (23:51 +0000)
  routines, such as distinguishedNameMatch, to be sure.

servers/slapd/attr.c
servers/slapd/back-ldbm/modify.c
servers/slapd/mr.c
servers/slapd/value.c

index 685d97bc9ebefc0e76fc50d3cdec3ab5db1bd548..dff429ded9a358e068cdca3db1ba3814cb09020b 100644 (file)
@@ -290,10 +290,10 @@ attr_delete(
                        *a = (*a)->a_next;
                        attr_free( save );
 
-                       return 0;
+                       return LDAP_SUCCESS;
                }
        }
 
-       return 1;
+       return LDAP_NO_SUCH_ATTRIBUTE;
 }
 
index 02c039ea6e9c3b025338f0f050da2092bcccbb00..613880ef5559089d5def3e9039da9c59ada5c688 100644 (file)
@@ -60,6 +60,8 @@ int ldbm_modify_internal(
                        err = add_values( e, mod, op->o_ndn );
 
                        if( err != LDAP_SUCCESS ) {
+                               Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: %d %s\n",
+                                       err, text, 0);
                                *text = "modify: add values failed";
                        }
                        break;
@@ -69,6 +71,8 @@ int ldbm_modify_internal(
                        err = delete_values( e, mod, op->o_ndn );
                        assert( err != LDAP_TYPE_OR_VALUE_EXISTS );
                        if( err != LDAP_SUCCESS ) {
+                               Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: %d %s\n",
+                                       err, text, 0);
                                *text = "modify: delete values failed";
                        }
                        break;
@@ -78,6 +82,8 @@ int ldbm_modify_internal(
                        err = replace_values( e, mod, op->o_ndn );
                        assert( err != LDAP_TYPE_OR_VALUE_EXISTS );
                        if( err != LDAP_SUCCESS ) {
+                               Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: %d %s\n",
+                                       err, text, 0);
                                *text = "modify: replace values failed";
                        }
                        break;
@@ -95,6 +101,8 @@ int ldbm_modify_internal(
                        }
 
                        if( err != LDAP_SUCCESS ) {
+                               Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: %d %s\n",
+                                       err, text, 0);
                                *text = "modify: (soft)add values failed";
                        }
                        break;
@@ -104,6 +112,8 @@ int ldbm_modify_internal(
                                mod->sm_op, 0, 0);
                        *text = "Invalid modify operation";
                        err = LDAP_OTHER;
+                       Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: %d %s\n",
+                               err, text, 0);
                }
 
                if ( err != LDAP_SUCCESS ) {
@@ -331,34 +341,50 @@ add_values(
        Attribute       *a;
 
 #ifdef SLAPD_SCHEMA_NOT_COMPAT
-       AttributeDescription *desc = mod->sm_desc;
+       /* char *desc = mod->sm_desc->ad_cname->bv_val; */
+       MatchingRule *mr = mod->sm_desc->ad_type->sat_equality;
+
+       if( mr == NULL ) {
+               return LDAP_INAPPROPRIATE_MATCHING;
+       }
+
 #else
-       char *desc = mod->mod_type;
+       /* char *desc = mod->mod_type; */
 #endif
 
-       a = attr_find( e->e_attrs, desc );
+       a = attr_find( e->e_attrs, mod->sm_desc );
 
        /* check if the values we're adding already exist */
        if ( a != NULL ) {
                for ( i = 0; mod->sm_bvalues[i] != NULL; i++ ) {
 #ifdef SLAPD_SCHEMA_NOT_COMPAT
-                       if ( value_find( desc, a->a_vals, mod->sm_bvalues[i] ) == 0 )
+                       int j;
+                       for ( j = 0; a->a_vals[j] != NULL; j++ ) {
+                               int match;
+                               const char *text = NULL;
+                               int rc = value_match( &match, mod->sm_desc, mr,
+                                       mod->sm_bvalues[i], a->a_vals[j], &text );
+
+                               if( rc == LDAP_SUCCESS && match == 0 ) {
+                                       return LDAP_TYPE_OR_VALUE_EXISTS;
+                               }
+                       }
 #else
                        if ( value_find( a->a_vals, mod->sm_bvalues[i],
-                           a->a_syntax, 3 ) == 0 )
-#endif
-                       {
+                           a->a_syntax, 3 ) == 0 ) {
                                return( LDAP_TYPE_OR_VALUE_EXISTS );
                        }
+#endif
                }
        }
 
        /* no - add them */
-       if( attr_merge( e, desc, mod->sm_bvalues ) != 0 ) {
-               return( LDAP_CONSTRAINT_VIOLATION );
+       if( attr_merge( e, mod->sm_desc, mod->sm_bvalues ) != 0 ) {
+               /* this should return result return of attr_merge */
+               return LDAP_OTHER;
        }
 
-       return( LDAP_SUCCESS );
+       return LDAP_SUCCESS;
 }
 
 static int
@@ -372,6 +398,11 @@ delete_values(
        Attribute       *a;
 #ifdef SLAPD_SCHEMA_NOT_COMPAT
        char *desc = mod->sm_desc->ad_cname->bv_val;
+       MatchingRule *mr = mod->sm_desc->ad_type->sat_equality;
+
+       if( mr == NULL || !mr->smr_match ) {
+               return LDAP_INAPPROPRIATE_MATCHING;
+       }
 #else
        char *desc = mod->mod_type;
 #endif
@@ -399,7 +430,7 @@ delete_values(
                        int match;
                        const char *text = NULL;
                        int rc = value_match( &match, mod->sm_desc,
-                               mod->sm_desc->ad_type->sat_equality,
+                               mr,
                                mod->sm_bvalues[i], a->a_vals[j], &text );
 
                        if( rc == LDAP_SUCCESS && match != 0 )
@@ -441,7 +472,7 @@ delete_values(
                }
        }
 
-       return( LDAP_SUCCESS );
+       return LDAP_SUCCESS;
 }
 
 static int
@@ -451,13 +482,17 @@ replace_values(
     char       *dn
 )
 {
-       (void) attr_delete( &e->e_attrs, mod->sm_desc );
+       int rc = attr_delete( &e->e_attrs, mod->sm_desc );
+
+       if( rc != LDAP_SUCCESS && rc != LDAP_NO_SUCH_ATTRIBUTE ) {
+               return rc;
+       }
 
        if ( mod->sm_bvalues != NULL &&
                attr_merge( e, mod->sm_desc, mod->sm_bvalues ) != 0 )
        {
-               return( LDAP_CONSTRAINT_VIOLATION );
+               return LDAP_OTHER;
        }
 
-       return( LDAP_SUCCESS );
+       return LDAP_SUCCESS;
 }
index 579f6389efd8d6d003bcf741ff8a927ccf3f3336..8e0f932c5641dccb3490ebea61126a8591741cc9 100644 (file)
@@ -176,12 +176,16 @@ register_matching_rule(
                return( -1 );
        }
 
-       code = mr_add( mr, usage, convert, normalize, match, indexer, filter, &err );
+       code = mr_add( mr, usage,
+               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 );
                return( -1 );
        }
+
        return( 0 );
 }
 
index 3cc7ba54a3bfbe22f1b89761cfe25f59ba1946a2..28b48fd144ea842ecaef55247847ba54d6271408 100644 (file)
@@ -48,7 +48,7 @@ value_add(
        }
        (*vals)[n + j] = NULL;
 
-       return( 0 );
+       return LDAP_SUCCESS;
 }
 
 #ifdef SLAPD_SCHEMA_NOT_COMPAT
@@ -289,7 +289,7 @@ value_find(
 #ifdef SLAPD_SCHEMA_NOT_COMPAT
        MatchingRule *mr = ad->ad_type->sat_equality;
 
-       if( mr == NULL ) {
+       if( mr == NULL || !mr->smr_match ) {
                return LDAP_INAPPROPRIATE_MATCHING;
        }
 #endif