[or-cvs] r14219: Backport r14214. This is not 100% trivial, options_init_from (in tor/branches/tor-0_2_0-patches: . src/or)

nickm at seul.org nickm at seul.org
Thu Mar 27 16:56:38 UTC 2008


Author: nickm
Date: 2008-03-27 12:56:36 -0400 (Thu, 27 Mar 2008)
New Revision: 14219

Modified:
   tor/branches/tor-0_2_0-patches/
   tor/branches/tor-0_2_0-patches/ChangeLog
   tor/branches/tor-0_2_0-patches/src/or/config.c
Log:
 r19101 at 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.



Property changes on: tor/branches/tor-0_2_0-patches
___________________________________________________________________
 svk:merge ticket from /tor/020 [r19101] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/branches/tor-0_2_0-patches/ChangeLog
===================================================================
--- tor/branches/tor-0_2_0-patches/ChangeLog	2008-03-27 16:56:33 UTC (rev 14218)
+++ tor/branches/tor-0_2_0-patches/ChangeLog	2008-03-27 16:56:36 UTC (rev 14219)
@@ -2,8 +2,10 @@
   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:
     - When a tunneled directory request is made to a directory server

Modified: tor/branches/tor-0_2_0-patches/src/or/config.c
===================================================================
--- tor/branches/tor-0_2_0-patches/src/or/config.c	2008-03-27 16:56:33 UTC (rev 14218)
+++ tor/branches/tor-0_2_0-patches/src/or/config.c	2008-03-27 16:56:36 UTC (rev 14219)
@@ -3535,6 +3535,7 @@
   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 @@
       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 @@
 #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 @@
           "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)



More information about the tor-commits mailing list