[tor-commits] [tor/master] Make "invisibility" and "undumpability" properties of variables.
dgoulet at torproject.org
dgoulet at torproject.org
Mon Aug 26 13:43:23 UTC 2019
commit f3330d2be3de287d4b15bd4d9b0e86fab3ffb9fd
Author: Nick Mathewson <nickm at torproject.org>
Date: Fri Jun 21 10:17:59 2019 -0400
Make "invisibility" and "undumpability" properties of variables.
Previously, these were magical things that we detected by checking
whether a variable's name was prefixed with two or three underscores.
---
src/app/config/config.c | 35 +++++++++++++++++++++++------------
src/app/config/confparse.c | 2 +-
src/lib/conf/conftypes.h | 10 ++++++++++
3 files changed, 34 insertions(+), 13 deletions(-)
diff --git a/src/app/config/config.c b/src/app/config/config.c
index d240a73fe..5667702a6 100644
--- a/src/app/config/config.c
+++ b/src/app/config/config.c
@@ -265,6 +265,13 @@ DUMMY_TYPECHECK_INSTANCE(or_options_t);
#define VAR_D(varname,conftype,member,initvalue) \
CONFIG_VAR_DEFN(or_options_t, varname, conftype, member, 0, initvalue)
+#define VAR_NODUMP(varname,conftype,member,initvalue) \
+ CONFIG_VAR_ETYPE(or_options_t, varname, conftype, member, \
+ CVFLAG_NODUMP, initvalue)
+#define VAR_INVIS(varname,conftype,member,initvalue) \
+ CONFIG_VAR_ETYPE(or_options_t, varname, conftype, member, \
+ CVFLAG_NODUMP|CVFLAG_INVISIBLE, initvalue)
+
#define V(member,conftype,initvalue) \
VAR(#member, conftype, member, initvalue)
@@ -285,7 +292,7 @@ DUMMY_TYPECHECK_INSTANCE(or_options_t);
#define VPORT(member) \
VAR(#member "Lines", LINELIST_V, member ## _lines, NULL), \
VAR(#member, LINELIST_S, member ## _lines, NULL), \
- VAR("__" #member, LINELIST_S, member ## _lines, NULL)
+ VAR_NODUMP("__" #member, LINELIST_S, member ## _lines, NULL)
/** UINT64_MAX as a decimal string */
#define UINT64_MAX_STRING "18446744073709551615"
@@ -682,15 +689,17 @@ static config_var_t option_vars_[] = {
V(WarnPlaintextPorts, CSV, "23,109,110,143"),
OBSOLETE("UseFilteringSSLBufferevents"),
OBSOLETE("__UseFilteringSSLBufferevents"),
- VAR("__ReloadTorrcOnSIGHUP", BOOL, ReloadTorrcOnSIGHUP, "1"),
- VAR("__AllDirActionsPrivate", BOOL, AllDirActionsPrivate, "0"),
- VAR("__DisablePredictedCircuits",BOOL,DisablePredictedCircuits, "0"),
- VAR("__DisableSignalHandlers", BOOL, DisableSignalHandlers, "0"),
- VAR("__LeaveStreamsUnattached",BOOL, LeaveStreamsUnattached, "0"),
- VAR("__HashedControlSessionPassword", LINELIST, HashedControlSessionPassword,
+ VAR_NODUMP("__ReloadTorrcOnSIGHUP", BOOL, ReloadTorrcOnSIGHUP, "1"),
+ VAR_NODUMP("__AllDirActionsPrivate", BOOL, AllDirActionsPrivate, "0"),
+ VAR_NODUMP("__DisablePredictedCircuits",BOOL,DisablePredictedCircuits, "0"),
+ VAR_NODUMP("__DisableSignalHandlers", BOOL, DisableSignalHandlers, "0"),
+ VAR_NODUMP("__LeaveStreamsUnattached",BOOL, LeaveStreamsUnattached, "0"),
+ VAR_NODUMP("__HashedControlSessionPassword", LINELIST,
+ HashedControlSessionPassword,
NULL),
- VAR("__OwningControllerProcess",STRING,OwningControllerProcess, NULL),
- VAR("__OwningControllerFD", UINT64, OwningControllerFD, UINT64_MAX_STRING),
+ VAR_NODUMP("__OwningControllerProcess",STRING,OwningControllerProcess, NULL),
+ VAR_NODUMP("__OwningControllerFD", UINT64, OwningControllerFD,
+ UINT64_MAX_STRING),
V(MinUptimeHidServDirectoryV2, INTERVAL, "96 hours"),
V(TestingServerDownloadInitialDelay, CSV_INTERVAL, "0"),
V(TestingClientDownloadInitialDelay, CSV_INTERVAL, "0"),
@@ -743,7 +752,8 @@ static config_var_t option_vars_[] = {
V(TestingDirAuthVoteGuardIsStrict, BOOL, "0"),
V_D(TestingDirAuthVoteHSDir, ROUTERSET, NULL),
V(TestingDirAuthVoteHSDirIsStrict, BOOL, "0"),
- VAR("___UsingTestNetworkDefaults", BOOL, UsingTestNetworkDefaults_, "0"),
+ VAR_INVIS("___UsingTestNetworkDefaults", BOOL, UsingTestNetworkDefaults_,
+ "0"),
END_OF_CONFIG_VARS
};
@@ -783,7 +793,8 @@ static const config_var_t testing_tor_network_defaults[] = {
V(TestingDirConnectionMaxStall, INTERVAL, "30 seconds"),
V(TestingEnableConnBwEvent, BOOL, "1"),
V(TestingEnableCellStatsEvent, BOOL, "1"),
- VAR("___UsingTestNetworkDefaults", BOOL, UsingTestNetworkDefaults_, "1"),
+ VAR_INVIS("___UsingTestNetworkDefaults", BOOL, UsingTestNetworkDefaults_,
+ "1"),
V(RendPostPeriod, INTERVAL, "2 minutes"),
END_OF_CONFIG_VARS
@@ -8180,7 +8191,7 @@ getinfo_helper_config(control_connection_t *conn,
for (i = 0; option_vars_[i].member.name; ++i) {
const config_var_t *var = &option_vars_[i];
/* don't tell controller about triple-underscore options */
- if (!strncmp(option_vars_[i].member.name, "___", 3))
+ if (option_vars_[i].flags & CVFLAG_INVISIBLE)
continue;
const char *type = struct_var_get_typename(&var->member);
if (!type)
diff --git a/src/app/config/confparse.c b/src/app/config/confparse.c
index 0d19974d7..450ff5e08 100644
--- a/src/app/config/confparse.c
+++ b/src/app/config/confparse.c
@@ -642,7 +642,7 @@ config_dump(const config_format_t *fmt, const void *default_options,
continue;
}
/* Don't save 'hidden' control variables. */
- if (!strcmpstart(fmt->vars[i].member.name, "__"))
+ if (fmt->vars[i].flags & CVFLAG_NODUMP)
continue;
if (minimal && config_is_same(fmt, options, defaults,
fmt->vars[i].member.name))
diff --git a/src/lib/conf/conftypes.h b/src/lib/conf/conftypes.h
index 6a44fb92e..3b754e07b 100644
--- a/src/lib/conf/conftypes.h
+++ b/src/lib/conf/conftypes.h
@@ -110,6 +110,16 @@ typedef struct struct_magic_decl_t {
* fetch this option should produce a warning.
**/
#define CVFLAG_OBSOLETE (1u<<0)
+/**
+ * Flag to indicate that an option is undumpable. An undumpable option is
+ * never saved to disk, and is prefixed with __.
+ **/
+#define CVFLAG_NODUMP (1u<<1)
+/**
+ * Flag to indicate that an option is "invisible". An invisible option
+ * is always undumpable, and we don't tell the controller about it.
+ **/
+#define CVFLAG_INVISIBLE (1u<<2)
/** A variable allowed in the configuration file or on the command line. */
typedef struct config_var_t {
More information about the tor-commits
mailing list