From b6404ec81920c0ee8397cabedc90159795f38ed8 Mon Sep 17 00:00:00 2001 From: Alberto Leiva Popper Date: Tue, 27 Jun 2023 16:21:26 -0600 Subject: [PATCH] Remove obsolete config options - sync-strategy - rrdp.enabled - rrdp.priority - rrdp.retry.count - rrdp.retry.interval - http.idle-timeout These were deprecated long ago. --- src/Makefile.am | 2 - src/config.c | 149 +------------------------ src/config.h | 19 +--- src/config/rrdp_conf.c | 209 ------------------------------------ src/config/rrdp_conf.h | 11 -- src/config/rsync_strategy.c | 9 +- src/config/rsync_strategy.h | 18 ---- src/config/sync_strategy.c | 87 --------------- src/config/sync_strategy.h | 8 -- src/config/work_offline.c | 2 - src/rsync/rsync.c | 2 - 11 files changed, 9 insertions(+), 507 deletions(-) delete mode 100644 src/config/rrdp_conf.c delete mode 100644 src/config/rrdp_conf.h delete mode 100644 src/config/sync_strategy.c delete mode 100644 src/config/sync_strategy.h diff --git a/src/Makefile.am b/src/Makefile.am index d657f4d6..2dc0519d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -55,11 +55,9 @@ fort_SOURCES += config/mode.c config/mode.h fort_SOURCES += config/incidences.h config/incidences.c fort_SOURCES += config/output_format.h config/output_format.c fort_SOURCES += config/init_tals.h config/init_tals.c -fort_SOURCES += config/rrdp_conf.h config/rrdp_conf.c fort_SOURCES += config/rsync_strategy.h config/rsync_strategy.c fort_SOURCES += config/str.c config/str.h fort_SOURCES += config/string_array.h config/string_array.c -fort_SOURCES += config/sync_strategy.h config/sync_strategy.c fort_SOURCES += config/types.h fort_SOURCES += config/uint.c config/uint.h fort_SOURCES += config/uint32.c config/uint32.h diff --git a/src/config.c b/src/config.c index c283200e..7900c438 100644 --- a/src/config.c +++ b/src/config.c @@ -19,9 +19,7 @@ #include "config/boolean.h" #include "config/incidences.h" #include "config/init_tals.h" -#include "config/rrdp_conf.h" #include "config/str.h" -#include "config/sync_strategy.h" #include "config/uint.h" #include "config/uint32.h" #include "config/work_offline.h" @@ -41,8 +39,6 @@ struct rpki_config { char *tal; /** Path of our local clone of the repository */ char *local_repository; - /** TODO (later) Deprecated, remove it. RSYNC download strategy. */ - enum rsync_strategy sync_strategy; /** * Handle TAL URIs in random order? * (https://tools.ietf.org/html/rfc8630#section-3, last @@ -110,23 +106,6 @@ struct rpki_config { } args; } rsync; - struct { - /* Enables the protocol */ - bool enabled; - /* - * Priority, this will override the order set at the CAs in - * their accessMethod extension. - */ - unsigned int priority; - /* Retry conf, utilized on errors */ - struct { - /* Maximum number of retries on error */ - unsigned int count; - /* Interval (in seconds) between each retry */ - unsigned int interval; - } retry; - } rrdp; - struct { /* Enables the protocol */ bool enabled; @@ -305,12 +284,6 @@ static const struct option_field options[] = { .offset = offsetof(struct rpki_config, local_repository), .doc = "Directory where the repository local cache will be stored/read", .arg_doc = "", - }, { - .id = 1001, - .name = "sync-strategy", - .type = >_sync_strategy, - .offset = offsetof(struct rpki_config, sync_strategy), - .doc = "RSYNC download strategy. Deprecated; use 'rsync.strategy' instead.", }, { .id = 2001, .name = "shuffle-uris", @@ -467,7 +440,7 @@ static const struct option_field options[] = { }, { .id = 3001, .name = "rsync.priority", - .type = >_uint32, + .type = >_uint32, /* TODO (#78) this is not u32 */ .offset = offsetof(struct rpki_config, rsync.priority), .doc = "Priority of execution to fetch repositories files, a higher value means higher priority", .min = 0, @@ -522,50 +495,17 @@ static const struct option_field options[] = { .max = 0, }, - /* RRDP fields */ - { - .id = 10000, - .name = "rrdp.enabled", - .type = >_rrdp_enabled, - .offset = offsetof(struct rpki_config, rrdp.enabled), - .doc = "Enables RRDP execution. Deprecated; use 'http.enabled' instead.", - }, { - .id = 10001, - .name = "rrdp.priority", - .type = >_rrdp_priority, - .offset = offsetof(struct rpki_config, rrdp.priority), - .doc = "Priority of execution to fetch repositories files, a higher value means higher priority. Deprecated; use 'http.priority' instead.", - .min = 0, - .max = 100, - }, { - .id = 10002, - .name = "rrdp.retry.count", - .type = >_rrdp_retry_count, - .offset = offsetof(struct rpki_config, rrdp.retry.count), - .doc = "Maximum amount of retries whenever there's an error fetching RRDP files. Deprecated; use 'http.retry.count' instead.", - .min = 0, - .max = UINT_MAX, - }, { - .id = 10003, - .name = "rrdp.retry.interval", - .type = >_rrdp_retry_interval, - .offset = offsetof(struct rpki_config, rrdp.retry.interval), - .doc = "Period (in seconds) to wait between retries after an error ocurred fetching RRDP files. Deprecated; use 'http.retry.interval' instead.", - .min = 0, - .max = UINT_MAX, - }, - /* HTTP requests parameters */ { .id = 9000, .name = "http.enabled", - .type = >_rrdp_enabled, + .type = >_bool, .offset = offsetof(struct rpki_config, http.enabled), .doc = "Enables outgoing HTTP requests", }, { .id = 9001, .name = "http.priority", - .type = >_rrdp_priority, + .type = >_uint, .offset = offsetof(struct rpki_config, http.priority), .doc = "Priority of execution to fetch repositories files, a higher value means higher priority", .min = 0, @@ -573,7 +513,7 @@ static const struct option_field options[] = { }, { .id = 9002, .name = "http.retry.count", - .type = >_rrdp_retry_count, + .type = >_uint, .offset = offsetof(struct rpki_config, http.retry.count), .doc = "Maximum amount of retries whenever there's an error requesting HTTP URIs", .min = 0, @@ -581,7 +521,7 @@ static const struct option_field options[] = { }, { .id = 9003, .name = "http.retry.interval", - .type = >_rrdp_retry_interval, + .type = >_uint, .offset = offsetof(struct rpki_config, http.retry.interval), .doc = "Period (in seconds) to wait between retries after an error ocurred doing HTTP requests", .min = 0, @@ -608,14 +548,6 @@ static const struct option_field options[] = { .doc = "Maximum transfer time (once the connection is established) before dropping the connection", .min = 0, .max = UINT_MAX, - }, { - .id = 9007, - .name = "http.idle-timeout", /* TODO DEPRECATED. */ - .type = >_uint, - .offset = offsetof(struct rpki_config, http.low_speed_time), - .doc = "Deprecated; currently an alias for --http.low-speed-time. Use --http.low-speed-time instead.", - .min = 0, - .max = UINT_MAX, }, { .id = 9009, .name = "http.low-speed-limit", @@ -994,7 +926,6 @@ set_default_values(void) rpki_config.tal = NULL; rpki_config.local_repository = pstrdup("/tmp/fort/repository"); - rpki_config.sync_strategy = RSYNC_ROOT_EXCEPT_TA; rpki_config.shuffle_tal_uris = false; rpki_config.maximum_certificate_depth = 32; rpki_config.slurm = NULL; @@ -1026,15 +957,6 @@ set_default_values(void) rpki_config.http.max_file_size = 1000000000; rpki_config.http.ca_path = NULL; /* Use system default */ - /* - * TODO (later) Same values as http.*, delete when rrdp.* is fully - * deprecated - */ - rpki_config.rrdp.enabled = rpki_config.http.enabled; - rpki_config.rrdp.priority = rpki_config.http.priority; - rpki_config.rrdp.retry.count = rpki_config.http.retry.count; - rpki_config.rrdp.retry.interval = rpki_config.http.retry.interval; - rpki_config.log.enabled = true; rpki_config.log.tag = NULL; rpki_config.log.color = false; @@ -1102,10 +1024,6 @@ validate_config(void) !valid_file_or_dir(rpki_config.slurm, true, true, pr_op_err)) return pr_op_err("Invalid slurm location."); - /* TODO (later) Remove when sync-strategy is fully deprecated */ - if (!rpki_config.rsync.enabled) - config_set_sync_strategy(RSYNC_OFF); - return 0; } @@ -1588,60 +1506,3 @@ free_rpki_config(void) if (is_rpki_config_field(option) && option->type->free != NULL) option->type->free(get_rpki_config_field(option)); } - -/* - * "To be deprecated" section - */ -void -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 -config_set_rrdp_priority(unsigned int value) -{ - rpki_config.rrdp.priority = value; -} - -void -config_set_http_priority(unsigned int value) -{ - rpki_config.http.priority = value; -} - -void -config_set_rrdp_retry_count(unsigned int value) -{ - rpki_config.rrdp.retry.count = value; -} - -void -config_set_http_retry_count(unsigned int value) -{ - rpki_config.http.retry.count = value; -} - -void -config_set_rrdp_retry_interval(unsigned int value) -{ - rpki_config.rrdp.retry.interval = value; -} - -void -config_set_http_retry_interval(unsigned int value) -{ - rpki_config.http.retry.interval = value; -} diff --git a/src/config.h b/src/config.h index 2fa38477..cfc4b933 100644 --- a/src/config.h +++ b/src/config.h @@ -74,26 +74,9 @@ uint8_t config_get_val_log_level(void); enum log_output config_get_val_log_output(void); uint32_t config_get_val_log_facility(void); -/* - * Public, so that work-offline can set them, or (to be deprecated) - * sync-strategy when set to 'off'. - */ +/* Public, so --work-offline can override them. */ void config_set_rsync_enabled(bool); void config_set_http_enabled(bool); -/* TODO (later) Deprecated */ -void config_set_rrdp_enabled(bool); - -/* TODO (later) Remove when sync-strategy is fully deprecated */ -void config_set_sync_strategy(enum rsync_strategy); -void config_set_rsync_strategy(enum rsync_strategy); - -/* TODO (later) Remove once rrdp.* is fully deprecated */ -void config_set_rrdp_priority(unsigned int); -void config_set_http_priority(unsigned int); -void config_set_rrdp_retry_count(unsigned int); -void config_set_http_retry_count(unsigned int); -void config_set_rrdp_retry_interval(unsigned int); -void config_set_http_retry_interval(unsigned int); /* Needed public by the JSON module */ void *get_rpki_config_field(struct option_field const *); diff --git a/src/config/rrdp_conf.c b/src/config/rrdp_conf.c deleted file mode 100644 index cbc509cc..00000000 --- a/src/config/rrdp_conf.c +++ /dev/null @@ -1,209 +0,0 @@ -#include "config/rrdp_conf.h" - -#include -#include -#include -#include "config.h" -#include "log.h" -#include "config/boolean.h" -#include "config/uint.h" -#include "config/uint32.h" - -/* - * Note that this is just a wrapper to set rrdp.* arguments and its equivalent - * http.* args. - * - * TODO (later) This wrapper will live until all rrdp.* args are fully - * deprecated. - */ - -#define DEREFERENCE_BOOL(void_value) (*((bool *) void_value)) -#define DEREFERENCE_UINT32(void_value) (*((uint32_t *) void_value)) -#define DEREFERENCE_UINT(void_value) (*((unsigned int *) void_value)) - -static int -set_rrdp_enabled(char const *name, bool value) -{ - /* Warn about future deprecation */ - if (strcmp(name, "rrdp.enabled") == 0) - pr_op_warn("'rrdp.enabled' is deprecated; use 'http.enabled' instead."); - - config_set_rrdp_enabled(value); - config_set_http_enabled(value); - return 0; -} - -static int -set_priority(char const *name, uint32_t value) -{ - /* Warn about future deprecation */ - if (strcmp(name, "rrdp.priority") == 0) - pr_op_warn("'rrdp.priority' is deprecated; use 'http.priority' instead."); - - config_set_rrdp_priority(value); - config_set_http_priority(value); - return 0; -} - -static int -set_retry_count(char const *name, unsigned int value) -{ - /* Warn about future deprecation */ - if (strcmp(name, "rrdp.retry.count") == 0) - pr_op_warn("'rrdp.retry.count' is deprecated; use 'http.retry.count' instead."); - - config_set_rrdp_retry_count(value); - config_set_http_retry_count(value); - return 0; -} - -static int -set_retry_interval(char const *name, unsigned int value) -{ - /* Warn about future deprecation */ - if (strcmp(name, "rrdp.retry.interval") == 0) - pr_op_warn("'rrdp.retry.interval' is deprecated; use 'http.retry.interval' instead."); - - config_set_rrdp_retry_interval(value); - config_set_http_retry_interval(value); - return 0; -} - -int -parse_argv_enabled(struct option_field const *field, char const *str, - void *result) -{ - int error; - - error = parse_argv_bool(field, str, result); - if (error) - return error; - - return set_rrdp_enabled(field->name, DEREFERENCE_BOOL(result)); -} - -int -parse_json_enabled(struct option_field const *opt, struct json_t *json, - void *result) -{ - int error; - - error = parse_json_bool(opt, json, result); - if (error) - return error; - - return set_rrdp_enabled(opt->name, DEREFERENCE_BOOL(result)); -} - -int -parse_argv_priority(struct option_field const *field, char const *str, - void *result) -{ - int error; - - error = parse_argv_uint32(field, str, result); - if (error) - return error; - - return set_priority(field->name, DEREFERENCE_UINT32(result)); -} - -int -parse_json_priority(struct option_field const *opt, json_t *json, void *result) -{ - int error; - - error = parse_json_uint32(opt, json, result); - if (error) - return error; - - return set_priority(opt->name, DEREFERENCE_UINT32(result)); -} - -int -parse_argv_retry_count(struct option_field const *field, char const *str, - void *result) -{ - int error; - - error = parse_argv_uint(field, str, result); - if (error) - return error; - - return set_retry_count(field->name, DEREFERENCE_UINT(result)); -} - -int -parse_json_retry_count(struct option_field const *opt, json_t *json, - void *result) -{ - int error; - - error = parse_json_uint(opt, json, result); - if (error) - return error; - - return set_retry_count(opt->name, DEREFERENCE_UINT(result)); -} - -int -parse_argv_retry_interval(struct option_field const *field, char const *str, - void *result) -{ - int error; - - error = parse_argv_uint(field, str, result); - if (error) - return error; - - return set_retry_interval(field->name, DEREFERENCE_UINT(result)); -} - -int -parse_json_retry_interval(struct option_field const *opt, json_t *json, - void *result) -{ - int error; - - error = parse_json_uint(opt, json, result); - if (error) - return error; - - return set_retry_interval(opt->name, DEREFERENCE_UINT(result)); -} - -const struct global_type gt_rrdp_enabled = { - .has_arg = optional_argument, - .size = sizeof(bool), - .print = print_bool, - .parse.argv = parse_argv_enabled, - .parse.json = parse_json_enabled, - .arg_doc = "true|false", -}; - -const struct global_type gt_rrdp_priority = { - .has_arg = required_argument, - .size = sizeof(uint32_t), - .print = print_uint32, - .parse.argv = parse_argv_priority, - .parse.json = parse_json_priority, - .arg_doc = "<32-bit unsigned integer>", -}; - -const struct global_type gt_rrdp_retry_count = { - .has_arg = required_argument, - .size = sizeof(unsigned int), - .print = print_uint, - .parse.argv = parse_argv_retry_count, - .parse.json = parse_json_retry_count, - .arg_doc = "", -}; - -const struct global_type gt_rrdp_retry_interval = { - .has_arg = required_argument, - .size = sizeof(unsigned int), - .print = print_uint, - .parse.argv = parse_argv_retry_interval, - .parse.json = parse_json_retry_interval, - .arg_doc = "", -}; diff --git a/src/config/rrdp_conf.h b/src/config/rrdp_conf.h deleted file mode 100644 index 85112bd3..00000000 --- a/src/config/rrdp_conf.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef SRC_CONFIG_RRDP_CONF_H_ -#define SRC_CONFIG_RRDP_CONF_H_ - -#include "config/types.h" - -extern const struct global_type gt_rrdp_enabled; -extern const struct global_type gt_rrdp_priority; -extern const struct global_type gt_rrdp_retry_count; -extern const struct global_type gt_rrdp_retry_interval; - -#endif /* SRC_CONFIG_RRDP_CONF_H_ */ diff --git a/src/config/rsync_strategy.c b/src/config/rsync_strategy.c index 0131ec83..8a58cf7b 100644 --- a/src/config/rsync_strategy.c +++ b/src/config/rsync_strategy.c @@ -24,7 +24,7 @@ str); #endif -void +static void print_rsync_strategy(struct option_field const *field, void *value) { char const *str = ""; @@ -46,7 +46,7 @@ print_rsync_strategy(struct option_field const *field, void *value) pr_op_info("%s: %s", field->name, str); } -int +static int parse_argv_rsync_strategy(struct option_field const *field, char const *str, void *result) { @@ -60,13 +60,10 @@ parse_argv_rsync_strategy(struct option_field const *field, char const *str, return pr_op_err("Unknown rsync synchronization strategy: '%s'", str); - /* TODO (later) Remove when sync-strategy is fully deprecated */ - config_set_sync_strategy(DEREFERENCE(result)); - return 0; } -int +static int parse_json_rsync_strategy(struct option_field const *opt, struct json_t *json, void *result) { diff --git a/src/config/rsync_strategy.h b/src/config/rsync_strategy.h index 620cff60..e3f90376 100644 --- a/src/config/rsync_strategy.h +++ b/src/config/rsync_strategy.h @@ -4,14 +4,6 @@ #include "config/types.h" enum rsync_strategy { - /* - * TODO (later) Deprecated. Still alive so that 'sync-strategy' and - * 'rsync.strategy' can live together. - * - * 'sync-strategy' type must handle this value to set 'rsync.enabled' - * as 'false'. - */ - RSYNC_OFF, /** * Strictly correct download strategy. * @@ -62,14 +54,4 @@ enum rsync_strategy { extern const struct global_type gt_rsync_strategy; -/* - * TODO (later) Public to live along with 'sync-strategy', return them to - * private whenever 'sync-strategy' is deleted. - */ -void print_rsync_strategy(struct option_field const *, void *); -int parse_argv_rsync_strategy(struct option_field const *, char const *, - void *); -int parse_json_rsync_strategy(struct option_field const *, struct json_t *, - void *); - #endif /* SRC_CONFIG_RSYNC_STRATEGY_H_ */ diff --git a/src/config/sync_strategy.c b/src/config/sync_strategy.c deleted file mode 100644 index ada711f1..00000000 --- a/src/config/sync_strategy.c +++ /dev/null @@ -1,87 +0,0 @@ -#include "config/sync_strategy.h" - -#include -#include -#include - -#include "config.h" -#include "log.h" -#include "config/str.h" -#include "config/rsync_strategy.h" - -/* - * Yeap, all of this is duplicated, better remove it with the whole source file - * whenever sync-strategy isn't supported anymore. - */ - -#define RSYNC_VALUE_OFF "off" -#define RSYNC_VALUE_STRICT "strict" -#define RSYNC_VALUE_ROOT "root" -#define RSYNC_VALUE_ROOT_EXCEPT_TA "root-except-ta" - -#define DEREFERENCE(void_value) (*((enum rsync_strategy *) void_value)) - -#ifdef ENABLE_STRICT_STRATEGY -#define PRINT_STRICT_ARG_DOC "|" RSYNC_VALUE_STRICT -#define HANDLE_RSYNC_STRICT DEREFERENCE(result) = RSYNC_STRICT; -#else -#define PRINT_STRICT_ARG_DOC -#define HANDLE_RSYNC_STRICT \ - return pr_err("Unknown synchronization strategy: '%s'. In order to use it, recompile using flag ENABLE_STRICT_STRATEGY.",\ - str); -#endif - -static void -print_sync_strategy(struct option_field const *field, void *value) -{ - if (DEREFERENCE(value) == RSYNC_OFF) { - pr_op_info("%s: %s", field->name, RSYNC_VALUE_OFF); - return; - } - - print_rsync_strategy(field, value); -} - -static int -parse_argv_sync_strategy(struct option_field const *field, char const *str, - void *result) -{ - int error; - - pr_op_warn("'sync-strategy' is deprecated."); - pr_op_warn("Use 'rsync.strategy' instead; or 'rsync.enabled=false' if you wish to use 'off' strategy."); - - if (strcmp(str, RSYNC_VALUE_OFF) == 0) { - DEREFERENCE(result) = RSYNC_OFF; - config_set_rsync_enabled(false); - return 0; - } - - error = parse_argv_rsync_strategy(field, str, result); - if (!error) - config_set_rsync_strategy(DEREFERENCE(result)); - return error; -} - -static int -parse_json_sync_strategy(struct option_field const *opt, struct json_t *json, - void *result) -{ - char const *string; - int error; - - error = parse_json_string(json, opt->name, &string); - return error ? error : parse_argv_sync_strategy(opt, string, result); -} - -const struct global_type gt_sync_strategy = { - .has_arg = required_argument, - .size = sizeof(enum rsync_strategy), - .print = print_sync_strategy, - .parse.argv = parse_argv_sync_strategy, - .parse.json = parse_json_sync_strategy, - .arg_doc = RSYNC_VALUE_OFF - "|" RSYNC_VALUE_ROOT - "|" RSYNC_VALUE_ROOT_EXCEPT_TA - PRINT_STRICT_ARG_DOC, -}; diff --git a/src/config/sync_strategy.h b/src/config/sync_strategy.h deleted file mode 100644 index 0f8c7767..00000000 --- a/src/config/sync_strategy.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef SRC_CONFIG_SYNC_STRATEGY_H_ -#define SRC_CONFIG_SYNC_STRATEGY_H_ - -#include "config/types.h" - -extern const struct global_type gt_sync_strategy; - -#endif /* SRC_CONFIG_SYNC_STRATEGY_H_ */ diff --git a/src/config/work_offline.c b/src/config/work_offline.c index 6adc161d..2343094f 100644 --- a/src/config/work_offline.c +++ b/src/config/work_offline.c @@ -18,7 +18,6 @@ parse_argv_offline(struct option_field const *field, char const *str, void *resu return error; config_set_rsync_enabled(!DEREFERENCE(result)); - config_set_rrdp_enabled(!DEREFERENCE(result)); config_set_http_enabled(!DEREFERENCE(result)); return 0; @@ -35,7 +34,6 @@ parse_json_offline(struct option_field const *opt, struct json_t *json, return error; config_set_rsync_enabled(!DEREFERENCE(result)); - config_set_rrdp_enabled(!DEREFERENCE(result)); config_set_http_enabled(!DEREFERENCE(result)); return 0; diff --git a/src/rsync/rsync.c b/src/rsync/rsync.c index 1504aabf..9380291a 100644 --- a/src/rsync/rsync.c +++ b/src/rsync/rsync.c @@ -156,8 +156,6 @@ get_rsync_uri(struct rpki_uri *requested_uri, bool is_ta, : handle_root_strategy(requested_uri, rsync_uri); case RSYNC_STRICT: return handle_strict_strategy(requested_uri, rsync_uri); - case RSYNC_OFF: - break; } pr_crit("Invalid rsync strategy: %u", config_get_rsync_strategy()); -- 2.47.3