]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Make hidden service use the config unix prefix
authorDavid Goulet <dgoulet@ev0ke.net>
Wed, 28 Jan 2015 23:01:53 +0000 (18:01 -0500)
committerDavid Goulet <dgoulet@ev0ke.net>
Wed, 28 Jan 2015 23:01:53 +0000 (18:01 -0500)
Signed-off-by: David Goulet <dgoulet@ev0ke.net>
src/or/rendservice.c

index 8d3f041759d620638a090c463ef6b055b70d1e62..69ea6a98579cccf29740d7f3c51de2a8d83010e7 100644 (file)
@@ -341,7 +341,6 @@ parse_port_config(const char *string)
   tor_addr_t addr;
   const char *addrport;
   rend_service_port_config_t *result = NULL;
-  const char *socket_prefix = "socket:";
   unsigned int is_unix_addr = 0;
   char *socket_path = NULL;
 
@@ -365,25 +364,19 @@ parse_port_config(const char *string)
     realport = virtport;
     tor_addr_from_ipv4h(&addr, 0x7F000001u); /* 127.0.0.1 */
   } else {
+    int ret;
+
     addrport = smartlist_get(sl,1);
-    /* If it starts with socket:, try to parse it as a socket path */
-    if (!strcmpstart(addrport, socket_prefix)) {
-      if (strlen(addrport + strlen(socket_prefix)) > 0) {
-#ifdef HAVE_SYS_UN_H
-        is_unix_addr = 1;
-        socket_path = tor_strdup(addrport + strlen(socket_prefix));
-#else
-        log_warn(LD_CONFIG,
-                 "Hidden service port configuration %s is for an AF_UNIX "
-                 "socket, but we have no support available on this platform",
-                 escaped(addrport));
-        goto err;
-#endif /* defined(HAVE_SYS_UN_H) */
-      } else {
+    ret = config_parse_unix_port(addrport, &socket_path);
+    if (ret < 0 && ret != ENOENT) {
+      if (ret == -EINVAL) {
         log_warn(LD_CONFIG,
                  "Empty socket path in hidden service port configuration.");
-        goto err;
       }
+      goto err;
+    }
+    if (socket_path) {
+      is_unix_addr = 1;
     } else if (strchr(addrport, ':') || strchr(addrport, '.')) {
       /* else try it as an IP:port pair if it has a : or . in it */
       if (tor_addr_port_lookup(addrport, &addr, &p)<0) {