commit 36af84ba5062b26d2ede647627e87f6ae74796cf Author: Nick Mathewson nickm@torproject.org Date: Thu Nov 7 09:14:44 2019 -0500
New configuration flag to warn that a variable is obsolete.
Part of 32404. --- src/lib/conf/conftypes.h | 8 +++++++- src/lib/confmgt/confmgt.c | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/lib/conf/conftypes.h b/src/lib/conf/conftypes.h index dfe51cfba..bf748efbb 100644 --- a/src/lib/conf/conftypes.h +++ b/src/lib/conf/conftypes.h @@ -183,12 +183,18 @@ typedef struct struct_magic_decl_t { * running. **/ #define CFLG_IMMUTABLE (1u<<6) +/** + * Flag to indicate that we should warn that an option or type is obsolete + * whenever the user tries to use it. + **/ +#define CFLG_WARN_OBSOLETE (1u<<7)
/** * A group of flags that should be set on all obsolete options and types. **/ #define CFLG_GROUP_OBSOLETE \ - (CFLG_NOCOPY|CFLG_NOCMP|CFLG_NODUMP|CFLG_NOSET|CFLG_NOLIST) + (CFLG_NOCOPY|CFLG_NOCMP|CFLG_NODUMP|CFLG_NOSET|CFLG_NOLIST|\ + CFLG_WARN_OBSOLETE)
/** A variable allowed in the configuration file or on the command line. */ typedef struct config_var_t { diff --git a/src/lib/confmgt/confmgt.c b/src/lib/confmgt/confmgt.c index a96c7f96b..c72efa847 100644 --- a/src/lib/confmgt/confmgt.c +++ b/src/lib/confmgt/confmgt.c @@ -657,6 +657,11 @@ config_assign_value(const config_mgr_t *mgr, void *options, tor_assert(!strcmp(c->key, var->cvar->member.name)); void *object = config_mgr_get_obj_mutable(mgr, options, var->object_idx);
+ if (config_var_has_flag(var->cvar, CFLG_WARN_OBSOLETE)) { + log_warn(LD_GENERAL, "Skipping obsolete configuration option "%s".", + var->cvar->member.name); + } + return struct_var_kvassign(object, c, msg, &var->cvar->member); }