diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-10-20 11:15:32 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-10-20 11:39:17 -0400 |
commit | 1df43aff41eb8198712af0aa14ec2d574b26682c (patch) | |
tree | c266322db182ee294c0d3adf570474fc4e36871e /src/or/config.c | |
parent | 853e73e815c1be9c9e533160f803de56e7d21147 (diff) | |
download | tor-1df43aff41eb8198712af0aa14ec2d574b26682c.tar.gz tor-1df43aff41eb8198712af0aa14ec2d574b26682c.zip |
Return instead of exiting in options_init_from_torrc()
Diffstat (limited to 'src/or/config.c')
-rw-r--r-- | src/or/config.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/or/config.c b/src/or/config.c index 55ab76c813..3795aeaa39 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -4981,7 +4981,8 @@ load_torrc_from_disk(config_line_t *cmd_arg, int defaults_file) /** Read a configuration file into <b>options</b>, finding the configuration * file location based on the command line. After loading the file * call options_init_from_string() to load the config. - * Return 0 if success, -1 if failure. */ + * Return 0 if success, -1 if failure, and 1 if we succeeded but should exit + * anyway. */ int options_init_from_torrc(int argc, char **argv) { @@ -5008,22 +5009,22 @@ options_init_from_torrc(int argc, char **argv) if (config_line_find(cmdline_only_options, "-h") || config_line_find(cmdline_only_options, "--help")) { print_usage(); - exit(0); // XXXX bad exit, though probably harmless + return 1; } if (config_line_find(cmdline_only_options, "--list-torrc-options")) { /* For validating whether we've documented everything. */ list_torrc_options(); - exit(0); // XXXX bad exit, though probably harmless + return 1; } if (config_line_find(cmdline_only_options, "--list-deprecated-options")) { /* For validating whether what we have deprecated really exists. */ list_deprecated_options(); - exit(0); // XXXX bad exit, though probably harmless + return 1; } if (config_line_find(cmdline_only_options, "--version")) { printf("Tor version %s.\n",get_version()); - exit(0); // XXXX bad exit, though probably harmless + return 1; } if (config_line_find(cmdline_only_options, "--library-versions")) { @@ -5051,7 +5052,7 @@ options_init_from_torrc(int argc, char **argv) tor_compress_header_version_str(ZSTD_METHOD)); } //TODO: Hex versions? - exit(0); // XXXX bad exit, though probably harmless + return 1; } command = CMD_RUN_TOR; @@ -5112,7 +5113,8 @@ options_init_from_torrc(int argc, char **argv) get_options_mutable()->keygen_force_passphrase = FORCE_PASSPHRASE_OFF; } else { log_err(LD_CONFIG, "--no-passphrase specified without --keygen!"); - exit(1); // XXXX bad exit + retval = -1; + goto err; } } @@ -5121,7 +5123,8 @@ options_init_from_torrc(int argc, char **argv) get_options_mutable()->change_key_passphrase = 1; } else { log_err(LD_CONFIG, "--newpass specified without --keygen!"); - exit(1); // XXXX bad exit + retval = -1; + goto err; } } @@ -5131,17 +5134,20 @@ options_init_from_torrc(int argc, char **argv) if (fd_line) { if (get_options()->keygen_force_passphrase == FORCE_PASSPHRASE_OFF) { log_err(LD_CONFIG, "--no-passphrase specified with --passphrase-fd!"); - exit(1); // XXXX bad exit + retval = -1; + goto err; } else if (command != CMD_KEYGEN) { log_err(LD_CONFIG, "--passphrase-fd specified without --keygen!"); - exit(1); // XXXX bad exit + retval = -1; + goto err; } else { const char *v = fd_line->value; int ok = 1; long fd = tor_parse_long(v, 10, 0, INT_MAX, &ok, NULL); if (fd < 0 || ok == 0) { log_err(LD_CONFIG, "Invalid --passphrase-fd value %s", escaped(v)); - exit(1); // XXXX bad exit + retval = -1; + goto err; } get_options_mutable()->keygen_passphrase_fd = (int)fd; get_options_mutable()->use_keygen_passphrase_fd = 1; @@ -5156,7 +5162,8 @@ options_init_from_torrc(int argc, char **argv) if (key_line) { if (command != CMD_KEYGEN) { log_err(LD_CONFIG, "--master-key without --keygen!"); - exit(1); // XXXX bad exit + retval = -1; + goto err; } else { get_options_mutable()->master_key_fname = tor_strdup(key_line->value); } |