From: Pierangelo Masarati Date: Fri, 16 Nov 2001 11:47:15 +0000 (+0000) Subject: check for update dn X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~860 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b1688462ce7c376097221f72e18bfbaaa4070181;p=openldap check for update dn --- diff --git a/servers/slapd/add.c b/servers/slapd/add.c index 6d733cf81d..9399d5d4a0 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -241,8 +241,7 @@ do_add( Connection *conn, Operation *op ) */ if ( be->be_add ) { /* do the update here */ - int repl_user = (be->be_update_ndn != NULL && - strcmp( be->be_update_ndn, op->o_ndn ) == 0); + int repl_user = be_isupdate(be, op->o_ndn ); #ifndef SLAPD_MULTIMASTER if ( be->be_update_ndn == NULL || repl_user ) #endif diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index feac0e595d..86a787b76f 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -584,6 +584,24 @@ be_isroot( Backend *be, const char *ndn ) return(rc); } +int +be_isupdate( Backend *be, const char *ndn ) +{ + int rc; + + if ( ndn == NULL || *ndn == '\0' ) { + return( 0 ); + } + + if ( be->be_update_ndn == NULL || *be->be_update_ndn == '\0' ) { + return( 0 ); + } + + rc = strcmp( be->be_update_ndn, ndn ) ? 0 : 1; + + return(rc); +} + char * be_root_dn( Backend *be ) { diff --git a/servers/slapd/delete.c b/servers/slapd/delete.c index 433e20855b..5d10e369d7 100644 --- a/servers/slapd/delete.c +++ b/servers/slapd/delete.c @@ -161,14 +161,13 @@ do_delete( if ( be->be_delete ) { /* do the update here */ #ifndef SLAPD_MULTIMASTER - if ( be->be_update_ndn == NULL || - strcmp( be->be_update_ndn, op->o_ndn ) == 0 ) + int repl_user = be_isupdate( be, op->o_ndn ); + if ( be->be_update_ndn == NULL || repl_user ) #endif { if ( (*be->be_delete)( be, conn, op, dn, ndn ) == 0 ) { #ifdef SLAPD_MULTIMASTER - if (be->be_update_ndn == NULL || - strcmp( be->be_update_ndn, op->o_ndn )) + if (be->be_update_ndn == NULL || !repl_user ) #endif { replog( be, op, dn, NULL ); diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index e2086b81a5..6264636007 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -287,8 +287,7 @@ do_modify( */ if ( be->be_modify ) { /* do the update here */ - int repl_user = (be->be_update_ndn != NULL && - strcmp( be->be_update_ndn, op->o_ndn ) == 0); + int repl_user = be_isupdate( be, op->o_ndn ); #ifndef SLAPD_MULTIMASTER /* Multimaster slapd does not have to check for replicator dn * because it accepts each modify request diff --git a/servers/slapd/modrdn.c b/servers/slapd/modrdn.c index 82908716c7..0ae0916fb9 100644 --- a/servers/slapd/modrdn.c +++ b/servers/slapd/modrdn.c @@ -306,15 +306,14 @@ do_modrdn( if ( be->be_modrdn ) { /* do the update here */ #ifndef SLAPD_MULTIMASTER - if ( be->be_update_ndn == NULL || - strcmp( be->be_update_ndn, op->o_ndn ) == 0 ) + int repl_user = be_isupdate( be, op->o_ndn ); + if ( be->be_update_ndn == NULL || repl_user ) #endif { if ( (*be->be_modrdn)( be, conn, op, dn, ndn, newrdn, deloldrdn, newSuperior ) == 0 #ifdef SLAPD_MULTIMASTER - && ( be->be_update_ndn == NULL || - strcmp( be->be_update_ndn, op->o_ndn ) ) + && ( be->be_update_ndn == NULL || !repl_user ) #endif ) { struct replog_moddn moddn; diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 0b60f5e693..e8f3d6ffa3 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -158,6 +158,7 @@ LDAP_SLAPD_F (int) be_issuffix LDAP_P(( Backend *be, const char *suffix )); LDAP_SLAPD_F (int) be_isroot LDAP_P(( Backend *be, const char *ndn )); LDAP_SLAPD_F (int) be_isroot_pw LDAP_P(( Backend *be, Connection *conn, const char *ndn, struct berval *cred )); +LDAP_SLAPD_F (int) be_isupdate LDAP_P(( Backend *be, const char *ndn )); LDAP_SLAPD_F (char *) be_root_dn LDAP_P(( Backend *be )); LDAP_SLAPD_F (int) be_entry_release_rw LDAP_P(( BackendDB *be, Connection *c, Operation *o, Entry *e, int rw ));