From f118dc80e0ef2eeb62ae52ed107af3384e2a1afd Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Mon, 30 May 2011 15:31:06 -0400 Subject: [PATCH 1/2] minor cleanups while reviewing 3216 --- src/or/config.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/or/config.c b/src/or/config.c index 117925549e..f97e9b1bea 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -211,7 +211,7 @@ static config_var_t _option_vars[] = { V(ControlPortFileGroupReadable,BOOL, "0"), V(ControlPortWriteToFile, FILENAME, NULL), V(ControlSocket, LINELIST, NULL), - V(ControlSocketsGroupWritable, BOOL, "0"), + V(ControlSocketsGroupWritable, BOOL, "0"), V(CookieAuthentication, BOOL, "0"), V(CookieAuthFileGroupReadable, BOOL, "0"), V(CookieAuthFile, STRING, NULL), @@ -2064,6 +2064,7 @@ get_assigned_option(config_format_t *fmt, void *options, escape_val = 0; break; } + /* fall through */ case CONFIG_TYPE_INTERVAL: case CONFIG_TYPE_UINT: /* This means every or_options_t uint or bool element From ca538290af507833c7cd5df7f663507c3540448d Mon Sep 17 00:00:00 2001 From: Sebastian Hahn Date: Sun, 29 May 2011 00:54:59 +0200 Subject: [PATCH 2/2] Warn when two hs use the same directory This simple implementation has a few issues, but it should do for 0.2.2.x. We will want to revisit this later and make it smarter. --- changes/bug3289 | 5 +++++ src/or/rendservice.c | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 changes/bug3289 diff --git a/changes/bug3289 b/changes/bug3289 new file mode 100644 index 0000000000..c469796d6e --- /dev/null +++ b/changes/bug3289 @@ -0,0 +1,5 @@ + o Minor bugfixes: + - Warn when the user configures two HiddenServiceDir lines that point + to the same directory. Bugfix on 0.0.6 (the version introducing + HiddenServiceDir); fixes bug 3289. + diff --git a/src/or/rendservice.c b/src/or/rendservice.c index edcf59d870..a10e43fead 100644 --- a/src/or/rendservice.c +++ b/src/or/rendservice.c @@ -181,6 +181,31 @@ rend_add_service(rend_service_t *service) log_warn(LD_CONFIG, "Hidden service with no ports configured; ignoring."); rend_service_free(service); } else { + int dupe = 0; + /* XXX This duplicate check has two problems: + * + * a) It's O(n^2), but the same comment from the bottom of + * rend_config_services() should apply. + * + * b) We only compare directory paths as strings, so we can't + * detect two distinct paths that specify the same directory + * (which can arise from symlinks, case-insensitivity, bind + * mounts, etc.). + * + * It also can't detect that two separate Tor instances are trying + * to use the same HiddenServiceDir; for that, we would need a + * lock file. But this is enough to detect a simple mistake that + * at least one person has actually made. + */ + SMARTLIST_FOREACH(rend_service_list, rend_service_t*, ptr, + dupe = dupe || + !strcmp(ptr->directory, service->directory)); + if (dupe) { + log_warn(LD_REND, "Another hidden service is already configured for " + "directory %s, ignoring.", service->directory); + rend_service_free(service); + return; + } smartlist_add(rend_service_list, service); log_debug(LD_REND,"Configuring service with directory \"%s\"", service->directory);