Fix 13941: make calling log_new_relay_greeting() optional.

Specifically, only if we're creating secret_id_key do we log the
greeting (and then only if the key is actually created).
This commit is contained in:
meejah 2014-12-10 22:30:14 -07:00
parent b73a7600af
commit 76753efd7b
4 changed files with 17 additions and 9 deletions

4
changes/bug13941 Normal file
View File

@ -0,0 +1,4 @@
o Minor bugfixes (hidden services):
- When adding a new hidden-service (for example, via SETCONF) Tor
no longer logs a congratulations for running a relay.

View File

@ -738,7 +738,7 @@ rend_service_load_keys(rend_service_t *s)
s->directory); s->directory);
return -1; return -1;
} }
s->private_key = init_key_from_file(fname, 1, LOG_ERR); s->private_key = init_key_from_file(fname, 1, LOG_ERR, 0);
if (!s->private_key) if (!s->private_key)
return -1; return -1;

View File

@ -392,10 +392,12 @@ log_new_relay_greeting(void)
/** Try to read an RSA key from <b>fname</b>. If <b>fname</b> doesn't exist /** Try to read an RSA key from <b>fname</b>. If <b>fname</b> doesn't exist
* and <b>generate</b> is true, create a new RSA key and save it in * and <b>generate</b> is true, create a new RSA key and save it in
* <b>fname</b>. Return the read/created key, or NULL on error. Log all * <b>fname</b>. Return the read/created key, or NULL on error. Log all
* errors at level <b>severity</b>. * errors at level <b>severity</b>. If <b>log_greeting</b> is non-zero and a
* new key was created, log_new_relay_greeting() is called.
*/ */
crypto_pk_t * crypto_pk_t *
init_key_from_file(const char *fname, int generate, int severity) init_key_from_file(const char *fname, int generate, int severity,
int log_greeting)
{ {
crypto_pk_t *prkey = NULL; crypto_pk_t *prkey = NULL;
@ -433,7 +435,9 @@ init_key_from_file(const char *fname, int generate, int severity)
goto error; goto error;
} }
log_info(LD_GENERAL, "Generated key seems valid"); log_info(LD_GENERAL, "Generated key seems valid");
log_new_relay_greeting(); if (log_greeting) {
log_new_relay_greeting();
}
if (crypto_pk_write_private_key_to_filename(prkey, fname)) { if (crypto_pk_write_private_key_to_filename(prkey, fname)) {
tor_log(severity, LD_FS, tor_log(severity, LD_FS,
"Couldn't write generated key to \"%s\".", fname); "Couldn't write generated key to \"%s\".", fname);
@ -545,7 +549,7 @@ load_authority_keyset(int legacy, crypto_pk_t **key_out,
fname = get_datadir_fname2("keys", fname = get_datadir_fname2("keys",
legacy ? "legacy_signing_key" : "authority_signing_key"); legacy ? "legacy_signing_key" : "authority_signing_key");
signing_key = init_key_from_file(fname, 0, LOG_INFO); signing_key = init_key_from_file(fname, 0, LOG_INFO, 0);
if (!signing_key) { if (!signing_key) {
log_warn(LD_DIR, "No version 3 directory key found in %s", fname); log_warn(LD_DIR, "No version 3 directory key found in %s", fname);
goto done; goto done;
@ -828,7 +832,7 @@ init_keys(void)
/* 1b. Read identity key. Make it if none is found. */ /* 1b. Read identity key. Make it if none is found. */
keydir = get_datadir_fname2("keys", "secret_id_key"); keydir = get_datadir_fname2("keys", "secret_id_key");
log_info(LD_GENERAL,"Reading/making identity key \"%s\"...",keydir); log_info(LD_GENERAL,"Reading/making identity key \"%s\"...",keydir);
prkey = init_key_from_file(keydir, 1, LOG_ERR); prkey = init_key_from_file(keydir, 1, LOG_ERR, 1);
tor_free(keydir); tor_free(keydir);
if (!prkey) return -1; if (!prkey) return -1;
set_server_identity_key(prkey); set_server_identity_key(prkey);
@ -851,7 +855,7 @@ init_keys(void)
/* 2. Read onion key. Make it if none is found. */ /* 2. Read onion key. Make it if none is found. */
keydir = get_datadir_fname2("keys", "secret_onion_key"); keydir = get_datadir_fname2("keys", "secret_onion_key");
log_info(LD_GENERAL,"Reading/making onion key \"%s\"...",keydir); log_info(LD_GENERAL,"Reading/making onion key \"%s\"...",keydir);
prkey = init_key_from_file(keydir, 1, LOG_ERR); prkey = init_key_from_file(keydir, 1, LOG_ERR, 1);
tor_free(keydir); tor_free(keydir);
if (!prkey) return -1; if (!prkey) return -1;
set_onion_key(prkey); set_onion_key(prkey);
@ -876,7 +880,7 @@ init_keys(void)
keydir = get_datadir_fname2("keys", "secret_onion_key.old"); keydir = get_datadir_fname2("keys", "secret_onion_key.old");
if (!lastonionkey && file_status(keydir) == FN_FILE) { if (!lastonionkey && file_status(keydir) == FN_FILE) {
prkey = init_key_from_file(keydir, 1, LOG_ERR); /* XXXX Why 1? */ prkey = init_key_from_file(keydir, 1, LOG_ERR, 0); /* XXXX Why 1? */
if (prkey) if (prkey)
lastonionkey = prkey; lastonionkey = prkey;
} }

View File

@ -29,7 +29,7 @@ crypto_pk_t *get_my_v3_legacy_signing_key(void);
void dup_onion_keys(crypto_pk_t **key, crypto_pk_t **last); void dup_onion_keys(crypto_pk_t **key, crypto_pk_t **last);
void rotate_onion_key(void); void rotate_onion_key(void);
crypto_pk_t *init_key_from_file(const char *fname, int generate, crypto_pk_t *init_key_from_file(const char *fname, int generate,
int severity); int severity, int log_greeting);
void v3_authority_check_key_expiry(void); void v3_authority_check_key_expiry(void);
di_digest256_map_t *construct_ntor_key_map(void); di_digest256_map_t *construct_ntor_key_map(void);