Unifdef SLAPD_MULTIMASTER, use config setting instead

This commit is contained in:
Howard Chu 2006-02-06 04:45:12 +00:00
parent fe3b6d0071
commit 0e6aa53cd1
7 changed files with 33 additions and 36 deletions

View File

@ -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 );

View File

@ -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;
}

View File

@ -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 {

View File

@ -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,

View File

@ -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,

View File

@ -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 ) {

View File

@ -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