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