From: pcarana Date: Thu, 6 Feb 2020 23:50:47 +0000 (-0600) Subject: Fix bug: complete compatibility of 'sync-strategy' with 'rsync.strategy' X-Git-Tag: v1.2.0~4 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=d9d632653ee6152887476319e928d3da0a0aa0b4;p=thirdparty%2FFORT-validator.git Fix bug: complete compatibility of 'sync-strategy' with 'rsync.strategy' --- diff --git a/src/config.c b/src/config.c index 42878630..453c2091 100644 --- a/src/config.c +++ b/src/config.c @@ -833,6 +833,10 @@ validate_config(void) if (rpki_config.slurm != NULL && !valid_file_or_dir(rpki_config.slurm)) return pr_err("Invalid slurm location."); + /* FIXME (later) Remove when sync-strategy is fully deprecated */ + if (!rpki_config.rsync.enabled) + config_set_sync_strategy(RSYNC_OFF); + return 0; } @@ -1196,6 +1200,18 @@ config_set_rrdp_enabled(bool value) rpki_config.rrdp.enabled = value; } +void +config_set_sync_strategy(enum rsync_strategy value) +{ + rpki_config.sync_strategy = value; +} + +void +config_set_rsync_strategy(enum rsync_strategy value) +{ + rpki_config.rsync.strategy = value; +} + void free_rpki_config(void) { diff --git a/src/config.h b/src/config.h index b64b867d..a15f1774 100644 --- a/src/config.h +++ b/src/config.h @@ -62,6 +62,10 @@ unsigned int config_get_asn1_decode_max_stack(void); void config_set_rsync_enabled(bool); void config_set_rrdp_enabled(bool); +/* FIXME (later) Remove when sync-strategy is fully deprecated */ +void config_set_sync_strategy(enum rsync_strategy); +void config_set_rsync_strategy(enum rsync_strategy); + /* Needed public by the JSON module */ void *get_rpki_config_field(struct option_field const *); struct option_field const *get_option_metadatas(void); diff --git a/src/config/rsync_strategy.c b/src/config/rsync_strategy.c index 5ca6a9bf..34dd815f 100644 --- a/src/config/rsync_strategy.c +++ b/src/config/rsync_strategy.c @@ -4,6 +4,7 @@ #include #include +#include "config.h" #include "log.h" #include "config/str.h" @@ -59,6 +60,9 @@ parse_argv_rsync_strategy(struct option_field const *field, char const *str, return pr_err("Unknown rsync synchronization strategy: '%s'", str); + /* FIXME (later) Remove when sync-strategy is fully deprecated */ + config_set_sync_strategy(DEREFERENCE(result)); + return 0; } diff --git a/src/config/sync_strategy.c b/src/config/sync_strategy.c index 4ea69c3e..146f7adf 100644 --- a/src/config/sync_strategy.c +++ b/src/config/sync_strategy.c @@ -46,6 +46,8 @@ static int parse_argv_sync_strategy(struct option_field const *field, char const *str, void *result) { + int error; + pr_warn("'sync-strategy' will be deprecated."); pr_warn("Use 'rsync.strategy' instead; or 'rsync.enabled=false' if you wish to use 'off' strategy."); @@ -55,7 +57,10 @@ parse_argv_sync_strategy(struct option_field const *field, char const *str, return 0; } - return parse_argv_rsync_strategy(field, str, result); + error = parse_argv_rsync_strategy(field, str, result); + if (!error) + config_set_rsync_strategy(DEREFERENCE(result)); + return error; } static int