kgiusti commented on a change in pull request #676: DISPATCH-1518: Added 
ability to turn on protocol frame trace logging …
URL: https://github.com/apache/qpid-dispatch/pull/676#discussion_r377677295
 
 

 ##########
 File path: src/router_core/agent_connection.c
 ##########
 @@ -563,47 +568,103 @@ void qdra_connection_update_CT(qdr_core_t      *core,
         // Find the connection that the user connected on. This connection 
must have the correct policy rights which
         // will allow the user on this connection to terminate some other 
connection.
         qdr_connection_t *user_conn = _find_conn_CT(core, query->in_conn);
+        qd_parsed_field_t *trace_field   = qd_parse_value_by_key(in_body, 
qdr_connection_columns[QDR_CONNECTION_ENABLE_PROTOCOL_TRACE]);
+        bool enable_protocol_trace = !!trace_field ? 
qd_parse_as_bool(trace_field) : false;
+
+        qdr_connection_t *conn = 0;
+
+        bool admin_status_bad_or_forbidden = false;
+
+        if (admin_state) {
+
+            if (!user_conn) {
+                // This is bad. The user connection (that was requesting that 
some
+                // other connection be dropped) is gone
+                query->status.description = "Parent connection no longer 
exists";
+                qdra_connection_set_bad_request(query);
+                admin_status_bad_or_forbidden = true;
+            }
+            else {
+                if (!user_conn->policy_allow_admin_status_update) {
+                    //
+                    // Policy on the connection that is requesting that some 
other connection be deleted does not allow
+                    // for the other connection to be deleted.Set the status 
to QD_AMQP_FORBIDDEN and just quit.
+                    //
+                    query->status = QD_AMQP_FORBIDDEN;
+                    query->status.description = "You are not allowed to 
perform this operation.";
+                    qd_compose_start_map(query->body);
+                    qd_compose_end_map(query->body);
+                    admin_status_bad_or_forbidden = true;
+                 }
+                else if (admin_state) { //admin state and trace are the only 
fields that can be updated via the update management request for type 
connection.
+                    if (identity) {
+                        conn = qdr_connection_find_by_identity_CT(core, 
identity);
+                        qdra_connection_update_set_status(core, query, conn, 
admin_state);
+                    }
+                    else {
+                        qdra_connection_set_bad_request(query);
+                        admin_status_bad_or_forbidden = true;
+                    }
+                }
+                else {
+                    qdra_connection_set_bad_request(query);
+                    admin_status_bad_or_forbidden = true;
+                }
+            }
+        }
+
+        if (admin_status_bad_or_forbidden) {
+            //
+            // Enqueue the response and return
+            //
+            qdr_agent_enqueue_response_CT(core, query);
+            return;
+        }
 
-        if (!user_conn) {
-            // This is bad. The user connection (that was requesting that some
-            // other connection be dropped) is gone
-            query->status.description = "Parent connection no longer exists";
+        //
+        // The only two fields that can be updated on a connection is the 
enableProtocolTrace flag and the admin state.
+        // If both these fields are not there, this is a bad request
+        // For example, this qdmanage is a bad request - qdmanage update 
--type=connection identity=1
+        //
+        if (!trace_field && !admin_state) {
 
 Review comment:
   why not check this first?  You've already checked admin_state above so this 
really is confusing.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@qpid.apache.org
For additional commands, e-mail: dev-h...@qpid.apache.org

Reply via email to