]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-ldbm/modify.c
add referral check to functions elaborated by overlays
[openldap] / servers / slapd / back-ldbm / modify.c
index a729fc3172d478551c3d0776e7f574794e1d28fd..4a574fceeed68d07d755bba3e1d3cd12394b7453 100644 (file)
@@ -1,8 +1,17 @@
 /* modify.c - ldbm backend modify routine */
 /* $OpenLDAP$ */
-/*
- * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 1998-2004 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
  */
 
 #include "portable.h"
@@ -153,6 +162,7 @@ int ldbm_modify_internal(
 
                        rc = modify_add_values( e, mod, get_permissiveModify( op ),
                                                text, textbuf, textlen );
+                       mod->sm_op = SLAP_MOD_SOFTADD;
                        if ( rc == LDAP_TYPE_OR_VALUE_EXISTS ) {
                                rc = LDAP_SUCCESS;
                        }
@@ -314,11 +324,8 @@ ldbm_back_modify(
        /* acquire and lock entry */
        e = dn2entry_w( op->o_bd, &op->o_req_ndn, &matched );
 
-#ifdef LDAP_SYNCREPL /* FIXME: dn2entry() should return non-glue entry */
+       /* FIXME: dn2entry() should return non-glue entry */
        if (( e == NULL ) || ( !manageDSAit && e && is_entry_glue( e ))) {
-#else
-       if ( e == NULL ) {
-#endif
                if ( matched != NULL ) {
                        rs->sr_matched = ch_strdup( matched->e_dn );
                        rs->sr_ref = is_entry_referral( matched )
@@ -326,13 +333,19 @@ ldbm_back_modify(
                                : NULL;
                        cache_return_entry_r( &li->li_cache, matched );
                } else {
-#ifdef LDAP_SYNCREPL
-                       BerVarray deref = op->o_bd->syncinfo ?
-                                                         op->o_bd->syncinfo->provideruri_bv : default_referral;
-#else
-                       BerVarray deref = default_referral;
-#endif
-                       rs->sr_ref = referral_rewrite( deref, NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
+                       BerVarray deref = NULL;
+                       if ( !LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
+                               syncinfo_t *si;
+                               LDAP_STAILQ_FOREACH( si, &op->o_bd->be_syncinfo, si_next ) {
+                                       struct berval tmpbv;
+                                       ber_dupbv( &tmpbv, &si->si_provideruri_bv[0] );
+                                       ber_bvarray_add( &deref, &tmpbv );
+                               }
+                       } else {
+                               deref = default_referral;
+                       }
+                       rs->sr_ref = referral_rewrite( deref, NULL, &op->o_req_dn,
+                                                       LDAP_SCOPE_DEFAULT );
                }
 
                ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock);
@@ -342,11 +355,9 @@ ldbm_back_modify(
                if ( rs->sr_ref ) ber_bvarray_free( rs->sr_ref );
                free( (char *)rs->sr_matched );
 
-#ifdef LDAP_SYNCREPL
+               rs->sr_ref = NULL;
+               rs->sr_matched = NULL;
                return rs->sr_err;
-#else
-               return( -1 );
-#endif
        }
 
        if ( !manageDSAit && is_entry_referral( e ) )
@@ -368,7 +379,8 @@ ldbm_back_modify(
                send_ldap_result( op, rs );
 
                if ( rs->sr_ref ) ber_bvarray_free( rs->sr_ref );
-
+               rs->sr_ref = NULL;
+               rs->sr_matched = NULL;
                goto error_return;
        }
        
@@ -392,6 +404,7 @@ ldbm_back_modify(
                goto error_return;
        }
 
+       rs->sr_text = NULL;
        send_ldap_error( op, rs, LDAP_SUCCESS,
                NULL );
 
@@ -403,9 +416,6 @@ ldbm_back_modify(
 error_return:;
        cache_return_entry_w( &li->li_cache, e );
        ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock);
-#ifdef LDAP_SYNCREPL
+       rs->sr_text = NULL;
        return rs->sr_err;
-#else
-       return( -1 );
-#endif
 }