aboutsummaryrefslogtreecommitdiff
path: root/src/app/config/confparse.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2019-09-05 11:48:29 -0400
committerDavid Goulet <dgoulet@torproject.org>2019-09-11 09:42:19 -0400
commit668e3a77090b031bec8254dfc6d816f5f4add54d (patch)
tree958b11a1d486e1904d7138b577006ef8a229312b /src/app/config/confparse.c
parent3bf38ffff5fc4a6af34d576962ca74080bbd5d87 (diff)
downloadtor-668e3a77090b031bec8254dfc6d816f5f4add54d.tar.gz
tor-668e3a77090b031bec8254dfc6d816f5f4add54d.zip
config: Introduce the concept of an "ungettable" variable.
We had though to make all obsolete and invisible variables ungettable, so that GETCONF would reject them. But it turns out that this isn't the current behavior of GETCONF with those variables. So for now, I'm leaving the current behavior unchanged. (See ticket 31647 for a proposal to change the behavior.)
Diffstat (limited to 'src/app/config/confparse.c')
-rw-r--r--src/app/config/confparse.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/app/config/confparse.c b/src/app/config/confparse.c
index 3341ee7844..1923a0c1ee 100644
--- a/src/app/config/confparse.c
+++ b/src/app/config/confparse.c
@@ -534,6 +534,23 @@ config_var_is_settable(const config_var_t *var)
return struct_var_is_settable(&var->member);
}
+/**
+ * Return true iff the controller is allowed to fetch the value of
+ * <b>var</b>.
+ **/
+static bool
+config_var_is_gettable(const config_var_t *var)
+{
+ /* Arguably, invisible or obsolete options should not be gettable. However,
+ * they have been gettable for a long time, and making them ungettable could
+ * have compatibility effects. For now, let's leave them alone.
+ */
+
+ // return (var->flags & (CVFLAG_OBSOLETE|CFGLAGS_INVISIBLE)) == 0;
+ (void)var;
+ return true;
+}
+
bool
config_var_is_contained(const config_var_t *var)
{
@@ -776,6 +793,11 @@ config_get_assigned_option(const config_mgr_t *mgr, const void *options,
log_warn(LD_CONFIG, "Unknown option '%s'. Failing.", key);
return NULL;
}
+ if (! config_var_is_gettable(var->cvar)) {
+ log_warn(LD_CONFIG, "Option '%s' is obsolete or unfetchable. Failing.",
+ key);
+ return NULL;
+ }
const void *object = config_mgr_get_obj(mgr, options, var->object_idx);
result = struct_var_kvencode(object, &var->cvar->member);