[or-cvs] Refuse to use RunAsDaemon when torrc is a relative path. Fi...

Nick Mathewson nickm at seul.org
Tue Jan 10 20:00:22 UTC 2006


Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv20970/src/or

Modified Files:
	config.c 
Log Message:
Refuse to use RunAsDaemon when torrc is a relative path. Fixes bug 229.

Index: config.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/config.c,v
retrieving revision 1.480
retrieving revision 1.481
diff -u -p -d -r1.480 -r1.481
--- config.c	7 Jan 2006 00:41:50 -0000	1.480
+++ config.c	10 Jan 2006 20:00:20 -0000	1.481
@@ -1887,6 +1887,11 @@ options_validate(or_options_t *old_optio
       result = -1;
   }
 
+#ifndef MS_WINDOWS
+  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 (options->SocksPort < 0 || options->SocksPort > 65535)
     REJECT("SocksPort option out of bounds.");
 
@@ -2502,6 +2507,9 @@ options_init_from_torrc(int argc, char *
   tor_assert(fname);
   log(LOG_DEBUG, LD_CONFIG, "Opening config file \"%s\"", fname);
 
+  tor_free(torrc_fname);
+  torrc_fname = fname;
+
   /* get config lines, assign them */
   if (file_status(fname) != FN_FILE ||
       !(cf = read_file_to_str(fname,0))) {
@@ -2543,8 +2551,6 @@ options_init_from_torrc(int argc, char *
 
   if (set_options(newoptions))
     goto err; /* frees and replaces old options */
-  tor_free(torrc_fname);
-  torrc_fname = fname;
   return 0;
  err:
   tor_free(fname);



More information about the tor-commits mailing list