summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2007-09-21 21:52:31 +0000
committerRoger Dingledine <arma@torproject.org>2007-09-21 21:52:31 +0000
commit41f3d0eb272aefa1dd583946b62f085cdf9a7b57 (patch)
treeee7f91141c57c11ec5ca5a0b5f25a7cc9189fc7e
parent6786ebf4f9c42c619bd18da0ebbcff56369dcc47 (diff)
downloadtor-41f3d0eb272aefa1dd583946b62f085cdf9a7b57.tar.gz
tor-41f3d0eb272aefa1dd583946b62f085cdf9a7b57.zip
only mess with 'state' in init_keys if we're planning to actually
run tor. this resolves a segfault in 'tor --list-fingerprints' introduced by r11437. backport candidate due to r11438. svn:r11566
-rw-r--r--src/or/router.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/or/router.c b/src/or/router.c
index 9e85d77552..34be215ed0 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -381,7 +381,6 @@ init_keys(void)
char v3_digest[20];
char *cp;
or_options_t *options = get_options();
- or_state_t *state = get_or_state();
authority_type_t type;
time_t now = time(NULL);
@@ -441,18 +440,23 @@ init_keys(void)
prkey = init_key_from_file(keydir, 1, LOG_ERR);
if (!prkey) return -1;
set_onion_key(prkey);
- if (state->LastRotatedOnionKey > 100 && state->LastRotatedOnionKey < now) {
- /* We allow for some parsing slop, but we don't want to risk accepting
- * values in the distant future. If we did, we might never rotate the
- * onion key. */
- onionkey_set_at = state->LastRotatedOnionKey;
- } else {
- /* We have no LastRotatedOnionKey set; either we just created the key
- * or it's a holdover from 0.1.2.4-alpha-dev or earlier. In either case,
- * start the clock ticking now so that we will eventually rotate it even
- * if we don't stay up for a full MIN_ONION_KEY_LIFETIME. */
- state->LastRotatedOnionKey = onionkey_set_at = now;
- or_state_mark_dirty(state, options->AvoidDiskWrites ? time(NULL)+3600 : 0);
+ if (options->command == CMD_RUN_TOR) {
+ /* only mess with the state file if we're actually running Tor */
+ or_state_t *state = get_or_state();
+ if (state->LastRotatedOnionKey > 100 && state->LastRotatedOnionKey < now) {
+ /* We allow for some parsing slop, but we don't want to risk accepting
+ * values in the distant future. If we did, we might never rotate the
+ * onion key. */
+ onionkey_set_at = state->LastRotatedOnionKey;
+ } else {
+ /* We have no LastRotatedOnionKey set; either we just created the key
+ * or it's a holdover from 0.1.2.4-alpha-dev or earlier. In either case,
+ * start the clock ticking now so that we will eventually rotate it even
+ * if we don't stay up for a full MIN_ONION_KEY_LIFETIME. */
+ state->LastRotatedOnionKey = onionkey_set_at = now;
+ or_state_mark_dirty(state, options->AvoidDiskWrites ?
+ time(NULL)+3600 : 0);
+ }
}
tor_snprintf(keydir,sizeof(keydir),