From 1c1b2bb6ee98457ec62e4593887a424256fcb836 Mon Sep 17 00:00:00 2001 From: Jong Hyuk Choi Date: Wed, 7 Apr 2004 17:32:37 +0000 Subject: [PATCH] updatedn fix for syncrepl --- servers/slapd/add.c | 2 -- servers/slapd/back-bdb/add.c | 4 ++-- servers/slapd/back-bdb/delete.c | 2 +- servers/slapd/back-bdb/modrdn.c | 2 +- servers/slapd/back-ldap/add.c | 2 +- servers/slapd/back-ldap/modify.c | 2 +- servers/slapd/back-ldbm/add.c | 4 ++-- servers/slapd/back-ldbm/delete.c | 3 ++- servers/slapd/back-ldbm/modrdn.c | 6 ++++-- servers/slapd/backend.c | 2 +- servers/slapd/delete.c | 2 -- servers/slapd/modify.c | 2 -- servers/slapd/modrdn.c | 2 -- servers/slapd/overlays/rwm.c | 2 +- servers/slapd/proto-slap.h | 2 ++ servers/slapd/syncrepl.c | 26 +++++++++++++++++++++++++- 16 files changed, 43 insertions(+), 22 deletions(-) diff --git a/servers/slapd/add.c b/servers/slapd/add.c index ebb06d69af..fb6f6e6a51 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -253,8 +253,6 @@ do_add( Operation *op, SlapReply *rs ) int repl_user = be_isupdate( op ); #ifndef SLAPD_MULTIMASTER if ( !SLAP_SHADOW(op->o_bd) || repl_user ) -#else - if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) #endif { int update = op->o_bd->be_update_ndn.bv_len; diff --git a/servers/slapd/back-bdb/add.c b/servers/slapd/back-bdb/add.c index 6e7ccdb9b0..3901900011 100644 --- a/servers/slapd/back-bdb/add.c +++ b/servers/slapd/back-bdb/add.c @@ -298,8 +298,8 @@ retry: /* transaction retry */ * no parent! * if not attempting to add entry at suffix or with parent "" */ - if ((( !be_isroot( op ) && !be_isupdate(op)) || pdn.bv_len > 0 ) - && !is_entry_glue( op->oq_add.rs_e )) + if ((( !be_isroot( op ) && !be_isupdate(op) && !syncrepl_isupdate(op)) + || pdn.bv_len > 0 ) && !is_entry_glue( op->oq_add.rs_e )) { #ifdef NEW_LOGGING LDAP_LOG ( OPERATION, DETAIL1, "bdb_add: %s denied\n", diff --git a/servers/slapd/back-bdb/delete.c b/servers/slapd/back-bdb/delete.c index 4f9bff15a1..feb7b81e9c 100644 --- a/servers/slapd/back-bdb/delete.c +++ b/servers/slapd/back-bdb/delete.c @@ -246,7 +246,7 @@ retry: /* transaction retry */ /* no parent, must be root to delete */ if( ! be_isroot( op ) ) { if ( be_issuffix( op->o_bd, (struct berval *)&slap_empty_bv ) - || be_isupdate( op ) ) { + || be_isupdate( op ) || syncrepl_isupdate( op ) ) { p = (Entry *)&slap_entry_root; /* check parent for "children" acl */ diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c index b950479151..9e3529be7f 100644 --- a/servers/slapd/back-bdb/modrdn.c +++ b/servers/slapd/back-bdb/modrdn.c @@ -396,7 +396,7 @@ retry: /* transaction retry */ isroot = be_isroot( op ); if ( ! isroot ) { if ( be_issuffix( op->o_bd, (struct berval *)&slap_empty_bv ) - || be_isupdate( op ) ) { + || be_isupdate( op ) || syncrepl_isupdate( op ) ) { p = (Entry *)&slap_entry_root; diff --git a/servers/slapd/back-ldap/add.c b/servers/slapd/back-ldap/add.c index 72c40f0b51..803bc4aef9 100644 --- a/servers/slapd/back-ldap/add.c +++ b/servers/slapd/back-ldap/add.c @@ -90,7 +90,7 @@ ldap_back_add( dc.ctx = "addAttrDN"; #endif - isupdate = be_isupdate( op ); + isupdate = be_isupdate( op ) || syncrepl_isupdate( op ); for (i=0, a=op->oq_add.rs_e->e_attrs; a; a=a->a_next) { if ( !isupdate && a->a_desc->ad_type->sat_no_user_mod ) { continue; diff --git a/servers/slapd/back-ldap/modify.c b/servers/slapd/back-ldap/modify.c index 6f1ccd169c..517a202e5c 100644 --- a/servers/slapd/back-ldap/modify.c +++ b/servers/slapd/back-ldap/modify.c @@ -91,7 +91,7 @@ ldap_back_modify( dc.ctx = "modifyAttrDN"; #endif - isupdate = be_isupdate( op ); + isupdate = be_isupdate( op ) || syncrepl_isupdate( op ); for (i=0, ml=op->oq_modify.rs_modlist; ml; ml=ml->sml_next) { int is_oc = 0; diff --git a/servers/slapd/back-ldbm/add.c b/servers/slapd/back-ldbm/add.c index d621eeb2a8..d415b2ec09 100644 --- a/servers/slapd/back-ldbm/add.c +++ b/servers/slapd/back-ldbm/add.c @@ -247,8 +247,8 @@ ldbm_back_add( } else { assert( pdn.bv_val == NULL || *pdn.bv_val == '\0' ); - if (( !be_isroot( op ) && !be_isupdate( op )) && - !is_entry_glue( op->oq_add.rs_e )) + if (( !be_isroot(op) && !be_isupdate(op) && !syncrepl_isupdate(op)) + && !is_entry_glue( op->oq_add.rs_e )) { ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock); diff --git a/servers/slapd/back-ldbm/delete.c b/servers/slapd/back-ldbm/delete.c index 7acf90ac89..24b9ac36b3 100644 --- a/servers/slapd/back-ldbm/delete.c +++ b/servers/slapd/back-ldbm/delete.c @@ -195,7 +195,8 @@ ldbm_back_delete( } else { /* no parent, must be root to delete */ if( ! be_isroot( op ) ) { - if ( be_issuffix( op->o_bd, (struct berval *)&slap_empty_bv ) || be_isupdate( op ) ) { + if ( be_issuffix( op->o_bd, (struct berval *)&slap_empty_bv ) + || be_isupdate( op ) || syncrepl_isupdate( op ) ) { p = (Entry *)&slap_entry_root; rc = access_allowed( op, p, diff --git a/servers/slapd/back-ldbm/modrdn.c b/servers/slapd/back-ldbm/modrdn.c index d0a7c791c4..acab4030da 100644 --- a/servers/slapd/back-ldbm/modrdn.c +++ b/servers/slapd/back-ldbm/modrdn.c @@ -248,7 +248,8 @@ ldbm_back_modrdn( /* no parent, must be root to modify rdn */ isroot = be_isroot( op ); if ( ! isroot ) { - if ( be_issuffix( op->o_bd, (struct berval *)&slap_empty_bv ) || be_isupdate( op ) ) { + if ( be_issuffix( op->o_bd, (struct berval *)&slap_empty_bv ) + || be_isupdate( op ) || syncrepl_isupdate( op ) ) { int can_access; p = (Entry *)&slap_entry_root; @@ -422,7 +423,8 @@ ldbm_back_modrdn( } if ( ! isroot ) { - if ( be_issuffix( op->o_bd, (struct berval *)&slap_empty_bv ) || be_isupdate( op ) ) { + if ( be_issuffix( op->o_bd, (struct berval *)&slap_empty_bv ) + || be_isupdate( op ) || syncrepl_isupdate( op )) { int can_access; np = (Entry *)&slap_entry_root; diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index 54249eebc4..30e3a3055f 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -730,7 +730,7 @@ be_isroot_dn( Backend *be, struct berval *ndn ) int be_isupdate( Operation *op ) { - return be_isupdate_dn( op->o_bd, &op->o_ndn ); + return ( be_isupdate_dn( op->o_bd, &op->o_ndn )); } int diff --git a/servers/slapd/delete.c b/servers/slapd/delete.c index eded998295..70f4cee5e0 100644 --- a/servers/slapd/delete.c +++ b/servers/slapd/delete.c @@ -208,8 +208,6 @@ do_delete( int repl_user = be_isupdate( op ); #ifndef SLAPD_MULTIMASTER if ( !SLAP_SHADOW(op->o_bd) || repl_user ) -#else - if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) #endif { slap_callback cb = { NULL, slap_replog_cb, NULL, NULL }; diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 0f81ef1a39..05d827301d 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -468,8 +468,6 @@ do_modify( */ #ifndef SLAPD_MULTIMASTER if ( !SLAP_SHADOW(op->o_bd) || repl_user ) -#else - if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) #endif { int update = op->o_bd->be_update_ndn.bv_len; diff --git a/servers/slapd/modrdn.c b/servers/slapd/modrdn.c index 205ea71166..9f184ada3c 100644 --- a/servers/slapd/modrdn.c +++ b/servers/slapd/modrdn.c @@ -365,8 +365,6 @@ do_modrdn( int repl_user = be_isupdate( op ); #ifndef SLAPD_MULTIMASTER if ( !SLAP_SHADOW(op->o_bd) || repl_user ) -#else - if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) #endif { slap_callback cb = { NULL, slap_replog_cb, NULL, NULL }; diff --git a/servers/slapd/overlays/rwm.c b/servers/slapd/overlays/rwm.c index 20f40dab49..9443ad27e0 100644 --- a/servers/slapd/overlays/rwm.c +++ b/servers/slapd/overlays/rwm.c @@ -100,7 +100,7 @@ rwm_add( Operation *op, SlapReply *rs ) } /* Count number of attributes in entry */ - isupdate = be_isupdate( op ); + isupdate = be_isupdate( op ) || syncrepl_isupdate( op ); for ( i = 0, ap = &op->oq_add.rs_e->e_attrs; *ap; ) { struct berval mapped; Attribute *a; diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index d1c05ebc7a..a24df9d9a7 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -1136,6 +1136,8 @@ LDAP_SLAPD_F (Entry*) slap_create_syncrepl_entry LDAP_P(( struct berval *, struct berval * )); LDAP_SLAPD_F (struct berval *) slap_uuidstr_from_normalized LDAP_P(( struct berval *, struct berval *, void * )); +LDAP_SLAPD_F (int) syncrepl_isupdate LDAP_P(( Operation * )); +LDAP_SLAPD_F (int) syncrepl_isupdate_dn LDAP_P(( Backend *, struct berval * )); /* syntax.c */ LDAP_SLAPD_F (Syntax *) syn_find LDAP_P(( diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index 5b2f8e8092..125d10ba68 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -1788,6 +1788,31 @@ done : return; } +int +syncrepl_isupdate( Operation *op ) +{ + return ( syncrepl_isupdate_dn( op->o_bd, &op->o_ndn )); +} + +int +syncrepl_isupdate_dn( + Backend* be, + struct berval* ndn +) +{ + syncinfo_t* si; + int ret = 0; + + if ( !LDAP_STAILQ_EMPTY( &be->be_syncinfo )) { + LDAP_STAILQ_FOREACH( si, &be->be_syncinfo, si_next ) { + if ( ret = dn_match( &si->si_updatedn, ndn )) { + return ret; + } + } + } + return 0; +} + static int dn_callback( Operation* op, @@ -1991,4 +2016,3 @@ avl_ber_bvfree( void *bv ) } ch_free ( (char *) bv ); } - -- 2.39.5