Merge remote-tracking branch 'origin/maint-0.2.2'

Conflicts:
	src/or/dirserv.h
This commit is contained in:
Nick Mathewson
2011-04-26 11:05:54 -04:00
2 changed files with 9 additions and 55 deletions
+9
View File
@@ -0,0 +1,9 @@
o Minor bugfixes:
- If the Nickname configuration option wasn't given, Tor used to pick
a nickname based on the local hostname as the nickname for a relay.
Because nicknames are not very important in today's Tor and the
"Unnamed" nickname has been implemented, this is now problematic
behaviour: It leaks information about the hostname without being
useful at all. Bugfix on tor-0.1.2.2-alpha, which introduced the
Unnamed nickname. Fixes bug 2979, reported by tagnaq.
-55
View File
@@ -2554,54 +2554,6 @@ is_local_addr(const tor_addr_t *addr)
return 0;
}
/** Called when we don't have a nickname set. Try to guess a good nickname
* based on the hostname, and return it in a newly allocated string. If we
* can't, return NULL and let the caller warn if it wants to. */
static char *
get_default_nickname(void)
{
static const char * const bad_default_nicknames[] = {
"localhost",
NULL,
};
char localhostname[256];
char *cp, *out, *outp;
int i;
if (gethostname(localhostname, sizeof(localhostname)) < 0)
return NULL;
/* Put it in lowercase; stop at the first dot. */
if ((cp = strchr(localhostname, '.')))
*cp = '\0';
tor_strlower(localhostname);
/* Strip invalid characters. */
cp = localhostname;
out = outp = tor_malloc(strlen(localhostname) + 1);
while (*cp) {
if (strchr(LEGAL_NICKNAME_CHARACTERS, *cp))
*outp++ = *cp++;
else
cp++;
}
*outp = '\0';
/* Enforce length. */
if (strlen(out) > MAX_NICKNAME_LEN)
out[MAX_NICKNAME_LEN]='\0';
/* Check for dumb names. */
for (i = 0; bad_default_nicknames[i]; ++i) {
if (!strcmp(out, bad_default_nicknames[i])) {
tor_free(out);
return NULL;
}
}
return out;
}
/** Release storage held by <b>options</b>. */
static void
config_free(config_format_t *fmt, void *options)
@@ -3034,14 +2986,7 @@ options_validate(or_options_t *old_options, or_options_t *options,
if (options->Nickname == NULL) {
if (server_mode(options)) {
if (!(options->Nickname = get_default_nickname())) {
log_notice(LD_CONFIG, "Couldn't pick a nickname based on "
"our hostname; using %s instead.", UNNAMED_ROUTER_NICKNAME);
options->Nickname = tor_strdup(UNNAMED_ROUTER_NICKNAME);
} else {
log_notice(LD_CONFIG, "Choosing default nickname '%s'",
options->Nickname);
}
}
} else {
if (!is_legal_nickname(options->Nickname)) {