Blame SOURCES/0058-Ticket-49541-repl-config-should-not-allow-rid-65535-.patch

b045b9
From 38ca528af83f1874a79ad6744215bd4af1404414 Mon Sep 17 00:00:00 2001
b045b9
From: Mark Reynolds <mreynolds@redhat.com>
b045b9
Date: Thu, 18 Jan 2018 13:17:08 -0500
b045b9
Subject: [PATCH] Ticket 49541 - repl config should not allow rid 65535 for
b045b9
 masters
b045b9
b045b9
Description:  Reject adding a replica config entry with a rid of 65535 or higher,
b045b9
              and prevent setting master's rid to 65535 or higher.
b045b9
b045b9
https://pagure.io/389-ds-base/issue/49541
b045b9
b045b9
Reviewed by: mreynolds(one line commit rule)
b045b9
b045b9
(cherry picked from commit ebb00a4180693225cf3c2f4aced54dc33141fa77)
b045b9
---
b045b9
 dirsrvtests/tests/suites/replication/replica_config_test.py | 9 +++++----
b045b9
 ldap/servers/plugins/replication/repl5_replica.c            | 2 +-
b045b9
 2 files changed, 6 insertions(+), 5 deletions(-)
b045b9
b045b9
diff --git a/dirsrvtests/tests/suites/replication/replica_config_test.py b/dirsrvtests/tests/suites/replication/replica_config_test.py
b045b9
index 50ea2ece9..143a12479 100644
b045b9
--- a/dirsrvtests/tests/suites/replication/replica_config_test.py
b045b9
+++ b/dirsrvtests/tests/suites/replication/replica_config_test.py
b045b9
@@ -24,7 +24,7 @@ replica_dict = {'objectclass': 'top nsDS5Replica'.split(),
b045b9
                 'nsDS5ReplicaRoot': 'dc=example,dc=com',
b045b9
                 'nsDS5ReplicaType': '3',
b045b9
                 'nsDS5Flags': '1',
b045b9
-                'nsDS5ReplicaId': '65535',
b045b9
+                'nsDS5ReplicaId': '65534',
b045b9
                 'nsds5ReplicaPurgeDelay': '604800',
b045b9
                 'nsDS5ReplicaBindDN': 'cn=u',
b045b9
                 'cn': 'replica'}
b045b9
@@ -42,7 +42,7 @@ agmt_dict = {'objectClass': 'top nsDS5ReplicationAgreement'.split(),
b045b9
 
b045b9
 repl_add_attrs = [('nsDS5ReplicaType', '-1', '4', overflow, notnum, '1'),
b045b9
                   ('nsDS5Flags', '-1', '2', overflow, notnum, '1'),
b045b9
-                  ('nsDS5ReplicaId', '0', '65536', overflow, notnum, '1'),
b045b9
+                  ('nsDS5ReplicaId', '0', '65535', overflow, notnum, '1'),
b045b9
                   ('nsds5ReplicaPurgeDelay', '-2', too_big, overflow, notnum, '1'),
b045b9
                   ('nsDS5ReplicaBindDnGroupCheckInterval', '-2', too_big, overflow, notnum, '1'),
b045b9
                   ('nsds5ReplicaTombstonePurgeInterval', '-2', too_big, overflow, notnum, '1'),
b045b9
@@ -60,7 +60,8 @@ repl_mod_attrs = [('nsDS5Flags', '-1', '2', overflow, notnum, '1'),
b045b9
                   ('nsds5ReplicaBackoffMin', '0', too_big, overflow, notnum, '3'),
b045b9
                   ('nsds5ReplicaBackoffMax', '0', too_big, overflow, notnum, '6')]
b045b9
 
b045b9
-agmt_attrs = [('nsds5ReplicaPort', '0', '65536', overflow, notnum, '389'),
b045b9
+agmt_attrs = [
b045b9
+              ('nsds5ReplicaPort', '0', '65535', overflow, notnum, '389'),
b045b9
               ('nsds5ReplicaTimeout', '-1', too_big, overflow, notnum, '6'),
b045b9
               ('nsds5ReplicaBusyWaitTime', '-1', too_big, overflow, notnum, '6'),
b045b9
               ('nsds5ReplicaSessionPauseTime', '-1', too_big, overflow, notnum, '6'),
b045b9
@@ -393,5 +394,5 @@ if __name__ == '__main__':
b045b9
     # Run isolated
b045b9
     # -s for DEBUG mode
b045b9
     CURRENT_FILE = os.path.realpath(__file__)
b045b9
-    pytest.main("-s %s" % CURRENT_FILE)
b045b9
+    pytest.main(["-s", CURRENT_FILE])
b045b9
 
b045b9
diff --git a/ldap/servers/plugins/replication/repl5_replica.c b/ldap/servers/plugins/replication/repl5_replica.c
b045b9
index e75807a62..bdb8a5167 100644
b045b9
--- a/ldap/servers/plugins/replication/repl5_replica.c
b045b9
+++ b/ldap/servers/plugins/replication/repl5_replica.c
b045b9
@@ -1988,7 +1988,7 @@ _replica_init_from_config(Replica *r, Slapi_Entry *e, char *errortext)
b045b9
              r->repl_type == REPLICA_TYPE_PRIMARY) {
b045b9
         if ((val = slapi_entry_attr_get_charptr(e, attr_replicaId))) {
b045b9
             int64_t rid;
b045b9
-            if (repl_config_valid_num(attr_replicaId, val, 1, 65535, &rc, errormsg, &rid) != 0) {
b045b9
+            if (repl_config_valid_num(attr_replicaId, val, 1, 65534, &rc, errormsg, &rid) != 0) {
b045b9
                 slapi_ch_free_string(&val;;
b045b9
                 return -1;
b045b9
             }
b045b9
-- 
b045b9
2.13.6
b045b9