mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-25 15:10:48 +01:00
Correctly re-process non-option cmdline args on sighup
Whenever we had an non-option commandline arguments *and*
option-bearing commandline arguments on the commandline, we would save
only the latter across invocations of options_init_from_torrc, but
take their existence as license not to re-parse the former. Yuck!
Incidentally, this fix lets us throw away the backup_arg[gv] logic.
Fix for bug 9746; bugfix on d98dfb3746
,
not in any released Tor. Found by Damian. Thanks, Damian!
This commit is contained in:
parent
57859980a8
commit
15b9a1ff10
1 changed files with 13 additions and 15 deletions
|
@ -582,8 +582,12 @@ static or_options_t *global_default_options = NULL;
|
||||||
static char *torrc_fname = NULL;
|
static char *torrc_fname = NULL;
|
||||||
/** Name of the most recently read torrc-defaults file.*/
|
/** Name of the most recently read torrc-defaults file.*/
|
||||||
static char *torrc_defaults_fname;
|
static char *torrc_defaults_fname;
|
||||||
/** Configuration Options set by command line. */
|
/** Configuration options set by command line. */
|
||||||
static config_line_t *global_cmdline_options = NULL;
|
static config_line_t *global_cmdline_options = NULL;
|
||||||
|
/** Non-configuration options set by the command line */
|
||||||
|
static config_line_t *global_cmdline_only_options = NULL;
|
||||||
|
/** Boolean: Have we parsed the command line? */
|
||||||
|
static int have_parsed_cmdline = 0;
|
||||||
/** Contents of most recently read DirPortFrontPage file. */
|
/** Contents of most recently read DirPortFrontPage file. */
|
||||||
static char *global_dirfrontpagecontents = NULL;
|
static char *global_dirfrontpagecontents = NULL;
|
||||||
/** List of port_cfg_t for all configured ports. */
|
/** List of port_cfg_t for all configured ports. */
|
||||||
|
@ -745,6 +749,9 @@ config_free_all(void)
|
||||||
config_free_lines(global_cmdline_options);
|
config_free_lines(global_cmdline_options);
|
||||||
global_cmdline_options = NULL;
|
global_cmdline_options = NULL;
|
||||||
|
|
||||||
|
config_free_lines(global_cmdline_only_options);
|
||||||
|
global_cmdline_only_options = NULL;
|
||||||
|
|
||||||
if (configured_ports) {
|
if (configured_ports) {
|
||||||
SMARTLIST_FOREACH(configured_ports,
|
SMARTLIST_FOREACH(configured_ports,
|
||||||
port_cfg_t *, p, port_cfg_free(p));
|
port_cfg_t *, p, port_cfg_free(p));
|
||||||
|
@ -3894,30 +3901,22 @@ options_init_from_torrc(int argc, char **argv)
|
||||||
char *cf=NULL, *cf_defaults=NULL;
|
char *cf=NULL, *cf_defaults=NULL;
|
||||||
int command;
|
int command;
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
static char **backup_argv;
|
|
||||||
static int backup_argc;
|
|
||||||
char *command_arg = NULL;
|
char *command_arg = NULL;
|
||||||
char *errmsg=NULL;
|
char *errmsg=NULL;
|
||||||
config_line_t *cmdline_only_options = NULL;
|
|
||||||
config_line_t *p_index = NULL;
|
config_line_t *p_index = NULL;
|
||||||
|
config_line_t *cmdline_only_options = NULL;
|
||||||
if (argv) { /* first time we're called. save command line args */
|
|
||||||
backup_argv = argv;
|
|
||||||
backup_argc = argc;
|
|
||||||
} else { /* we're reloading. need to clean up old options first. */
|
|
||||||
argv = backup_argv;
|
|
||||||
argc = backup_argc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Go through command-line variables */
|
/* Go through command-line variables */
|
||||||
if (!global_cmdline_options) {
|
if (! have_parsed_cmdline) {
|
||||||
/* Or we could redo the list every time we pass this place.
|
/* Or we could redo the list every time we pass this place.
|
||||||
* It does not really matter */
|
* It does not really matter */
|
||||||
if (config_parse_commandline(argc, argv, 0, &global_cmdline_options,
|
if (config_parse_commandline(argc, argv, 0, &global_cmdline_options,
|
||||||
&cmdline_only_options) < 0) {
|
&global_cmdline_only_options) < 0) {
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
have_parsed_cmdline = 1;
|
||||||
}
|
}
|
||||||
|
cmdline_only_options = global_cmdline_only_options;
|
||||||
|
|
||||||
if (config_line_find(cmdline_only_options, "-h") ||
|
if (config_line_find(cmdline_only_options, "-h") ||
|
||||||
config_line_find(cmdline_only_options, "--help")) {
|
config_line_find(cmdline_only_options, "--help")) {
|
||||||
|
@ -3990,7 +3989,6 @@ options_init_from_torrc(int argc, char **argv)
|
||||||
|
|
||||||
tor_free(cf);
|
tor_free(cf);
|
||||||
tor_free(cf_defaults);
|
tor_free(cf_defaults);
|
||||||
config_free_lines(cmdline_only_options);
|
|
||||||
if (errmsg) {
|
if (errmsg) {
|
||||||
log_warn(LD_CONFIG,"%s", errmsg);
|
log_warn(LD_CONFIG,"%s", errmsg);
|
||||||
tor_free(errmsg);
|
tor_free(errmsg);
|
||||||
|
|
Loading…
Add table
Reference in a new issue