From ded55fa296a5cb3b91cd7d1bb75fbc8d04638e25 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Mon, 10 Mar 2008 12:41:33 +0000 Subject: [PATCH] options_init_from_torrc(): tread non-existing torrc like empty torrc. Tread the case of a non-existing conffile, when allowed, exactly like the one with an empty torrc. svn:r13943 --- src/or/config.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/or/config.c b/src/or/config.c index 229c52fd4e..f9521c0dd4 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -3642,7 +3642,7 @@ options_init_from_torrc(int argc, char **argv) tor_free(torrc_fname); torrc_fname = fname; - /* get config lines, assign them */ + /* Open config file */ if (file_status(fname) != FN_FILE || !(cf = read_file_to_str(fname,0,NULL))) { if (using_default_torrc == 1 || ignore_missing_torrc ) { @@ -3650,22 +3650,24 @@ options_init_from_torrc(int argc, char **argv) "using reasonable defaults.", fname); tor_free(fname); /* sets fname to NULL */ torrc_fname = NULL; + cf = tor_strdup(""); } else { log(LOG_WARN, LD_CONFIG, "Unable to open configuration file \"%s\".", fname); goto err; } - } else { /* it opened successfully. use it. */ - retval = config_get_lines(cf, &cl); - tor_free(cf); - if (retval < 0) - goto err; - retval = config_assign(&options_format, newoptions, cl, 0, 0, &errmsg); - config_free_lines(cl); - if (retval < 0) - goto err; } + /* get config lines, assign them */ + retval = config_get_lines(cf, &cl); + tor_free(cf); + if (retval < 0) + goto err; + retval = config_assign(&options_format, newoptions, cl, 0, 0, &errmsg); + config_free_lines(cl); + if (retval < 0) + goto err; + /* Go through command-line variables too */ if (config_get_commandlines(argc, argv, &cl) < 0) goto err;