From 1eec9a9887f617de287a3e939d021af7bc1c0cd6 Mon Sep 17 00:00:00 2001 From: Mark Reynolds Date: Thu, 12 Oct 2017 16:44:47 -0400 Subject: [PATCH] Ticket 48006 - Missing warning for invalid replica backoff configuration Description: Add warning if you try to set a min backoff time that is greater than the configured maximum, or the max time that is less than the minimum. https://pagure.io/389-ds-base/issue/48006 Reviewed by: ? --- .../plugins/replication/repl5_replica_config.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ldap/servers/plugins/replication/repl5_replica_config.c b/ldap/servers/plugins/replication/repl5_replica_config.c index f28044c..3597cf9 100644 --- a/ldap/servers/plugins/replication/repl5_replica_config.c +++ b/ldap/servers/plugins/replication/repl5_replica_config.c @@ -466,6 +466,7 @@ replica_config_modify(Slapi_PBlock *pb, } else if (strcasecmp(config_attr, type_replicaBackoffMin) == 0) { if (apply_mods) { PRUint64 val = atoll(config_attr_value); + PRUint64 max; if (val <= 0) { *returncode = LDAP_UNWILLING_TO_PERFORM; @@ -475,11 +476,21 @@ replica_config_modify(Slapi_PBlock *pb, slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "replica_config_modify - %s\n", errortext); break; } + max = replica_get_backoff_max(r); + if (val > max){ + *returncode = LDAP_UNWILLING_TO_PERFORM; + PR_snprintf(errortext, SLAPI_DSE_RETURNTEXT_SIZE, + "Attribute %s value (%s) is invalid, must be a number less than the max backoff time (%d).\n", + config_attr, config_attr_value, (int)max); + slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "replica_config_modify - %s\n", errortext); + break; + } replica_set_backoff_min(r, val); } } else if (strcasecmp(config_attr, type_replicaBackoffMax) == 0) { if (apply_mods) { PRUint64 val = atoll(config_attr_value); + PRUint64 min; if (val <= 0) { *returncode = LDAP_UNWILLING_TO_PERFORM; @@ -490,6 +501,15 @@ replica_config_modify(Slapi_PBlock *pb, errortext); break; } + min = replica_get_backoff_min(r); + if (val < min) { + *returncode = LDAP_UNWILLING_TO_PERFORM; + PR_snprintf(errortext, SLAPI_DSE_RETURNTEXT_SIZE, + "Attribute %s value (%s) is invalid, must be a number more than the min backoff time (%d).\n", + config_attr, config_attr_value, (int)min); + slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "replica_config_modify - %s\n", errortext); + break; + } replica_set_backoff_max(r, val); } } else if (strcasecmp(config_attr, type_replicaPrecisePurge) == 0) { -- 2.9.5