瀏覽代碼

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

Nick Mathewson 14 年之前
父節點
當前提交
d274f539e5
共有 3 個文件被更改,包括 32 次插入1 次删除
  1. 5 0
      changes/bug3289
  2. 2 1
      src/or/config.c
  3. 25 0
      src/or/rendservice.c

+ 5 - 0
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.
+

+ 2 - 1
src/or/config.c

@@ -216,7 +216,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),
@@ -2124,6 +2124,7 @@ get_assigned_option(config_format_t *fmt, void *options,
         escape_val = 0;
         break;
       }
+      /* fall through */
     case CONFIG_TYPE_INTERVAL:
     case CONFIG_TYPE_MSEC_INTERVAL:
     case CONFIG_TYPE_UINT:

+ 25 - 0
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);