]> git.sur5r.net Git - openldap/commitdiff
Unifdef SLAPD_MULTIMASTER, use config setting instead
authorHoward Chu <hyc@openldap.org>
Mon, 6 Feb 2006 04:45:12 +0000 (04:45 +0000)
committerHoward Chu <hyc@openldap.org>
Mon, 6 Feb 2006 04:45:12 +0000 (04:45 +0000)
servers/slapd/add.c
servers/slapd/bconfig.c
servers/slapd/delete.c
servers/slapd/modify.c
servers/slapd/modrdn.c
servers/slapd/passwd.c
servers/slapd/slap.h

index bca76664dd02e2a836a512da7eefd895bf5242b7..a5fa0769b01c7d189f0b586b0058a81d3b823776 100644 (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 );
index a5cf6730cf54bac7c2a007902431112bbbd9e533..684211281b127bde4e39fc6acd2b22b4d6d1d462 100644 (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;
 }
index 8c696fa22ac83cbe77bac2b6f383e36245c2fe46..ab5653b6c3dad04d6cf2ce4e8892d8e126945eef 100644 (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 {
index b044c059fc02a14f9cee0df2ccb1defcb72038ec..27e746050ad1cf046c714cf533450c3c337b8439 100644 (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,
index 4a5cf8f9f628a7dc931e2215c74670dd52bb0745..234cc83ac91fd2e42d5e3f08457443579e2fc022 100644 (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,
index 5c4390c3379c56dbd75de4726378f48e44d0954f..fef49ef8b7b8db917e6538c971df2d29b8f57db4 100644 (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 ) {
index 5c84c13db4910eac992a0cbd0088c0acc784c05c..edd5748c3a2b76c09987fd3df05b09996aba0974 100644 (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