diff options
author | Nick Mathewson <nickm@torproject.org> | 2019-11-11 11:54:14 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2019-11-11 11:54:14 -0500 |
commit | 4462766d32eb3ee4505e300b116dcb7493bf3b0b (patch) | |
tree | e3146d9d4f63e4402ec6d6333cffee31c5328c83 /src | |
parent | 2b3dc3384c41a1e8961b9303b5fa533edf4922c3 (diff) | |
parent | 9d562bba40d1e56ba459467611c815ab8d27f27e (diff) | |
download | tor-4462766d32eb3ee4505e300b116dcb7493bf3b0b.tar.gz tor-4462766d32eb3ee4505e300b116dcb7493bf3b0b.zip |
Merge branch 'ticket32404'
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/conf/confdecl.h | 1 | ||||
-rw-r--r-- | src/lib/conf/conftypes.h | 21 | ||||
-rw-r--r-- | src/lib/confmgt/confmgt.c | 5 | ||||
-rw-r--r-- | src/lib/confmgt/type_defs.c | 15 |
4 files changed, 32 insertions, 10 deletions
diff --git a/src/lib/conf/confdecl.h b/src/lib/conf/confdecl.h index 695f9f307f..26c71e1d43 100644 --- a/src/lib/conf/confdecl.h +++ b/src/lib/conf/confdecl.h @@ -191,6 +191,7 @@ extern const struct var_type_def_t CSV_INTERVAL_type_defn; extern const struct var_type_def_t LINELIST_type_defn; extern const struct var_type_def_t LINELIST_V_type_defn; extern const struct var_type_def_t LINELIST_S_type_defn; +extern const struct var_type_def_t IGNORE_type_defn; extern const struct var_type_def_t OBSOLETE_type_defn; /**@}*/ diff --git a/src/lib/conf/conftypes.h b/src/lib/conf/conftypes.h index dfe51cfba1..19ea997316 100644 --- a/src/lib/conf/conftypes.h +++ b/src/lib/conf/conftypes.h @@ -64,7 +64,18 @@ typedef enum config_type_t { CONFIG_TYPE_LINELIST_V, /**< Catch-all "virtual" option to summarize * context-sensitive config lines when fetching. */ - CONFIG_TYPE_OBSOLETE, /**< Obsolete (ignored) option. */ + /** Ignored (obsolete) option. Uses no storage. + * + * Reported as "obsolete" when its type is queried. + */ + CONFIG_TYPE_OBSOLETE, + /** Ignored option. Uses no storage. + * + * Reported as "ignored" when its type is queried. For use with options used + * by disabled modules. + **/ + CONFIG_TYPE_IGNORE, + /** * Extended type: definition appears in the <b>type_def</b> pointer * of the corresponding struct_member_t. @@ -183,12 +194,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 a96c7f96bf..c72efa847c 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); } diff --git a/src/lib/confmgt/type_defs.c b/src/lib/confmgt/type_defs.c index 0bf82ee934..7200218f74 100644 --- a/src/lib/confmgt/type_defs.c +++ b/src/lib/confmgt/type_defs.c @@ -682,17 +682,13 @@ static const var_type_fns_t linelist_s_fns = { ///// // CONFIG_TYPE_ROUTERSET // -// XXXX This type is not implemented here, since routerset_t is not available // XXXX to this module. ///// ///// -// CONFIG_TYPE_OBSOLETE +// CONFIG_TYPE_IGNORE // -// Used to indicate an obsolete option. -// -// XXXX This is not a type, and should be handled at a higher level of -// XXXX abstraction. +// Used to indicate an option that cannot be stored or encoded. ///// static int @@ -703,8 +699,6 @@ ignore_parse(void *target, const char *value, char **errmsg, (void)value; (void)errmsg; (void)params; - // XXXX move this to a higher level, once such a level exists. - log_warn(LD_GENERAL, "Skipping obsolete configuration option."); return 0; } @@ -774,6 +768,10 @@ const var_type_def_t LINELIST_S_type_defn = { const var_type_def_t LINELIST_V_type_defn = { .name="Virtual", .fns=&linelist_v_fns, .flags=CFLG_NOREPLACE|CFLG_NOSET }; +const var_type_def_t IGNORE_type_defn = { + .name="Ignored", .fns=&ignore_fns, + .flags=CFLG_NOCOPY|CFLG_NOCMP|CFLG_NODUMP|CFLG_NOSET, +}; const var_type_def_t OBSOLETE_type_defn = { .name="Obsolete", .fns=&ignore_fns, .flags=CFLG_GROUP_OBSOLETE, @@ -800,6 +798,7 @@ static const var_type_def_t *type_definitions_table[] = { [CONFIG_TYPE_LINELIST] = &LINELIST_type_defn, [CONFIG_TYPE_LINELIST_S] = &LINELIST_S_type_defn, [CONFIG_TYPE_LINELIST_V] = &LINELIST_V_type_defn, + [CONFIG_TYPE_IGNORE] = &IGNORE_type_defn, [CONFIG_TYPE_OBSOLETE] = &OBSOLETE_type_defn, }; |