summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-03-27 16:56:36 +0000
committerNick Mathewson <nickm@torproject.org>2008-03-27 16:56:36 +0000
commitf58d16ed9e58071057b366ea94795a0cbbf6d708 (patch)
treeb43d90b9242549b32388dbd0a71c7f974a67024d
parentf5557c0d28c24cb95c29c91661331a129863c61e (diff)
downloadtor-f58d16ed9e58071057b366ea94795a0cbbf6d708.tar.gz
tor-f58d16ed9e58071057b366ea94795a0cbbf6d708.zip
r19101@catbus: nickm | 2008-03-27 12:56:29 -0400
Backport r14214. This is not 100% trivial, options_init_from_torrc() got cleaned up a lot. The fact that it was much easier to do in trunk probably means that the cleanups were the right thing to do. svn:r14219
-rw-r--r--ChangeLog4
-rw-r--r--src/or/config.c23
2 files changed, 18 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index c6e278cb7e..c5d52a4b05 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,7 +2,9 @@ Changes in version 0.2.0.24-?? - 2008-??-??
o Minor bugfixes:
- Initialize log mutex before initializing dmalloc. Otherwise,
running with dmalloc would crash. Bugfix on 0.2.0.x-alpha.
-
+ - Do not read the configuration file when we've only been told to
+ generate a password hash. Fixes bug 643. Bugfix on 0.0.9pre5. Fix
+ based on patch from Sebastian Hahn.
Changes in version 0.2.0.23-rc - 2008-03-24
o Major bugfixes:
diff --git a/src/or/config.c b/src/or/config.c
index a7f127f20a..2b5153c0fa 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -3535,6 +3535,7 @@ options_init_from_torrc(int argc, char **argv)
int i, retval;
int using_default_torrc;
int ignore_missing_torrc;
+ int ignore_torrc = 0;
static char **backup_argv;
static int backup_argc;
@@ -3597,11 +3598,12 @@ options_init_from_torrc(int argc, char **argv)
newoptions->command = CMD_HASH_PASSWORD;
newoptions->command_arg = tor_strdup( (i < argc-1) ? argv[i+1] : "");
++i;
+ ignore_torrc = 1;
} else if (!strcmp(argv[i],"--verify-config")) {
newoptions->command = CMD_VERIFY_CONFIG;
}
}
- if (using_default_torrc) {
+ if (using_default_torrc && !ignore_torrc) {
/* didn't find one, try CONFDIR */
const char *dflt = get_default_conf_file();
if (dflt && file_status(dflt) == FN_FILE) {
@@ -3621,16 +3623,20 @@ options_init_from_torrc(int argc, char **argv)
#endif
}
}
- tor_assert(fname);
- log(LOG_DEBUG, LD_CONFIG, "Opening config file \"%s\"", fname);
+ if (!ignore_torrc) {
+ tor_assert(fname);
+ log(LOG_DEBUG, LD_CONFIG, "Opening config file \"%s\"", fname);
- tor_free(torrc_fname);
- torrc_fname = fname;
+ tor_free(torrc_fname);
+ torrc_fname = fname;
+ }
/* get config lines, assign them */
- if (file_status(fname) != FN_FILE ||
+ if (ignore_torrc) {
+ cf = tor_strdup("");
+ } else if (file_status(fname) != FN_FILE ||
!(cf = read_file_to_str(fname,0,NULL))) {
- if (using_default_torrc == 1 || ignore_missing_torrc ) {
+ if (using_default_torrc == 1 || ignore_missing_torrc) {
log(LOG_NOTICE, LD_CONFIG, "Configuration file \"%s\" not present, "
"using reasonable defaults.", fname);
tor_free(fname); /* sets fname to NULL */
@@ -3640,7 +3646,8 @@ options_init_from_torrc(int argc, char **argv)
"Unable to open configuration file \"%s\".", fname);
goto err;
}
- } else { /* it opened successfully. use it. */
+ }
+ if (cf) { /* It opened successfully. use it. */
retval = config_get_lines(cf, &cl);
tor_free(cf);
if (retval < 0)