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
This commit is contained in:
Roger Dingledine 2007-09-21 21:52:31 +00:00
parent 6786ebf4f9
commit 41f3d0eb27

View File

@ -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,6 +440,9 @@ init_keys(void)
prkey = init_key_from_file(keydir, 1, LOG_ERR);
if (!prkey) return -1;
set_onion_key(prkey);
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
@ -452,7 +454,9 @@ init_keys(void)
* 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);
or_state_mark_dirty(state, options->AvoidDiskWrites ?
time(NULL)+3600 : 0);
}
}
tor_snprintf(keydir,sizeof(keydir),