aboutsummaryrefslogtreecommitdiff
path: root/src/or/confparse.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-08-03 11:40:43 -0400
committerNick Mathewson <nickm@torproject.org>2016-08-03 11:43:19 -0400
commite6220ccbf8004090b9bcc7228b33d85d2cf9c067 (patch)
tree3f67bbd1ca1d5c7b6ee95bcbe968162273aa6810 /src/or/confparse.c
parentc9b8d4c086931d806655a48b16b82ed132613382 (diff)
downloadtor-e6220ccbf8004090b9bcc7228b33d85d2cf9c067.tar.gz
tor-e6220ccbf8004090b9bcc7228b33d85d2cf9c067.zip
Add deprecation for configuration options that need to go away.
Diffstat (limited to 'src/or/confparse.c')
-rw-r--r--src/or/confparse.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/or/confparse.c b/src/or/confparse.c
index 3532b39d93..233cc7c77d 100644
--- a/src/or/confparse.c
+++ b/src/or/confparse.c
@@ -181,6 +181,26 @@ config_free_lines(config_line_t *front)
}
}
+/** If <b>key</b> is a deprecated configuration option, return the message
+ * explaining why it is deprecated (which may be an empty string). Return NULL
+ * if it is not deprecated. The <b>key</b> field must be fully expanded. */
+static const char *
+config_find_deprecation(const config_format_t *fmt, const char *key)
+{
+ if (BUG(fmt == NULL) || BUG(key == NULL))
+ return NULL;
+ if (fmt->deprecations == NULL)
+ return NULL;
+
+ config_deprecation_t *d;
+ for (d = fmt->deprecations; d->name; ++d) {
+ if (!strcasecmp(d->name, key)) {
+ return d->why_deprecated ? d->why_deprecated : "";
+ }
+ }
+ return NULL;
+}
+
/** As config_find_option, but return a non-const pointer. */
config_var_t *
config_find_option_mutable(config_format_t *fmt, const char *key)
@@ -463,6 +483,15 @@ config_mark_lists_fragile(const config_format_t *fmt, void *options)
}
}
+void
+warn_deprecated_option(const char *what, const char *why)
+{
+ log_warn(LD_CONFIG, "The %s option is deprecated, and will most likely "
+ "be removed in a future version of Tor.%s (If you think this is "
+ "a mistake, please let us know!)",
+ what, why);
+}
+
/** If <b>c</b> is a syntactically valid configuration line, update
* <b>options</b> with its value and return 0. Otherwise return -1 for bad
* key, -2 for bad value.
@@ -502,6 +531,11 @@ config_assign_line(const config_format_t *fmt, void *options,
c->key = tor_strdup(var->name);
}
+ const char *deprecation_msg = config_find_deprecation(fmt, var->name);
+ if (deprecation_msg) {
+ warn_deprecated_option(var->name, deprecation_msg);
+ }
+
if (!strlen(c->value)) {
/* reset or clear it, then return */
if (!clear_first) {