Browse Source

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
Peter Palfrader 16 years ago
parent
commit
ded55fa296
1 changed files with 12 additions and 10 deletions
  1. 12 10
      src/or/config.c

+ 12 - 10
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;