aboutsummaryrefslogtreecommitdiff
path: root/src/or/rendservice.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-05-30 15:51:46 -0400
committerNick Mathewson <nickm@torproject.org>2011-05-30 15:51:46 -0400
commitd274f539e5ae8ffe50f2bb364c3a3b64e3920e9c (patch)
tree100ee1d09b9165be4c501bf9dfb7b93ee680976b /src/or/rendservice.c
parentfa1d47293b62fd378a7e43cf3ce3e7bb3be884e3 (diff)
parentd35a555348dfccb19d7534af24d3c364372d515b (diff)
downloadtor-d274f539e5ae8ffe50f2bb364c3a3b64e3920e9c.tar
tor-d274f539e5ae8ffe50f2bb364c3a3b64e3920e9c.tar.gz
Merge remote-tracking branch 'origin/maint-0.2.2'
Diffstat (limited to 'src/or/rendservice.c')
-rw-r--r--src/or/rendservice.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index fa81fb3d0..79abc57ee 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -182,6 +182,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);