Tuesday, February 25, 2020

[389-commits] [389-ds-base] branch 389-ds-base-1.4.1 updated: Issue 50909 - nsDS5ReplicaId cant be set to the old value it had before

This is an automated email from the git hooks/post-receive script.

mreynolds pushed a commit to branch 389-ds-base-1.4.1
in repository 389-ds-base.

The following commit(s) were added to refs/heads/389-ds-base-1.4.1 by this push:
new 074dac5 Issue 50909 - nsDS5ReplicaId cant be set to the old value it had before
074dac5 is described below

commit 074dac5172e775868cb1a89e36fd5da47045a036
Author: Mark Reynolds <mreynolds@redhat.com>
AuthorDate: Mon Feb 24 15:32:03 2020 -0500

Issue 50909 - nsDS5ReplicaId cant be set to the old value it had before

Bug Description: We were not handling the process of changing the replica
type and id correctly. For one, we were not correctly
handling a change to a hub/consumer, but it just happened
to work by accident in most cases. In other caes you
could not change the rid more than once.

Fix Description: Changed the value checking to allow ID changes to 65535
which allowed the type/id pointers to be set correctly.
Then the checking of the type & ID change combination had
to be revised.

Also, removed the option to get just set the RID or type
from dsconf. Only replication promotion/demotion should
be touching these values.

relates: https://pagure.io/389-ds-base/issue/50909

Reviewed by: firstyear & tbordaz(Thanks!!)

(cherry picked from commit ea4fa549e6daeba648ce11c8c2ce4e7688ffab7b)
---
.../suites/replication/replica_config_test.py | 2 +-
.../plugins/replication/repl5_replica_config.c | 22 +++++++++++-----------
src/lib389/lib389/cli_conf/replication.py | 3 ---
3 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/dirsrvtests/tests/suites/replication/replica_config_test.py b/dirsrvtests/tests/suites/replication/replica_config_test.py
index 599f6ac..14267a2 100644
--- a/dirsrvtests/tests/suites/replication/replica_config_test.py
+++ b/dirsrvtests/tests/suites/replication/replica_config_test.py
@@ -43,7 +43,7 @@ agmt_dict = {'cn': 'test_agreement',

repl_add_attrs = [('nsDS5ReplicaType', '-1', '4', overflow, notnum, '1'),
('nsDS5Flags', '-1', '2', overflow, notnum, '1'),
- ('nsDS5ReplicaId', '0', '65535', overflow, notnum, '1'),
+ ('nsDS5ReplicaId', '0', '65536', overflow, notnum, '1'),
('nsds5ReplicaPurgeDelay', '-2', too_big, overflow, notnum, '1'),
('nsDS5ReplicaBindDnGroupCheckInterval', '-2', too_big, overflow, notnum, '1'),
('nsds5ReplicaTombstonePurgeInterval', '-2', too_big, overflow, notnum, '1'),
diff --git a/ldap/servers/plugins/replication/repl5_replica_config.c b/ldap/servers/plugins/replication/repl5_replica_config.c
index 02b36f6..d64d4bf 100644
--- a/ldap/servers/plugins/replication/repl5_replica_config.c
+++ b/ldap/servers/plugins/replication/repl5_replica_config.c
@@ -461,7 +461,7 @@ replica_config_modify(Slapi_PBlock *pb,
}
} else if (strcasecmp(config_attr, attr_replicaId) == 0) {
int64_t rid = 0;
- if (repl_config_valid_num(config_attr, config_attr_value, 1, 65534, returncode, errortext, &rid) == 0) {
+ if (repl_config_valid_num(config_attr, config_attr_value, 1, MAX_REPLICA_ID, returncode, errortext, &rid) == 0) {
slapi_ch_free_string(&new_repl_id);
new_repl_id = slapi_ch_strdup(config_attr_value);
} else {
@@ -890,7 +890,7 @@ replica_config_search(Slapi_PBlock *pb,
static int
replica_config_change_type_and_id(Replica *r, const char *new_type, const char *new_id, char *returntext, int apply_mods)
{
- int type;
+ int type = REPLICA_TYPE_READONLY; /* by default - replica is read-only */
ReplicaType oldtype;
ReplicaId rid;
ReplicaId oldrid;
@@ -899,21 +899,21 @@ replica_config_change_type_and_id(Replica *r, const char *new_type, const char *

oldtype = replica_get_type(r);
oldrid = replica_get_rid(r);
- if (new_type == NULL) /* by default - replica is read-only */
- {
- type = REPLICA_TYPE_READONLY;
+ if (new_type == NULL) {
+ if (oldtype) {
+ type = oldtype;
+ }
} else {
type = atoi(new_type);
if (type <= REPLICA_TYPE_UNKNOWN || type >= REPLICA_TYPE_END) {
PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE, "invalid replica type %d", type);
return LDAP_OPERATIONS_ERROR;
}
- }
-
- /* disallow changing type to itself just to permit a replica ID change */
- if (oldtype == type) {
- PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE, "replica type is already %d - not changing", type);
- return LDAP_OPERATIONS_ERROR;
+ /* disallow changing type to itself just to permit a replica ID change */
+ if (oldtype == type) {
+ PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE, "replica type is already %d - not changing", type);
+ return LDAP_OPERATIONS_ERROR;
+ }
}

if (type == REPLICA_TYPE_READONLY) {
diff --git a/src/lib389/lib389/cli_conf/replication.py b/src/lib389/lib389/cli_conf/replication.py
index 7acbb33..1c0c925 100644
--- a/src/lib389/lib389/cli_conf/replication.py
+++ b/src/lib389/lib389/cli_conf/replication.py
@@ -1189,9 +1189,6 @@ def create_parser(subparsers):
repl_set_parser = repl_subcommands.add_parser('set', help='Set an attribute in the replication configuration')
repl_set_parser.set_defaults(func=set_repl_config)
repl_set_parser.add_argument('--suffix', required=True, help='The DN of the replication suffix')
- repl_set_parser.add_argument('--replica-id', help="The Replication Identifier number")
- repl_set_parser.add_argument('--replica-role', help="The Replication role: master, hub, or consumer")
-
repl_set_parser.add_argument('--repl-add-bind-dn', help="Add a bind (supplier) DN")
repl_set_parser.add_argument('--repl-del-bind-dn', help="Remove a bind (supplier) DN")
repl_set_parser.add_argument('--repl-add-ref', help="Add a replication referral (for consumers only)")

--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
389-commits mailing list -- 389-commits@lists.fedoraproject.org
To unsubscribe send an email to 389-commits-leave@lists.fedoraproject.org
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/389-commits@lists.fedoraproject.org

No comments:

Post a Comment