]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
config: Fix duplicate error message for nonlocal SocksPorts.
authorIsis Lovecruft <isis@torproject.org>
Thu, 22 Jun 2017 00:28:31 +0000 (00:28 +0000)
committerIsis Lovecruft <isis@torproject.org>
Thu, 22 Jun 2017 00:28:31 +0000 (00:28 +0000)
If `validate_only` is true, then just validate the configuration without warning
about it.  This way, we only emit warnings when the listener is actually opened.
(Otherwise, every time we parse the config we will might re-warn and we would
need to keep state; whereas the listeners are only opened once.)

 * FIXES #4019.

src/or/config.c

index 7d2ebbdd03226a996fe11fc16fb78079cf3b0478..a1bd8352208f1404893c635de1bc24a37f517154 100644 (file)
@@ -6251,8 +6251,9 @@ port_cfg_free(port_cfg_t *port)
 /** Warn for every port in <b>ports</b> of type <b>listener_type</b> that is
  * on a publicly routable address. */
 static void
-warn_nonlocal_client_ports(const smartlist_t *ports, const char *portname,
-                           int listener_type)
+warn_nonlocal_client_ports(const smartlist_t *ports,
+                           const char *portname,
+                           const int listener_type)
 {
   SMARTLIST_FOREACH_BEGIN(ports, const port_cfg_t *, port) {
     if (port->type != listener_type)
@@ -6936,7 +6937,8 @@ parse_ports(or_options_t *options, int validate_only,
              options->SocksPort_lines,
              "Socks", CONN_TYPE_AP_LISTENER,
              "127.0.0.1", 9050,
-             CL_PORT_WARN_NONLOCAL|CL_PORT_TAKES_HOSTNAMES|gw_flag) < 0) {
+             ((validate_only ? 0 : CL_PORT_WARN_NONLOCAL)
+              | CL_PORT_TAKES_HOSTNAMES | gw_flag)) < 0) {
     *msg = tor_strdup("Invalid SocksPort configuration");
     goto err;
   }