]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Tolerate relative paths for torrc files with RunAsDaemon
authorNick Mathewson <nickm@torproject.org>
Mon, 5 Jan 2015 00:34:38 +0000 (19:34 -0500)
committerNick Mathewson <nickm@torproject.org>
Mon, 5 Jan 2015 00:34:38 +0000 (19:34 -0500)
We had a check to block these, but the patch we merged as a1c1fc72
broke this check by making them absolute on demand every time we
opened them.  That's not so great though. Instead, we should make them
absolute on startup, and not let them change after that.

Fixes bug 13397; bugfix on 0.2.3.11-alpha.

changes/bug13397 [new file with mode: 0644]
src/or/config.c

diff --git a/changes/bug13397 b/changes/bug13397
new file mode 100644 (file)
index 0000000..5020928
--- /dev/null
@@ -0,0 +1,4 @@
+  o Minor bugfixes:
+    - Avoid crashing when trying to reload a torrc specified as a relative
+      path with RunAsDaemon turned on.  Fixes bug 13397; bugfix on
+      0.2.3.11-alpha.
index e7891a5bd3de712d67becc8ca3509dc3c074eb28..cf42f30f7a751048636176e982876dbfd454d99b 100644 (file)
@@ -2584,11 +2584,6 @@ options_validate(or_options_t *old_options, or_options_t *options,
       REJECT("Failed to resolve/guess local address. See logs for details.");
   }
 
-#ifndef _WIN32
-  if (options->RunAsDaemon && torrc_fname && path_is_relative(torrc_fname))
-    REJECT("Can't use a relative path to torrc when RunAsDaemon is set.");
-#endif
-
   if (server_mode(options) && options->RendConfigLines)
     log_warn(LD_CONFIG,
         "Tor is currently configured as a relay and a hidden service. "
@@ -4152,14 +4147,17 @@ load_torrc_from_disk(config_line_t *cmd_arg, int defaults_file)
   int ignore_missing_torrc = 0;
   char **fname_var = defaults_file ? &torrc_defaults_fname : &torrc_fname;
 
-  fname = find_torrc_filename(cmd_arg, defaults_file,
-                              &using_default_torrc, &ignore_missing_torrc);
-  tor_assert(fname);
+  if (*fname_var == NULL) {
+    fname = find_torrc_filename(cmd_arg, defaults_file,
+                                &using_default_torrc, &ignore_missing_torrc);
+    tor_assert(fname);
+    tor_free(*fname_var);
+    *fname_var = fname;
+  } else {
+    fname = *fname_var;
+  }
   log_debug(LD_CONFIG, "Opening config file \"%s\"", fname);
 
-  tor_free(*fname_var);
-  *fname_var = fname;
-
   /* Open config file */
   if (file_status(fname) != FN_FILE ||
       !(cf = read_file_to_str(fname,0,NULL))) {