[tor-commits] [tor/release-0.2.2] Reinit keys at the start of options_act().

arma at torproject.org arma at torproject.org
Wed Oct 26 20:35:33 UTC 2011


commit 55d9e4b8bad18a99d51b0b6347cef46e730dceda
Author: Nick Mathewson <nickm at torproject.org>
Date:   Mon May 23 16:38:35 2011 -0400

    Reinit keys at the start of options_act().
    
    Previously we did this nearer to the end (in the old_options &&
    transition_affects_workers() block).  But other stuff cares about
    keys being consistent with options... particularly anything which
    tries to access a key, which can die in assert_identity_keys_ok().
    
    Fixes bug 3228; bugfix on 0.2.2.18-alpha.
    
    Conflicts:
    
    	src/or/config.c
---
 changes/bug3228 |    3 +++
 src/or/config.c |   23 +++++++++++++++--------
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/changes/bug3228 b/changes/bug3228
new file mode 100644
index 0000000..4aca810
--- /dev/null
+++ b/changes/bug3228
@@ -0,0 +1,3 @@
+  o Major bugfixes:
+    - Resolve a crash that occured when setting BridgeRelay to 1 with
+      accounting enabled. Fixes bug 3228; bugfix on 0.2.2.18-alpha.
diff --git a/src/or/config.c b/src/or/config.c
index 7d7f2c3..ea389ff 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -1269,12 +1269,26 @@ options_act(or_options_t *old_options)
   or_options_t *options = get_options();
   int running_tor = options->command == CMD_RUN_TOR;
   char *msg;
+  const int transition_affects_workers =
+    old_options && options_transition_affects_workers(old_options, options);
 
   if (running_tor && !have_lockfile()) {
     if (try_locking(options, 1) < 0)
       return -1;
   }
 
+  /* We want to reinit keys as needed before we do much of anything else:
+     keys are important, and other things can depend on them. */
+  if (running_tor &&
+      (transition_affects_workers ||
+       (options->V3AuthoritativeDir && (!old_options ||
+                                        !old_options->V3AuthoritativeDir)))) {
+    if (init_keys() < 0) {
+      log_warn(LD_BUG,"Error initializing keys; exiting");
+      return -1;
+    }
+  }
+
   if (consider_adding_dir_authorities(options, old_options) < 0)
     return -1;
 
@@ -1368,14 +1382,10 @@ options_act(or_options_t *old_options)
       geoip_remove_old_clients(time(NULL)+(2*60*60));
     }
 
-    if (options_transition_affects_workers(old_options, options)) {
+    if (transition_affects_workers) {
       log_info(LD_GENERAL,
                "Worker-related options changed. Rotating workers.");
 
-      if (init_keys() < 0) {
-        log_warn(LD_BUG,"Error initializing keys; exiting");
-        return -1;
-      }
       if (server_mode(options) && !server_mode(old_options)) {
         ip_address_changed(0);
         if (has_completed_circuit || !any_predicted_circuits(time(NULL)))
@@ -1388,9 +1398,6 @@ options_act(or_options_t *old_options)
       if (dns_reset())
         return -1;
     }
-
-    if (options->V3AuthoritativeDir && !old_options->V3AuthoritativeDir)
-      init_keys();
   }
 
   /* Maybe load geoip file */





More information about the tor-commits mailing list