aboutsummaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2019-10-23 15:38:15 -0400
committerNick Mathewson <nickm@torproject.org>2019-10-24 20:30:32 -0400
commitdc6d7f072d7307c21df80b982c1d1f98130d3286 (patch)
tree93298a500138ab9c332c0fb16492188205241bcc /src/app
parent0cb42385378d539185a20ce8899cdc16cf46145c (diff)
downloadtor-dc6d7f072d7307c21df80b982c1d1f98130d3286.tar.gz
tor-dc6d7f072d7307c21df80b982c1d1f98130d3286.zip
Make foo_validate() functions call config_validate().
The former foo_validate() functions are now toplevel legacy_validate_fn callbacks. The new foo_validate() functions now call them. This change lets us remove the old shared_random disk state validation callback entirely.
Diffstat (limited to 'src/app')
-rw-r--r--src/app/config/config.c37
-rw-r--r--src/app/config/statefile.c26
2 files changed, 37 insertions, 26 deletions
diff --git a/src/app/config/config.c b/src/app/config/config.c
index 4e7720b0b3..b372791a4d 100644
--- a/src/app/config/config.c
+++ b/src/app/config/config.c
@@ -3239,13 +3239,20 @@ compute_publishserverdescriptor(or_options_t *options)
* */
#define RECOMMENDED_MIN_CIRCUIT_BUILD_TIMEOUT (10)
-static int
-options_validate_cb(const void *old_options, void *options, char **msg)
+/**
+ * Return 0 if every setting in <b>options</b> is reasonable, is a
+ * permissible transition from <b>old_options</b>, and none of the
+ * testing-only settings differ from <b>default_options</b> unless in
+ * testing mode. Else return -1. Should have no side effects, except for
+ * normalizing the contents of <b>options</b>.
+ *
+ * On error, tor_strdup an error explanation into *<b>msg</b>.
+ */
+STATIC int
+options_validate(const or_options_t *old_options, or_options_t *options,
+ char **msg)
{
- in_option_validation = 1;
- int rv = options_validate(old_options, options, msg);
- in_option_validation = 0;
- return rv;
+ return config_validate(get_options_mgr(), old_options, options, msg);
}
#define REJECT(arg) \
@@ -3431,18 +3438,16 @@ options_validate_single_onion(or_options_t *options, char **msg)
return 0;
}
-/** Return 0 if every setting in <b>options</b> is reasonable, is a
- * permissible transition from <b>old_options</b>, and none of the
- * testing-only settings differ from <b>default_options</b> unless in
- * testing mode. Else return -1. Should have no side effects, except for
- * normalizing the contents of <b>options</b>.
- *
- * On error, tor_strdup an error explanation into *<b>msg</b>.
+/**
+ * Legacy validation/normalization callback for or_options_t. See
+ * legacy_validate_fn_t for more information.
*/
-STATIC int
-options_validate(const or_options_t *old_options, or_options_t *options,
- char **msg)
+static int
+options_validate_cb(const void *old_options_, void *options_, char **msg)
{
+ const or_options_t *old_options = old_options_;
+ or_options_t *options = options_;
+
config_line_t *cl;
const char *uname = get_uname();
int n_ports=0;
diff --git a/src/app/config/statefile.c b/src/app/config/statefile.c
index e277e722cd..d3a0ec1790 100644
--- a/src/app/config/statefile.c
+++ b/src/app/config/statefile.c
@@ -265,16 +265,6 @@ validate_transports_in_state(or_state_t *state)
return 0;
}
-static int
-or_state_validate_cb(const void *old_state, void *state, char **msg)
-{
- /* We don't use these; only options do. Still, we need to match that
- * signature. */
- (void) old_state;
-
- return or_state_validate(state, msg);
-}
-
/** Return 0 if every setting in <b>state</b> is reasonable, and a
* permissible transition from <b>old_state</b>. Else warn and return -1.
* Should have no side effects, except for normalizing the contents of
@@ -283,6 +273,22 @@ or_state_validate_cb(const void *old_state, void *state, char **msg)
static int
or_state_validate(or_state_t *state, char **msg)
{
+ return config_validate(get_state_mgr(), NULL, state, msg);
+}
+
+/**
+ * Legacy validation/normalization callback for or_state_t. See
+ * legacy_validate_fn_t for more information.
+ */
+static int
+or_state_validate_cb(const void *old_state, void *state_, char **msg)
+{
+ /* There is not a meaningful concept of a state-to-state transition,
+ * since we do not reload the state after we start. */
+ (void) old_state;
+
+ or_state_t *state = state_;
+
if (entry_guards_parse_state(state, 0, msg)<0)
return -1;