mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
Merge remote-tracking branch 'tor-github/pr/1449'
This commit is contained in:
commit
34509e78c6
3
changes/ticket32187
Normal file
3
changes/ticket32187
Normal file
@ -0,0 +1,3 @@
|
||||
o Code simplification and refactoring:
|
||||
- Remove some unused arguments from the options_validate() function,
|
||||
to simplify our code and tests. Closes ticket 32187.
|
@ -843,9 +843,8 @@ static int parse_outbound_addresses(or_options_t *options, int validate_only,
|
||||
char **msg);
|
||||
static void config_maybe_load_geoip_files_(const or_options_t *options,
|
||||
const or_options_t *old_options);
|
||||
static int options_validate_cb(void *old_options, void *options,
|
||||
void *default_options,
|
||||
int from_setconf, char **msg);
|
||||
static int options_validate_cb(const void *old_options, void *options,
|
||||
char **msg);
|
||||
static void cleanup_protocol_warning_severity_level(void);
|
||||
static void set_protocol_warning_severity_level(int warning_severity);
|
||||
static void options_clear_cb(const config_mgr_t *mgr, void *opts);
|
||||
@ -1228,7 +1227,8 @@ add_default_fallback_dir_servers,(void))
|
||||
* user if we changed any dangerous ones.
|
||||
*/
|
||||
static int
|
||||
validate_dir_servers(or_options_t *options, or_options_t *old_options)
|
||||
validate_dir_servers(const or_options_t *options,
|
||||
const or_options_t *old_options)
|
||||
{
|
||||
config_line_t *cl;
|
||||
|
||||
@ -2682,7 +2682,7 @@ options_trial_assign(config_line_t *list, unsigned flags, char **msg)
|
||||
in_option_validation = 1;
|
||||
|
||||
if (options_validate(cur_options, trial_options,
|
||||
global_default_options, 1, msg) < 0) {
|
||||
msg) < 0) {
|
||||
or_options_free(trial_options);
|
||||
rv = SETOPT_ERR_PARSE; /*XXX make this a separate return value. */
|
||||
goto done;
|
||||
@ -3231,12 +3231,10 @@ compute_publishserverdescriptor(or_options_t *options)
|
||||
#define RECOMMENDED_MIN_CIRCUIT_BUILD_TIMEOUT (10)
|
||||
|
||||
static int
|
||||
options_validate_cb(void *old_options, void *options, void *default_options,
|
||||
int from_setconf, char **msg)
|
||||
options_validate_cb(const void *old_options, void *options, char **msg)
|
||||
{
|
||||
in_option_validation = 1;
|
||||
int rv = options_validate(old_options, options, default_options,
|
||||
from_setconf, msg);
|
||||
int rv = options_validate(old_options, options, msg);
|
||||
in_option_validation = 0;
|
||||
return rv;
|
||||
}
|
||||
@ -3433,16 +3431,13 @@ options_validate_single_onion(or_options_t *options, char **msg)
|
||||
* On error, tor_strdup an error explanation into *<b>msg</b>.
|
||||
*/
|
||||
STATIC int
|
||||
options_validate(or_options_t *old_options, or_options_t *options,
|
||||
or_options_t *default_options_unused, int from_setconf_unused,
|
||||
options_validate(const or_options_t *old_options, or_options_t *options,
|
||||
char **msg)
|
||||
{
|
||||
config_line_t *cl;
|
||||
const char *uname = get_uname();
|
||||
int n_ports=0;
|
||||
int world_writable_control_socket=0;
|
||||
(void)from_setconf_unused; /* 29211 TODO: Remove this from the API. */
|
||||
(void)default_options_unused; /* 29211 TODO: Remove this from the API. */
|
||||
|
||||
tor_assert(msg);
|
||||
*msg = NULL;
|
||||
@ -5522,8 +5517,7 @@ options_init_from_string(const char *cf_defaults, const char *cf,
|
||||
newoptions->FilesOpenedByIncludes = opened_files;
|
||||
|
||||
/* Validate newoptions */
|
||||
if (options_validate(oldoptions, newoptions, newdefaultoptions,
|
||||
0, msg) < 0) {
|
||||
if (options_validate(oldoptions, newoptions, msg) < 0) {
|
||||
err = SETOPT_ERR_PARSE; /*XXX make this a separate return value.*/
|
||||
goto err;
|
||||
}
|
||||
|
@ -277,10 +277,9 @@ STATIC void port_cfg_free_(port_cfg_t *port);
|
||||
STATIC void or_options_free_(or_options_t *options);
|
||||
STATIC int options_validate_single_onion(or_options_t *options,
|
||||
char **msg);
|
||||
STATIC int options_validate(or_options_t *old_options,
|
||||
STATIC int options_validate(const or_options_t *old_options,
|
||||
or_options_t *options,
|
||||
or_options_t *default_options,
|
||||
int from_setconf, char **msg);
|
||||
char **msg);
|
||||
STATIC int parse_transport_line(const or_options_t *options,
|
||||
const char *line, int validate_only,
|
||||
int server);
|
||||
|
@ -141,9 +141,8 @@ static const config_var_t state_vars_[] = {
|
||||
|
||||
static int or_state_validate(or_state_t *state, char **msg);
|
||||
|
||||
static int or_state_validate_cb(void *old_options, void *options,
|
||||
void *default_options,
|
||||
int from_setconf, char **msg);
|
||||
static int or_state_validate_cb(const void *old_options,
|
||||
void *options, char **msg);
|
||||
|
||||
/** Magic value for or_state_t. */
|
||||
#define OR_STATE_MAGIC 0x57A73f57
|
||||
@ -269,13 +268,10 @@ validate_transports_in_state(or_state_t *state)
|
||||
}
|
||||
|
||||
static int
|
||||
or_state_validate_cb(void *old_state, void *state, void *default_state,
|
||||
int from_setconf, char **msg)
|
||||
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) from_setconf;
|
||||
(void) default_state;
|
||||
(void) old_state;
|
||||
|
||||
return or_state_validate(state, msg);
|
||||
|
@ -60,8 +60,7 @@ DUMMY_TYPECHECK_INSTANCE(sr_disk_state_t);
|
||||
#define SR_DISK_STATE_MAGIC 0x98AB1254
|
||||
|
||||
static int
|
||||
disk_state_validate_cb(void *old_state, void *state, void *default_state,
|
||||
int from_setconf, char **msg);
|
||||
disk_state_validate_cb(const void *old_state, void *state, char **msg);
|
||||
|
||||
/** Array of variables that are saved to disk as a persistent state. */
|
||||
static const config_var_t state_vars[] = {
|
||||
@ -345,12 +344,9 @@ disk_state_validate(const sr_disk_state_t *state)
|
||||
|
||||
/** Validate the disk state (NOP for now). */
|
||||
static int
|
||||
disk_state_validate_cb(void *old_state, void *state, void *default_state,
|
||||
int from_setconf, char **msg)
|
||||
disk_state_validate_cb(const void *old_state, void *state, char **msg)
|
||||
{
|
||||
/* We don't use these; only options do. */
|
||||
(void) from_setconf;
|
||||
(void) default_state;
|
||||
(void) old_state;
|
||||
|
||||
/* This is called by config_dump which is just before we are about to
|
||||
|
@ -1166,7 +1166,7 @@ config_dump(const config_mgr_t *mgr, const void *default_options,
|
||||
|
||||
/* XXX use a 1 here so we don't add a new log line while dumping */
|
||||
if (default_options == NULL) {
|
||||
if (fmt->validate_fn(NULL, defaults_tmp, defaults_tmp, 1, &msg) < 0) {
|
||||
if (fmt->validate_fn(NULL, defaults_tmp, &msg) < 0) {
|
||||
// LCOV_EXCL_START
|
||||
log_err(LD_BUG, "Failed to validate default config: %s", msg);
|
||||
tor_free(msg);
|
||||
|
@ -68,10 +68,8 @@ typedef struct config_deprecation_t {
|
||||
* config_dump(); later in our refactoring, it will be cleaned up and used
|
||||
* more generally.
|
||||
*/
|
||||
typedef int (*validate_fn_t)(void *oldval,
|
||||
typedef int (*validate_fn_t)(const void *oldval,
|
||||
void *newval,
|
||||
void *default_val,
|
||||
int from_setconf,
|
||||
char **msg_out);
|
||||
|
||||
struct config_mgr_t;
|
||||
|
@ -906,14 +906,12 @@ test_config_fix_my_family(void *arg)
|
||||
family3->next = NULL;
|
||||
|
||||
or_options_t* options = options_new();
|
||||
or_options_t* defaults = options_new();
|
||||
(void) arg;
|
||||
|
||||
options_init(options);
|
||||
options_init(defaults);
|
||||
options->MyFamily_lines = family;
|
||||
|
||||
options_validate(NULL, options, defaults, 0, &err) ;
|
||||
options_validate(NULL, options, &err) ;
|
||||
|
||||
if (err != NULL) {
|
||||
TT_FAIL(("options_validate failed: %s", err));
|
||||
@ -935,7 +933,6 @@ test_config_fix_my_family(void *arg)
|
||||
done:
|
||||
tor_free(err);
|
||||
or_options_free(options);
|
||||
or_options_free(defaults);
|
||||
}
|
||||
|
||||
static int n_hostname_01010101 = 0;
|
||||
@ -5640,7 +5637,6 @@ test_config_check_bridge_distribution_setting_not_a_bridge(void *arg)
|
||||
{
|
||||
or_options_t* options = get_options_mutable();
|
||||
or_options_t* old_options = options;
|
||||
or_options_t* default_options = options;
|
||||
char* message = NULL;
|
||||
int ret;
|
||||
|
||||
@ -5649,7 +5645,7 @@ test_config_check_bridge_distribution_setting_not_a_bridge(void *arg)
|
||||
options->BridgeRelay = 0;
|
||||
options->BridgeDistribution = (char*)("https");
|
||||
|
||||
ret = options_validate(old_options, options, default_options, 0, &message);
|
||||
ret = options_validate(old_options, options, &message);
|
||||
|
||||
tt_int_op(ret, OP_EQ, -1);
|
||||
tt_str_op(message, OP_EQ, "You set BridgeDistribution, but you "
|
||||
|
@ -103,12 +103,9 @@ static config_deprecation_t test_deprecation_notes[] = {
|
||||
};
|
||||
|
||||
static int
|
||||
test_validate_cb(void *old_options, void *options, void *default_options,
|
||||
int from_setconf, char **msg)
|
||||
test_validate_cb(const void *old_options, void *options, char **msg)
|
||||
{
|
||||
(void)old_options;
|
||||
(void)default_options;
|
||||
(void)from_setconf;
|
||||
(void)msg;
|
||||
test_struct_t *ts = options;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user