summaryrefslogtreecommitdiff
path: root/src/feature/control/control.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-12-13 19:35:02 -0500
committerNick Mathewson <nickm@torproject.org>2018-12-13 19:35:02 -0500
commit4bc3983f64ab2a60a79127f47573836373ddf587 (patch)
treed36b88ccf7336de0a685ebdfea00c69891a4a6f2 /src/feature/control/control.c
parentf8dac5c900856494867996f60da848b0111aad35 (diff)
downloadtor-4bc3983f64ab2a60a79127f47573836373ddf587.tar.gz
tor-4bc3983f64ab2a60a79127f47573836373ddf587.zip
Add a DROPOWNERSHIP controller command to undo TAKEOWNERSHIP.
Closes ticket 28843.
Diffstat (limited to 'src/feature/control/control.c')
-rw-r--r--src/feature/control/control.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/feature/control/control.c b/src/feature/control/control.c
index c2da7fe48b..50f43c0f44 100644
--- a/src/feature/control/control.c
+++ b/src/feature/control/control.c
@@ -1741,6 +1741,26 @@ handle_control_takeownership(control_connection_t *conn, uint32_t len,
return 0;
}
+/** Called when we get a DROPOWNERSHIP command. Mark this connection
+ * as a non-owning connection, so that we will not exit if the connection
+ * closes. */
+static int
+handle_control_dropownership(control_connection_t *conn, uint32_t len,
+ const char *body)
+{
+ (void)len;
+ (void)body;
+
+ conn->is_owning_control_connection = 0;
+
+ log_info(LD_CONTROL, "Control connection %d has dropped ownership of this "
+ "Tor instance.",
+ (int)(conn->base_.s));
+
+ send_control_done(conn);
+ return 0;
+}
+
/** Return true iff <b>addr</b> is unusable as a mapaddress target because of
* containing funny characters. */
static int
@@ -5548,6 +5568,9 @@ connection_control_process_inbuf(control_connection_t *conn)
} else if (!strcasecmp(conn->incoming_cmd, "TAKEOWNERSHIP")) {
if (handle_control_takeownership(conn, cmd_data_len, args))
return -1;
+ } else if (!strcasecmp(conn->incoming_cmd, "DROPOWNERSHIP")) {
+ if (handle_control_dropownership(conn, cmd_data_len, args))
+ return -1;
} else if (!strcasecmp(conn->incoming_cmd, "MAPADDRESS")) {
if (handle_control_mapaddress(conn, cmd_data_len, args))
return -1;