#ifdef LDAP_DEVEL
#define LDAP_CLIENT_UPDATE 1
#define LDAP_SYNC 2
+#define LDAP_SYNCREPL 1
#endif
#ifdef LDAP_CLIENT_UPDATE
repl.c lock.c controls.c extended.c kerberos.c passwd.c \
schema.c schema_check.c schema_init.c schema_prep.c \
schemaparse.c ad.c at.c mr.c syntax.c oc.c saslauthz.c \
- oidm.c starttls.c index.c sets.c referral.c \
- root_dse.c sasl.c module.c mra.c mods.c sl_malloc.c \
- limits.c backglue.c operational.c matchedValues.c cancel.c \
+ oidm.c starttls.c index.c sets.c referral.c root_dse.c \
+ sasl.c module.c mra.c mods.c sl_malloc.c limits.c \
+ backglue.c operational.c matchedValues.c cancel.c syncrepl.c \
$(@PLAT@_SRCS)
OBJS = main.o globals.o config.o daemon.o \
repl.o lock.o controls.o extended.o kerberos.o passwd.o \
schema.o schema_check.o schema_init.o schema_prep.o \
schemaparse.o ad.o at.o mr.o syntax.o oc.o saslauthz.o \
- oidm.o starttls.o index.o sets.o referral.o \
- root_dse.o sasl.o module.o mra.o mods.o sl_malloc.o \
- limits.o backglue.o operational.o matchedValues.o cancel.o \
+ oidm.o starttls.o index.o sets.o referral.o root_dse.o \
+ sasl.o module.o mra.o mods.o sl_malloc.o limits.o \
+ backglue.o operational.o matchedValues.o cancel.o syncrepl.o \
$(@PLAT@_OBJS)
LDAP_INCDIR= ../../include -I$(srcdir)/slapi
if ( op->o_bd->be_add ) {
/* do the update here */
int repl_user = be_isupdate(op->o_bd, &op->o_ndn );
-#ifndef SLAPD_MULTIMASTER
+#if defined(LDAP_SYNCREPL) && !defined(SLAPD_MULTIMASTER)
+ if ( !op->o_bd->syncinfo &&
+ ( !op->o_bd->be_update_ndn.bv_len || repl_user ))
+#elif defined(LDAP_SYNCREPL) && defined(SLAPD_MULTIMASTER)
+ if ( !op->o_bd->syncinfo ) /* LDAP_SYNCREPL overrides MM */
+#elif !defined(LDAP_SYNCREPL) && !defined(SLAPD_MULTIMASTER)
if ( !op->o_bd->be_update_ndn.bv_len || repl_user )
#endif
{
size_t textlen = sizeof textbuf;
rs->sr_err = slap_mods_check( modlist, update, &rs->sr_text,
- textbuf, textlen, NULL );
+ textbuf, textlen, NULL );
if( rs->sr_err != LDAP_SUCCESS ) {
send_ldap_result( op, rs );
e = NULL;
}
-#ifndef SLAPD_MULTIMASTER
+#if defined(LDAP_SYNCREPL) || !defined(SLAPD_MULTIMASTER)
} else {
- BerVarray defref;
+ BerVarray defref = NULL;
#ifdef LDAP_SLAPI
/*
* SLAPI_ADD_ENTRY will be empty, but this may be acceptable
}
#endif /* LDAP_SLAPI */
- defref = op->o_bd->be_update_refs
- ? op->o_bd->be_update_refs : default_referral;
+#ifdef LDAP_SYNCREPL
+ if ( op->o_bd->syncinfo ) {
+ defref = op->o_bd->syncinfo->master_bv;
+ } else
+#endif
+ {
+ defref = op->o_bd->be_update_refs
+ ? op->o_bd->be_update_refs : default_referral;
+ }
+
if ( defref != NULL ) {
rs->sr_ref = referral_rewrite( defref,
NULL, &e->e_name, LDAP_SCOPE_DEFAULT );
LDAP_BEGIN_DECL
+#ifdef LDAP_SYNCREPL
+#define BDB_SUBENTRIES 1
+#endif
+
#define DN_BASE_PREFIX SLAP_INDEX_EQUALITY_PREFIX
#define DN_ONE_PREFIX '%'
#define DN_SUBTREE_PREFIX '@'
#define GOT_TYPE 0x0200
#define GOT_INTERVAL 0x0400
#define GOT_LASTMOD 0x0800
+#define GOT_UPDATEDN 0x1000
-#define GOT_ALL 0x0FFF
+#define GOT_ALL 0x1FFF
static int
parse_syncrepl_line(
si->masterport = 0;
}
si->mastername = strdup( val );
+ si->master_bv = (BerVarray) ch_calloc( 2, sizeof (struct berval ));
+ ber_str2bv( si->masteruri, strlen(si->masteruri), 0,
+ &si->master_bv[0] );
+ si->master_bv[1].bv_len = 0;
+ si->master_bv[1].bv_val = NULL;
gots |= GOT_HOST;
} else if ( !strncasecmp( cargv[ i ], TLSSTR, sizeof( TLSSTR ) - 1 ) ) {
val = cargv[ i ] + sizeof( TLSSTR );
si->tls = TLS_ON;
}
} else if ( !strncasecmp( cargv[ i ],
- "binddn", sizeof( BINDDNSTR ) - 1 ) ) {
+ UPDATEDNSTR, sizeof( UPDATEDNSTR ) - 1 ) ) {
+ char *str;
+ struct berval updatedn = {0, NULL};
+ val = cargv[ i ] + sizeof( UPDATEDNSTR );
+ str = strdup( val );
+ ber_str2bv( str, strlen(str), 1, &updatedn );
+ dnNormalize( 0, NULL, NULL, &updatedn, &si->updatedn, NULL );
+ ch_free( str );
+ ch_free( updatedn.bv_val );
+ gots |= GOT_UPDATEDN;
+ } else if ( !strncasecmp( cargv[ i ],
+ BINDDNSTR, sizeof( BINDDNSTR ) - 1 ) ) {
val = cargv[ i ] + sizeof( BINDDNSTR );
si->binddn = strdup( val );
gots |= GOT_DN;
} else if ( !strncasecmp( val, "refreshAndPersist", sizeof( "refreshAndPersist" ) - 1 )) {
gots |= GOT_INTERVAL;
si->type = LDAP_SYNC_REFRESH_AND_PERSIST;
+ si->interval = 0;
} else {
fprintf( stderr, "Error: parse_syncrepl_line: "
"unknown sync type \"%s\"\n", val);
INTERVALSTR, sizeof( INTERVALSTR ) - 1 ) ) {
val = cargv[ i ] + sizeof( INTERVALSTR );
gots |= GOT_INTERVAL;
- si->interval = atoi( val );
- if ( si->interval <= 0 ) {
+ if ( gots & GOT_TYPE && si->type == LDAP_SYNC_REFRESH_AND_PERSIST )
+ si->interval = 0;
+ else
+ si->interval = atoi( val );
+ if ( si->interval < 0 ) {
fprintf( stderr, "Error: parse_syncrepl_line: "
"invalid interval \"%d\"\n", si->interval);
return 1;
if ( op->o_bd->be_delete ) {
/* do the update here */
int repl_user = be_isupdate( op->o_bd, &op->o_ndn );
-#ifndef SLAPD_MULTIMASTER
+#if defined(LDAP_SYNCREPL) && !defined(SLAPD_MULTIMASTER)
+ if ( !op->o_bd->syncinfo && ( !op->o_bd->be_update_ndn.bv_len || repl_user ))
+#elif defined(LDAP_SYNCREPL) && defined(SLAPD_MULTIMASTER)
+ if ( !op->o_bd->syncinfo ) /* LDAP_SYNCREPL overrides MM */
+#elif !defined(LDAP_SYNCREPL) && !defined(SLAPD_MULTIMASTER)
if ( !op->o_bd->be_update_ndn.bv_len || repl_user )
#endif
{
replog( op );
}
}
-#ifndef SLAPD_MULTIMASTER
+#if defined(LDAP_SYNCREPL) || !defined(SLAPD_MULTIMASTER)
} else {
- BerVarray defref = op->o_bd->be_update_refs
- ? op->o_bd->be_update_refs : default_referral;
+ BerVarray defref = NULL;
+#ifdef LDAP_SYNCREPL
+ if ( op->o_bd->syncinfo ) {
+ defref = op->o_bd->syncinfo->master_bv;
+ } else
+#endif
+ {
+ defref = op->o_bd->be_update_refs
+ ? op->o_bd->be_update_refs : default_referral;
+ }
if ( defref != NULL ) {
- rs->sr_ref = referral_rewrite( default_referral,
+ rs->sr_ref = referral_rewrite( defref,
NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
if (!rs->sr_ref) rs->sr_ref = defref;
rs->sr_err = LDAP_REFERRAL;
if ( op->o_bd->be_modify ) {
/* do the update here */
int repl_user = be_isupdate( op->o_bd, &op->o_ndn );
-#ifndef SLAPD_MULTIMASTER
+
/* Multimaster slapd does not have to check for replicator dn
* because it accepts each modify request
*/
+#if defined(LDAP_SYNCREPL) && !defined(SLAPD_MULTIMASTER)
+ if ( !op->o_bd->syncinfo &&
+ ( !op->o_bd->be_update_ndn.bv_len || repl_user ))
+#elif defined(LDAP_SYNCREPL) && defined(SLAPD_MULTIMASTER)
+ if ( !op->o_bd->syncinfo ) /* LDAP_SYNCREPL overrides MM */
+#elif !defined(LDAP_SYNCREPL) && !defined(SLAPD_MULTIMASTER)
if ( !op->o_bd->be_update_ndn.bv_len || repl_user )
#endif
{
replog( op );
}
-#ifndef SLAPD_MULTIMASTER
+#if defined(LDAP_SYNCREPL) || !defined(SLAPD_MULTIMASTER)
/* send a referral */
} else {
- BerVarray defref = op->o_bd->be_update_refs
- ? op->o_bd->be_update_refs : default_referral;
+ BerVarray defref = NULL;
+#ifdef LDAP_SYNCREPL
+ if ( op->o_bd->syncinfo ) {
+ defref = op->o_bd->syncinfo->master_bv;
+ } else
+#endif
+ {
+ defref = op->o_bd->be_update_refs
+ ? op->o_bd->be_update_refs : default_referral;
+ }
if ( defref != NULL ) {
rs->sr_ref = referral_rewrite( defref,
NULL, &op->o_req_dn,
if ( op->o_bd->be_modrdn ) {
/* do the update here */
int repl_user = be_isupdate( op->o_bd, &op->o_ndn );
-#ifndef SLAPD_MULTIMASTER
+#if defined(LDAP_SYNCREPL) && !defined(SLAPD_MULTIMASTER)
+ if ( !op->o_bd->syncinfo &&
+ ( !op->o_bd->be_update_ndn.bv_len || repl_user ))
+#elif defined(LDAP_SYNCREPL) && defined(SLAPD_MULTIMASTER)
+ if ( !op->o_bd->syncinfo ) /* LDAP_SYNCREPL overrides MM */
+#elif !defined(LDAP_SYNCREPL) && !defined(SLAPD_MULTIMASTER)
if ( !op->o_bd->be_update_ndn.bv_len || repl_user )
#endif
{
) {
replog( op );
}
-#ifndef SLAPD_MULTIMASTER
+#if defined(LDAP_SYNCREPL) || !defined(SLAPD_MULTIMASTER)
} else {
- BerVarray defref = op->o_bd->be_update_refs
- ? op->o_bd->be_update_refs : default_referral;
+ BerVarray defref = NULL;
+#ifdef LDAP_SYNCREPL
+ if ( op->o_bd->syncinfo ) {
+ defref = op->o_bd->syncinfo->master_bv;
+ } else
+#endif
+ {
+ defref = op->o_bd->be_update_refs
+ ? op->o_bd->be_update_refs : default_referral;
+ }
if ( defref != NULL ) {
rs->sr_ref = referral_rewrite( defref,
NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
rs->sr_err = LDAP_OTHER;
#endif
-#ifndef SLAPD_MULTIMASTER
+#if defined(LDAP_SYNCREPL) || !defined(SLAPD_MULTIMASTER)
/* This does not apply to multi-master case */
} else if( op->o_bd->be_update_ndn.bv_len ) {
/* we SHOULD return a referral in this case */
- rs->sr_ref = referral_rewrite( op->o_bd->be_update_refs,
- NULL, NULL, LDAP_SCOPE_DEFAULT );
- rs->sr_err = LDAP_REFERRAL;
+ BerVarray defref = NULL;
+#ifdef LDAP_SYNCREPL
+ if ( op->o_bd->syncinfo ) {
+ defref = op->o_bd->syncinfo->master_bv;
+ } else
+#endif
+ {
+ defref = referral_rewrite( op->o_bd->be_update_refs,
+ NULL, NULL, LDAP_SCOPE_DEFAULT );
+ }
+ rs->sr_ref = defref;
+ rs->sr_err = LDAP_REFERRAL;
#endif /* !SLAPD_MULTIMASTER */
} else {
void *ctx;
int id;
char *masteruri;
+ struct berval *master_bv;
char *mastername;
int masterport;
int type;
+ struct berval updatedn;
char *binddn;
int bindmethod;
char *passwd;
char *authzId;
char *srvtab;
char *saslmech;
- int interval;
+ time_t interval;
char *base;
int scope;
int deref;
#define IDSTR "id"
#define MASTERSTR "master"
#define SUFFIXSTR "suffix"
+#define UPDATEDNSTR "updatedn"
#define BINDDNSTR "binddn"
#define BINDMETHSTR "bindmethod"
#define SIMPLESTR "simple"
op.o_tmpmemctx = NULL; /* FIXME : to use per-thread mem context */
op.o_tag = LDAP_REQ_SEARCH;
- op.o_dn = be->be_rootdn;
- op.o_ndn = be->be_rootndn;
+ op.o_dn = si->updatedn;
+ op.o_ndn = si->updatedn;
op.o_callback = &cb;
op.o_time = slap_get_time();
op.o_managedsait = 1;