#50910 Issue 50909 - nsDS5ReplicaId cant be set to the old value it had before
Closed 3 years ago by spichugi. Opened 4 years ago by mreynolds.
mreynolds/389-ds-base issue50909  into  master

@@ -43,7 +43,7 @@ 

  

  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'),

@@ -461,7 +461,7 @@ 

                      }

                  } 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 @@ 

  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 @@ 

  

      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) {

@@ -1189,9 +1189,6 @@ 

      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)")

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 cases 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

Except the minor comment, the patch looks also valid to me. Ack

rebased onto e66b946db692e97c1e629545c951228e2155ce23

4 years ago

rebased onto ea4fa54

4 years ago

Pull-Request has been merged by mreynolds

4 years ago

389-ds-base is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in 389-ds-base's github repository.

This pull request has been cloned to Github as issue and is available here:
- https://github.com/389ds/389-ds-base/issues/3963

If you want to continue to work on the PR, please navigate to the github issue,
download the patch from the attachments and file a new pull request.

Thank you for understanding. We apologize for all inconvenience.

Pull-Request has been closed by spichugi

3 years ago