From a28e3bc6e17b30f5d664876fbcfbc8b2f226c508 Mon Sep 17 00:00:00 2001 From: Mark Reynolds Date: Mon, 17 Jul 2017 11:41:39 -0400 Subject: [PATCH] Ticket 49038 - Remove legacy replication Description: Removed all things legacy replication. Also added a upgrade script to remove the plugin on upgrade. https://pagure.io/389-ds-base/issue/49038 Reviewed by: ? --- Makefile.am | 17 +- .../src/scripts/50removeLegacyReplication.ldif | 2 + ldap/ldif/50replication-plugins.ldif | 13 - ldap/schema/01core389.ldif | 2 +- ldap/servers/plugins/replication/cl4.h | 73 -- ldap/servers/plugins/replication/cl4_api.c | 804 --------------------- ldap/servers/plugins/replication/cl4_api.h | 75 -- ldap/servers/plugins/replication/cl4_init.c | 357 --------- ldap/servers/plugins/replication/legacy_consumer.c | 723 ------------------ ldap/servers/plugins/replication/profile.c | 1 - ldap/servers/plugins/replication/repl.h | 394 ---------- ldap/servers/plugins/replication/repl5.h | 120 ++- .../plugins/replication/repl5_inc_protocol.c | 6 +- ldap/servers/plugins/replication/repl5_init.c | 9 +- .../servers/plugins/replication/repl5_mtnode_ext.c | 1 - ldap/servers/plugins/replication/repl5_plugins.c | 126 +--- .../plugins/replication/repl5_protocol_util.c | 13 - ldap/servers/plugins/replication/repl5_replica.c | 168 +---- .../plugins/replication/repl5_replica_config.c | 34 +- .../plugins/replication/repl5_tot_protocol.c | 1 - ldap/servers/plugins/replication/repl5_total.c | 1 - ldap/servers/plugins/replication/repl_add.c | 38 - ldap/servers/plugins/replication/repl_bind.c | 58 -- ldap/servers/plugins/replication/repl_compare.c | 48 -- ldap/servers/plugins/replication/repl_connext.c | 3 - ldap/servers/plugins/replication/repl_controls.c | 1 - ldap/servers/plugins/replication/repl_delete.c | 34 - ldap/servers/plugins/replication/repl_entry.c | 46 -- ldap/servers/plugins/replication/repl_ext.c | 2 +- ldap/servers/plugins/replication/repl_extop.c | 8 - ldap/servers/plugins/replication/repl_globals.c | 3 +- ldap/servers/plugins/replication/repl_init.c | 302 -------- ldap/servers/plugins/replication/repl_modify.c | 37 - ldap/servers/plugins/replication/repl_modrdn.c | 36 - ldap/servers/plugins/replication/repl_monitor.c | 73 -- ldap/servers/plugins/replication/repl_opext.c | 7 - ldap/servers/plugins/replication/repl_ops.c | 188 ----- ldap/servers/plugins/replication/repl_rootdse.c | 92 --- ldap/servers/plugins/replication/repl_search.c | 33 - .../plugins/replication/repl_session_plugin.c | 1 - ldap/servers/plugins/replication/repl_shared.h | 1 - ldap/servers/plugins/replication/replutil.c | 1 - ldap/servers/plugins/replication/urp.c | 1 - .../plugins/replication/windows_inc_protocol.c | 1 - ldap/servers/plugins/replication/windows_private.c | 1 - .../plugins/replication/windows_tot_protocol.c | 2 - ldap/servers/slapd/add.c | 13 +- ldap/servers/slapd/mapping_tree.c | 1 - ldap/servers/slapd/pblock.c | 9 +- ldap/servers/slapd/plugin_acl.c | 6 +- ldap/servers/slapd/search.c | 16 - ldap/servers/slapd/slapi-plugin.h | 1 - ldap/servers/slapd/slapi-private.h | 3 - test/libslapd/pblock/pblock_accessors.txt | 1 - test/libslapd/pblock/pblock_accessors_freq.txt | 2 - 55 files changed, 133 insertions(+), 3876 deletions(-) create mode 100644 ldap/admin/src/scripts/50removeLegacyReplication.ldif delete mode 100644 ldap/servers/plugins/replication/cl4.h delete mode 100644 ldap/servers/plugins/replication/cl4_api.c delete mode 100644 ldap/servers/plugins/replication/cl4_api.h delete mode 100644 ldap/servers/plugins/replication/cl4_init.c delete mode 100644 ldap/servers/plugins/replication/legacy_consumer.c delete mode 100644 ldap/servers/plugins/replication/repl.h delete mode 100644 ldap/servers/plugins/replication/repl_add.c delete mode 100644 ldap/servers/plugins/replication/repl_bind.c delete mode 100644 ldap/servers/plugins/replication/repl_compare.c delete mode 100644 ldap/servers/plugins/replication/repl_delete.c delete mode 100644 ldap/servers/plugins/replication/repl_entry.c delete mode 100644 ldap/servers/plugins/replication/repl_init.c delete mode 100644 ldap/servers/plugins/replication/repl_modify.c delete mode 100644 ldap/servers/plugins/replication/repl_modrdn.c delete mode 100644 ldap/servers/plugins/replication/repl_monitor.c delete mode 100644 ldap/servers/plugins/replication/repl_ops.c delete mode 100644 ldap/servers/plugins/replication/repl_rootdse.c delete mode 100644 ldap/servers/plugins/replication/repl_search.c diff --git a/Makefile.am b/Makefile.am index f075a47..b2c736b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -417,13 +417,11 @@ dist_noinst_HEADERS = \ ldap/servers/plugins/uiduniq/plugin-utils.h \ ldap/servers/plugins/memberof/memberof.h \ ldap/servers/plugins/replication/cl5_api.h \ - ldap/servers/plugins/replication/cl4_api.h \ ldap/servers/plugins/replication/llist.h \ ldap/servers/plugins/replication/repl_shared.h \ ldap/servers/plugins/replication/csnpl.h \ ldap/servers/plugins/replication/cl5.h \ ldap/servers/plugins/replication/repl-session-plugin.h \ - ldap/servers/plugins/replication/repl.h \ ldap/servers/plugins/replication/windows_prot_private.h \ ldap/servers/plugins/replication/repl_helper.h \ ldap/servers/plugins/replication/repl_objset.h \ @@ -431,7 +429,6 @@ dist_noinst_HEADERS = \ ldap/servers/plugins/replication/cl5_test.h \ ldap/servers/plugins/replication/repl5_ruv.h \ ldap/servers/plugins/replication/cl5_clcache.h \ - ldap/servers/plugins/replication/cl4.h \ ldap/servers/plugins/replication/cl_crypt.h \ ldap/servers/plugins/replication/urp.h \ ldap/servers/plugins/replication/winsync-plugin.h \ @@ -943,6 +940,7 @@ update_DATA = ldap/admin/src/scripts/exampleupdate.pl \ ldap/admin/src/scripts/50telexnumbersyntaxplugin.ldif \ ldap/admin/src/scripts/50guidesyntaxplugin.ldif \ ldap/admin/src/scripts/50targetuniqueid.ldif \ + ldap/admin/src/scripts/50removeLegacyReplication.ldif \ ldap/ldif/50replication-plugins.ldif \ ldap/admin/src/scripts/50linkedattrsplugin.ldif \ $(POSIX_WINSYNC_PLUGIN_LDIF) \ @@ -1653,27 +1651,14 @@ libreplication_plugin_la_SOURCES = ldap/servers/plugins/replication/cl5_api.c \ ldap/servers/plugins/replication/cl5_init.c \ ldap/servers/plugins/replication/cl_crypt.c \ ldap/servers/plugins/replication/csnpl.c \ - ldap/servers/plugins/replication/legacy_consumer.c \ ldap/servers/plugins/replication/llist.c \ - ldap/servers/plugins/replication/repl_add.c \ - ldap/servers/plugins/replication/repl_bind.c \ - ldap/servers/plugins/replication/repl_compare.c \ ldap/servers/plugins/replication/repl_connext.c \ ldap/servers/plugins/replication/repl_controls.c \ - ldap/servers/plugins/replication/repl_delete.c \ - ldap/servers/plugins/replication/repl_entry.c \ ldap/servers/plugins/replication/repl_ext.c \ ldap/servers/plugins/replication/repl_extop.c \ ldap/servers/plugins/replication/repl_globals.c \ - ldap/servers/plugins/replication/repl_init.c \ - ldap/servers/plugins/replication/repl_modify.c \ - ldap/servers/plugins/replication/repl_modrdn.c \ - ldap/servers/plugins/replication/repl_monitor.c \ ldap/servers/plugins/replication/repl_objset.c \ ldap/servers/plugins/replication/repl_opext.c \ - ldap/servers/plugins/replication/repl_ops.c \ - ldap/servers/plugins/replication/repl_rootdse.c \ - ldap/servers/plugins/replication/repl_search.c \ ldap/servers/plugins/replication/repl_session_plugin.c \ ldap/servers/plugins/replication/repl5_agmt.c \ ldap/servers/plugins/replication/repl5_agmtlist.c \ diff --git a/ldap/admin/src/scripts/50removeLegacyReplication.ldif b/ldap/admin/src/scripts/50removeLegacyReplication.ldif new file mode 100644 index 0000000..7c64a96 --- /dev/null +++ b/ldap/admin/src/scripts/50removeLegacyReplication.ldif @@ -0,0 +1,2 @@ +dn: cn=Legacy Replication Plugin,cn=plugins,cn=config +changetype: delete diff --git a/ldap/ldif/50replication-plugins.ldif b/ldap/ldif/50replication-plugins.ldif index 71afbea..2a978be 100644 --- a/ldap/ldif/50replication-plugins.ldif +++ b/ldap/ldif/50replication-plugins.ldif @@ -1,16 +1,3 @@ -dn: cn=Legacy Replication Plugin,cn=plugins,cn=config -objectclass: top -objectclass: nsSlapdPlugin -objectclass: extensibleObject -cn: Legacy Replication Plugin -nsslapd-pluginpath: libreplication-plugin -nsslapd-plugininitfunc: replication_legacy_plugin_init -nsslapd-plugintype: object -nsslapd-pluginenabled: on -nsslapd-plugin-depends-on-type: database -nsslapd-plugin-depends-on-named: Multimaster Replication Plugin -nsslapd-plugin-depends-on-named: Class of Service - dn: cn=Multimaster Replication Plugin,cn=plugins,cn=config objectclass: top objectclass: nsSlapdPlugin diff --git a/ldap/schema/01core389.ldif b/ldap/schema/01core389.ldif index 836b953..2464952 100644 --- a/ldap/schema/01core389.ldif +++ b/ldap/schema/01core389.ldif @@ -71,7 +71,7 @@ attributeTypes: ( 2.16.840.1.113730.3.1.686 NAME 'nsds5replicaLastUpdateEnd' DES attributeTypes: ( 2.16.840.1.113730.3.1.687 NAME 'nsds5replicaChangesSentSinceStartup' DESC 'Netscape defined attribute type' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE NO-USER-MODIFICATION X-ORIGIN 'Netscape Directory Server' ) attributeTypes: ( 2.16.840.1.113730.3.1.688 NAME 'nsds5replicaLastUpdateStatus' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE NO-USER-MODIFICATION X-ORIGIN 'Netscape Directory Server' ) attributeTypes: ( 2.16.840.1.113730.3.1.689 NAME 'nsds5replicaUpdateInProgress' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 SINGLE-VALUE NO-USER-MODIFICATION X-ORIGIN 'Netscape Directory Server' ) -attributeTypes: ( 2.16.840.1.113730.3.1.802 NAME 'nsds5ReplicaLegacyConsumer' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' ) +attributeTypes: ( 2.16.840.1.113730.3.1.802 NAME 'nsds5ReplicaLegacyConsumer' DESC 'Netscape defined attribute type - OBSOLETE' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' ) attributeTypes: ( 2.16.840.1.113730.3.1.2132 NAME 'nsds5ReplicaEnabled' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' ) attributeTypes: ( 2.16.840.1.113730.3.1.804 NAME 'nsSchemaCSN' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE USAGE directoryOperation X-ORIGIN 'Netscape Directory Server' ) attributeTypes: ( 2.16.840.1.113730.3.1.805 NAME 'nsds5replicaTimeout' DESC 'Netscape defined attribute type' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' ) diff --git a/ldap/servers/plugins/replication/cl4.h b/ldap/servers/plugins/replication/cl4.h deleted file mode 100644 index 65da4c8..0000000 --- a/ldap/servers/plugins/replication/cl4.h +++ /dev/null @@ -1,73 +0,0 @@ -/** BEGIN COPYRIGHT BLOCK - * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission. - * Copyright (C) 2005 Red Hat, Inc. - * All rights reserved. - * - * License: GPL (version 3 or any later version). - * See LICENSE for details. - * END COPYRIGHT BLOCK **/ - -#ifdef HAVE_CONFIG_H -# include -#endif - -/* cl4.h - global declarations used by the 4.0 style changelog module - */ - -#ifndef CL4_H -#define CL4_H - -#include "slapi-private.h" -#include "portable.h" /* GGOODREPL - is this cheating? */ - -#define CONFIG_CHANGELOG_SUFFIX_ATTRIBUTE "nsslapd-changelogsuffix" - -/* A place to store changelog config info */ -typedef struct _chglog4Info chglog4Info; - -/* in cl4.c */ -chglog4Info* changelog4_new (Slapi_Entry *e, char *errorbuf); -void changelog4_free (chglog4Info** cl4); -void changelog4_lock (Object *obj, PRBool write); -void changelog4_unlock (Object *obj); -const char * changelog4_get_dir (const chglog4Info* cl4); -const char * changelog4_get_suffix (const chglog4Info* cl4); -time_t changelog4_get_maxage (const chglog4Info* cl4); -unsigned long changelog4_get_maxentries (const chglog4Info* cl4); -void changelog4_set_dir (chglog4Info* cl4, const char *dir); -void changelog4_set_suffix (chglog4Info* cl4, const char *suffix); -void changelog4_set_maxage (chglog4Info* cl4, const char *maxage); -void changelog4_set_maxentries (chglog4Info* cl4, const char* maxentries); - -/* In cl4_suffix.c */ -char *get_changelog_dataversion(const chglog4Info* cl4); -void set_changelog_dataversion(chglog4Info* cl4, const char *dataversion); - -/* In cl4_config.c */ -int changelog4_config_init(void); -void changelog4_config_destroy(void); - -/* - * backend configuration information - * Previously, these two typedefs were in ../../slapd/slapi-plugin.h but - * the CL4 code is the only remaining code that references these definitions. - */ -typedef struct config_directive -{ - char *file_name; /* file from which to read directive */ - int lineno; /* line to read */ - int argc; /* number of argvs */ - char **argv; /* directive in agrv format */ -} slapi_config_directive; - -typedef struct be_config -{ - char *type; /* type of the backend */ - char *suffix; /* suffix of the backend */ - int is_private; /* 1 - private, 0 -not */ - int log_change; /* 1 - write change to the changelog; 0 - don't */ - slapi_config_directive *directives;/* configuration directives */ - int dir_count; /* number of directives */ -} slapi_be_config; - -#endif diff --git a/ldap/servers/plugins/replication/cl4_api.c b/ldap/servers/plugins/replication/cl4_api.c deleted file mode 100644 index 0d830cb..0000000 --- a/ldap/servers/plugins/replication/cl4_api.c +++ /dev/null @@ -1,804 +0,0 @@ -/** BEGIN COPYRIGHT BLOCK - * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission. - * Copyright (C) 2005 Red Hat, Inc. - * All rights reserved. - * - * License: GPL (version 3 or any later version). - * See LICENSE for details. - * END COPYRIGHT BLOCK **/ - -#ifdef HAVE_CONFIG_H -# include -#endif - -/* cl4_api.h - implementation of the minimal interface to 4.0 changelog necessary to - link 4.0 changelog to 5.0 replication - */ - -#include "repl.h" -#include "cl4_api.h" -#include "csnpl.h" -#include "cl4.h" - -/*** Data Structures ***/ - -/* changelog internal data */ -typedef struct cl4priv -{ - CSNPL *csnPL; /* csn pending list */ - int regID; /* csn function registration id */ -}CL4Private; - -/* callback data to get result of internal operations */ -typedef struct cl4ret -{ - int err; /* error code */ - Slapi_Entry *e; /* target entry */ -}CL4Ret; - -/* Global Data */ -static CL4Private s_cl4Desc; /* represents changelog state */ - -/*** Helper functions forward declarations ***/ -static int _cl4WriteOperation (const slapi_operation_parameters *op); -static void _cl4AssignCSNCallback (const CSN *csn, void *data); -static void _cl4AbortCSNCallback (const CSN *csn, void *data); -static char* _cl4MakeCSNDN (const CSN* csn); -static int _cl4GetEntry (const CSN *csn, Slapi_Entry **entry); -static void _cl4ResultCallback (int err, void *callback_data); -static int _cl4EntryCallback (Slapi_Entry *e, void *callback_data); -static PRBool _cl4CanAssignChangeNumber (const CSN *csn); -static int _cl4ResolveTargetDN (Slapi_Entry *entry, Slapi_DN **newTargetDN); -static int _cl4GetTargetEntry (Slapi_DN *targetDN, const char *uniqueid, Slapi_Entry **entry); -static int _cl4FindTargetDN (const CSN *csn, const char *uniqueid, - const Slapi_DN *targetSDN, Slapi_DN **newTargetDN); -static int _cl4AssignChangeNumber (changeNumber *cnum); -static int _cl4UpdateEntry (const CSN *csn, const char *changeType, const Slapi_DN *newTargetDN, changeNumber cnum); - -/*** API ***/ -int cl4Init () -{ - s_cl4Desc.csnPL = csnplNew (); - if (s_cl4Desc.csnPL == NULL) - { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "cl4Init: failed to create CSN pending list\n"); - return CL4_CSNPL_ERROR; - } - - s_cl4Desc.regID = csnRegisterNewCSNCb(_cl4AssignCSNCallback, NULL, - _cl4AbortCSNCallback, NULL); - - return CL4_SUCCESS; -} - -void cl4Cleanup () -{ - if (s_cl4Desc.regID >= 0) - { - csnRemoveNewCSNCb(s_cl4Desc.regID); - s_cl4Desc.regID = -1; - } - - if (s_cl4Desc.csnPL == NULL) - csnplFree (&s_cl4Desc.csnPL); -} - -int cl4WriteOperation (const slapi_operation_parameters *op) -{ - int rc; - ReplicaId rd; - - if (op == NULL || !IsValidOperation (op)) - { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "cl4WriteEntry: invalid entry\n"); - return CL4_BAD_DATA; - } - - rc = _cl4WriteOperation (op); - if (rc != CL4_SUCCESS) - { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "cl4WriteEntry: failed to write changelog entry\n"); - return rc; - } - - /* the entry is generated by this server - remove the entry from the pending list */ - rd= csn_get_replicaid(op->csn); - if (rd == slapi_get_replicaid ()) - { - rc = csnplRemove (s_cl4Desc.csnPL, op->csn); - - if (rc != 0) - { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, - "cl4WriteEntry: failed to remove CSN from the pending list\n"); - rc = CL4_CSNPL_ERROR; - } - } - - return rc; -} - -int cl4ChangeTargetDN (const CSN *csn, const char *newDN) -{ - Slapi_PBlock *pb; - char *changeEntryDN; - Slapi_Mods smods; - int res; - - if (csn == NULL || newDN == NULL) - { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "cl4ChangeTargetDN: invalid argument\n"); - return CL4_BAD_DATA; - } - - /* construct dn of the change entry */ - changeEntryDN = _cl4MakeCSNDN (csn); - if (changeEntryDN == NULL) - { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, - "cl4ChangeTargetDN: failed to construct change entry dn\n"); - return CL4_MEMORY_ERROR; - } - - pb = slapi_pblock_new (); - - slapi_mods_init(&smods, 1); - slapi_mods_add(&smods, LDAP_MOD_REPLACE | LDAP_MOD_BVALUES, attr_targetdn, - strlen (newDN), newDN); - slapi_modify_internal_set_pb(pb, changeEntryDN, slapi_mods_get_ldapmods_byref(&smods), - NULL, NULL, repl_get_plugin_identity(PLUGIN_LEGACY_REPLICATION), 0); - slapi_modify_internal_pb (pb); - - slapi_mods_done(&smods); - slapi_ch_free ((void**)&changeEntryDN); - - slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &res); - slapi_pblock_destroy(pb); - - if (res != LDAP_SUCCESS) - { - char s[CSN_STRSIZE]; - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, - "cl4ChangeTargetDN: an error occured while modifying change entry with csn %s: %s. " - "Logging of changes is disabled.\n", csn_as_string(csn,PR_FALSE,s), ldap_err2string(res)); - /* GGOODREPL g_set_repl_backend( NULL ); */ - return CL4_LDAP_ERROR; - } - - return CL4_SUCCESS; -} - -void cl4AssignChangeNumbers (time_t when, void *arg) -{ - int rc = CL4_SUCCESS; - Slapi_Entry *entry; - CSN *csn = NULL; - Slapi_DN *newTargetDN; - changeNumber cnum; - char *changetype; - - /* we are looping though the entries ready to be commited updating there target dn - and assigning change numbers */ - while (_cl4GetEntry (csn, &entry) == CL4_SUCCESS) - { - /* ONREPL - I think we need to free previous csn */ - csn = csn_new_by_string(slapi_entry_attr_get_charptr (entry, attr_csn)); - /* all conflicts involving this entry have been resolved */ - if (_cl4CanAssignChangeNumber (csn)) - { - /* figure out the name of the target entry that corresponds to change csn */ - rc = _cl4ResolveTargetDN (entry, &newTargetDN); - slapi_entry_free (entry); - if (rc != CL4_SUCCESS) - { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "cl4AssignChangeNumbers: failed to resolve target dn\n"); - break; - } - - _cl4AssignChangeNumber (&cnum); - - changetype = slapi_entry_attr_get_charptr (entry, attr_changetype); - - /* update change entry: write change number and remove csn attribute. - Note that we leave uniqueid in the entry to avoid an extra update. - This is ok since uniqueid is an operational attribute not returned - to the client by default. */ - rc = _cl4UpdateEntry (csn, changetype, newTargetDN, cnum); - if (newTargetDN) - { - slapi_sdn_free (&newTargetDN); - } - - slapi_ch_free ((void**)&changetype); - - if (rc != CL4_SUCCESS) - { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, - "cl4AssignChangeNumbers: failed to update changelog entry\n"); - break; - } - } - else /* went too far */ - { - slapi_entry_free (entry); - break; - } - } -} - - -/*** Helper Functions ***/ - -/* adds new change record to 4.0 changelog */ -static int _cl4WriteOperation (const slapi_operation_parameters *op) -{ - int rc = CL4_SUCCESS, res; - char *changeEntryDN, *timeStr; - Slapi_Entry *e = NULL; - Slapi_PBlock *pb = NULL; - Slapi_Value *values[3]; - char s[CSN_STRSIZE]; - - slapi_log_err(SLAPI_LOG_PLUGIN, repl_plugin_name, - "_cl4WriteEntry: writing change record with csn %s for dn: \"%s\"\n", - csn_as_string(op->csn,PR_FALSE,s), op->target_address.dn); - - /* create change entry dn */ - changeEntryDN = _cl4MakeCSNDN (op->csn); - if (changeEntryDN == NULL) - { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, - "_cl4WriteEntry: failed to create entry dn\n"); - return CL4_MEMORY_ERROR; - } - - /* - * Create the entry struct, and fill in fields common to all types - * of change records. - */ - e = slapi_entry_alloc(); - if (e == NULL) - { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, - "_cl4WriteEntry: failed to allocate change entry\n"); - return CL4_MEMORY_ERROR; - } - - slapi_entry_set_dn(e, slapi_ch_strdup (changeEntryDN)); - - /* Set the objectclass attribute */ - values [0] = slapi_value_new (NULL); - values [1] = slapi_value_new (NULL); - values [2] = NULL; - slapi_value_set_string(values[0], "top"); - slapi_value_set_string(values[1], "changelogentry"); - slapi_entry_add_values_sv (e, "objectclass", values); - - /* ONREPL - for now we have to free Slapi_Values since api makes copy; - this will change when a new set of api is added */ - slapi_value_free (&(values[0])); - slapi_value_free (&(values[1])); - - /* Set the changeNumber attribute */ - /* Need to set this because it is required by schema */ - slapi_entry_attr_set_charptr (e, attr_changenumber, "0"); - - /* Set the targetentrydn attribute */ - if (op->operation_type == SLAPI_OPERATION_ADD) /* use raw dn */ - slapi_entry_attr_set_charptr (e, attr_targetdn, slapi_entry_get_dn (op->p.p_add.target_entry)); - else /* use normolized dn */ - slapi_entry_attr_set_charptr (e, attr_targetdn, op->target_address.dn); - - /* ONREPL - set dbid attribute */ - - /* Set the changeTime attribute */ - timeStr = format_localTime (current_time()); - slapi_entry_attr_set_charptr (e, attr_changetime, timeStr); - slapi_ch_free((void**)&timeStr); - - /* - * Finish constructing the entry. How to do it depends on the type - * of modification being logged. - */ - switch (op->operation_type) - { - case SLAPI_OPERATION_ADD: if (entry2reple(e, op->p.p_add.target_entry) != 0 ) - { - rc = CL4_INTERNAL_ERROR; - goto done; - } - - break; - - case SLAPI_OPERATION_MODIFY: if (mods2reple(e, op->p.p_modify.modify_mods) != 0) - { - rc = CL4_INTERNAL_ERROR; - goto done; - } - - break; - - case SLAPI_OPERATION_MODDN: if (modrdn2reple(e, op->p.p_modrdn.modrdn_newrdn, - op->p.p_modrdn.modrdn_deloldrdn, op->p.p_modrdn.modrdn_mods) != 0) - { - rc = CL4_INTERNAL_ERROR; - goto done; - } - - break; - - case SLAPI_OPERATION_DELETE: /* Set the changetype attribute */ - slapi_entry_attr_set_charptr (e, attr_changetype, "delete"); - break; - } - - pb = slapi_pblock_new (pb); - slapi_add_entry_internal_set_pb (pb, e, NULL, repl_get_plugin_identity (PLUGIN_LEGACY_REPLICATION), 0); - slapi_add_internal_pb (pb); - e = NULL; /* add consumes entry */ - - slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &res); - slapi_pblock_destroy(pb); - - if (res != LDAP_SUCCESS) - { - char s[CSN_STRSIZE]; - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, - "_cl4WriteEntry: an error occured while adding change entry with csn %s, dn = %s: %s. " - "Logging of changes is disabled.\n", csn_as_string(op->csn,PR_FALSE,s), op->target_address.dn, - ldap_err2string(res)); - /* GGOODREPL g_set_repl_backend( NULL ); */ - rc = CL4_LDAP_ERROR; - } - -done: - slapi_entry_free(e); - if (changeEntryDN) - slapi_ch_free((void **) &changeEntryDN); - - return rc; -} - -static void _cl4AssignCSNCallback (const CSN *csn, void *data) -{ - int rc; - - if (csn == NULL) - { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "_cl4AssignCSNCallback: null csn\n"); - return; - } - - rc = csnplInsert (s_cl4Desc.csnPL, csn); - - if (rc == -1) - { - char s[CSN_STRSIZE]; - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, - "_cl4AssignCSNCallback: failed to insert csn %s to the pending list\n", - csn_as_string(csn,PR_FALSE,s)); - } -} - -static void _cl4AbortCSNCallback (const CSN *csn, void *data) -{ - int rc; - - if (csn == NULL) - { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "_cl4AbortCSNCallback: null csn\n"); - return; - } - - rc = csnplRemove (s_cl4Desc.csnPL, csn); - if (rc == -1) - { - char s[CSN_STRSIZE]; - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, - "_cl4AbortCSNCallback: failed to remove csn %s from the pending list\n", - csn_as_string(csn,PR_FALSE,s)); - } -} - -/* initial dn format: csn=,. For instance, csn=013744022939465,cn=changelog4 */ -static char* _cl4MakeCSNDN (const CSN* csn) -{ - char *pat, *edn; - char *suffix = changelog4_get_suffix (); - char s[CSN_STRSIZE]; - - if (suffix == NULL) - return NULL; - - /* Construct the dn of this change record */ - edn = slapi_ch_smprintf("%s=%s,%s", attr_csn, csn_as_string(csn,PR_FALSE,s), suffix); - slapi_ch_free ((void **)&suffix); - - return edn; -} - -static int _cl4GetEntry (const CSN *csn, Slapi_Entry **entry) -{ - int rc; - char *suffix = changelog4_get_suffix (); - int type; - const char *value; - CL4Ret ret; - char s[CSN_STRSIZE]; - - if (csn == NULL) /* entry with smallest csn */ - { - type = SLAPI_SEQ_FIRST; - value = NULL; - } - else /* entry with next csn */ - { - type = SLAPI_SEQ_NEXT; - value = csn_as_string(csn,PR_FALSE,s); - } - - rc = slapi_seq_callback(suffix, type, attr_csn, (char*)value, NULL, 0, &ret, NULL, - _cl4ResultCallback, _cl4EntryCallback, NULL); - slapi_ch_free ((void**)&suffix); - - if (rc != 0 || ret.err != 0) - { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "_cl4GetEntry: failed to get next changelog entry\n"); - return CL4_INTERNAL_ERROR; - } - - *entry = ret.e; - return CL4_SUCCESS; -} - -static void _cl4ResultCallback (int err, void *callback_data) -{ - CL4Ret *ret = (CL4Ret *)callback_data; - - if (ret) - { - ret->err = err; - } -} - -static int _cl4EntryCallback (Slapi_Entry *e, void *callback_data) -{ - CL4Ret *ret = (CL4Ret *)callback_data; - - if (ret) - { - ret->e = slapi_entry_dup (e); - } - - return 0; -} - -static PRBool _cl4CanAssignChangeNumber (const CSN *csn) -{ - CSN *commitCSN = NULL; - - /* th CSN is withtin region that can be commited */ - if (csn && csn_compare(csn, commitCSN) < 0) - return PR_TRUE; - - return PR_FALSE; -} - -/* ONREPL - describe algorithm */ -static int _cl4ResolveTargetDN (Slapi_Entry *entry, Slapi_DN **newTargetDN) -{ - int rc; - char *csnStr = slapi_entry_attr_get_charptr (entry, attr_csn); - char *targetdn = slapi_entry_attr_get_charptr (entry, attr_targetdn); - const char *uniqueid = slapi_entry_get_uniqueid (entry); - char *changetype = slapi_entry_attr_get_charptr (entry, attr_changetype); - CSN *csn = csn_new_by_string (csnStr); - Slapi_Entry *targetEntry = NULL; - const Slapi_DN *teSDN; - Slapi_DN *targetSDN; - const CSN *teDNCSN = NULL; - - *newTargetDN = NULL; - - targetSDN = slapi_sdn_new(); - if (strcasecmp (changetype, "add") == 0) /* this is add operation - we have rawdn */ - slapi_sdn_set_dn_byref (targetSDN, targetdn); - else - slapi_sdn_set_normdn_byref (targetSDN, targetdn); - - /* read the entry to which the change was applied */ - rc = _cl4GetTargetEntry (targetSDN, uniqueid, &targetEntry); - if (rc != CL4_SUCCESS) - { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "_cl4ResolveTargetDN: failed to get target entry\n"); - goto done; - } - - teDNCSN = entry_get_dncsn(targetEntry); - if (teDNCSN == NULL) - { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "_cl4ResolveTargetDN: failed to get target entry dn\n"); - rc = CL4_BAD_FORMAT; - goto done; - } - - if (csn_compare(teDNCSN, csn) <= 0) - { - /* the change entry target dn should be the same as target entry dn */ - teSDN = slapi_entry_get_sdn_const(targetEntry); - - /* target dn of change entry is not the same as dn of the target entry - update */ - if (slapi_sdn_compare (teSDN, targetSDN) != 0) - { - *newTargetDN = slapi_sdn_dup (targetSDN); - } - } - else /* the target entry was renamed since this change occur - find the right target dn */ - { - rc = _cl4FindTargetDN (csn, uniqueid, targetSDN, newTargetDN); - } - -done:; - if (csnStr) - slapi_ch_free ((void**)&csnStr); - - if (targetdn) - slapi_ch_free ((void**)&targetdn); - - if (uniqueid) - slapi_ch_free ((void**)&uniqueid); - - if (changetype) - slapi_ch_free ((void**)&changetype); - - if (targetEntry) - slapi_entry_free (targetEntry); - - if (targetSDN) - slapi_sdn_free (&targetSDN); - - return rc; -} - -static int _cl4GetTargetEntry (Slapi_DN *sdn, const char *uniqueid, Slapi_Entry **entry) -{ - Slapi_PBlock *pb; - char filter [128]; - int res, rc = CL4_SUCCESS; - Slapi_Entry **entries = NULL; - - /* read corresponding database entry based on its uniqueid */ - PR_snprintf (filter, sizeof(filter), "uniqueid=%s", uniqueid); - pb = slapi_pblock_new (); - slapi_search_internal_set_pb (pb, (char*)slapi_sdn_get_ndn(sdn), LDAP_SCOPE_SUBTREE, filter, NULL, 0, NULL, NULL, - repl_get_plugin_identity (PLUGIN_LEGACY_REPLICATION), 0); - slapi_search_internal_pb (pb); - - if (pb == NULL) - { - rc = CL4_LDAP_ERROR; - goto done; - } - - slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &res); - if (res == LDAP_NO_SUCH_OBJECT) /* entry not found */ - { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "_cl4GetTargetEntry: entry (%s) not found\n", - slapi_sdn_get_ndn(sdn)); - rc = CL4_NOT_FOUND; - goto done; - } - - if (res != LDAP_SUCCESS) - { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, - "_cl4ResolveTargetDN: an error occured while searching for directory entry with uniqueid %s: %s. " - "Logging of changes is disabled.\n", uniqueid, ldap_err2string(res)); - /* GGOODREPL g_set_repl_backend( NULL ); */ - rc = CL4_LDAP_ERROR; - goto done; - } - - slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries); - if (entries == NULL || entries [0] == NULL) - { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "_cl4GetTargetEntry: entry (%s) not found\n", - slapi_sdn_get_ndn(sdn)); - rc = CL4_NOT_FOUND; - goto done; - } - - *entry = slapi_entry_dup (entries[0]); - -done: - if (pb) - { - slapi_free_search_results_internal(pb); - slapi_pblock_destroy (pb); - } - - return rc; -} - -static int _cl4FindTargetDN (const CSN *csn, const char *uniqueid, - const Slapi_DN *targetSDN, Slapi_DN **newTargetDN) -{ - int rc = CL4_SUCCESS; - int res, i; - Slapi_PBlock *pb; - char *suffix = changelog4_get_suffix (); - char filter [128]; - Slapi_Entry **entries; - int minIndex = 0; - CSN *minCSN = NULL, *curCSN; - char *curType; - const Slapi_DN *sdn; - char s[CSN_STRSIZE]; - - *newTargetDN = NULL; - - /* Look for all modifications to the target entry with csn larger than - this csn. We are only interested in rename operations, but change type - is currently not indexed */ - PR_snprintf (filter, 128, "&(uniqueid=%s)(csn>%s)", uniqueid, csn_as_string(csn,PR_FALSE,s)); - pb = slapi_pblock_new (); - slapi_search_internal_set_pb (pb, suffix, LDAP_SCOPE_SUBTREE, filter, NULL, 0, NULL, NULL, - repl_get_plugin_identity (PLUGIN_LEGACY_REPLICATION), 0); - slapi_search_internal_pb (pb); - slapi_ch_free ((void**)&suffix); - if (pb == NULL) - { - rc = CL4_LDAP_ERROR; - goto done; - } - - slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &res); - if (res == LDAP_NO_SUCH_OBJECT) /* entry not found */ - { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "_cl4FindTargetDN: no entries much filter (%s)\n", - filter); - rc = CL4_NOT_FOUND; - goto done; - } - - if (res != LDAP_SUCCESS) - { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, - "_cl4ResolveTargetDN: an error occured while searching change entries matching filter %s: %s. " - "Logging of changes is disabled.\n", filter, ldap_err2string(res)); - /* GGOODREPL g_set_repl_backend( NULL ); */ - rc = CL4_LDAP_ERROR; - goto done; - } - - slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries); - if (entries == NULL) - { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "_cl4FindTargetDN: no entries much filter (%s)\n", - filter); - rc = CL4_NOT_FOUND; - goto done; - } - - i = 0; - - /* find rename operation with smallest csn - its target dn should be the name - of our change entry */ - while (entries[i]) - { - curType = slapi_entry_attr_get_charptr (entries[i], attr_changetype); - if (curType && strcasecmp (curType, "modrdn") == 0) - { - curCSN = csn_new_by_string (slapi_entry_attr_get_charptr (entries[i], attr_csn)); - if (minCSN == NULL || csn_compare (curCSN, minCSN) < 0) - { - minCSN = curCSN; - minIndex = i; - } - } - - if (curType) - slapi_ch_free ((void**)&curType); - - i ++; - } - - if (curCSN == NULL) - { - rc = CL4_NOT_FOUND; - goto done; - } - - /* update targetDN of our entry if necessary */ - sdn = slapi_entry_get_sdn_const(entries[minIndex]); - - /* target dn does not match to renaming operation - rename change entry */ - if (slapi_sdn_compare (sdn, targetSDN) != 0) - *newTargetDN = slapi_sdn_dup (sdn); - -done: - if (pb) - { - slapi_free_search_results_internal(pb); - slapi_pblock_destroy (pb); - } - - return rc; -} - -static int _cl4AssignChangeNumber (changeNumber *cnum) -{ - *cnum = ldapi_assign_changenumber(); - return CL4_SUCCESS; -} - -static int _cl4UpdateEntry (const CSN *csn, const char *changeType, - const Slapi_DN *newDN, changeNumber cnum) -{ - Slapi_PBlock *pb; - char *dn; - const char *dnTemp; - int res; - Slapi_Mods smods; - char cnumbuf[32]; - - if (csn == NULL || changeType == NULL) - { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "_cl4UpdateEntry: invalid argument\n"); - return CL4_BAD_DATA; - } - - dn = _cl4MakeCSNDN (csn); - if (dn == NULL) - { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "_cl4UpdateEntry: failed to create entry dn\n"); - return CL4_MEMORY_ERROR; - } - - slapi_mods_init(&smods, 2); - if (newDN) - { - if (strcasecmp (changeType, "add") == 0) - dnTemp = slapi_sdn_get_dn (newDN); - else - dnTemp = slapi_sdn_get_ndn (newDN); - - slapi_mods_add(&smods, LDAP_MOD_REPLACE | LDAP_MOD_BVALUES, attr_targetdn, - strlen (dnTemp), dnTemp); - } - /* Set the changeNumber attribute */ - sprintf(cnumbuf, "%lu", cnum); - slapi_mods_add (&smods, LDAP_MOD_REPLACE | LDAP_MOD_BVALUES, attr_changenumber, - strlen (cnumbuf), cnumbuf); - pb = slapi_pblock_new (); - slapi_modify_internal_set_pb (pb, dn, slapi_mods_get_ldapmods_byref(&smods), NULL, NULL, - repl_get_plugin_identity (PLUGIN_LEGACY_REPLICATION), 0); - slapi_modify_internal_pb (pb); - slapi_mods_done(&smods); - slapi_ch_free ((void**)&dn); - - if (pb == NULL) - { - return CL4_LDAP_ERROR; - } - - slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &res); - slapi_pblock_destroy(pb); - if (res != LDAP_SUCCESS) - { - char s[CSN_STRSIZE]; - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, - "cl4ChangeTargetDN: an error occured while modifying change entry with csn %s: %s. " - "Logging of changes is disabled.\n", csn_as_string(csn,PR_FALSE,s), ldap_err2string(res)); - /* GGOODREPL g_set_repl_backend( NULL ); */ - return CL4_LDAP_ERROR; - } - - if ( ldapi_get_first_changenumber() == (changeNumber) 0L ) - { - ldapi_set_first_changenumber( cnum ); - } - - ldapi_commit_changenumber(cnum); - return CL4_SUCCESS; -} diff --git a/ldap/servers/plugins/replication/cl4_api.h b/ldap/servers/plugins/replication/cl4_api.h deleted file mode 100644 index e5812c6..0000000 --- a/ldap/servers/plugins/replication/cl4_api.h +++ /dev/null @@ -1,75 +0,0 @@ -/** BEGIN COPYRIGHT BLOCK - * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission. - * Copyright (C) 2005 Red Hat, Inc. - * All rights reserved. - * - * License: GPL (version 3 or any later version). - * See LICENSE for details. - * END COPYRIGHT BLOCK **/ - -#ifdef HAVE_CONFIG_H -# include -#endif - -/* cl4_api.h - minimal interface to 4.0 changelog necessary to link 4.0 changelog - to 5.0 replication - */ - -#ifndef CL4_API_H -#define CL4_API_H - -#include "repl.h" - -/*** Error Codes ***/ -enum -{ - CL4_SUCCESS, - CL4_BAD_DATA, - CL4_BAD_FORMAT, - CL4_NOT_FOUND, - CL4_MEMORY_ERROR, - CL4_CSNPL_ERROR, - CL4_LDAP_ERROR, - CL4_INTERNAL_ERROR -}; - -/*** APIs ***/ -/* Name: cl4Init - Description: initializes 4.0 changelog subsystem - Parameters: none - Return: ???? - */ -int cl4Init (); - -/* Name: cl4WriteOperation - Description: logs operation to 4.0 changelog; operation must go through CD&R engine first - Parameters: op - operation to be logged - - Return: ???? - */ -int cl4WriteOperation (const slapi_operation_parameters *op); - -/* Name: cl4ChangeTargetDN - Description: modifies change entry target dn; should be called for conflicts due to naming collisions; - raw dn should be passed for add operations; normolized dn otherwise. - Parameters: csn - csn of the change entry to be modified - newDN - new target dn of the entry - Return: ???? - */ -int cl4ChangeTargetDN (const CSN* csn, const char *newDN); - -/* Name: cl4AssignChangeNumbers - Description: this function should be called periodically to assign change numbers to changelog - entries. Intended for use with event queue - Parameters: parameters are not currently used - Return: none - */ -void cl4AssignChangeNumbers (time_t when, void *arg); - -/* Name: cl4Cleanup - Description: frees memory held by 4.0 changelog subsystem - Parameters: none - Return: none - */ -void cl4Clean (); -#endif diff --git a/ldap/servers/plugins/replication/cl4_init.c b/ldap/servers/plugins/replication/cl4_init.c deleted file mode 100644 index 7ff1d66..0000000 --- a/ldap/servers/plugins/replication/cl4_init.c +++ /dev/null @@ -1,357 +0,0 @@ -/** BEGIN COPYRIGHT BLOCK - * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission. - * Copyright (C) 2005 Red Hat, Inc. - * All rights reserved. - * - * License: GPL (version 3 or any later version). - * See LICENSE for details. - * END COPYRIGHT BLOCK **/ - -#ifdef HAVE_CONFIG_H -# include -#endif - - -/* cl4_init.c - implments initialization/cleanup functions for - 4.0 style changelog - */ - -#include - -#include "slapi-plugin.h" -#include "cl4.h" -#include "repl.h" - -/* forward declarations */ -static int changelog4_create_be(); -static int changelog4_start_be (); -static int changelog4_close(); -static int changelog4_remove(); - -/* - * Initialise the 4.0 Changelog - */ -int changelog4_init () -{ - int rc= 0; /* OK */ - Slapi_Backend *rbe; - changeNumber first_change = 0UL, last_change = 0UL; - int lderr; - - if (changelog4_create_be() < 0 ) - { - rc= -1; - } - else - { - rc = changelog4_start_be (); - } - - if(rc == 0) - { - rbe = get_repl_backend(); - if(rbe!=NULL) - { - /* We have a Change Log. Check it's valid. */ - /* changelog has to be started before its - data version can be read */ - const char *sdv= get_server_dataversion(); - const char *cdv= get_changelog_dataversion(); - char *suffix = changelog4_get_suffix (); - if(!cdv || strcmp(sdv,cdv)!=0) - { - - /* The SDV and CDV are not the same. The Change Log is invalid. - It must be removed. */ - /* ONREPL - currently we go through this code when the changelog - is first created because we can't tell new backend from the - existing one.*/ - rc = changelog4_close(); - rc = changelog4_remove(); - - /* now restart the changelog */ - changelog4_start_be (); - - create_entity( suffix, "extensibleobject"); - /* Write the Server Data Version onto the changelog suffix entry */ - /* JCMREPL - And the changelog database version number */ - set_changelog_dataversion(sdv); - slapi_ch_free ((void **)&suffix); - - } - } - } - - if(rc != 0) - { - slapi_log_err(SLAPI_LOG_PLUGIN, repl_plugin_name, - "An error occurred configuring the changelog database\n" ); - } - - first_change = replog_get_firstchangenum( &lderr ); - last_change = replog_get_lastchangenum( &lderr ); - ldapi_initialize_changenumbers( first_change, last_change ); - - return rc; -} - -static int - -changelog4_close() -{ - int rc= 0 /* OK */; - Slapi_Backend *rbe= get_repl_backend(); - Slapi_PBlock *pb = slapi_pblock_new (); - IFP closefn = NULL; - - rc = slapi_be_getentrypoint (rbe, SLAPI_PLUGIN_CLOSE_FN, (void**)&closefn, pb); - if (rc != 0) - { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, - "Error: backend close entry point is missing. " - "Replication subsystem disabled.\n"); - slapi_pblock_destroy (pb); - set_repl_backend( NULL ); - return -1; - } - - rc = closefn (pb); - - if (rc != 0) - { - - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "Error: the changelog database could " - "not be closed. Replication subsystem disabled.\n"); - set_repl_backend( NULL ); - rc = -1; - } - - slapi_pblock_destroy (pb); - return rc; - -} - -static int -changelog4_remove() -{ - int rc= 0 /* OK */; - Slapi_Backend *rbe= get_repl_backend(); - Slapi_PBlock *pb = slapi_pblock_new (); - IFP rmdbfn = NULL; - - rc = slapi_be_getentrypoint (rbe, SLAPI_PLUGIN_DB_RMDB_FN, (void**)&rmdbfn, pb); - if (rc != 0) - { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, - "Error: backend rmdb entry point is missing. " - "Replication subsystem disabled.\n"); - slapi_pblock_destroy (pb); - set_repl_backend( NULL ); - return -1; - } - - rc = rmdbfn (pb); - - if (rc != 0) - { - - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "Error: the changelog database could " - "not be removed. Replication subsystem disabled.\n"); - rc = -1; - } - else - { - slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name, "New database generation computed. " - "Changelog database removed.\n"); - } - - slapi_pblock_destroy (pb); - return rc; -} - -static Slapi_Backend *repl_backend = NULL; - -Slapi_Backend -*get_repl_backend() -{ - return repl_backend; -} - -void -set_repl_backend(Slapi_Backend *be) -{ - repl_backend = be; -} - - -int changelog4_shutdown () -{ - /* ONREPL - will shutdown the backend */ - int rc = 1; - - return rc; -} - -static void changelog4_init_trimming () -{ - char *cl_maxage = changelog4_get_maxage (); - unsigned long cl_maxentries = changelog4_get_maxentries (); - time_t ageval = slapi_parse_duration(cl_maxage); - - slapi_ch_free ((void **)&cl_maxage); - - init_changelog_trimming(cl_maxentries, ageval ); -} - - - -/* - * Function: changelog4_create_be - * Arguments: none - * Returns: 0 on success, non-0 on error - * Description: configures changelog backend instance. - */ - -static int -changelog4_create_be() -{ - int i, dir_count = 5; - Slapi_Backend *rbe; - slapi_be_config config; - char *cl_dir = changelog4_get_dir (); - char *cl_suffix; - - if ( cl_dir == NULL ) { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, - "Error: no directory specified for changelog database.\n"); - return -1; - } - - cl_suffix = changelog4_get_suffix (); - - if ( cl_suffix == NULL ) { - slapi_ch_free ((void **)&cl_dir); - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, - "Error: no suffix specified for changelog database.\n"); - return -1; - } - - /* setup configuration parameters for backend initialization */ - config.type = CHANGELOG_LDBM_TYPE; - config.suffix = cl_suffix; - config.is_private = 1; /* yes */ - config.log_change = 0; /* no */ - config.directives = (slapi_config_directive*)slapi_ch_calloc( - dir_count, sizeof(slapi_config_directive)); - config.dir_count = dir_count; - - for (i = 0; i < dir_count; i++) - { - config.directives[i].file_name = "(internal)"; - config.directives[i].lineno = 0; - } - - /* setup indexes */ - config.directives[0].argv = NULL; - config.directives[0].argc = 3; - charray_add( &(config.directives[0].argv), slapi_ch_strdup( "index" )); - charray_add( &(config.directives[0].argv), slapi_ch_strdup( attr_changenumber )); - charray_add( &(config.directives[0].argv), slapi_ch_strdup( "eq" )); - - /* Set up the database directory */ - config.directives[1].argv = NULL; - config.directives[1].argc = 2; - charray_add( &(config.directives[1].argv), slapi_ch_strdup( "directory" )); - charray_add( &(config.directives[1].argv), slapi_ch_strdup( cl_dir )); - - /* Override the entry cache size */ - config.directives[2].argv = NULL; - config.directives[2].argc = 2; - charray_add( &(config.directives[2].argv), slapi_ch_strdup( "cachesize" )); - charray_add( &(config.directives[2].argv), slapi_ch_strdup( "10" )); - - /* Override the database cache size */ - config.directives[3].argv = NULL; - config.directives[3].argc = 2; - charray_add( &(config.directives[3].argv), slapi_ch_strdup( "dbcachesize" )); - charray_add( &(config.directives[3].argv), slapi_ch_strdup( "1000000" )); - - /* Override the allids threshold */ - config.directives[4].argv = NULL; - config.directives[4].argc = 2; - charray_add( &(config.directives[4].argv), slapi_ch_strdup( "allidsthreshold" )); - /* assumes sizeof(int) >= 32 bits */ - charray_add( &(config.directives[4].argv), slapi_ch_strdup( "2147483647" )); - - /* rbe = slapi_be_create_instance(&config, LDBM_TYPE); */ - rbe= NULL; - - /* free memory allocated to argv */ - for (i = 0; i < dir_count; i++) - { - charray_free (config.directives[i].argv); - } - - slapi_ch_free ((void **)&config.directives); - slapi_ch_free ((void **)&cl_dir); - slapi_ch_free ((void **)&cl_suffix); - - if (rbe == NULL) - { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, - "Error: failed to create changelog backend. " - "Replication disabled.\n"); - return -1; - } - - set_repl_backend (rbe); - - changelog4_init_trimming (); - - return 0; -} - -/* Name: changelog4_start_be - * Parameters: none - * Return: 0 if successful, non 0 otherwise - * Description: starts the changelog backend; backend must be configured - * first via call to changelog4_create_be - */ -static int -changelog4_start_be () -{ - int rc; - IFP startfn = NULL; - Slapi_PBlock *pb; - Slapi_Backend *rbe = get_repl_backend (); - - if (rbe) - { - pb = slapi_pblock_new(); - rc = slapi_be_getentrypoint(rbe, SLAPI_PLUGIN_START_FN, (void**)&startfn, pb); - if (rc != 0) - { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, - "Error: backend start entry point is missing. " - "Replication subsystem disabled.\n"); - slapi_pblock_destroy (pb); - set_repl_backend( NULL ); - return -1; - } - - rc = startfn (pb); - slapi_pblock_destroy (pb); - - if (rc != 0) - { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, - "Error: Failed to start changelog backend. " - "Replication subsystem disabled.\n"); - set_repl_backend( NULL ); - return -1; - } - } - - return 0; -} - diff --git a/ldap/servers/plugins/replication/legacy_consumer.c b/ldap/servers/plugins/replication/legacy_consumer.c deleted file mode 100644 index e8173f9..0000000 --- a/ldap/servers/plugins/replication/legacy_consumer.c +++ /dev/null @@ -1,723 +0,0 @@ -/** BEGIN COPYRIGHT BLOCK - * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission. - * Copyright (C) 2005 Red Hat, Inc. - * All rights reserved. - * - * License: GPL (version 3 or any later version). - * See LICENSE for details. - * END COPYRIGHT BLOCK **/ - -#ifdef HAVE_CONFIG_H -# include -#endif - - -/* - * repl_legacy_consumer.c - support for legacy replication (consumer-side) - * - * Support for legacy replication involves correctly dealing with - * the addition and removal of attribute types "copiedFrom" and - * "copyingFrom". The behavior is: - * 1) If a copiedFrom appears in an entry, and that entry is the root - * of a replicated area, then put the backend into "refer on update" - * mode and install a referral corresponding to the URL contained - * in the copiedFrom attribute. This referral overrides the mode - * of the replica, e.g. if it was previously an updateable replica, - * it now becomes read-only except for the updatedn. - * 2) If a copiedFrom disappears from an entry, or the entry containing - * the copiedFrom is removed, restore the backend to the state - * determined by the DS 5.0 replica configuration. - * 3) If a "copyingFrom" referral appears in an entry, and that entry - * is the root of a replicated area, then put the backend into - * "refer all operations" mode and install a referral corresponding - * to the URL contained in the copyingFrom attribute. This referral - * overrides the mode of the replica, e.g if it was previously an - * updateable replica, it now becomes read-only and refers all - * operations except for the updatedn. - * 4) If a copyingFrom disappears from an entry, or the entry containing - * the copyingFrom is removed, restore the backend to the state - * determined by the DS 5.0 replica configuration. - */ - - -#include "repl5.h" -#include "repl.h" - -/* Forward Declarations */ -static int legacy_consumer_config_add (Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg); -static int legacy_consumer_config_modify (Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg); -static int legacy_consumer_config_delete (Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg); - -static int legacy_consumer_extract_config(Slapi_Entry* entry, char *returntext); -static int legacy_consumer_read_config(void); -static void legacy_consumer_encode_pw (Slapi_Entry *e); -static void set_legacy_purl (Slapi_PBlock *pb, const char *purl); -static int get_legacy_referral (Slapi_Entry *e, char **referral, char **state); - -/* LEGACY_CONSUMER_CONFIG_DN is no need to be normalized. */ -#define LEGACY_CONSUMER_CONFIG_DN "cn=legacy consumer," REPL_CONFIG_TOP -#define LEGACY_CONSUMER_FILTER "(objectclass=*)" - -/* Configuration parameters local to this module */ -static Slapi_DN *legacy_consumer_replicationdn = NULL; -static char *legacy_consumer_replicationpw = NULL; -/* Lock which protects the above config parameters */ -Slapi_RWLock *legacy_consumer_config_lock = NULL; - -static PRBool -target_is_a_replica_root(Slapi_PBlock *pb, const Slapi_DN **root) -{ - Slapi_DN *sdn = NULL; - PRBool return_value = PR_FALSE; - Object *repl_obj; - - slapi_pblock_get(pb, SLAPI_TARGET_SDN, &sdn); - if (NULL == sdn) { - return return_value; - } - repl_obj = replica_get_replica_from_dn(sdn); - if (NULL != repl_obj) - { - Replica *r = object_get_data(repl_obj); - *root = replica_get_root(r); - return_value = PR_TRUE; - object_release(repl_obj); - } - else - { - *root = NULL; - return_value = PR_FALSE; - } - return return_value; -} - - - -static int -parse_cfstring(const char *cfstring, char **referral, char **generation, char **lastreplayed) -{ - int return_value = -1; - char *ref, *gen, *lastplayed; - - if (cfstring != NULL) - { - char *tmp; - char *cfcopy = slapi_ch_strdup(cfstring); - ref = cfcopy; - tmp = strchr(cfcopy, ' '); - if (NULL != tmp) - { - *tmp++ = '\0'; - while ('\0' != *tmp && ' ' == *tmp) tmp++; - gen = tmp; - tmp = strchr(gen, ' '); - if (NULL != tmp) - { - *tmp++ = '\0'; - while ('\0' != *tmp && ' ' == *tmp) tmp++; - lastplayed = tmp; - return_value = 0; - } - } - - if (return_value == 0) - { - if (referral) - *referral = slapi_ch_strdup(ref); - if (generation) - *generation = slapi_ch_strdup(gen); - if (lastreplayed) - *lastreplayed = slapi_ch_strdup(lastplayed); - } - slapi_ch_free((void **)&cfcopy); - } - return return_value; -} - - - -/* - * This is called from the consumer post-op plugin point. - * It's called if: - * 1) The operation is an add or modify operation, and a - * copiedfrom/copyingfrom was found in the entry/mods, or - * 2) the operation is a delete operation, or - * 3) the operation is a moddn operation. - */ - -void -process_legacy_cf(Slapi_PBlock *pb) -{ - consumer_operation_extension *opext; - Slapi_Operation *op; - char *referral_array[2] = {0}; - char *referral; - char *state; - int rc; - const Slapi_DN *replica_root_sdn = NULL; - Slapi_Entry *e; - - slapi_pblock_get(pb, SLAPI_OPERATION, &op); - opext = (consumer_operation_extension*) repl_con_get_ext (REPL_CON_EXT_OP, op); - - if (opext->has_cf) - { - PR_ASSERT (operation_get_type (op) == SLAPI_OPERATION_ADD || - operation_get_type (op) == SLAPI_OPERATION_MODIFY); - - if ((PR_FALSE == target_is_a_replica_root(pb, &replica_root_sdn)) || - (NULL == replica_root_sdn)){ - return; - } - - slapi_pblock_get (pb, SLAPI_ENTRY_POST_OP, &e); - PR_ASSERT (e); - - if (NULL == e) - return; - - rc = get_legacy_referral (e, &referral, &state); - if (rc == 0) - { - referral_array[0] = referral; - referral_array[1] = NULL; - repl_set_mtn_state_and_referrals(replica_root_sdn, state, NULL, NULL, - referral_array); - /* set partial url in the replica_object */ - set_legacy_purl (pb, referral); - - slapi_ch_free((void **)&referral); - } - - } -} - -void legacy_consumer_be_state_change (void *handle __attribute__((unused)), char *be_name, - int old_be_state __attribute__((unused)), int new_be_state) -{ - Object *r_obj; - Replica *r; - - /* we only interested when a backend is coming online */ - if (new_be_state == SLAPI_BE_STATE_ON) - { - r_obj = replica_get_for_backend (be_name); - if (r_obj) - { - r = (Replica*)object_get_data (r_obj); - PR_ASSERT (r); - - if (replica_is_legacy_consumer (r)) - legacy_consumer_init_referrals (r); - - object_release (r_obj); - } - } -} - - -static int -dont_allow_that(Slapi_PBlock *pb __attribute__((unused)), - Slapi_Entry* entryBefore __attribute__((unused)), - Slapi_Entry* e __attribute__((unused)), - int *returncode, - char *returntext __attribute__((unused)), - void *arg __attribute__((unused))) -{ - *returncode = LDAP_UNWILLING_TO_PERFORM; - return SLAPI_DSE_CALLBACK_ERROR; -} - -int -legacy_consumer_config_init() -{ - /* The FE DSE *must* be initialised before we get here */ - int rc; - - if ((legacy_consumer_config_lock = slapi_new_rwlock()) == NULL) { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, - "Failed to create legacy_consumer config read-write lock\n"); - exit(1); - } - - rc = legacy_consumer_read_config (); - if (rc != LDAP_SUCCESS) - { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, - "Failed to initialize legacy replication configuration\n"); - return 1; - } - - slapi_config_register_callback(SLAPI_OPERATION_ADD,DSE_FLAG_PREOP,LEGACY_CONSUMER_CONFIG_DN,LDAP_SCOPE_SUBTREE,LEGACY_CONSUMER_FILTER,legacy_consumer_config_add,NULL); - slapi_config_register_callback(SLAPI_OPERATION_MODIFY,DSE_FLAG_PREOP,LEGACY_CONSUMER_CONFIG_DN,LDAP_SCOPE_SUBTREE,LEGACY_CONSUMER_FILTER,legacy_consumer_config_modify,NULL); - slapi_config_register_callback(SLAPI_OPERATION_MODRDN,DSE_FLAG_PREOP,LEGACY_CONSUMER_CONFIG_DN,LDAP_SCOPE_SUBTREE,LEGACY_CONSUMER_FILTER,dont_allow_that,NULL); - slapi_config_register_callback(SLAPI_OPERATION_DELETE,DSE_FLAG_PREOP,LEGACY_CONSUMER_CONFIG_DN,LDAP_SCOPE_SUBTREE,LEGACY_CONSUMER_FILTER,legacy_consumer_config_delete,NULL); - - return 0; -} - -static int -legacy_consumer_config_add (Slapi_PBlock *pb __attribute__((unused)), - Slapi_Entry* e, - Slapi_Entry* entryAfter __attribute__((unused)), - int *returncode, - char *returntext, - void *arg __attribute__((unused))) -{ - int rc; - - rc = legacy_consumer_extract_config(e, returntext); - if (rc != LDAP_SUCCESS) - { - *returncode = rc; - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "Failed to configure legacy replication\n"); - return SLAPI_DSE_CALLBACK_ERROR; - } - /* make sure that the password is encoded */ - legacy_consumer_encode_pw(e); - - slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name, "legacy_consumer_config_add: " - "successfully configured legacy consumer credentials\n"); - - return SLAPI_DSE_CALLBACK_OK; -} - -#define config_copy_strval( s ) s ? slapi_ch_strdup (s) : NULL; - -static int -legacy_consumer_config_modify (Slapi_PBlock *pb, - Slapi_Entry* entryBefore __attribute__((unused)), - Slapi_Entry* e, - int *returncode, - char *returntext, - void *arg __attribute__((unused))) -{ - int rc= 0; - LDAPMod **mods; - int not_allowed = 0; - int i; - - if (returntext) - { - returntext[0] = '\0'; - } - *returncode = LDAP_SUCCESS; - - - slapi_pblock_get( pb, SLAPI_MODIFY_MODS, &mods ); - slapi_rwlock_wrlock (legacy_consumer_config_lock); - - for (i = 0; mods && (mods[i] && (!not_allowed)); i++) - { - if (mods[i]->mod_op & LDAP_MOD_DELETE) - { - /* We don't support deleting an attribute from cn=config */ - } - else - { - int j; - for (j = 0; ((mods[i]->mod_values[j]) && (LDAP_SUCCESS == rc)); j++) - { - char *config_attr, *config_attr_value; - int mod_type; - config_attr = (char *) mods[i]->mod_type; - config_attr_value = (char *) mods[i]->mod_bvalues[j]->bv_val; - /* replace existing value */ - mod_type = mods[i]->mod_op & ~LDAP_MOD_BVALUES; - if ( strcasecmp (config_attr, CONFIG_LEGACY_REPLICATIONDN_ATTRIBUTE ) == 0 ) - { - if (legacy_consumer_replicationdn) - slapi_sdn_free (&legacy_consumer_replicationdn); - - if (mod_type == LDAP_MOD_REPLACE) - { - if (config_attr_value) - legacy_consumer_replicationdn = slapi_sdn_new_dn_byval (config_attr_value); - } - else if (mod_type == LDAP_MOD_DELETE) - { - legacy_consumer_replicationdn = NULL; - } - else if (mod_type == LDAP_MOD_ADD) - { - if (legacy_consumer_replicationdn != NULL) - { - not_allowed = 1; - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, - "Multiple replicationdns not permitted." ); - } - else - { - if (config_attr_value) - legacy_consumer_replicationdn = slapi_sdn_new_dn_byval (config_attr_value); - } - } - } - else if ( strcasecmp ( config_attr, CONFIG_LEGACY_REPLICATIONPW_ATTRIBUTE ) == 0 ) - { - if (mod_type == LDAP_MOD_REPLACE) - { - slapi_ch_free_string(&legacy_consumer_replicationpw); - legacy_consumer_replicationpw = config_copy_strval(config_attr_value); - } - else if (mod_type == LDAP_MOD_DELETE) - { - slapi_ch_free_string(&legacy_consumer_replicationpw); - } - else if (mod_type == LDAP_MOD_ADD) - { - if (legacy_consumer_replicationpw != NULL) - { - not_allowed = 1; - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, - "Multiple replicationpws not permitted." ); - } - else - { - slapi_ch_free_string(&legacy_consumer_replicationpw); - legacy_consumer_replicationpw = config_copy_strval(config_attr_value); - } - } - } - } - } - } - - slapi_rwlock_unlock (legacy_consumer_config_lock); - - - if (not_allowed) - { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, - "Failed to modify legacy replication configuration\n" ); - *returncode= LDAP_CONSTRAINT_VIOLATION; - return SLAPI_DSE_CALLBACK_ERROR; - } - - /* make sure that the password is encoded */ - legacy_consumer_encode_pw (e); - - return SLAPI_DSE_CALLBACK_OK; -} - -static int -legacy_consumer_config_delete (Slapi_PBlock *pb __attribute__((unused)), - Slapi_Entry* e __attribute__((unused)), - Slapi_Entry* entryAfter __attribute__((unused)), - int *returncode, - char *returntext __attribute__((unused)), - void *arg __attribute__((unused))) -{ - - slapi_rwlock_wrlock (legacy_consumer_config_lock); - if (legacy_consumer_replicationdn) { - slapi_sdn_free (&legacy_consumer_replicationdn); - } - slapi_ch_free_string(&legacy_consumer_replicationpw); - legacy_consumer_replicationdn = NULL; - slapi_rwlock_unlock (legacy_consumer_config_lock); - - *returncode = LDAP_SUCCESS; - return SLAPI_DSE_CALLBACK_OK; -} - -/* - * Given the changelog configuration entry, extract the configuration directives. - */ -static int -legacy_consumer_extract_config(Slapi_Entry* entry, char *returntext __attribute__((unused))) -{ - int rc = LDAP_SUCCESS; /* OK */ - char *arg; - - slapi_rwlock_wrlock (legacy_consumer_config_lock); - - arg= slapi_entry_attr_get_charptr(entry,CONFIG_LEGACY_REPLICATIONDN_ATTRIBUTE); - if (arg) { - legacy_consumer_replicationdn = slapi_sdn_new_dn_passin (arg); - } - - arg= slapi_entry_attr_get_charptr(entry,CONFIG_LEGACY_REPLICATIONPW_ATTRIBUTE); - slapi_ch_free_string(&legacy_consumer_replicationpw); - legacy_consumer_replicationpw = arg; - - slapi_rwlock_unlock (legacy_consumer_config_lock); - - return rc; -} - - - - -static int -legacy_consumer_read_config(void) -{ - int rc = LDAP_SUCCESS; - int scope= LDAP_SCOPE_BASE; - Slapi_PBlock *pb; - - pb = slapi_pblock_new (); - slapi_search_internal_set_pb (pb, LEGACY_CONSUMER_CONFIG_DN, scope, - "(objectclass=*)", NULL /*attrs*/, 0 /* attrs only */, - NULL /* controls */, NULL /* uniqueid */, - repl_get_plugin_identity(PLUGIN_LEGACY_REPLICATION), 0 /* actions */); - slapi_search_internal_pb (pb); - slapi_pblock_get( pb, SLAPI_PLUGIN_INTOP_RESULT, &rc ); - if ( LDAP_SUCCESS == rc ) - { - Slapi_Entry **entries = NULL; - slapi_pblock_get( pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries ); - if ( NULL != entries && NULL != entries[0]) - { - /* Extract the config info from the changelog entry */ - rc = legacy_consumer_extract_config(entries[0], NULL); - } - } - else - { - rc = LDAP_SUCCESS; - } - slapi_free_search_results_internal(pb); - slapi_pblock_destroy(pb); - - return rc; -} - - -int -legacy_consumer_is_replicationdn(const char *dn) -{ - int return_value = 0; /* Assume not */ - - if (NULL != dn && '\0' != dn[0]) - { - if (NULL != legacy_consumer_replicationdn) - { - Slapi_DN *sdn = slapi_sdn_new_dn_byref (dn); - - if (slapi_sdn_compare (legacy_consumer_replicationdn, sdn) == 0) { - return_value = 1; - } - - slapi_sdn_free (&sdn); - } - } - return return_value; -} - - -int -legacy_consumer_is_replicationpw(struct berval *pwval) -{ - int return_value = 0; /* Assume not */ - - if (NULL != pwval && NULL != pwval->bv_val) - { - if (NULL != legacy_consumer_replicationpw && - '\0' != legacy_consumer_replicationpw[0]) { - struct berval *pwvals[2]; - struct berval config_pw; - - config_pw.bv_val = legacy_consumer_replicationpw; - config_pw.bv_len = strlen(legacy_consumer_replicationpw); - pwvals[0] = &config_pw; - pwvals[1] = NULL; - - return_value = slapi_pw_find(pwvals, pwval) == 0; - } - } - return return_value; -} - -static void -legacy_consumer_encode_pw (Slapi_Entry *e) -{ - char *updatepw = slapi_entry_attr_get_charptr(e, - CONFIG_LEGACY_REPLICATIONPW_ATTRIBUTE); - int is_encoded; - char *encoded_value = NULL; - - if (updatepw != NULL) - { - is_encoded = slapi_is_encoded (updatepw); - - if (!is_encoded) - { - encoded_value = slapi_encode (updatepw, "SHA"); - } - - if (encoded_value) - { - slapi_entry_attr_set_charptr(e, - CONFIG_LEGACY_REPLICATIONPW_ATTRIBUTE, encoded_value); - } - } -} - -static void -set_legacy_purl (Slapi_PBlock *pb, const char *purl) -{ - Object *r_obj; - Replica *r; - - r_obj = replica_get_replica_for_op (pb); - PR_ASSERT (r_obj); - r = (Replica*)object_get_data (r_obj); - PR_ASSERT (r && replica_is_legacy_consumer(r)); - - replica_set_legacy_purl (r, purl); - - object_release (r_obj); -} - -/* this function get referrals from an entry. - Returns 0 if successful - 1 if no referrals are present - -1 in case of error - */ -static int -get_legacy_referral (Slapi_Entry *e, char **referral, char **state) -{ - char* pat = "ldap://%s"; - const char *val = NULL; - char *hostport; - int rc = 1; - Slapi_Attr *attr; - const Slapi_Value *sval; - - PR_ASSERT (e && referral && state); - - /* Find any copiedFrom/copyingFrom attributes - - copyingFrom has priority */ - if (slapi_entry_attr_find(e, type_copyingFrom, &attr) == 0) - { - slapi_attr_first_value(attr, (Slapi_Value **)&sval); - val = slapi_value_get_string(sval); - *state = STATE_REFERRAL; - } - else if (slapi_entry_attr_find(e, type_copiedFrom, &attr) == 0) - { - slapi_attr_first_value(attr, (Slapi_Value **)&sval); - val = slapi_value_get_string(sval); - *state = STATE_UPDATE_REFERRAL; - } - - if (val) - { - rc = parse_cfstring(val, &hostport, NULL, NULL); - if (rc != 0) - { - const char *target_dn = slapi_entry_get_dn_const(e); - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "Warning: a copiedFrom " - "or copyingFrom attribute was added to or removed from an " - "entry that is not the root of a replicated area. It is possible " - "that a legacy replication supplier is incorrectly configured " - "to supply updates to the subtree rooted at %s\n", - target_dn == NULL ? "null" : target_dn); - } - else - { - *referral = slapi_ch_smprintf (pat, hostport); - - slapi_ch_free ((void**)&hostport); - } - } - else - { - rc = 1; /* no copiedFrom or copyingFrom int the entry */ - } - - return rc; -} - -/* this function is called during server startup or when replica's data - is reloaded. It sets up referrals in the mapping tree based on the - copiedFrom and copyingFrom attributes. It also sets up partial url in - the replica object used to update RUV. - Returns 0 if successful and -1 otherwise - - */ -int -legacy_consumer_init_referrals (Replica *r) -{ - Slapi_PBlock *pb; - const Slapi_DN *root_sdn; - const char *root_dn; - char *attrs[] = {"copiedFrom", "copyingFrom"}; - int rc; - Slapi_Entry **entries = NULL; - char *referral = NULL; - char *referral_array[2]; - char *state = NULL; - - PR_ASSERT (r); - - pb = slapi_pblock_new (); - PR_ASSERT (pb); - - root_sdn = replica_get_root(r); - PR_ASSERT (root_sdn); - - root_dn = slapi_sdn_get_ndn(root_sdn); - PR_ASSERT (root_dn); - - slapi_search_internal_set_pb (pb, root_dn, LDAP_SCOPE_BASE, "objectclass=*",attrs, - 0 /* attrsonly */, NULL /* controls */, - NULL /* uniqueid */, - repl_get_plugin_identity (PLUGIN_LEGACY_REPLICATION), - 0 /* flags */); - - slapi_search_internal_pb (pb); - - slapi_pblock_get (pb, SLAPI_PLUGIN_INTOP_RESULT, &rc); - if (rc != LDAP_SUCCESS) - { - if (rc == LDAP_REFERRAL) - { - /* We are in referral mode, probably because ORC failed */ - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "legacy_consumer_init_referrals " - "data for replica %s is in referral mode due to failed " - "initialization. Replica need to be reinitialized\n", - root_dn); - rc = 0; - } - else - { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "legacy_consumer_init_referrals " - "failed to obtain root entry for replica %s; LDAP error - %d\n", - root_dn, rc); - rc = -1; - } - - goto done; - } - - slapi_pblock_get (pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries); - - PR_ASSERT (entries && entries[0]); - - rc = get_legacy_referral (entries[0], &referral, &state); - if (rc == 0) - { - referral_array[0] = referral; - referral_array[1] = NULL; - repl_set_mtn_state_and_referrals(root_sdn, state, NULL, NULL, referral_array); - - /* set purtial url in the replica_object */ - replica_set_legacy_purl (r, referral); - - slapi_ch_free((void **)&referral); - } - else if (rc == 1) /* no referrals - treat as success */ - { - rc = 0; - } - - slapi_free_search_results_internal (pb); - -done: - - slapi_pblock_destroy (pb); - return rc; -} - diff --git a/ldap/servers/plugins/replication/profile.c b/ldap/servers/plugins/replication/profile.c index 059711a..661b5b8 100644 --- a/ldap/servers/plugins/replication/profile.c +++ b/ldap/servers/plugins/replication/profile.c @@ -13,7 +13,6 @@ #include "slapi-plugin.h" -#include "repl.h" /* module: provide an interface to the profile file */ diff --git a/ldap/servers/plugins/replication/repl.h b/ldap/servers/plugins/replication/repl.h deleted file mode 100644 index 9460ca9..0000000 --- a/ldap/servers/plugins/replication/repl.h +++ /dev/null @@ -1,394 +0,0 @@ -/** BEGIN COPYRIGHT BLOCK - * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission. - * Copyright (C) 2005 Red Hat, Inc. - * All rights reserved. - * - * License: GPL (version 3 or any later version). - * See LICENSE for details. - * END COPYRIGHT BLOCK **/ - -#ifdef HAVE_CONFIG_H -# include -#endif - - -#ifndef _REPL_H_ -#define _REPL_H_ - -/* Provides our int types and platform specific requirements. */ -#include - -#include -#include -#include -#include -#include - -#include "portable.h" /* GGOODREPL - is this cheating? */ -#include "repl_shared.h" -#include "cl4.h" - -typedef struct schedule_item -{ - unsigned long sch_start; /* seconds after midnight */ - unsigned long sch_length; /* sec */ - unsigned int sch_weekdays; /* bit mask; LSB = Sunday */ - struct schedule_item* sch_next; -} schedule_item; - -/* XXXggood - copied from slap.h - bad */ -/* XXXrichm - copied to match definition in slap.h - 20060406 */ -#ifndef NO_TIME -#define NO_TIME (time_t)0 /* cannot be -1, NT's localtime( -1 ) returns NULL */ -#endif - -/* - * A status message contains a time, the textual message, - * and a count of the number of times the message occured. - */ -typedef struct _status_message { - time_t sm_time; - char *sm_message; - int sm_occurances; -} status_message; - -/* - * A status_message_list is a circular array of status messages. - * Old messages roll off the end and are discarded. - */ -typedef struct _status_message_list { - int sml_size; /* number of slots in array */ - int sml_tail; /* next slot to be written */ - status_message *sml_messages; /* array of messages */ -} sm_list; -#define NUM_REPL_MESSAGES 20 /* max # of messages to save */ - -/* Selective attribute Inclusion states. ORDERING IS SIGNIFICANT */ -#define IMPLICITLY_INCLUDED 1 -#define IMPLICITLY_EXCLUDED 2 -#define EXPLICITLY_EXCLUDED 3 -#define EXPLICITLY_INCLUDED 4 - -#if defined(__JCMREPL_FILTER__) -/* - * Structure used to implement selective attribute filtering. - * sa_filter nodes are arranged in a linked list. - */ -typedef struct _sa_filter { - Slapi_Filter *sa_filter; /* Filter to apply */ - int sa_isexclude; /* non-zero if list is exclude list */ - char **sa_attrlist; /* array - attrs to replicate */ - struct _sa_filter *sa_next; /* Link to next struct */ -} sa_filter; -#endif - -typedef unsigned long changeNumber; -#define a2changeNumber( a ) strtoul(( a ), (char **)NULL, 10 ) - -#define AUTH_SIMPLE 1 -#define AUTH_KERBEROS 2 - -typedef struct modinfo { - char *type; - char *value; - int len; -} modinfo; - -/* - * Representation of one change entry from the replog file. - */ -typedef struct repl { - char *time; /* time of modification */ - changeNumber change; /* number of this change */ - char *dn; /* dn of entry being modified - normalized */ - char *raw_dn; /* dn of entry - not normalized */ - int changetype; /* type of change */ - modinfo *mods; /* modifications to make */ - char *newrdn; /* new rdn for modrdn */ - int deleteoldrdn; /* flag for modrdn */ - -} repl; - -#define BIND_OK 0 -#define BIND_ERR_BADLDP 1 -#define BIND_ERR_OPEN 2 -#define BIND_ERR_BAD_ATYPE 3 -#define BIND_ERR_SIMPLE_FAILED 4 -#define BIND_ERR_KERBEROS_FAILED 5 -#define BIND_ERR_SSL_INIT_FAILED 6 -#define BIND_ERR_RACE 7 - -#define MAX_CHANGENUMBER ULONG_MAX - -#define REPLICATION_SUBSYSTEM "replication" -#define REPL_LDAP_TIMEOUT 30L /* Wait 30 seconds for responses */ - -/* Update the copiedFrom attribute every updates */ -#define UPDATE_COPIEDFROM_INTERVAL 10 -#define REPL_ERROR_REPL_HALTED "REPLICATION HALTED" -#define ATTR_NETSCAPEMDSUFFIX "netscapemdsuffix" - -#define CONFIG_LEGACY_REPLICATIONDN_ATTRIBUTE "nsslapd-legacy-updatedn" -#define CONFIG_LEGACY_REPLICATIONPW_ATTRIBUTE "nsslapd-legacy-updatepw" - -#define LDAP_CONTROL_REPL_MODRDN_EXTRAMODS "2.16.840.1.113730.3.4.999" - -/* Operation types */ -#define OP_MODIFY 1 -#define OP_ADD 2 -#define OP_DELETE 3 -#define OP_MODDN 4 -#define OP_SEARCH 5 -#define OP_COMPARE 6 - -/* 4.0-style housekeeping interval */ -#define REPLICATION_HOUSEKEEPING_INTERVAL (30 * 1000) /* 30 seconds */ - -/* Top of tree for replication configuration information */ -#define REPL_CONFIG_TOP "cn=replication,cn=config" - -/* Functions */ - -/* repl_rootdse.c */ -int repl_rootdse_init(void); - -/* In repl.c */ -Slapi_Entry *get_changerecord(const chglog4Info *cl4, changeNumber cnum, int *err); -changeNumber replog_get_firstchangenum(const chglog4Info *cl4, int *err); -changeNumber replog_get_lastchangenum(const chglog4Info *cl4, int *err); -void changelog_housekeeping(time_t cur_time ); - -/* In repl_config.c */ -int repl_config_init(void); - -/* Legacy Plugin Functions */ - -int legacy_preop_bind( Slapi_PBlock *pb ); -int legacy_bepreop_bind( Slapi_PBlock *pb ); -int legacy_postop_bind( Slapi_PBlock *pb ); -int legacy_preop_add( Slapi_PBlock *pb ); -int legacy_bepreop_add( Slapi_PBlock *pb ); -int legacy_postop_add( Slapi_PBlock *pb ); -int legacy_preop_modify( Slapi_PBlock *pb ); -int legacy_bepreop_modify( Slapi_PBlock *pb ); -int legacy_postop_modify( Slapi_PBlock *pb ); -int legacy_preop_modrdn( Slapi_PBlock *pb ); -int legacy_bepreop_modrdn( Slapi_PBlock *pb ); -int legacy_postop_modrdn( Slapi_PBlock *pb ); -int legacy_preop_delete( Slapi_PBlock *pb ); -int legacy_bepreop_delete( Slapi_PBlock *pb ); -int legacy_postop_delete( Slapi_PBlock *pb ); -int legacy_preop_search( Slapi_PBlock *pb ); -int legacy_preop_compare( Slapi_PBlock *pb ); -int legacy_pre_entry( Slapi_PBlock *pb ); -int legacy_bepostop_assignchangenum( Slapi_PBlock *pb ); - -int replication_plugin_start( Slapi_PBlock *pb ); -int replication_plugin_poststart( Slapi_PBlock *pb ); -int replication_plugin_stop( Slapi_PBlock *pb ); - -/* In repl.c */ -void replog( Slapi_PBlock *pb, int optype ); -void init_changelog_trimming( changeNumber max_changes, time_t max_age ); - -/* From repl_globals.c */ - -extern char *attr_changenumber; -extern char *attr_targetdn; -extern char *attr_changetype; -extern char *attr_newrdn; -extern char *attr_deleteoldrdn; -extern char *attr_changes; -extern char *attr_newsuperior; -extern char *attr_changetime; -extern char *attr_dataversion; -extern char *attr_csn; - -extern char *changetype_add; -extern char *changetype_delete; -extern char *changetype_modify; -extern char *changetype_modrdn; -extern char *changetype_moddn; - -extern char *type_copyingFrom; -extern char *type_copiedFrom; -extern char *filter_copyingFrom; -extern char *filter_copiedFrom; -extern char *filter_objectclass; - -extern char *type_cn; -extern char *type_objectclass; - -#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wstrict-prototypes" -#endif - -/* JCMREPL - IFP should be defined centrally */ -#ifndef _IFP -#define _IFP -typedef int (*IFP)(); /* takes undefined arguments */ -#endif - -#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) -#pragma GCC diagnostic pop -#endif - -/* In cl4.c */ - -changeNumber ldapi_assign_changenumber(chglog4Info *cl4); -changeNumber ldapi_get_last_changenumber(chglog4Info *cl4); -changeNumber ldapi_get_first_changenumber(chglog4Info *cl4); -void ldapi_commit_changenumber(chglog4Info *cl4, changeNumber cnum); -void ldapi_set_first_changenumber(chglog4Info *cl4, changeNumber cnum); -void ldapi_set_last_changenumber(chglog4Info *cl4, changeNumber cnum); -void ldapi_initialize_changenumbers(chglog4Info *cl4, changeNumber first, changeNumber last); - -#define LDBM_TYPE "ldbm" -#define CHANGELOG_LDBM_TYPE "changelog-ldbm" - -#define MAX_RETRY_INTERVAL 3600 /* sec = 1 hour */ - -#define REPL_PROTOCOL_UNKNOWN 0 -#define REPL_PROTOCOL_40 1 -#define REPL_PROTOCOL_50_INCREMENTAL 2 -#define REPL_PROTOCOL_50_TOTALUPDATE 3 -/* TEL 20120529: REPL_PROTOCOL_71_TOTALUPDATE is never used in the code, and the - * equivalent code checking the 7.1 OID for incremental updates assigns the - * protocol version as REPL_PROTOCOL_50_INCREMENTAL. One or the other of these - * is wrong, but there are many tests for REPL_PROTOCOL_50_TOTALUPDATE that would - * need to be rewritten to to make use of REPL_PROTOCOL_71_TOTALUPDATE, so it - * seems safer and simpler to take this definition out. */ -/* #define REPL_PROTOCOL_71_TOTALUPDATE 4 */ - -/* In repl_globals.c */ -int decrement_repl_active_threads(void); -int increment_repl_active_threads(void); - -/* operation extensions */ - -/* Type of extensions that can be registered */ -typedef enum -{ - REPL_SUP_EXT_OP, /* extension for Operation object, replication supplier */ - REPL_SUP_EXT_CONN, /* extension for Connection object, replication supplier */ - REPL_CON_EXT_OP, /* extension for Operation object, replication consumer */ - REPL_CON_EXT_CONN, /* extension for Connection object, replication consumer */ - REPL_CON_EXT_MTNODE,/* extension for mapping_tree_node object, replication consumer */ - REPL_EXT_ALL -} ext_type; - -/* general extension functions - repl_ext.c */ -void repl_sup_init_ext(void); /* initializes registrations - must be called first */ -void repl_con_init_ext(void); /* initializes registrations - must be called first */ -int repl_sup_register_ext (ext_type type); /* registers an extension of the specified type */ -int repl_con_register_ext (ext_type type); /* registers an extension of the specified type */ -void* repl_sup_get_ext (ext_type type, void *object); /* retireves the extension from the object */ -void* repl_con_get_ext (ext_type type, void *object); /* retireves the extension from the object */ - -/* Operation extension functions - supplier_operation_extension.c */ - -/* --- supplier operation extension --- */ -typedef struct supplier_operation_extension -{ - int prevent_recursive_call; - struct slapi_operation_parameters *operation_parameters; - char *repl_gen; -} supplier_operation_extension; - -/* extension construct/destructor */ -void* supplier_operation_extension_constructor (void *object, void *parent); -void supplier_operation_extension_destructor (void* ext,void *object, void *parent); - -/* --- consumer operation extension --- */ -typedef struct consumer_operation_extension -{ - int has_cf; /* non-zero if the operation contains a copiedFrom/copyingFrom attr */ - void *search_referrals; -} consumer_operation_extension; - -/* extension construct/destructor */ -void* consumer_operation_extension_constructor (void *object, void *parent); -void consumer_operation_extension_destructor (void* ext,void *object, void *parent); - -/* Connection extension functions - repl_connext.c */ - -/* --- connection extension --- */ -/* ONREPL - some pointers are void* because they represent 5.0 data structures - not known in this header. Fix */ -typedef struct consumer_connection_extension -{ - int is_legacy_replication_dn; - int repl_protocol_version; /* the replication protocol version number the supplier is talking. */ - void *replica_acquired; /* Object* for replica */ - void *supplier_ruv; /* RUV* */ - int isreplicationsession; - Slapi_Connection *connection; - PRLock *lock; /* protects entire structure */ - int in_use_opid; /* the id of the operation actively using this, else -1 */ -} consumer_connection_extension; - -/* extension construct/destructor */ -void* consumer_connection_extension_constructor (void *object,void *parent); -void consumer_connection_extension_destructor (void* ext,void *object,void *parent); - -/* extension helpers for managing exclusive access */ -consumer_connection_extension* consumer_connection_extension_acquire_exclusive_access(void* conn, PRUint64 connid, int opid); -int consumer_connection_extension_relinquish_exclusive_access(void* conn, PRUint64 connid, int opid, PRBool force); - -/* mapping tree extension - stores replica object */ -typedef struct multimaster_mtnode_extension -{ - Object *replica; -} multimaster_mtnode_extension; -void* multimaster_mtnode_extension_constructor (void *object,void *parent); -void multimaster_mtnode_extension_destructor (void* ext,void *object,void *parent); - -/* In repl_init.c */ - -int get_legacy_stop(void); - -/* In repl_entry.c */ -void repl_entry_init(int argc, char** argv); - -/* In repl_ops.c */ -int legacy_preop( Slapi_PBlock *pb, const char* caller, int operation_type); -int legacy_postop( Slapi_PBlock *pb, const char* caller, int operation_type); - -/* In profile.c */ - -#ifdef PROFILE -#define PROFILE_POINT if (CFG_profile) profile_log(__FILE__,__LINE__) /* JCMREPL - Where is the profiling flag stored? */ -#else -#define PROFILE_POINT ((void)0) -#endif - -void profile_log(char *file,int line); -void profile_open(void); -void profile_close(void); - -/* in repl_controls.c */ -void add_repl_control_mods( Slapi_PBlock *pb, Slapi_Mods *smods ); - -/* ... */ -void create_entity (char* DN, const char* oclass); - -void write_replog_db( int optype, char *dn, void *change, int flag, changeNumber changenum, time_t curtime, LDAPMod **modrdn_mods ); -int entry2reple( Slapi_Entry *e, Slapi_Entry *oe ); -int mods2reple( Slapi_Entry *e, LDAPMod **ldm ); -int modrdn2reple( Slapi_Entry *e, char *newrdn, int deloldrdn, LDAPMod **ldm ); - -/* In legacy_consumer.c */ -void process_legacy_cf(Slapi_PBlock *pb); -int legacy_consumer_is_replicationdn(const char *dn); -int legacy_consumer_is_replicationpw(struct berval *creds); -int legacy_consumer_config_init(void); - -/* function that gets called when a backend state is changed */ -void legacy_consumer_be_state_change (void *handle, char *be_name, - int old_be_state, int new_be_state); - -#endif /* _REPL_H_ */ - - - diff --git a/ldap/servers/plugins/replication/repl5.h b/ldap/servers/plugins/replication/repl5.h index 718f64e..b0c2856 100644 --- a/ldap/servers/plugins/replication/repl5.h +++ b/ldap/servers/plugins/replication/repl5.h @@ -27,7 +27,6 @@ #include "repl_shared.h" #include "llist.h" #include "repl5_ruv.h" -#include "cl4.h" #include "plstr.h" #define START_UPDATE_DELAY 2 /* 2 second */ @@ -36,6 +35,8 @@ #define REPL_DIRSYNC_CONTROL_OID "1.2.840.113556.1.4.841" #define REPL_RETURN_DELETED_OBJS_CONTROL_OID "1.2.840.113556.1.4.417" #define REPL_WIN2K3_AD_OID "1.2.840.113556.1.4.1670" +#define LDAP_CONTROL_REPL_MODRDN_EXTRAMODS "2.16.840.1.113730.3.4.999" +#define REPLICATION_SUBSYSTEM "replication" /* DS 5.0 replication protocol OIDs */ #define REPL_START_NSDS50_REPLICATION_REQUEST_OID "2.16.840.1.113730.3.5.3" @@ -91,7 +92,6 @@ #define NSDS50_REPL_BELOW_PURGEPOINT 0x07 /* Supplier provided a CSN below the consumer's purge point */ #define NSDS50_REPL_INTERNAL_ERROR 0x08 /* Something bad happened on consumer */ #define NSDS50_REPL_REPLICA_RELEASE_SUCCEEDED 0x09 /* Replica released successfully */ -#define NSDS50_REPL_LEGACY_CONSUMER 0x0A /* replica is a legacy consumer */ #define NSDS50_REPL_REPLICAID_ERROR 0x0B /* replicaID doesn't seem to be unique */ #define NSDS50_REPL_DISABLED 0x0C /* replica suffix is disabled */ #define NSDS50_REPL_UPTODATE 0x0D /* replica is uptodate */ @@ -192,7 +192,6 @@ extern const char *type_agmtMaxCSN; extern const char *type_replicaPurgeDelay; extern const char *type_replicaChangeCount; extern const char *type_replicaTombstonePurgeInterval; -extern const char *type_replicaLegacyConsumer; extern const char *type_replicaCleanRUV; extern const char *type_replicaAbortCleanRUV; extern const char *type_ruvElementUpdatetime; @@ -273,6 +272,37 @@ struct berval *NSDS90StartReplicationRequest_new(const char *protocol_oid, /* In repl5_total.c */ int multimaster_extop_NSDS50ReplicationEntry(Slapi_PBlock *pb); +/* From repl_globals.c */ +extern char *attr_changenumber; +extern char *attr_targetdn; +extern char *attr_changetype; +extern char *attr_newrdn; +extern char *attr_deleteoldrdn; +extern char *attr_changes; +extern char *attr_newsuperior; +extern char *attr_changetime; +extern char *attr_dataversion; +extern char *attr_csn; +extern char *changetype_add; +extern char *changetype_delete; +extern char *changetype_modify; +extern char *changetype_modrdn; +extern char *changetype_moddn; +extern char *type_copyingFrom; +extern char *type_copiedFrom; +extern char *filter_copyingFrom; +extern char *filter_copiedFrom; +extern char *filter_objectclass; +extern char *type_cn; +extern char *type_objectclass; + +/* In profile.c */ +#ifdef PROFILE +#define PROFILE_POINT if (CFG_profile) profile_log(__FILE__,__LINE__) /* JCMREPL - Where is the profiling flag stored? */ +#else +#define PROFILE_POINT ((void)0) +#endif + /* In repl_controls.c */ int create_NSDS50ReplUpdateInfoControl(const char *uuid, const char *superior_uuid, const CSN *csn, @@ -433,6 +463,85 @@ time_t backoff_step(Backoff_Timer *bt); int backoff_expired(Backoff_Timer *bt, int margin); void backoff_delete(Backoff_Timer **btp); +#define REPL_PROTOCOL_UNKNOWN 0 +#define REPL_PROTOCOL_50_INCREMENTAL 2 +#define REPL_PROTOCOL_50_TOTALUPDATE 3 + +/* Type of extensions that can be registered */ +typedef enum +{ + REPL_SUP_EXT_OP, /* extension for Operation object, replication supplier */ + REPL_SUP_EXT_CONN, /* extension for Connection object, replication supplier */ + REPL_CON_EXT_OP, /* extension for Operation object, replication consumer */ + REPL_CON_EXT_CONN, /* extension for Connection object, replication consumer */ + REPL_CON_EXT_MTNODE,/* extension for mapping_tree_node object, replication consumer */ + REPL_EXT_ALL +} ext_type; + +/* Operation extension functions - supplier_operation_extension.c */ + +/* --- supplier operation extension --- */ +typedef struct supplier_operation_extension +{ + int prevent_recursive_call; + struct slapi_operation_parameters *operation_parameters; + char *repl_gen; +} supplier_operation_extension; + +/* extension construct/destructor */ +void* supplier_operation_extension_constructor (void *object, void *parent); +void supplier_operation_extension_destructor (void* ext,void *object, void *parent); + +/* --- consumer operation extension --- */ +typedef struct consumer_operation_extension +{ + int has_cf; /* non-zero if the operation contains a copiedFrom/copyingFrom attr */ + void *search_referrals; +} consumer_operation_extension; + +/* extension construct/destructor */ +void* consumer_operation_extension_constructor (void *object, void *parent); +void consumer_operation_extension_destructor (void* ext,void *object, void *parent); + + +/* Connection extension functions - repl_connext.c */ +typedef struct consumer_connection_extension +{ + int repl_protocol_version; /* the replication protocol version number the supplier is talking. */ + void *replica_acquired; /* Object* for replica */ + void *supplier_ruv; /* RUV* */ + int isreplicationsession; + Slapi_Connection *connection; + PRLock *lock; /* protects entire structure */ + int in_use_opid; /* the id of the operation actively using this, else -1 */ +} consumer_connection_extension; + +/* extension construct/destructor */ +void* consumer_connection_extension_constructor (void *object,void *parent); +void consumer_connection_extension_destructor (void* ext,void *object,void *parent); + +/* extension helpers for managing exclusive access */ +consumer_connection_extension* consumer_connection_extension_acquire_exclusive_access(void* conn, PRUint64 connid, int opid); +int consumer_connection_extension_relinquish_exclusive_access(void* conn, PRUint64 connid, int opid, PRBool force); + +/* mapping tree extension - stores replica object */ +typedef struct multimaster_mtnode_extension +{ + Object *replica; +} multimaster_mtnode_extension; +void* multimaster_mtnode_extension_constructor (void *object,void *parent); +void multimaster_mtnode_extension_destructor (void* ext,void *object,void *parent); + +/* general extension functions - repl_ext.c */ +void repl_sup_init_ext (); /* initializes registrations - must be called first */ +void repl_con_init_ext (); /* initializes registrations - must be called first */ +int repl_sup_register_ext (ext_type type); /* registers an extension of the specified type */ +int repl_con_register_ext (ext_type type); /* registers an extension of the specified type */ +void* repl_sup_get_ext (ext_type type, void *object); /* retireves the extension from the object */ +void* repl_con_get_ext (ext_type type, void *object); /* retireves the extension from the object */ + + + /* In repl5_connection.c * keep in sync with conn_result2string */ @@ -573,10 +682,6 @@ void replica_set_ruv (Replica *r, RUV *ruv); Object *replica_get_csngen (const Replica *r); ReplicaType replica_get_type (const Replica *r); void replica_set_type (Replica *r, ReplicaType type); -PRBool replica_is_legacy_consumer (const Replica *r); -void replica_set_legacy_consumer (Replica *r, PRBool legacy); -char *replica_get_legacy_purl (const Replica *r); -void replica_set_legacy_purl (Replica *r, const char *purl); PRBool replica_is_updatedn (Replica *r, const Slapi_DN *sdn); void replica_set_updatedn (Replica *r, const Slapi_ValueSet *vs, int mod_op); void replica_set_groupdn (Replica *r, const Slapi_ValueSet *vs, int mod_op); @@ -614,7 +719,6 @@ void replica_destroy_dn_hash(void); int replica_add_by_dn (const char *dn); int replica_delete_by_dn (const char *dn); int replica_is_being_configured (const char *dn); -int legacy_consumer_init_referrals (Replica *r); void consumer5_set_mapping_tree_state_for_replica(const Replica *r, RUV *supplierRuv); Object *replica_get_for_backend (const char *be_name); void replica_set_purge_delay (Replica *r, PRUint32 purge_delay); diff --git a/ldap/servers/plugins/replication/repl5_inc_protocol.c b/ldap/servers/plugins/replication/repl5_inc_protocol.c index 68185bf..1a597fe 100644 --- a/ldap/servers/plugins/replication/repl5_inc_protocol.c +++ b/ldap/servers/plugins/replication/repl5_inc_protocol.c @@ -30,13 +30,9 @@ Perhaps these events should be properties of the main protocol. */ #include -#include "repl.h" -#include "repl5.h" -#include "repl5_ruv.h" -#include "repl5_prot_private.h" -#include "cl5_api.h" #include "repl5.h" +#include "repl5_ruv.h" #include "repl5_prot_private.h" #include "cl5_api.h" #include "slapi-plugin.h" diff --git a/ldap/servers/plugins/replication/repl5_init.c b/ldap/servers/plugins/replication/repl5_init.c index 5294edb..a4f2bd3 100644 --- a/ldap/servers/plugins/replication/repl5_init.c +++ b/ldap/servers/plugins/replication/repl5_init.c @@ -23,7 +23,7 @@ dn: cn=Multi-Master Replication Plugin,cn=plugins,cn=config objectclass: top objectclass: nsSlapdPlugin objectclass: extensibleObject -cn: Legacy Replication Plugin +cn: Multi-Master Replication Plugin nsslapd-pluginpath: /export2/servers/Hydra-supplier/lib/replication-plugin.so nsslapd-plugininitfunc: replication_multimaster_plugin_init nsslapd-plugintype: object @@ -38,7 +38,6 @@ nsslapd-plugindescription: Multi-Master Replication Plugin */ #include "slapi-plugin.h" -#include "repl.h" #include "repl5.h" #include "cl5.h" /* changelog interface */ #include "plstr.h" @@ -262,7 +261,6 @@ get_repl_session_id (Slapi_PBlock *pb, char *idstr, CSN **csn) return idstr; } - /* preop acquires csn generator handle */ int repl5_is_betxn = 0; int @@ -795,11 +793,6 @@ multimaster_start( Slapi_PBlock *pb ) if (rc != 0) goto out; - /* Initialise support for cn=monitor */ - rc = repl_monitor_init(); - if (rc != 0) - goto out; - /* initialize name hash */ rc = replica_init_name_hash (); if (rc != 0) diff --git a/ldap/servers/plugins/replication/repl5_mtnode_ext.c b/ldap/servers/plugins/replication/repl5_mtnode_ext.c index 9f65485..6514a2e 100644 --- a/ldap/servers/plugins/replication/repl5_mtnode_ext.c +++ b/ldap/servers/plugins/replication/repl5_mtnode_ext.c @@ -14,7 +14,6 @@ /* repl5_replica.c */ -#include "repl.h" /* ONREPL - this is bad */ #include "repl5.h" #include "cl5_api.h" diff --git a/ldap/servers/plugins/replication/repl5_plugins.c b/ldap/servers/plugins/replication/repl5_plugins.c index e53572b..14582f2 100644 --- a/ldap/servers/plugins/replication/repl5_plugins.c +++ b/ldap/servers/plugins/replication/repl5_plugins.c @@ -42,7 +42,6 @@ */ #include "repl5.h" -#include "repl.h" #include "cl5_api.h" #include "urp.h" @@ -147,23 +146,9 @@ multimaster_preop_add (Slapi_PBlock *pb) Slapi_Operation *op; int is_replicated_operation; int is_fixup_operation; - int is_legacy_operation; slapi_pblock_get(pb, SLAPI_OPERATION, &op); - /* If there is no replica or it is a legacy consumer - we don't need to continue. - Legacy plugin is handling 4.0 consumer code */ - /* but if it is legacy, csngen_handler needs to be assigned here */ - is_legacy_operation = - operation_is_flag_set(op,OP_FLAG_LEGACY_REPLICATION_DN); - if (is_legacy_operation) - { - copy_operation_parameters(pb); - slapi_operation_set_csngen_handler(op, - (void*)replica_generate_next_csn); - return SLAPI_PLUGIN_SUCCESS; - } - if (!is_mmr_replica (pb)) { copy_operation_parameters(pb); @@ -276,24 +261,9 @@ multimaster_preop_delete (Slapi_PBlock *pb) Slapi_Operation *op; int is_replicated_operation; int is_fixup_operation; - int is_legacy_operation; slapi_pblock_get(pb, SLAPI_OPERATION, &op); - /* If there is no replica or it is a legacy consumer - we don't need to continue. - Legacy plugin is handling 4.0 consumer code */ - /* but if it is legacy, csngen_handler needs to be assigned here */ - is_legacy_operation = - operation_is_flag_set(op,OP_FLAG_LEGACY_REPLICATION_DN); - if (is_legacy_operation) - { - copy_operation_parameters(pb); - slapi_operation_set_replica_attr_handler ( op, (void*)replica_get_attr ); - slapi_operation_set_csngen_handler(op, - (void*)replica_generate_next_csn); - return SLAPI_PLUGIN_SUCCESS; - } - if (!is_mmr_replica (pb)) { copy_operation_parameters(pb); @@ -376,23 +346,9 @@ multimaster_preop_modify (Slapi_PBlock *pb) Slapi_Operation *op; int is_replicated_operation; int is_fixup_operation; - int is_legacy_operation; slapi_pblock_get(pb, SLAPI_OPERATION, &op); - /* If there is no replica or it is a legacy consumer - we don't need to continue. - Legacy plugin is handling 4.0 consumer code */ - /* but if it is legacy, csngen_handler needs to be assigned here */ - is_legacy_operation = - operation_is_flag_set(op,OP_FLAG_LEGACY_REPLICATION_DN); - if (is_legacy_operation) - { - copy_operation_parameters(pb); - slapi_operation_set_csngen_handler(op, - (void*)replica_generate_next_csn); - return SLAPI_PLUGIN_SUCCESS; - } - if (!is_mmr_replica (pb)) { copy_operation_parameters(pb); @@ -478,23 +434,9 @@ multimaster_preop_modrdn (Slapi_PBlock *pb) Slapi_Operation *op; int is_replicated_operation; int is_fixup_operation; - int is_legacy_operation; slapi_pblock_get(pb, SLAPI_OPERATION, &op); - /* If there is no replica or it is a legacy consumer - we don't need to continue. - Legacy plugin is handling 4.0 consumer code */ - /* but if it is legacy, csngen_handler needs to be assigned here */ - is_legacy_operation = - operation_is_flag_set(op,OP_FLAG_LEGACY_REPLICATION_DN); - if (is_legacy_operation) - { - copy_operation_parameters(pb); - slapi_operation_set_csngen_handler(op, - (void*)replica_generate_next_csn); - return SLAPI_PLUGIN_SUCCESS; - } - if (!is_mmr_replica (pb)) { copy_operation_parameters(pb); @@ -997,7 +939,6 @@ copy_operation_parameters(Slapi_PBlock *pb) static int update_ruv_component(Replica *replica, CSN *opcsn, Slapi_PBlock *pb) { - PRBool legacy; char *purl; int rc = RUV_NOTFOUND; @@ -1005,18 +946,10 @@ update_ruv_component(Replica *replica, CSN *opcsn, Slapi_PBlock *pb) return rc; /* Replica configured, so update its ruv */ - legacy = replica_is_legacy_consumer (replica); - if (legacy) - purl = replica_get_legacy_purl (replica); - else - purl = (char*)replica_get_purl_for_op (replica, pb, opcsn); + purl = (char*)replica_get_purl_for_op (replica, pb, opcsn); rc = replica_update_ruv(replica, opcsn, purl); - if (legacy) - { - slapi_ch_free ((void**)&purl); - } return rc; } @@ -1504,23 +1437,15 @@ static PRBool is_mmr_replica (Slapi_PBlock *pb) { Object *r_obj; - Replica *r; - PRBool mmr; r_obj = replica_get_replica_for_op(pb); if (r_obj == NULL) { return PR_FALSE; } - - r = (Replica*)object_get_data (r_obj); - PR_ASSERT (r); - - mmr = !replica_is_legacy_consumer (r); - object_release (r_obj); - return mmr; + return PR_TRUE; } static const char *replica_get_purl_for_op (const Replica *r __attribute__((unused)), Slapi_PBlock *pb, const CSN *opcsn) @@ -1563,53 +1488,6 @@ static const char *replica_get_purl_for_op (const Replica *r __attribute__((unus return purl; } -#ifdef NOTUSED -/* ONREPL at the moment, I decided not to trim copiedFrom and copyingFrom - attributes when sending operation to replicas. This is because, each - operation results in a state information stored in the database and - if we don't replay all operations we will endup with state inconsistency. - - Keeping the function just in case - */ -static void strip_legacy_info (slapi_operation_parameters *op_params) -{ - switch (op_params->operation_type) - { - case SLAPI_OPERATION_ADD: - slapi_entry_delete_values_sv(op_params->p.p_add.target_entry, - type_copiedFrom, NULL); - slapi_entry_delete_values_sv(op_params->p.p_add.target_entry, - type_copyingFrom, NULL); - break; - case SLAPI_OPERATION_MODIFY: - { - Slapi_Mods smods; - LDAPMod *mod; - - slapi_mods_init_byref(&smods, op_params->p.p_modify.modify_mods); - mod = slapi_mods_get_first_mod(&smods); - while (mod) - { - /* modify just to update copiedFrom or copyingFrom attribute - does not contain modifiersname or modifytime - so we don't - have to strip them */ - if (strcasecmp (mod->mod_type, type_copiedFrom) == 0 || - strcasecmp (mod->mod_type, type_copyingFrom) == 0) - slapi_mods_remove(&smods); - mod = slapi_mods_get_next_mod(&smods); - } - - op_params->p.p_modify.modify_mods = slapi_mods_get_ldapmods_passout (&smods); - slapi_mods_done (&smods); - - break; - } - - default: break; - } -} -#endif - /* this function is called when state of a backend changes */ void multimaster_be_state_change (void *handle __attribute__((unused)), char *be_name, int old_be_state, int new_be_state) diff --git a/ldap/servers/plugins/replication/repl5_protocol_util.c b/ldap/servers/plugins/replication/repl5_protocol_util.c index 6db4e4f..92da1cd 100644 --- a/ldap/servers/plugins/replication/repl5_protocol_util.c +++ b/ldap/servers/plugins/replication/repl5_protocol_util.c @@ -403,18 +403,6 @@ acquire_replica(Private_Repl_Protocol *prp, char *prot_oid, RUV **ruv) "supplier."); return_value = ACQUIRE_REPLICA_BUSY; break; - case NSDS50_REPL_LEGACY_CONSUMER: - /* remote replica is a legacy consumer */ - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, - "acquire_replica - " - "%s: Unable to acquire replica: the replica " - "is supplied by a legacy supplier. " - "Replication is aborting.\n", agmt_get_long_name(prp->agmt)); - agmt_set_last_update_status(prp->agmt, 0, extop_result, - "Unable to acquire replica: the replica is supplied " - "by a legacy supplier. Replication is aborting."); - return_value = ACQUIRE_FATAL_ERROR; - break; case NSDS50_REPL_REPLICAID_ERROR: /* remote replica detected a duplicate ReplicaID */ slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, @@ -715,7 +703,6 @@ protocol_response2string (int response) case NSDS50_REPL_BELOW_PURGEPOINT: return "csn below purge point"; case NSDS50_REPL_INTERNAL_ERROR: return "internal error"; case NSDS50_REPL_REPLICA_RELEASE_SUCCEEDED: return "replica released"; - case NSDS50_REPL_LEGACY_CONSUMER: return "replica is a legacy consumer"; case NSDS50_REPL_REPLICAID_ERROR: return "duplicate replica ID detected"; case NSDS50_REPL_UPTODATE: return "no change to send"; case NSDS50_REPL_CL_ERROR: return "changelog error"; diff --git a/ldap/servers/plugins/replication/repl5_replica.c b/ldap/servers/plugins/replication/repl5_replica.c index 2f3683e..f48ab86 100644 --- a/ldap/servers/plugins/replication/repl5_replica.c +++ b/ldap/servers/plugins/replication/repl5_replica.c @@ -15,7 +15,6 @@ /* repl5_replica.c */ #include "slapi-plugin.h" -#include "repl.h" /* ONREPL - this is bad */ #include "repl5.h" #include "repl_shared.h" #include "csnpl.h" @@ -25,7 +24,6 @@ #define RUV_SAVE_INTERVAL (30 * 1000) /* 30 seconds */ #define REPLICA_RDN "cn=replica" -#define CHANGELOG_RDN "cn=legacy changelog" /* * A replica is a locally-held copy of a portion of the DIT. @@ -42,8 +40,6 @@ struct replica { PRUint32 updatedn_group_last_check; int updatedn_group_check_interval; ReplicaType repl_type; /* is this replica read-only ? */ - PRBool legacy_consumer; /* if true, this replica is supplied by 4.0 consumer */ - char* legacy_purl; /* partial url of the legacy supplier */ ReplicaId repl_rid; /* replicaID */ Object *repl_ruv; /* replica update vector */ PRBool repl_ruv_dirty; /* Dirty flag for ruv */ @@ -100,8 +96,6 @@ static void abort_csn_callback(const CSN *csn, void *data); static void eq_cb_reap_tombstones(time_t when, void *arg); static CSN *_replica_get_purge_csn_nolock (const Replica *r); static void replica_get_referrals_nolock (const Replica *r, char ***referrals); -static void replica_clear_legacy_referrals (const Slapi_DN *repl_root_sdn, char **referrals, const char *state); -static void replica_remove_legacy_attr (const Slapi_DN *repl_root_sdn, const char *attr); static int replica_log_ruv_elements_nolock (const Replica *r); static void replica_replace_ruv_tombstone(Replica *r); static void start_agreements_for_replica (Replica *r, PRBool start); @@ -259,14 +253,6 @@ replica_new_from_entry (Slapi_Entry *e, char *errortext, PRBool is_add_operation 1000 * r->tombstone_reap_interval); } - if (r->legacy_consumer) - { - legacy_consumer_init_referrals (r); - slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name, "replica_new_from_entry: " - "replica for %s was configured as legacy consumer\n", - slapi_sdn_get_dn(r->repl_root)); - } - replica_check_for_tasks(r, e); done: @@ -364,7 +350,6 @@ replica_destroy(void **arg) /* slapi_ch_free accepts NULL pointer */ slapi_ch_free ((void**)&r->repl_name); - slapi_ch_free ((void**)&r->legacy_purl); if (r->repl_lock) { @@ -1052,93 +1037,6 @@ replica_set_type (Replica *r, ReplicaType type) replica_unlock(r->repl_lock); } -/* - * Returns PR_TRUE if this replica is a consumer of 4.0 server - * and PR_FALSE otherwise - */ -PRBool -replica_is_legacy_consumer (const Replica *r) -{ - PR_ASSERT(r); - return r->legacy_consumer; -} - -/* - * Sets the replica type. - */ -void -replica_set_legacy_consumer (Replica *r, PRBool legacy_consumer) -{ - int legacy2mmr; - Slapi_DN *repl_root_sdn = NULL; - char **referrals = NULL; - char *replstate = NULL; - PR_ASSERT(r); - - replica_lock(r->repl_lock); - - legacy2mmr = r->legacy_consumer && !legacy_consumer; - - /* making the server a regular 5.0 replica */ - if (legacy2mmr) - { - slapi_ch_free ((void**)&r->legacy_purl); - /* Remove copiedFrom/copyingFrom attributes from the root entry */ - /* set the right state in the mapping tree */ - if (r->repl_type == REPLICA_TYPE_READONLY) - { - replica_get_referrals_nolock (r, &referrals); - replstate = STATE_UPDATE_REFERRAL; - } - else /* updateable */ - { - replstate = STATE_BACKEND; - } - } - - r->legacy_consumer = legacy_consumer; - repl_root_sdn = slapi_sdn_dup(r->repl_root); - replica_unlock(r->repl_lock); - - if (legacy2mmr) - { - replica_clear_legacy_referrals(repl_root_sdn, referrals, replstate); - /* Also change state of the mapping tree node and/or referrals */ - replica_remove_legacy_attr (repl_root_sdn, type_copiedFrom); - replica_remove_legacy_attr (repl_root_sdn, type_copyingFrom); - } - charray_free(referrals); - slapi_sdn_free(&repl_root_sdn); -} - -/* Gets partial url of the legacy supplier - applicable for legacy consumer only */ -char * -replica_get_legacy_purl (const Replica *r) -{ - char *purl; - - replica_lock(r->repl_lock); - purl = slapi_ch_strdup(r->legacy_purl); - replica_unlock(r->repl_lock); - - return purl; -} - -void -replica_set_legacy_purl (Replica *r, const char *purl) -{ - replica_lock(r->repl_lock); - - PR_ASSERT (r->legacy_consumer); - - /* slapi_ch_free accepts NULL pointer */ - slapi_ch_free ((void**)&r->legacy_purl); - - r->legacy_purl = slapi_ch_strdup (purl); - - replica_unlock(r->repl_lock); -} - static PRBool valuesets_equal(Slapi_ValueSet *new_dn_groups, Slapi_ValueSet *old_dn_groups) { @@ -1608,7 +1506,7 @@ consumer5_set_mapping_tree_state_for_replica(const Replica *r, RUV *supplierRuv) replica_get_referrals_nolock (r, &replica_referrals); /* replica_referrals has to be free'd */ /* JCMREPL - What if there's a Total update in progress? */ - if( (r->repl_type==REPLICA_TYPE_READONLY) || (r->legacy_consumer) ) + if(r->repl_type==REPLICA_TYPE_READONLY) { state_backend = 0; } @@ -2025,7 +1923,6 @@ _replica_check_validity (const Replica *r) nsds5ReplicaReferral: consumers only nsds5ReplicaPurgeDelay: nsds5ReplicaTombstonePurgeInterval: - nsds5ReplicaLegacyConsumer: richm: changed slapi entry from const to editable - if the replica id is supplied for a read only replica, we ignore it and replace the value with the READ_ONLY_REPLICA_ID @@ -2070,21 +1967,6 @@ _replica_init_from_config (Replica *r, Slapi_Entry *e, char *errortext) r->repl_type = REPLICA_TYPE_READONLY; } - /* get legacy consumer flag */ - val = slapi_entry_attr_get_charptr (e, type_replicaLegacyConsumer); - if (val){ - if (strcasecmp (val, "on") == 0 || strcasecmp (val, "yes") == 0 || - strcasecmp (val, "true") == 0 || strcasecmp (val, "1") == 0) - { - r->legacy_consumer = PR_TRUE; - } else { - r->legacy_consumer = PR_FALSE; - } - slapi_ch_free ((void**)&val); - } else { - r->legacy_consumer = PR_FALSE; - } - /* grab and validate the backoff retry settings */ if(slapi_entry_attr_exists(e, type_replicaBackoffMin)){ backoff_min = slapi_entry_attr_get_int(e, type_replicaBackoffMin); @@ -3770,51 +3652,6 @@ replica_get_referrals_nolock (const Replica *r, char ***referrals) } } -static void -replica_clear_legacy_referrals(const Slapi_DN *repl_root_sdn, - char **referrals, const char *state) -{ - repl_set_mtn_state_and_referrals(repl_root_sdn, state, NULL, NULL, referrals); -} - -static void -replica_remove_legacy_attr (const Slapi_DN *repl_root_sdn, const char *attr) -{ - Slapi_PBlock *pb; - Slapi_Mods smods; - LDAPControl **ctrls; - int rc; - - pb = slapi_pblock_new (); - - slapi_mods_init(&smods, 1); - slapi_mods_add(&smods, LDAP_MOD_DELETE, attr, 0, NULL); - - - ctrls = (LDAPControl**)slapi_ch_malloc (2 * sizeof (LDAPControl*)); - ctrls[0] = create_managedsait_control (); - ctrls[1] = NULL; - - /* remove copiedFrom/copyingFrom first */ - slapi_modify_internal_set_pb_ext (pb, repl_root_sdn, - slapi_mods_get_ldapmods_passout (&smods), - ctrls, NULL /*uniqueid */, - repl_get_plugin_identity (PLUGIN_MULTIMASTER_REPLICATION) , - 0 /* operation_flags */); - - slapi_modify_internal_pb (pb); - slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &rc); - if (rc != LDAP_SUCCESS) - { - /* this is not a fatal error because the attribute may not be there */ - slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name, "replica_remove_legacy_attr - " - "Failed to remove legacy attribute %s for replica %s; LDAP error - %d\n", - attr, slapi_sdn_get_dn(repl_root_sdn), rc); - } - - slapi_mods_done (&smods); - slapi_pblock_destroy (pb); -} typedef struct replinfo { char *repl_gen; char *repl_name; @@ -4279,8 +4116,7 @@ replica_generate_next_csn ( Slapi_PBlock *pb, const CSN *basecsn ) { Slapi_Operation *op; slapi_pblock_get (pb, SLAPI_OPERATION, &op); - if ( replica->repl_type != REPLICA_TYPE_READONLY || - operation_is_flag_set (op, OP_FLAG_LEGACY_REPLICATION_DN )) + if ( replica->repl_type != REPLICA_TYPE_READONLY ) { Object *gen_obj = replica_get_csngen (replica); if (NULL != gen_obj) diff --git a/ldap/servers/plugins/replication/repl5_replica_config.c b/ldap/servers/plugins/replication/repl5_replica_config.c index f09055b..7206c20 100644 --- a/ldap/servers/plugins/replication/repl5_replica_config.c +++ b/ldap/servers/plugins/replication/repl5_replica_config.c @@ -14,7 +14,6 @@ /* repl5_replica_config.c - replica configuration over ldap */ #include /* for isdigit() */ -#include "repl.h" /* ONREPL - this is bad */ #include "repl5.h" #include "cl5_api.h" #include "cl5.h" @@ -235,9 +234,7 @@ replica_config_add (Slapi_PBlock *pb __attribute__((unused)), } /* Set the mapping tree node state, and the referrals from the RUV */ - /* if this server is a 4.0 consumer the referrals are set by legacy plugin */ - if (!replica_is_legacy_consumer (r)) - consumer5_set_mapping_tree_state_for_replica(r, NULL); + consumer5_set_mapping_tree_state_for_replica(r, NULL); /* ONREPL if replica is added as writable we need to execute protocol that introduces new writable replica to the topology */ @@ -383,16 +380,9 @@ replica_config_modify (Slapi_PBlock *pb, { if (apply_mods) { replica_set_referrals(r, NULL); - if (!replica_is_legacy_consumer (r)) { - consumer5_set_mapping_tree_state_for_replica(r, NULL); - } + consumer5_set_mapping_tree_state_for_replica(r, NULL); } } - else if (strcasecmp (config_attr, type_replicaLegacyConsumer) == 0) - { - if (apply_mods) - replica_set_legacy_consumer (r, PR_FALSE); - } else if (strcasecmp (config_attr, type_replicaCleanRUV) == 0 || strcasecmp (config_attr, type_replicaAbortCleanRUV) == 0) { @@ -486,9 +476,7 @@ replica_config_modify (Slapi_PBlock *pb, replica_set_referrals (r, vs); slapi_mod_done(&smod); slapi_valueset_free(vs); - if (!replica_is_legacy_consumer (r)) { - consumer5_set_mapping_tree_state_for_replica(r, NULL); - } + consumer5_set_mapping_tree_state_for_replica(r, NULL); } } else if (strcasecmp (config_attr, type_replicaPurgeDelay) == 0) @@ -514,18 +502,6 @@ replica_config_modify (Slapi_PBlock *pb, replica_set_tombstone_reap_interval (r, interval); } } - else if (strcasecmp (config_attr, type_replicaLegacyConsumer) == 0) - { - if (apply_mods && config_attr_value[0]) - { - PRBool legacy = (strcasecmp (config_attr_value, "on") == 0) || - (strcasecmp (config_attr_value, "true") == 0) || - (strcasecmp (config_attr_value, "yes") == 0) || - (strcasecmp (config_attr_value, "1") == 0); - - replica_set_legacy_consumer (r, legacy); - } - } /* ignore modifiers attributes added by the server */ else if (slapi_attr_is_last_mod(config_attr)) { @@ -1065,9 +1041,7 @@ replica_config_change_type_and_id (Replica *r, const char *new_type, replica_set_rid(r, rid); /* Set the mapping tree node, and the list of referrals */ - /* if this server is a 4.0 consumer the referrals are set by legacy plugin */ - if (!replica_is_legacy_consumer(r)) - consumer5_set_mapping_tree_state_for_replica(r, NULL); + consumer5_set_mapping_tree_state_for_replica(r, NULL); } return LDAP_SUCCESS; diff --git a/ldap/servers/plugins/replication/repl5_tot_protocol.c b/ldap/servers/plugins/replication/repl5_tot_protocol.c index ab113d3..e609b47 100644 --- a/ldap/servers/plugins/replication/repl5_tot_protocol.c +++ b/ldap/servers/plugins/replication/repl5_tot_protocol.c @@ -20,7 +20,6 @@ */ -#include "repl.h" #include "repl5.h" #include "repl5_prot_private.h" diff --git a/ldap/servers/plugins/replication/repl5_total.c b/ldap/servers/plugins/replication/repl5_total.c index b3703fa..5ea9ccb 100644 --- a/ldap/servers/plugins/replication/repl5_total.c +++ b/ldap/servers/plugins/replication/repl5_total.c @@ -47,7 +47,6 @@ } */ -#include "repl.h" #include "repl5.h" #define CSN_TYPE_VALUE_UPDATED_ON_WIRE 1 diff --git a/ldap/servers/plugins/replication/repl_add.c b/ldap/servers/plugins/replication/repl_add.c deleted file mode 100644 index d0881d8..0000000 --- a/ldap/servers/plugins/replication/repl_add.c +++ /dev/null @@ -1,38 +0,0 @@ -/** BEGIN COPYRIGHT BLOCK - * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission. - * Copyright (C) 2005 Red Hat, Inc. - * All rights reserved. - * - * License: GPL (version 3 or any later version). - * See LICENSE for details. - * END COPYRIGHT BLOCK **/ - -#ifdef HAVE_CONFIG_H -# include -#endif - - -#include "slapi-plugin.h" -#include "repl.h" - - -/* Add Operation Plugin Functions for legacy replication plugin */ - -int -legacy_preop_add( Slapi_PBlock *pb ) -{ - return legacy_preop( pb, "legacy_preop_add", OP_ADD ); -} - -int -legacy_bepreop_add( Slapi_PBlock *pb __attribute__((unused))) -{ - int rc= 0; /* OK */ - return rc; -} - -int -legacy_postop_add( Slapi_PBlock *pb ) -{ - return legacy_postop( pb, "legacy_postop_add", OP_ADD ); -} diff --git a/ldap/servers/plugins/replication/repl_bind.c b/ldap/servers/plugins/replication/repl_bind.c deleted file mode 100644 index ad351dc..0000000 --- a/ldap/servers/plugins/replication/repl_bind.c +++ /dev/null @@ -1,58 +0,0 @@ -/** BEGIN COPYRIGHT BLOCK - * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission. - * Copyright (C) 2005 Red Hat, Inc. - * All rights reserved. - * - * License: GPL (version 3 or any later version). - * See LICENSE for details. - * END COPYRIGHT BLOCK **/ - -#ifdef HAVE_CONFIG_H -# include -#endif - - - -#include "slapi-plugin.h" -#include "repl.h" -#include "repl5.h" - - -int -legacy_preop_bind( Slapi_PBlock *pb ) -{ - int return_value = 0; - const char *dn = NULL; - Slapi_DN *sdn = NULL; - struct berval *cred = NULL; - ber_tag_t method; - - slapi_pblock_get(pb, SLAPI_BIND_METHOD, &method); - slapi_pblock_get(pb, SLAPI_BIND_TARGET_SDN, &sdn); - slapi_pblock_get(pb, SLAPI_BIND_CREDENTIALS, &cred); - dn = slapi_sdn_get_dn(sdn); - - if (LDAP_AUTH_SIMPLE == method) - { - if (legacy_consumer_is_replicationdn(dn) && legacy_consumer_is_replicationpw(cred)) - { - /* Successful bind as replicationdn */ - void *conn = NULL; - consumer_connection_extension *connext = NULL; -#ifdef DEBUG - slapi_log_err(SLAPI_LOG_REPL, REPLICATION_SUBSYSTEM, "legacy_preop_bind: begin\n"); -#endif - slapi_pblock_get( pb, SLAPI_CONNECTION, &conn ); - /* TEL 20120529 - Is there any reason we must protect this connext access? */ - connext = (consumer_connection_extension*) repl_con_get_ext (REPL_CON_EXT_CONN, conn); - if (NULL != connext) - { - connext->is_legacy_replication_dn = 1; - } - slapi_send_ldap_result(pb, LDAP_SUCCESS, NULL, NULL, 0, NULL); - return_value = 1; /* Prevent further processing in front end */ - } - } - return return_value; - -} diff --git a/ldap/servers/plugins/replication/repl_compare.c b/ldap/servers/plugins/replication/repl_compare.c deleted file mode 100644 index 20428ef..0000000 --- a/ldap/servers/plugins/replication/repl_compare.c +++ /dev/null @@ -1,48 +0,0 @@ -/** BEGIN COPYRIGHT BLOCK - * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission. - * Copyright (C) 2005 Red Hat, Inc. - * All rights reserved. - * - * License: GPL (version 3 or any later version). - * See LICENSE for details. - * END COPYRIGHT BLOCK **/ - -#ifdef HAVE_CONFIG_H -# include -#endif - - -#include "slapi-plugin.h" -#include "repl.h" - -int -legacy_preop_compare( Slapi_PBlock *pb ) -{ - int is_replicated_operation = 0; - struct berval **referral = NULL; - int return_code = 0; - Slapi_DN *basesdn = NULL; - - slapi_pblock_get(pb, SLAPI_IS_REPLICATED_OPERATION, &is_replicated_operation); - slapi_pblock_get(pb, SLAPI_COMPARE_TARGET_SDN, &basesdn); - if (NULL == basesdn) { - slapi_send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL, - "Null target DN", 0, NULL ); - - return_code = 1; /* return 1 to prevent further search processing */ - goto bail; - } - referral = get_data_source(pb, basesdn, 1, NULL); - if (NULL != referral && !is_replicated_operation) - { - /* - * There is a copyingFrom in this entry or an ancestor. - * Return a referral to the supplier, and we're all done. - */ - slapi_send_ldap_result(pb, LDAP_REFERRAL, NULL, NULL, 0, referral); - return_code = 1; /* return 1 to prevent further search processing */ - } - slapi_ch_free((void**)&referral); -bail: - return return_code; -} diff --git a/ldap/servers/plugins/replication/repl_connext.c b/ldap/servers/plugins/replication/repl_connext.c index 5c2f3c4..eb03497 100644 --- a/ldap/servers/plugins/replication/repl_connext.c +++ b/ldap/servers/plugins/replication/repl_connext.c @@ -14,8 +14,6 @@ /* repl_connext.c - replication extension to the Connection object */ - -#include "repl.h" #include "repl5.h" @@ -36,7 +34,6 @@ void* consumer_connection_extension_constructor (void *object __attribute__((unu } else { - ext->is_legacy_replication_dn= 0; ext->repl_protocol_version = REPL_PROTOCOL_UNKNOWN; ext->replica_acquired = NULL; ext->isreplicationsession= 0; diff --git a/ldap/servers/plugins/replication/repl_controls.c b/ldap/servers/plugins/replication/repl_controls.c index 18c11f8..a7c83fe 100644 --- a/ldap/servers/plugins/replication/repl_controls.c +++ b/ldap/servers/plugins/replication/repl_controls.c @@ -14,7 +14,6 @@ #include "slapi-plugin.h" #include "repl5.h" -#include "repl.h" /* For LDAP_CONTROL_REPL_MODRDN_EXTRAMODS */ /* * repl_controls.c - convenience functions for creating and diff --git a/ldap/servers/plugins/replication/repl_delete.c b/ldap/servers/plugins/replication/repl_delete.c deleted file mode 100644 index ce4bb7c..0000000 --- a/ldap/servers/plugins/replication/repl_delete.c +++ /dev/null @@ -1,34 +0,0 @@ -/** BEGIN COPYRIGHT BLOCK - * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission. - * Copyright (C) 2005 Red Hat, Inc. - * All rights reserved. - * - * License: GPL (version 3 or any later version). - * See LICENSE for details. - * END COPYRIGHT BLOCK **/ - -#ifdef HAVE_CONFIG_H -# include -#endif - - -#include "slapi-plugin.h" -#include "repl.h" - -int -legacy_preop_delete( Slapi_PBlock *pb ) -{ - return legacy_preop(pb, "legacy_preop_delete", OP_DELETE); -} - -int -legacy_bepreop_delete( Slapi_PBlock *pb __attribute__((unused))) -{ - return 0; /* OK */ -} - -int -legacy_postop_delete( Slapi_PBlock *pb ) -{ - return legacy_postop(pb, "legacy_preop_delete", OP_DELETE); -} diff --git a/ldap/servers/plugins/replication/repl_entry.c b/ldap/servers/plugins/replication/repl_entry.c deleted file mode 100644 index 9b53438..0000000 --- a/ldap/servers/plugins/replication/repl_entry.c +++ /dev/null @@ -1,46 +0,0 @@ -/** BEGIN COPYRIGHT BLOCK - * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission. - * Copyright (C) 2005 Red Hat, Inc. - * All rights reserved. - * - * License: GPL (version 3 or any later version). - * See LICENSE for details. - * END COPYRIGHT BLOCK **/ - -#ifdef HAVE_CONFIG_H -# include -#endif - - -#include "slapi-plugin.h" -#include "repl.h" - -static int dumping_to_ldif= 0; -static int doing_replica_init= 0; -static char **include_suffix= NULL; - -/* - * This is passed the slapd command line arguments. - */ -void -repl_entry_init(int argc, char** argv) -{ - int i; - for(i=1;i -#endif - - -/* - * Add an entry like the following to dse.ldif to enable this plugin: - -dn: cn=Legacy Replication Plugin,cn=plugins,cn=config -objectclass: top -objectclass: nsSlapdPlugin -objectclass: extensibleObject -cn: Legacy Replication Plugin -nsslapd-pluginpath: /export2/servers/Hydra-supplier/lib/replication-plugin.so -nsslapd-plugininitfunc: replication_legacy_plugin_init -nsslapd-plugintype: object -nsslapd-pluginenabled: on -nsslapd-plugin-depends-on-type: database -nsslapd-plugin-depends-on-named: Class of Service -nsslapd-plugin-depends-on-named: Multi-Master Replication Plugin -nsslapd-pluginid: replication-legacy -nsslapd-pluginversion: 5.0b1 -nsslapd-pluginvendor: Netscape Communications -nsslapd-plugindescription: Legacy Replication Plugin - -NOTE: This plugin depends on the Multi-Master Replication Plugin - -*/ - -#include "slapi-plugin.h" -#include "repl.h" -#include "repl5.h" -#include "repl_shared.h" -#include "cl4.h" /* changelog interface */ - - -/* ----------------------------- Legacy Replication Plugin */ - -static Slapi_PluginDesc legacydesc = { "replication-legacy", VENDOR, DS_PACKAGE_VERSION, "Legacy Replication Plugin" }; -static Slapi_PluginDesc legacypreopdesc = { "replication-legacy-preop", VENDOR, DS_PACKAGE_VERSION, "Legacy replication pre-operation plugin" }; -static Slapi_PluginDesc legacypostopdesc = { "replication-legacy-postop", VENDOR, DS_PACKAGE_VERSION, "Legacy replication post-operation plugin" }; -static Slapi_PluginDesc legacyinternalpreopdesc = { "replication-legacy-internalpreop", VENDOR, DS_PACKAGE_VERSION, "Legacy replication internal pre-operation plugin" }; -static Slapi_PluginDesc legacyinternalpostopdesc = { "replication-legacy-internalpostop", VENDOR, DS_PACKAGE_VERSION, "Legacy replication internal post-operation plugin" }; -static Slapi_PluginDesc legacyentrydesc = { "replication-legacy-entry", VENDOR, DS_PACKAGE_VERSION, "Legacy replication entry plugin" }; - -static int legacy_stopped; /* A flag which is set when all the plugin threads are to stop */ - - -/* Initialize preoperation plugin points */ -int -legacy_preop_init( Slapi_PBlock *pb ) -{ - int rc= 0; /* OK */ - - if( slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01 ) != 0 || - slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&legacypreopdesc ) != 0 || - slapi_pblock_set( pb, SLAPI_PLUGIN_PRE_BIND_FN, (void *) legacy_preop_bind ) != 0 || - slapi_pblock_set( pb, SLAPI_PLUGIN_PRE_ADD_FN, (void *) legacy_preop_add ) != 0 || - slapi_pblock_set( pb, SLAPI_PLUGIN_PRE_DELETE_FN, (void *) legacy_preop_delete ) != 0 || - slapi_pblock_set( pb, SLAPI_PLUGIN_PRE_MODIFY_FN, (void *) legacy_preop_modify ) != 0 || - slapi_pblock_set( pb, SLAPI_PLUGIN_PRE_MODRDN_FN, (void *) legacy_preop_modrdn ) != 0 || - slapi_pblock_set( pb, SLAPI_PLUGIN_PRE_SEARCH_FN, (void *) legacy_preop_search ) != 0 || - slapi_pblock_set( pb, SLAPI_PLUGIN_PRE_COMPARE_FN, (void *) legacy_preop_compare ) != 0 || - slapi_pblock_set( pb, SLAPI_PLUGIN_PRE_ENTRY_FN, (void *) legacy_pre_entry )) - { - slapi_log_err(SLAPI_LOG_PLUGIN, repl_plugin_name, "legacy_preop_init failed\n" ); - rc= -1; - } - return rc; -} - - - -/* Initialize postoperation plugin points */ -static int -legacy_postop_init( Slapi_PBlock *pb ) -{ - int rc= 0; /* OK */ - - if( slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01 ) != 0 || - slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&legacypostopdesc ) != 0 || - slapi_pblock_set( pb, SLAPI_PLUGIN_POST_ADD_FN, (void *) legacy_postop_add ) != 0 || - slapi_pblock_set( pb, SLAPI_PLUGIN_POST_DELETE_FN, (void *) legacy_postop_delete ) != 0 || - slapi_pblock_set( pb, SLAPI_PLUGIN_POST_MODIFY_FN, (void *) legacy_postop_modify ) != 0 || - slapi_pblock_set( pb, SLAPI_PLUGIN_POST_MODRDN_FN, (void *) legacy_postop_modrdn ) != 0 ) - { - slapi_log_err(SLAPI_LOG_PLUGIN, repl_plugin_name, "legacy_postop_init failed\n" ); - rc= -1; - } - - return rc; -} - - - -/* Initialize internal preoperation plugin points (called for internal operations) */ -static int -legacy_internalpreop_init( Slapi_PBlock *pb ) -{ - int rc= 0; /* OK */ - - if( slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01 ) != 0 || - slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&legacyinternalpreopdesc ) != 0 || - slapi_pblock_set( pb, SLAPI_PLUGIN_INTERNAL_PRE_ADD_FN, (void *) legacy_preop_add ) != 0 || - slapi_pblock_set( pb, SLAPI_PLUGIN_INTERNAL_PRE_DELETE_FN, (void *) legacy_preop_delete ) != 0 || - slapi_pblock_set( pb, SLAPI_PLUGIN_INTERNAL_PRE_MODIFY_FN, (void *) legacy_preop_modify ) != 0 || - slapi_pblock_set( pb, SLAPI_PLUGIN_INTERNAL_PRE_MODRDN_FN, (void *) legacy_preop_modrdn ) != 0 ) - { - slapi_log_err(SLAPI_LOG_PLUGIN, repl_plugin_name, "legacy_internalpreop_init failed\n" ); - rc= -1; - } - return rc; -} - - - -/* Initialize internal postoperation plugin points (called for internal operations) */ -static int -legacy_internalpostop_init( Slapi_PBlock *pb ) -{ - int rc= 0; /* OK */ - - if( slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01 ) != 0 || - slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&legacyinternalpostopdesc ) != 0 || - slapi_pblock_set( pb, SLAPI_PLUGIN_INTERNAL_POST_ADD_FN, (void *) legacy_postop_add ) != 0 || - slapi_pblock_set( pb, SLAPI_PLUGIN_INTERNAL_POST_DELETE_FN, (void *) legacy_postop_delete ) != 0 || - slapi_pblock_set( pb, SLAPI_PLUGIN_INTERNAL_POST_MODIFY_FN, (void *) legacy_postop_modify ) != 0 || - slapi_pblock_set( pb, SLAPI_PLUGIN_INTERNAL_POST_MODRDN_FN, (void *) legacy_postop_modrdn ) != 0 ) - { - slapi_log_err(SLAPI_LOG_PLUGIN, repl_plugin_name, "legacy_internalpostop_init failed\n" ); - rc= -1; - } - - return rc; -} - - - -/* Initialize the entry plugin point for the legacy replication plugin */ -static int -legacy_entry_init( Slapi_PBlock *pb ) -{ - int rc= 0; /* OK */ - - /* Set up the fn pointers for the preop and postop operations we're interested in */ - if( slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01 ) != 0 || - slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&legacyentrydesc ) != 0 ) - { - slapi_log_err(SLAPI_LOG_PLUGIN, repl_plugin_name, "legacy_entry_init failed\n" ); - rc= -1; - } - return rc; -} - - - - -/* - * Create the entry at the top of the replication configuration subtree. - */ -static int -create_config_top(void) -{ - /* DN part of this entry_string: no need to be optimized. */ - char *entry_string = slapi_ch_strdup("dn: cn=replication,cn=config\nobjectclass: top\nobjectclass: extensibleobject\ncn: replication\n"); - Slapi_PBlock *pb = slapi_pblock_new(); - Slapi_Entry *e = slapi_str2entry(entry_string, 0); - int return_value; - - slapi_add_entry_internal_set_pb(pb, e, NULL, /* controls */ - repl_get_plugin_identity(PLUGIN_MULTIMASTER_REPLICATION), 0 /* flags */); - slapi_add_internal_pb(pb); - slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &return_value); - slapi_pblock_destroy(pb); - slapi_ch_free((void **)&entry_string); - return return_value; -} - - -/* Start the legacy replication plugin */ -static int -legacy_start( Slapi_PBlock *pb ) -{ - static int legacy_started = 0; - int rc= 0; /* OK */ - - if (!legacy_started) - { - int ctrc; - - /* Initialise support for cn=monitor */ - repl_monitor_init(); - - /* Initialise support for "" (the rootdse) */ - /* repl_rootdse_init(); */ - - /* Decode the command line args to see if we're dumping to LDIF */ - { - int argc; - char **argv; - slapi_pblock_get( pb, SLAPI_ARGC, &argc); - slapi_pblock_get( pb, SLAPI_ARGV, &argv); - repl_entry_init(argc,argv); - } - - /* Create the entry at the top of the config area, if it doesn't exist */ - /* XXXggood this should be in the 5.0 plugin! */ - ctrc = create_config_top(); - if (ctrc != LDAP_SUCCESS && ctrc != LDAP_ALREADY_EXISTS) - { - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "Warning: unable to " - "create configuration entry %s: %s\n", REPL_CONFIG_TOP, - ldap_err2string(ctrc)); - } - (void)legacy_consumer_config_init(); - - /* register to be notified when backend state changes */ - slapi_register_backend_state_change((void *)legacy_consumer_be_state_change, - legacy_consumer_be_state_change); - - legacy_started = 1; - legacy_stopped = 0; - } - return rc; -} - - -/* Post-start function for the legacy replication plugin */ -static int -legacy_poststart( Slapi_PBlock *pb __attribute__((unused))) -{ - int rc = 0; /* OK */ - return rc; -} - - -/* Stop the legacy replication plugin */ -static int -legacy_stop( Slapi_PBlock *pb __attribute__((unused))) -{ - int rc= 0; /* OK */ - - if (!legacy_stopped) - { - /*csnShutdown();*/ - legacy_stopped = 1; - } - - /* unregister backend state change notification */ - slapi_unregister_backend_state_change((void *)legacy_consumer_be_state_change); - - return rc; -} - - -/* Initialize the legacy replication plugin */ -int -replication_legacy_plugin_init(Slapi_PBlock *pb) -{ - static int legacy_initialised= 0; - int rc= 0; /* OK */ - void *identity = NULL; - - slapi_pblock_get (pb, SLAPI_PLUGIN_IDENTITY, &identity); - PR_ASSERT (identity); - repl_set_plugin_identity (PLUGIN_LEGACY_REPLICATION, identity); - - if(rc==0 && !legacy_initialised) - { - rc= slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01 ); - rc= slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&legacydesc ); - rc= slapi_pblock_set( pb, SLAPI_PLUGIN_START_FN, (void *) legacy_start ); - rc= slapi_pblock_set( pb, SLAPI_PLUGIN_CLOSE_FN, (void *) legacy_stop ); - rc= slapi_pblock_set( pb, SLAPI_PLUGIN_POSTSTART_FN, (void *) legacy_poststart ); - - /* Register the plugin interfaces we implement */ - rc= slapi_register_plugin("preoperation", 1 /* Enabled */, "legacy_preop_init", legacy_preop_init, "Legacy replication preoperation plugin", NULL, identity); - rc= slapi_register_plugin("postoperation", 1 /* Enabled */, "legacy_postop_init", legacy_postop_init, "Legacy replication postoperation plugin", NULL, identity); - rc= slapi_register_plugin("internalpreoperation", 1 /* Enabled */, "legacy_internalpreop_init", legacy_internalpreop_init, "Legacy replication internal preoperation plugin", NULL, identity); - rc= slapi_register_plugin("internalpostoperation", 1 /* Enabled */, "legacy_internalpostop_init", legacy_internalpostop_init, "Legacy replication internal postoperation plugin", NULL, identity); - rc= slapi_register_plugin("entry", 1 /* Enabled */, "legacy_entry_init", legacy_entry_init, "Legacy replication entry plugin", NULL, identity); - - legacy_initialised= 1; - } - return rc; -} - - -int -get_legacy_stop() -{ - return legacy_stopped; -} diff --git a/ldap/servers/plugins/replication/repl_modify.c b/ldap/servers/plugins/replication/repl_modify.c deleted file mode 100644 index 4022a37..0000000 --- a/ldap/servers/plugins/replication/repl_modify.c +++ /dev/null @@ -1,37 +0,0 @@ -/** BEGIN COPYRIGHT BLOCK - * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission. - * Copyright (C) 2005 Red Hat, Inc. - * All rights reserved. - * - * License: GPL (version 3 or any later version). - * See LICENSE for details. - * END COPYRIGHT BLOCK **/ - -#ifdef HAVE_CONFIG_H -# include -#endif - - -#include "slapi-plugin.h" -#include "repl.h" - -/* The modify operation plugin functions for the legacy replication plugin */ - -int -legacy_preop_modify( Slapi_PBlock *pb ) -{ - return legacy_preop( pb, "legacy_preop_modify", OP_MODIFY ); -} - -int -legacy_bepreop_modify( Slapi_PBlock *pb __attribute__((unused))) -{ - int rc= 0; /* OK */ - return rc; -} - -int -legacy_postop_modify( Slapi_PBlock *pb ) -{ - return legacy_postop( pb, "legacy_postop_modify", OP_MODIFY ); -} diff --git a/ldap/servers/plugins/replication/repl_modrdn.c b/ldap/servers/plugins/replication/repl_modrdn.c deleted file mode 100644 index 0528180..0000000 --- a/ldap/servers/plugins/replication/repl_modrdn.c +++ /dev/null @@ -1,36 +0,0 @@ -/** BEGIN COPYRIGHT BLOCK - * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission. - * Copyright (C) 2005 Red Hat, Inc. - * All rights reserved. - * - * License: GPL (version 3 or any later version). - * See LICENSE for details. - * END COPYRIGHT BLOCK **/ - -#ifdef HAVE_CONFIG_H -# include -#endif - - -#include "slapi-plugin.h" -#include "repl.h" - -/* The modrdn plugin points for the legacy replication plugin */ - -int -legacy_preop_modrdn( Slapi_PBlock *pb ) -{ - return legacy_preop(pb, "legacy_preop_modrdn", OP_MODDN); -} - -int -legacy_bepreop_modrdn( Slapi_PBlock *pb __attribute__((unused))) -{ - return 0; /* OK */ -} - -int -legacy_postop_modrdn( Slapi_PBlock *pb ) -{ - return legacy_postop(pb, "legacy_postop_modrdn", OP_MODDN); -} diff --git a/ldap/servers/plugins/replication/repl_monitor.c b/ldap/servers/plugins/replication/repl_monitor.c deleted file mode 100644 index 9e9f02a..0000000 --- a/ldap/servers/plugins/replication/repl_monitor.c +++ /dev/null @@ -1,73 +0,0 @@ -/** BEGIN COPYRIGHT BLOCK - * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission. - * Copyright (C) 2005 Red Hat, Inc. - * All rights reserved. - * - * License: GPL (version 3 or any later version). - * See LICENSE for details. - * END COPYRIGHT BLOCK **/ - -#ifdef HAVE_CONFIG_H -# include -#endif - - -#include - -#include "repl.h" -#include "slapi-plugin.h" - -#ifdef FOR_40_STYLE_CHANGELOG -/* Forward Declartions */ -static int repl_monitor_search (Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg); -#endif - -int -repl_monitor_init() -{ - /* The FE DSE *must* be initialised before we get here */ - int return_value= LDAP_SUCCESS; - static int initialized = 0; - - if (!initialized) - { -#ifdef FOR_40_STYLE_CHANGELOG - /* ONREPL - this is commented until we implement 4.0 style changelog */ - slapi_config_register_callback(SLAPI_OPERATION_SEARCH,DSE_FLAG_PREOP,"cn=monitor",LDAP_SCOPE_BASE,"(objectclass=*)",repl_monitor_search,NULL); -#endif - initialized = 1; - } - - return return_value; -} - -#ifdef FOR_40_STYLE_CHANGELOG -static int -repl_monitor_search(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg) -{ - const char *sdv = get_server_dataversion(); - if ( sdv != NULL ) - { - int port; - char buf[BUFSIZ]; - struct berval val; - struct berval *vals[2]; - vals[0] = &val; - vals[1] = NULL; - port= config_get_port(); - if(port==0) - { - port= config_get_secureport(); - } - buf[0] = (char)0; - /* ONREPL - how do we publish changenumbers now with multiple changelogs? - sprintf( buf, "%s:%lu %s% lu", get_localhost_DNS(), port, sdv, ldapi_get_last_changenumber()); - */ - val.bv_val = buf; - val.bv_len = strlen( buf ); - slapi_entry_attr_replace( e, attr_dataversion, vals ); - } - return SLAPI_DSE_CALLBACK_OK; -} -#endif - diff --git a/ldap/servers/plugins/replication/repl_opext.c b/ldap/servers/plugins/replication/repl_opext.c index d9fdd2d..8769ee2 100644 --- a/ldap/servers/plugins/replication/repl_opext.c +++ b/ldap/servers/plugins/replication/repl_opext.c @@ -14,8 +14,6 @@ /* supplier_operation_extension.c - replication extension to the Operation object */ - -#include "repl.h" #include "repl5.h" /* ***** Supplier side ***** */ @@ -70,11 +68,6 @@ void* consumer_operation_extension_constructor (void *object, void *parent) { operation_set_flag((Slapi_Operation *)object,OP_FLAG_REPLICATED); } - /* We set the Replication DN flag if session bound as replication dn */ - if (connext->is_legacy_replication_dn) - { - operation_set_flag((Slapi_Operation *)object, OP_FLAG_LEGACY_REPLICATION_DN); - } } } else diff --git a/ldap/servers/plugins/replication/repl_ops.c b/ldap/servers/plugins/replication/repl_ops.c deleted file mode 100644 index 81e0103..0000000 --- a/ldap/servers/plugins/replication/repl_ops.c +++ /dev/null @@ -1,188 +0,0 @@ -/** BEGIN COPYRIGHT BLOCK - * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission. - * Copyright (C) 2005 Red Hat, Inc. - * All rights reserved. - * - * License: GPL (version 3 or any later version). - * See LICENSE for details. - * END COPYRIGHT BLOCK **/ - -#ifdef HAVE_CONFIG_H -# include -#endif - - -#include "slapi-plugin.h" -#include "repl.h" -#include "repl5.h" - -int -legacy_postop( Slapi_PBlock *pb, const char *caller __attribute__((unused)), int operation_type) -{ - int rc = 0; - Object *r_obj; - Replica *r; - - r_obj = replica_get_replica_for_op (pb); - if (r_obj == NULL) /* there is no replica configured for this operations */ - return 0; - else - { - /* check if this replica is 4.0 consumer */ - r = (Replica*)object_get_data (r_obj); - PR_ASSERT (r); - - /* this replica is not a 4.0 consumer - so we don't need to do any processing */ - if (!replica_is_legacy_consumer (r)) - { - object_release (r_obj); - return 0; - } - - object_release (r_obj); - } - - slapi_pblock_get(pb, SLAPI_PLUGIN_OPRETURN, &rc); - if (0 == rc) - { - if (OP_ADD == operation_type || OP_MODIFY == operation_type) - { - void *op; - consumer_operation_extension *opext = NULL; - - /* Optimise out traversal of mods/entry if no cop{ied|ying}From present */ - slapi_pblock_get(pb, SLAPI_OPERATION, &op); - opext = (consumer_operation_extension*) repl_con_get_ext (REPL_CON_EXT_OP, op); - if (NULL != opext && opext->has_cf) - { - process_legacy_cf( pb ); - } - } - } - - return 0; -} - -int -legacy_preop(Slapi_PBlock *pb, const char *caller __attribute__((unused)), int operation_type) -{ - int rc = 0; - Slapi_Operation *operation = NULL; - consumer_operation_extension *opext = NULL; - int has_cf = 0; - Object *r_obj; - Replica *r; - int is_legacy_op = 0; - - slapi_pblock_get( pb, SLAPI_OPERATION, &operation ); - if (NULL == operation) { - slapi_send_ldap_result(pb, LDAP_UNWILLING_TO_PERFORM, NULL, - "Null replication operation is given", 0, NULL); - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, - "Null replication operation is given\n"); - return -1; - } - is_legacy_op = operation_is_flag_set(operation,OP_FLAG_LEGACY_REPLICATION_DN); - r_obj = replica_get_replica_for_op (pb); - - if (r_obj == NULL) { /* there is no replica configured for this operations */ - if (is_legacy_op){ - /* This is a legacy replication operation but there are NO replica defined - Just refuse it */ - slapi_send_ldap_result(pb, LDAP_UNWILLING_TO_PERFORM, NULL, - "Replication operation refused because the consumer is not defined as a replica", 0, NULL); - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, - "Incoming replication operation was refused because " - "there's no replica defined for this operation\n"); - return -1; - } - else { - return 0; - } - } - else - { - /* check if this replica is 4.0 consumer */ - r = (Replica*)object_get_data (r_obj); - PR_ASSERT (r); - - if (!replica_is_legacy_consumer (r)) - { - object_release (r_obj); - if (is_legacy_op) { - /* This is a legacy replication operation - but the replica is doesn't accept from legacy - Just refuse it */ - slapi_send_ldap_result(pb, LDAP_UNWILLING_TO_PERFORM, NULL, - "Replication operation refused because " - "the consumer is not defined as a legacy replica", 0, NULL); - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, - "Incoming replication operation was refused because " - "there's no legacy replica defined for this operation\n"); - return -1; - } else { - return 0; - } - } - - object_release (r_obj); - } - - opext = (consumer_operation_extension*) repl_con_get_ext (REPL_CON_EXT_OP, operation); - - switch (operation_type) { - case OP_ADD: - { - Slapi_Entry *e = NULL; - Slapi_Attr *attr; - /* - * Check if the entry being added has copiedFrom/copyingFrom - * attributes. - */ - slapi_pblock_get(pb, SLAPI_ADD_ENTRY, &e); - if (NULL != e) - { - if (slapi_entry_attr_find(e, type_copiedFrom, &attr) == 0) - { - has_cf = 1; - } - else - if (slapi_entry_attr_find(e, type_copyingFrom, &attr) == 0) - { - has_cf = 1; - } - } - /* JCMREPL - If this is a replicated operation then the baggage control also contains the Unique Identifier of the superior entry. */ - } - break; - case OP_MODIFY: - { - LDAPMod **mods = NULL; - int i; - - /* - * Check if the modification contains copiedFrom/copyingFrom - * attributes. - */ - slapi_pblock_get(pb, SLAPI_MODIFY_MODS, &mods); - for (i = 0; NULL != mods && NULL != mods[i]; i++) - { - if ((strcasecmp(mods[i]->mod_type, type_copiedFrom) == 0) || - (strcasecmp(mods[i]->mod_type, type_copyingFrom) == 0)) - { - has_cf = 1; - } - } - } - break; - case OP_DELETE: - break; - case OP_MODDN: - break; - } - - /* Squirrel away an optimization hint for the postop plugin */ - opext->has_cf = has_cf; - - return rc; -} diff --git a/ldap/servers/plugins/replication/repl_rootdse.c b/ldap/servers/plugins/replication/repl_rootdse.c deleted file mode 100644 index be7be22..0000000 --- a/ldap/servers/plugins/replication/repl_rootdse.c +++ /dev/null @@ -1,92 +0,0 @@ -/** BEGIN COPYRIGHT BLOCK - * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission. - * Copyright (C) 2005 Red Hat, Inc. - * All rights reserved. - * - * License: GPL (version 3 or any later version). - * See LICENSE for details. - * END COPYRIGHT BLOCK **/ - -#ifdef HAVE_CONFIG_H -# include -#endif - - -#include - -#include "repl.h" -#include "cl4.h" -#include "slapi-plugin.h" - -/* Forward Declartions */ -static int repl_rootdse_search (Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg); - -int -repl_rootdse_init() -{ - /* The FE DSE *must* be initialised before we get here */ - int return_value= LDAP_SUCCESS; - - slapi_config_register_callback(SLAPI_OPERATION_SEARCH,DSE_FLAG_PREOP,"",LDAP_SCOPE_BASE,"(objectclass=*)",repl_rootdse_search,NULL); - - return return_value; -} - -static int -repl_rootdse_search(Slapi_PBlock *pb __attribute__((unused)), - Slapi_Entry* e __attribute__((unused)), - Slapi_Entry* entryAfter __attribute__((unused)), - int *returncode __attribute__((unused)), - char *returntext __attribute__((unused)), - void *arg __attribute__((unused))) -{ - -#if 0 - struct berval val; - struct berval *vals[2]; - vals[0] = &val; - vals[1] = NULL; - - /* machine data suffix */ - val.bv_val = REPL_CONFIG_TOP; - val.bv_len = strlen( val.bv_val ); - slapi_entry_attr_replace( e, ATTR_NETSCAPEMDSUFFIX, vals ); - - /* Changelog information */ -/* ONREPL because we now support multiple 4.0 changelogs we no longer publish - info in the rootdse */ - if ( get_repl_backend() != NULL ) - { - char buf[BUFSIZ]; - changeNumber cnum; - - /* Changelog suffix */ - val.bv_val = changelog4_get_suffix (); - if ( val.bv_val != NULL ) - { - val.bv_len = strlen( val.bv_val ); - slapi_entry_attr_replace( e, "changelog", vals ); - } - slapi_ch_free ((void **)&val.bv_val); - - /* First change number contained in log */ - cnum = ldapi_get_first_changenumber(); - sprintf( buf, "%lu", cnum ); - val.bv_val = buf; - val.bv_len = strlen( val.bv_val ); - slapi_entry_attr_replace( e, "firstchangenumber", vals ); - - /* Last change number contained in log */ - cnum = ldapi_get_last_changenumber(); - sprintf( buf, "%lu", cnum ); - val.bv_val = buf; - val.bv_len = strlen( val.bv_val ); - slapi_entry_attr_replace( e, "lastchangenumber", vals ); - } -#endif - - return SLAPI_DSE_CALLBACK_OK; -} - - - diff --git a/ldap/servers/plugins/replication/repl_search.c b/ldap/servers/plugins/replication/repl_search.c deleted file mode 100644 index 66330d0..0000000 --- a/ldap/servers/plugins/replication/repl_search.c +++ /dev/null @@ -1,33 +0,0 @@ -/** BEGIN COPYRIGHT BLOCK - * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission. - * Copyright (C) 2005 Red Hat, Inc. - * All rights reserved. - * - * License: GPL (version 3 or any later version). - * See LICENSE for details. - * END COPYRIGHT BLOCK **/ - -#ifdef HAVE_CONFIG_H -# include -#endif - - -#include "slapi-plugin.h" -#include "repl.h" - -/* XXXggood I think we no longer need this - the mapping tree should do it for us */ -int -legacy_preop_search( Slapi_PBlock *pb __attribute__((unused))) -{ - int return_code = 0; - return return_code; -} - - -/* XXXggood I think we no longer need this - the mapping tree should do it for us */ -int -legacy_pre_entry( Slapi_PBlock *pb __attribute__((unused))) -{ - int return_code = 0; - return return_code; -} diff --git a/ldap/servers/plugins/replication/repl_session_plugin.c b/ldap/servers/plugins/replication/repl_session_plugin.c index 5e452f3..9c13309 100644 --- a/ldap/servers/plugins/replication/repl_session_plugin.c +++ b/ldap/servers/plugins/replication/repl_session_plugin.c @@ -8,7 +8,6 @@ /* repl_session_plugin.c */ -#include "repl.h" #include "repl5.h" #include "slap.h" #include "slapi-plugin.h" diff --git a/ldap/servers/plugins/replication/repl_shared.h b/ldap/servers/plugins/replication/repl_shared.h index fac3e7b..b7cd98d 100644 --- a/ldap/servers/plugins/replication/repl_shared.h +++ b/ldap/servers/plugins/replication/repl_shared.h @@ -113,7 +113,6 @@ PRBool is_ruv_tombstone_entry (Slapi_Entry *e); /* replication plugins */ enum { - PLUGIN_LEGACY_REPLICATION, PLUGIN_MULTIMASTER_REPLICATION, PLUGIN_MAX }; diff --git a/ldap/servers/plugins/replication/replutil.c b/ldap/servers/plugins/replication/replutil.c index f1b114e..70ae688 100644 --- a/ldap/servers/plugins/replication/replutil.c +++ b/ldap/servers/plugins/replication/replutil.c @@ -35,7 +35,6 @@ #include "slapi-plugin.h" #include "repl5.h" -#include "repl.h" typedef int (*open_fn)(const char *path, int flags, ...); diff --git a/ldap/servers/plugins/replication/urp.c b/ldap/servers/plugins/replication/urp.c index 64810e9..8d58acd 100644 --- a/ldap/servers/plugins/replication/urp.c +++ b/ldap/servers/plugins/replication/urp.c @@ -17,7 +17,6 @@ */ #include "slapi-plugin.h" -#include "repl.h" #include "repl5.h" #include "urp.h" diff --git a/ldap/servers/plugins/replication/windows_inc_protocol.c b/ldap/servers/plugins/replication/windows_inc_protocol.c index 94a2933..4671f83 100644 --- a/ldap/servers/plugins/replication/windows_inc_protocol.c +++ b/ldap/servers/plugins/replication/windows_inc_protocol.c @@ -29,7 +29,6 @@ Stuff to do: Perhaps these events should be properties of the main protocol. */ -#include "repl.h" #include "repl5.h" #include "windowsrepl.h" #include "windows_prot_private.h" diff --git a/ldap/servers/plugins/replication/windows_private.c b/ldap/servers/plugins/replication/windows_private.c index 7442801..dbdfe42 100644 --- a/ldap/servers/plugins/replication/windows_private.c +++ b/ldap/servers/plugins/replication/windows_private.c @@ -14,7 +14,6 @@ /* windows_private.c */ -#include "repl.h" #include "repl5.h" #include "slap.h" #include "slapi-plugin.h" diff --git a/ldap/servers/plugins/replication/windows_tot_protocol.c b/ldap/servers/plugins/replication/windows_tot_protocol.c index 6de0e93..3b09d61 100644 --- a/ldap/servers/plugins/replication/windows_tot_protocol.c +++ b/ldap/servers/plugins/replication/windows_tot_protocol.c @@ -20,8 +20,6 @@ */ - -#include "repl.h" #include "repl5.h" #include "windowsrepl.h" #include "windows_prot_private.h" diff --git a/ldap/servers/slapd/add.c b/ldap/servers/slapd/add.c index eb9a9fc..cd78c55 100644 --- a/ldap/servers/slapd/add.c +++ b/ldap/servers/slapd/add.c @@ -419,7 +419,7 @@ static void op_shared_add (Slapi_PBlock *pb) Slapi_Entry *e, *pse; Slapi_Backend *be = NULL; int err; - int internal_op, repl_op, legacy_op, lastmod; + int internal_op, repl_op, lastmod; char *pwdtype = NULL; Slapi_Attr *attr = NULL; Slapi_Entry *referral; @@ -437,7 +437,6 @@ static void op_shared_add (Slapi_PBlock *pb) slapi_pblock_get (pb, SLAPI_CONNECTION, &pb_conn); slapi_pblock_get (pb, SLAPI_ADD_ENTRY, &e); slapi_pblock_get (pb, SLAPI_IS_REPLICATED_OPERATION, &repl_op); - slapi_pblock_get (pb, SLAPI_IS_LEGACY_REPLICATED_OPERATION, &legacy_op); internal_op= operation_is_flag_set(operation, OP_FLAG_INTERNAL); pwpolicy = new_passwdPolicy(pb, slapi_entry_get_dn(e)); @@ -665,16 +664,6 @@ static void op_shared_add (Slapi_PBlock *pb) slapi_schema_expand_objectclasses( e ); } - /* uniqueid needs to be generated for entries added during legacy replication */ - if (legacy_op){ - if (add_uniqueid(e) != UID_SUCCESS) - { - send_ldap_result(pb, LDAP_UNWILLING_TO_PERFORM, NULL, - "cannot insert computed attributes", 0, NULL); - goto done; - } - } - /* * call the pre-add plugins. if they succeed, call * the backend add function. then call the post-add diff --git a/ldap/servers/slapd/mapping_tree.c b/ldap/servers/slapd/mapping_tree.c index 7552839..bd285a1 100644 --- a/ldap/servers/slapd/mapping_tree.c +++ b/ldap/servers/slapd/mapping_tree.c @@ -2671,7 +2671,6 @@ static int mtn_get_be(mapping_tree_node *target_node, Slapi_PBlock *pb, override_referral = ((cid != NULL) && (pw_get_componentID() != NULL) && (pw_get_componentID() == cid)) || - operation_is_flag_set(op, OP_FLAG_LEGACY_REPLICATION_DN) || /* 4.0 lgacy update */ operation_is_flag_set(op, OP_FLAG_REPLICATED) || /* 5.0 replication update */ operation_is_flag_set(op, OP_FLAG_TOMBSTONE_ENTRY) || /* 5.1 fix to enable tombstone delete on a R-O consumer */ operation_is_flag_set(op, SLAPI_OP_FLAG_BYPASS_REFERRALS); /* 6.1 fix to allow internal updates from plugins on R-O consumer */ diff --git a/ldap/servers/slapd/pblock.c b/ldap/servers/slapd/pblock.c index 429329a..53d48b4 100644 --- a/ldap/servers/slapd/pblock.c +++ b/ldap/servers/slapd/pblock.c @@ -599,7 +599,7 @@ int slapi_pblock_get(Slapi_PBlock *pblock, int arg, void *value) { if (pblock->pb_op == NULL) { (*(int *)value) = 0; /* No Operation -> Not Replicated */ } else { - (*(int *)value) = (pblock->pb_op->o_flags & (OP_FLAG_REPLICATED | OP_FLAG_LEGACY_REPLICATION_DN)); + (*(int *)value) = (pblock->pb_op->o_flags & OP_FLAG_REPLICATED); } break; case SLAPI_IS_MMR_REPLICATED_OPERATION: @@ -609,13 +609,6 @@ int slapi_pblock_get(Slapi_PBlock *pblock, int arg, void *value) { (*(int *)value) = (pblock->pb_op->o_flags & OP_FLAG_REPLICATED); } break; - case SLAPI_IS_LEGACY_REPLICATED_OPERATION: - if (pblock->pb_op == NULL) { - (*(int *)value) = 0; /* No Operation -> Not Replicated */ - } else { - (*(int *)value) = (pblock->pb_op->o_flags & OP_FLAG_LEGACY_REPLICATION_DN); - } - break; case SLAPI_OPERATION_PARAMETERS: if (pblock->pb_op != NULL) { diff --git a/ldap/servers/slapd/plugin_acl.c b/ldap/servers/slapd/plugin_acl.c index dcc49a7..6ceed23 100644 --- a/ldap/servers/slapd/plugin_acl.c +++ b/ldap/servers/slapd/plugin_acl.c @@ -50,7 +50,7 @@ plugin_call_acl_plugin ( Slapi_PBlock *pb, Slapi_Entry *e, char **attrs, slapi_pblock_get (pb, SLAPI_OPERATION, &operation); /* we don't perform acl check for internal operations and if the plugin has set it not to be checked */ - if (operation_is_flag_set(operation, SLAPI_OP_FLAG_NO_ACCESS_CHECK|OP_FLAG_INTERNAL|OP_FLAG_REPLICATED|OP_FLAG_LEGACY_REPLICATION_DN)) + if (operation_is_flag_set(operation, SLAPI_OP_FLAG_NO_ACCESS_CHECK|OP_FLAG_INTERNAL|OP_FLAG_REPLICATED)) return LDAP_SUCCESS; /* call the global plugins first and then the backend specific */ @@ -81,7 +81,7 @@ plugin_call_acl_mods_access ( Slapi_PBlock *pb, Slapi_Entry *e, LDAPMod **mods, slapi_pblock_get (pb, SLAPI_OPERATION, &operation); /* we don't perform acl check for internal operations and if the plugin has set it not to be checked */ - if (operation_is_flag_set(operation, SLAPI_OP_FLAG_NO_ACCESS_CHECK|OP_FLAG_INTERNAL|OP_FLAG_REPLICATED|OP_FLAG_LEGACY_REPLICATION_DN)) + if (operation_is_flag_set(operation, SLAPI_OP_FLAG_NO_ACCESS_CHECK|OP_FLAG_INTERNAL|OP_FLAG_REPLICATED)) return LDAP_SUCCESS; /* call the global plugins first and then the backend specific */ @@ -179,7 +179,7 @@ plugin_call_acl_verify_syntax ( Slapi_PBlock *pb, Slapi_Entry *e, char **errbuf slapi_pblock_get (pb, SLAPI_OPERATION, &operation); /* we don't perform acl check for internal operations and if the plugin has set it not to be checked */ - if (operation_is_flag_set(operation, SLAPI_OP_FLAG_NO_ACCESS_CHECK|OP_FLAG_INTERNAL|OP_FLAG_REPLICATED|OP_FLAG_LEGACY_REPLICATION_DN)) + if (operation_is_flag_set(operation, SLAPI_OP_FLAG_NO_ACCESS_CHECK|OP_FLAG_INTERNAL|OP_FLAG_REPLICATED)) return LDAP_SUCCESS; /* call the global plugins first and then the backend specific */ diff --git a/ldap/servers/slapd/search.c b/ldap/servers/slapd/search.c index 7b2b462..0d51923 100644 --- a/ldap/servers/slapd/search.c +++ b/ldap/servers/slapd/search.c @@ -204,22 +204,6 @@ do_search( Slapi_PBlock *pb ) goto free_and_return; } - /* - * This search is performed against the legacy consumer, so ask explicitly - * for the aci attribute as it is an operational in 5.0 - */ - if ( operation->o_flags & OP_FLAG_LEGACY_REPLICATION_DN ) - { - /* If attrs==NULL in a 4.x request, means that we want all the attributes, as aci is - * now operational, we need to ask it explicilty as well as all the attributes - */ - if ( (attrs == NULL) || (attrs[0] == NULL) ) - { - charray_add(&attrs, slapi_attr_syntax_normalize("aci")); - charray_add(&attrs, slapi_attr_syntax_normalize(LDAP_ALL_USER_ATTRS)); - } - } - if ( attrs != NULL ) { char *normaci = slapi_attr_syntax_normalize("aci"); int replace_aci = 0; diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h index 09fef07..bf3fa3f 100644 --- a/ldap/servers/slapd/slapi-plugin.h +++ b/ldap/servers/slapd/slapi-plugin.h @@ -6989,7 +6989,6 @@ slapi_timer_result slapi_timespec_expire_check(struct timespec *expire); #define SLAPI_OPERATION_SSF 750 #define SLAPI_IS_REPLICATED_OPERATION 142 #define SLAPI_IS_MMR_REPLICATED_OPERATION 153 -#define SLAPI_IS_LEGACY_REPLICATED_OPERATION 154 #define SLAPI_SKIP_MODIFIED_ATTRS 155 /* connection */ diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h index a48fe6a..52d908d 100644 --- a/ldap/servers/slapd/slapi-private.h +++ b/ldap/servers/slapd/slapi-private.h @@ -403,9 +403,6 @@ char *slapi_filter_to_string_internal( const struct slapi_filter *f, char *buf, #define OP_FLAG_NEVER_CHAIN SLAPI_OP_FLAG_NEVER_CHAIN /* 0x000800 */ #define OP_FLAG_TOMBSTONE_ENTRY SLAPI_OP_FLAG_TOMBSTONE_ENTRY /* 0x001000 */ #define OP_FLAG_RESURECT_ENTRY 0x002000 -#define OP_FLAG_LEGACY_REPLICATION_DN 0x004000 /* Operation done by legacy - * replication DN - */ #define OP_FLAG_ACTION_NOLOG 0x008000 /* Do not log the entry in * audit log or change log */ diff --git a/test/libslapd/pblock/pblock_accessors.txt b/test/libslapd/pblock/pblock_accessors.txt index a5e00d8..8a4805d 100644 --- a/test/libslapd/pblock/pblock_accessors.txt +++ b/test/libslapd/pblock/pblock_accessors.txt @@ -66,7 +66,6 @@ SLAPI_EXT_OP_REQ_OID SLAPI_EXT_OP_REQ_VALUE SLAPI_EXT_OP_RET_OID SLAPI_EXT_OP_RET_VALUE -SLAPI_IS_LEGACY_REPLICATED_OPERATION SLAPI_IS_MMR_REPLICATED_OPERATION SLAPI_IS_REPLICATED_OPERATION SLAPI_LDIF2DB_ENCRYPT diff --git a/test/libslapd/pblock/pblock_accessors_freq.txt b/test/libslapd/pblock/pblock_accessors_freq.txt index b98f848..cb3b5ef 100644 --- a/test/libslapd/pblock/pblock_accessors_freq.txt +++ b/test/libslapd/pblock/pblock_accessors_freq.txt @@ -134,8 +134,6 @@ SLAPI_EXT_OP_RET_OID 18 SLAPI_EXT_OP_RET_VALUE 19 -SLAPI_IS_LEGACY_REPLICATED_OPERATION -7 SLAPI_IS_MMR_REPLICATED_OPERATION 7 SLAPI_IS_REPLICATED_OPERATION -- 2.9.4