From: Howard Chu Date: Mon, 6 Feb 2006 04:45:12 +0000 (+0000) Subject: Unifdef SLAPD_MULTIMASTER, use config setting instead X-Git-Tag: OPENLDAP_REL_ENG_2_4_BP~229 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0e6aa53cd10d62c9924d4cdc5ce44a592f81c76a;p=openldap Unifdef SLAPD_MULTIMASTER, use config setting instead --- diff --git a/servers/slapd/add.c b/servers/slapd/add.c index bca76664dd..a5fa0769b0 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -281,9 +281,7 @@ fe_op_add( Operation *op, SlapReply *rs ) if ( op->o_bd->be_add ) { /* do the update here */ int repl_user = be_isupdate( op ); -#ifndef SLAPD_MULTIMASTER - if ( !SLAP_SHADOW(op->o_bd) || repl_user ) -#endif /* ! SLAPD_MULTIMASTER */ + if ( !SLAP_SINGLE_SHADOW(op->o_bd) || repl_user ) { int update = !BER_BVISEMPTY( &op->o_bd->be_update_ndn ); slap_callback cb = { NULL, slap_replog_cb, NULL, NULL }; @@ -325,15 +323,11 @@ fe_op_add( Operation *op, SlapReply *rs ) send_ldap_result( op, rs ); goto done; } - } -#ifdef SLAPD_MULTIMASTER - if ( !repl_user ) -#endif /* SLAPD_MULTIMASTER */ - { cb.sc_next = op->o_callback; op->o_callback = &cb; } + rc = op->o_bd->be_add( op, rs ); if ( rc == LDAP_SUCCESS ) { /* NOTE: be_entry_release_w() is @@ -343,7 +337,6 @@ fe_op_add( Operation *op, SlapReply *rs ) op->o_private = op->o_bd; } -#ifndef SLAPD_MULTIMASTER } else { BerVarray defref = NULL; @@ -366,7 +359,6 @@ fe_op_add( Operation *op, SlapReply *rs ) LDAP_UNWILLING_TO_PERFORM, "shadow context; no update referral" ); } -#endif /* SLAPD_MULTIMASTER */ } } else { Debug( LDAP_DEBUG_ARGS, "do_add: no backend support\n", 0, 0, 0 ); diff --git a/servers/slapd/bconfig.c b/servers/slapd/bconfig.c index a5cf6730cf..684211281b 100644 --- a/servers/slapd/bconfig.c +++ b/servers/slapd/bconfig.c @@ -159,6 +159,7 @@ enum { CFG_SSTR_IF_MAX, CFG_SSTR_IF_MIN, CFG_TTHREADS, + CFG_MULTIMASTER, CFG_LAST }; @@ -363,6 +364,9 @@ static ConfigTable config_back_cf_table[] = { #endif "( OLcfgGlAt:31 NAME 'olcModulePath' " "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL }, + { "multimaster", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_MULTIMASTER, + &config_generic, "( OLcfgDbAt:0.16 NAME 'olcMultiMaster' " + "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL }, { "objectclass", "objectclass", 2, 0, 0, ARG_PAREN|ARG_MAGIC|CFG_OC|ARG_NO_DELETE|ARG_NO_INSERT, &config_generic, "( OLcfgGlAt:32 NAME 'olcObjectClasses' " "DESC 'OpenLDAP object classes' " @@ -669,7 +673,7 @@ static ConfigOCs cf_ocs[] = { "olcReplicaArgsFile $ olcReplicaPidFile $ olcReplicationInterval $ " "olcReplogFile $ olcRequires $ olcRestrict $ olcRootDN $ olcRootPW $ " "olcSchemaDN $ olcSecurity $ olcSizeLimit $ olcSyncrepl $ " - "olcTimeLimit $ olcUpdateDN $ olcUpdateRef ) )", + "olcTimeLimit $ olcUpdateDN $ olcUpdateRef $ olcMultiMaster ) )", Cft_Database, NULL, cfAddDatabase }, { "( OLcfgGlOc:5 " "NAME 'olcOverlayConfig' " @@ -893,6 +897,9 @@ config_generic(ConfigArgs *c) { case CFG_LASTMOD: c->value_int = (SLAP_NOLASTMOD(c->be) == 0); break; + case CFG_MULTIMASTER: + c->value_int = (SLAP_SINGLE_SHADOW(c->be) == 0); + break; case CFG_SSTR_IF_MAX: c->value_int = index_substr_if_maxlen; break; @@ -979,6 +986,7 @@ config_generic(ConfigArgs *c) { case CFG_AZPOLICY: case CFG_DEPTH: case CFG_LASTMOD: + case CFG_MULTIMASTER: case CFG_SASLSECP: case CFG_SSTR_IF_MAX: case CFG_SSTR_IF_MIN: @@ -1334,6 +1342,20 @@ config_generic(ConfigArgs *c) { SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_NOLASTMOD; break; + case CFG_MULTIMASTER: + if(!SLAP_SHADOW(c->be)) { + snprintf( c->msg, sizeof( c->msg ), "<%s> database is not a shadow", + c->argv[0] ); + Debug(LDAP_DEBUG_ANY, "%s: %s\n", + c->log, c->msg, 0 ); + return(1); + } + if(c->value_int) + SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_SINGLE_SHADOW; + else + SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_SINGLE_SHADOW; + break; + case CFG_SSTR_IF_MAX: if (c->value_int < index_substr_if_minlen) { snprintf( c->msg, sizeof( c->msg ), "<%s> invalid value", c->argv[0] ); @@ -2669,7 +2691,7 @@ config_shadow( ConfigArgs *c, int flag ) return 1; } - SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | flag); + SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SINGLE_SHADOW | flag); return 0; } diff --git a/servers/slapd/delete.c b/servers/slapd/delete.c index 8c696fa22a..ab5653b6c3 100644 --- a/servers/slapd/delete.c +++ b/servers/slapd/delete.c @@ -155,9 +155,7 @@ fe_op_delete( Operation *op, SlapReply *rs ) if ( op->o_bd->be_delete ) { /* do the update here */ int repl_user = be_isupdate( op ); -#ifndef SLAPD_MULTIMASTER - if ( !SLAP_SHADOW(op->o_bd) || repl_user ) -#endif /* ! SLAPD_MULTIMASTER */ + if ( !SLAP_SINGLE_SHADOW(op->o_bd) || repl_user ) { struct berval org_req_dn = BER_BVNULL; struct berval org_req_ndn = BER_BVNULL; @@ -168,9 +166,7 @@ fe_op_delete( Operation *op, SlapReply *rs ) op->o_bd = op_be; -#ifdef SLAPD_MULTIMASTER if ( !op->o_bd->be_update_ndn.bv_len || !repl_user ) -#endif /* SLAPD_MULTIMASTER */ { cb.sc_next = op->o_callback; op->o_callback = &cb; @@ -211,7 +207,6 @@ fe_op_delete( Operation *op, SlapReply *rs ) op->o_req_ndn = org_req_ndn; op->o_delete_glue_parent = 0; -#ifndef SLAPD_MULTIMASTER } else { BerVarray defref = op->o_bd->be_update_refs ? op->o_bd->be_update_refs : default_referral; @@ -230,7 +225,6 @@ fe_op_delete( Operation *op, SlapReply *rs ) LDAP_UNWILLING_TO_PERFORM, "shadow context; no update referral" ); } -#endif /* ! SLAPD_MULTIMASTER */ } } else { diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index b044c059fc..27e746050a 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -367,9 +367,7 @@ fe_op_modify( Operation *op, SlapReply *rs ) /* Multimaster slapd does not have to check for replicator dn * because it accepts each modify request */ -#ifndef SLAPD_MULTIMASTER - if ( !SLAP_SHADOW(op->o_bd) || repl_user ) -#endif /* ! SLAPD_MULTIMASTER */ + if ( !SLAP_SINGLE_SHADOW(op->o_bd) || repl_user ) { int update = !BER_BVISEMPTY( &op->o_bd->be_update_ndn ); slap_callback cb = { NULL, slap_replog_cb, NULL, NULL }; @@ -385,9 +383,7 @@ fe_op_modify( Operation *op, SlapReply *rs ) } } -#ifdef SLAPD_MULTIMASTER if ( !repl_user ) -#endif /* SLAPD_MULTIMASTER */ { /* but multimaster slapd logs only the ones * not from a replicator user */ @@ -396,7 +392,6 @@ fe_op_modify( Operation *op, SlapReply *rs ) } op->o_bd->be_modify( op, rs ); -#ifndef SLAPD_MULTIMASTER /* send a referral */ } else { BerVarray defref = op->o_bd->be_update_refs @@ -420,7 +415,6 @@ fe_op_modify( Operation *op, SlapReply *rs ) send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM, "shadow context; no update referral" ); } -#endif /* ! SLAPD_MULTIMASTER */ } } else { send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM, diff --git a/servers/slapd/modrdn.c b/servers/slapd/modrdn.c index 4a5cf8f9f6..234cc83ac9 100644 --- a/servers/slapd/modrdn.c +++ b/servers/slapd/modrdn.c @@ -296,17 +296,13 @@ fe_op_modrdn( Operation *op, SlapReply *rs ) if ( op->o_bd->be_modrdn ) { /* do the update here */ int repl_user = be_isupdate( op ); -#ifndef SLAPD_MULTIMASTER - if ( !SLAP_SHADOW(op->o_bd) || repl_user ) -#endif /* ! SLAPD_MULTIMASTER */ + if ( !SLAP_SINGLE_SHADOW(op->o_bd) || repl_user ) { slap_callback cb = { NULL, slap_replog_cb, NULL, NULL }; op->o_bd = op_be; -#ifdef SLAPD_MULTIMASTER if ( !op->o_bd->be_update_ndn.bv_len || !repl_user ) -#endif /* SLAPD_MULTIMASTER */ { cb.sc_next = op->o_callback; op->o_callback = &cb; @@ -352,7 +348,6 @@ fe_op_modrdn( Operation *op, SlapReply *rs ) op->o_delete_glue_parent = 0; } -#ifndef SLAPD_MULTIMASTER } else { BerVarray defref = op->o_bd->be_update_refs ? op->o_bd->be_update_refs : default_referral; @@ -370,7 +365,6 @@ fe_op_modrdn( Operation *op, SlapReply *rs ) send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM, "shadow context; no update referral" ); } -#endif /* ! SLAPD_MULTIMASTER */ } } else { send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM, diff --git a/servers/slapd/passwd.c b/servers/slapd/passwd.c index 5c4390c337..fef49ef8b7 100644 --- a/servers/slapd/passwd.c +++ b/servers/slapd/passwd.c @@ -153,9 +153,8 @@ int passwd_extop( goto error_return; } -#ifndef SLAPD_MULTIMASTER /* This does not apply to multi-master case */ - if(!( !SLAP_SHADOW( op->o_bd ) || be_isupdate( op ))) { + if(!( !SLAP_SINGLE_SHADOW( op->o_bd ) || be_isupdate( op ))) { /* we SHOULD return a referral in this case */ BerVarray defref = op->o_bd->be_update_refs ? op->o_bd->be_update_refs : default_referral; @@ -177,7 +176,6 @@ int passwd_extop( rc = LDAP_UNWILLING_TO_PERFORM; goto error_return; } -#endif /* !SLAPD_MULTIMASTER */ /* generate a new password if none was provided */ if ( qpw->rs_new.bv_len == 0 ) { diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 5c84c13db4..edd5748c3a 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -1704,6 +1704,7 @@ struct slap_backend_db { #define SLAP_DBFLAG_GLOBAL_OVERLAY 0x0200U /* this db struct is a global overlay */ #define SLAP_DBFLAG_DYNAMIC 0x0400U /* this db allows dynamicObjects */ #define SLAP_DBFLAG_SHADOW 0x8000U /* a shadow */ +#define SLAP_DBFLAG_SINGLE_SHADOW 0x4000U /* a single-master shadow */ #define SLAP_DBFLAG_SYNC_SHADOW 0x1000U /* a sync shadow */ #define SLAP_DBFLAG_SLURP_SHADOW 0x2000U /* a slurp shadow */ slap_mask_t be_flags; @@ -1725,6 +1726,8 @@ struct slap_backend_db { #define SLAP_SHADOW(be) (SLAP_DBFLAGS(be) & SLAP_DBFLAG_SHADOW) #define SLAP_SYNC_SHADOW(be) (SLAP_DBFLAGS(be) & SLAP_DBFLAG_SYNC_SHADOW) #define SLAP_SLURP_SHADOW(be) (SLAP_DBFLAGS(be) & SLAP_DBFLAG_SLURP_SHADOW) +#define SLAP_SINGLE_SHADOW(be) (SLAP_DBFLAGS(be) & SLAP_DBFLAG_SINGLE_SHADOW) +#define SLAP_MULTIMASTER(be) (!SLAP_SINGLE_SHADOW(be)) slap_mask_t be_restrictops; /* restriction operations */ #define SLAP_RESTRICT_OP_ADD 0x0001U