From 56771f392e68eb2f78180daab0d8f17c9284ad11 Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Mon, 30 May 2011 23:50:37 -0400 Subject: [PATCH 1/2] stop asserting at boot The patch for 3228 made us try to run init_keys() before we had loaded our state file, resulting in an assert inside init_keys. We had moved it too early in the function. Now it's later in the function, but still above the accounting calls. --- src/or/config.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/or/config.c b/src/or/config.c index f97e9b1bea..6635cac5d6 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -1180,18 +1180,6 @@ options_act(or_options_t *old_options) 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; @@ -1237,6 +1225,17 @@ options_act(or_options_t *old_options) finish_daemon(options->DataDirectory); } + /* 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 (transition_affects_workers || + (options->V3AuthoritativeDir && (!old_options || + !old_options->V3AuthoritativeDir))) { + if (init_keys() < 0) { + log_warn(LD_BUG,"Error initializing keys; exiting"); + return -1; + } + } + /* Write our PID to the PID file. If we do not have write permissions we * will log a warning */ if (options->PidFile) From 0fd3ad75daf925e8192aa1d44b229b3b7c29829d Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 1 Jun 2011 11:07:08 -0400 Subject: [PATCH 2/2] Report wrong key sizes correctly When we introduced NEED_KEY_1024 in routerparse.c back in 0.2.0.1-alpha, I forgot to add a *8 when logging the length of a bad-length key. Bugfix for 3318 on 0.2.0.1-alpha. --- changes/bug3318 | 3 +++ src/or/routerparse.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changes/bug3318 diff --git a/changes/bug3318 b/changes/bug3318 new file mode 100644 index 0000000000..38991c4b1d --- /dev/null +++ b/changes/bug3318 @@ -0,0 +1,3 @@ + o Minor bugfixes: + - Fix a log message that said "bits" while displaying a value in + bytes. Fixes bug 3318; bugfix on 0.2.0.1-alpha. diff --git a/src/or/routerparse.c b/src/or/routerparse.c index 1dcbc6a184..3728e9932b 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -3767,7 +3767,7 @@ token_check_object(memarea_t *area, const char *kwd, case NEED_SKEY_1024: /* There must be a 1024-bit private key. */ if (tok->key && crypto_pk_keysize(tok->key) != PK_BYTES) { tor_snprintf(ebuf, sizeof(ebuf), "Wrong size on key for %s: %d bits", - kwd, (int)crypto_pk_keysize(tok->key)); + kwd, (int)crypto_pk_keysize(tok->key)*8); RET_ERR(ebuf); } /* fall through */