relayd: return invalid protocol error on close chunk disallowed clear
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 12 Dec 2019 17:53:27 +0000 (12:53 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 19 Dec 2019 23:37:07 +0000 (18:37 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ic10283d5a9769f01486d3f6df07f54a8d2856699
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-relayd/main.c

index 5e99befa7c5c775ef888a4166366abf44a9a3114..4e30ac49882e5c392097b51dfedf95b0d7207686 100644 (file)
@@ -2699,6 +2699,20 @@ static int relay_close_trace_chunk(const struct lttcomm_relayd_hdr *recv_hdr,
        }
 
        pthread_mutex_lock(&session->lock);
+       if (close_command.is_set &&
+                       close_command.value == LTTNG_TRACE_CHUNK_COMMAND_TYPE_DELETE) {
+               /*
+                * Clear command. It is a protocol error to ask for a
+                * clear on a relay which does not allow it. Querying
+                * the configuration allows figuring out whether
+                * clearing is allowed before doing the clear.
+                */
+               if (!opt_allow_clear) {
+                       ret = -1;
+                       reply_code = LTTNG_ERR_INVALID_PROTOCOL;
+                       goto end_unlock_session;
+               }
+       }
        if (session->pending_closure_trace_chunk &&
                        session->pending_closure_trace_chunk != chunk) {
                ERR("Trace chunk close command for session \"%s\" does not target the trace chunk pending closure",
This page took 0.027343 seconds and 4 git commands to generate.