diff options
author | Nick Mathewson <nickm@torproject.org> | 2007-09-24 15:53:47 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2007-09-24 15:53:47 +0000 |
commit | 383c8deced74589a0ee4385eaf77335e8effdb5a (patch) | |
tree | ad905b47b18d8cb91aa401343ee0a74fce3c7fbc /src/or/router.c | |
parent | dcbae324ecc555b1df31f181c6383f63f1ce3c05 (diff) | |
download | tor-383c8deced74589a0ee4385eaf77335e8effdb5a.tar.gz tor-383c8deced74589a0ee4385eaf77335e8effdb5a.zip |
r15318@catbus: nickm | 2007-09-24 11:42:25 -0400
Backport r11566 so that --list-fingerprint will not die when it finds no state file.
svn:r11606
Diffstat (limited to 'src/or/router.c')
-rw-r--r-- | src/or/router.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/or/router.c b/src/or/router.c index b7a761c52a..e0bd1fc47c 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -239,7 +239,6 @@ init_keys(void) char digest[20]; char *cp; or_options_t *options = get_options(); - or_state_t *state = get_or_state(); if (!key_lock) key_lock = tor_mutex_new(); @@ -284,15 +283,21 @@ init_keys(void) prkey = init_key_from_file(keydir); if (!prkey) return -1; set_onion_key(prkey); - if (state->LastRotatedOnionKey > 100) { /* allow for some parsing slop. */ - 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 = time(NULL); - 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) { /* allow for some parsing slop. */ + 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 = time(NULL); + or_state_mark_dirty(state, + options->AvoidDiskWrites ? time(NULL)+3600 : 0); + } } tor_snprintf(keydir,sizeof(keydir),"%s/keys/secret_onion_key.old",datadir); |