summaryrefslogtreecommitdiff
path: root/src/or/dnsserv.c
diff options
context:
space:
mode:
authorRobert Hogan <robert@roberthogan.net>2010-08-06 20:29:15 +0100
committerRobert Hogan <robert@roberthogan.net>2010-08-08 12:37:59 +0100
commit462568674a2465e8eb9cbb1cda65fa3e736c99fd (patch)
treed32105b4c399849dcf590d034cb8b979bb994970 /src/or/dnsserv.c
parentf060b18e6c4292be58de0e1b08f25b770cbddff8 (diff)
downloadtor-462568674a2465e8eb9cbb1cda65fa3e736c99fd.tar.gz
tor-462568674a2465e8eb9cbb1cda65fa3e736c99fd.zip
Ensure controller RESOLVE commands respect __LeaveStreamsUnattached
https://trac.torproject.org/projects/tor/ticket/1525 "The codepath taken by the control port "RESOLVE" command to create a synthetic SOCKS resolve request isn't the same as the path taken by a real SOCKS request from 'tor-resolve'. This prevents controllers who set LeaveStreamsUnattached=1 from being able to attach RESOLVE streams to circuits of their choosing." Create a new function connection_ap_rewrite_and_attach_if_allowed() and call that when Tor needs to attach a stream to a circuit but needs to know if the controller permits it. No tests added.
Diffstat (limited to 'src/or/dnsserv.c')
-rw-r--r--src/or/dnsserv.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/or/dnsserv.c b/src/or/dnsserv.c
index e231b655f4..ad4f4122bc 100644
--- a/src/or/dnsserv.c
+++ b/src/or/dnsserv.c
@@ -141,16 +141,17 @@ evdns_server_callback(struct evdns_server_request *req, void *_data)
control_event_stream_status(conn, STREAM_EVENT_NEW, 0);
- /* Now, throw the connection over to get rewritten (which will answer it
- * immediately if it's in the cache, or completely bogus, or automapped),
- * and then attached to a circuit. */
+ /* Now, unless a controller asked us to leave streams unattached,
+ * throw the connection over to get rewritten (which will
+ * answer it immediately if it's in the cache, or completely bogus, or
+ * automapped), and then attached to a circuit. */
log_info(LD_APP, "Passing request for %s to rewrite_and_attach.",
escaped_safe_str_client(q->name));
q_name = tor_strdup(q->name); /* q could be freed in rewrite_and_attach */
- connection_ap_handshake_rewrite_and_attach(conn, NULL, NULL);
+ connection_ap_rewrite_and_attach_if_allowed(conn, NULL, NULL);
/* Now, the connection is marked if it was bad. */
- log_info(LD_APP, "Passed request for %s to rewrite_and_attach.",
+ log_info(LD_APP, "Passed request for %s to rewrite_and_attach_if_allowed.",
escaped_safe_str_client(q_name));
tor_free(q_name);
}
@@ -186,16 +187,17 @@ dnsserv_launch_request(const char *name, int reverse)
return -1;
}
- /* Now, throw the connection over to get rewritten (which will answer it
- * immediately if it's in the cache, or completely bogus, or automapped),
- * and then attached to a circuit. */
+ /* Now, unless a controller asked us to leave streams unattached,
+ * throw the connection over to get rewritten (which will
+ * answer it immediately if it's in the cache, or completely bogus, or
+ * automapped), and then attached to a circuit. */
log_info(LD_APP, "Passing request for %s to rewrite_and_attach.",
escaped_safe_str_client(name));
q_name = tor_strdup(name); /* q could be freed in rewrite_and_attach */
- connection_ap_handshake_rewrite_and_attach(conn, NULL, NULL);
+ connection_ap_rewrite_and_attach_if_allowed(conn, NULL, NULL);
/* Now, the connection is marked if it was bad. */
- log_info(LD_APP, "Passed request for %s to rewrite_and_attach.",
+ log_info(LD_APP, "Passed request for %s to rewrite_and_attach_if_allowed.",
escaped_safe_str_client(q_name));
tor_free(q_name);
return 0;