[Spice-devel] [PATCH spice 2/2] reds: Adjust agent capabilites to disabled features

Pavel Grunt pgrunt at redhat.com
Tue Dec 20 19:39:32 UTC 2016


File transfer and Copy & Paste can be disabled, tell it the client
by adjusting the agent capabilities.

Require newer protocol for VD_AGENT_CLEAR_CAPABILITY() and
VD_AGENT_CAP_FILE_XFER_DISABLED.

Related: rhbz#1373725
---
 configure.ac  |  2 +-
 server/reds.c | 17 ++++++++++++++++-
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index a78b4ece..c155c355 100644
--- a/configure.ac
+++ b/configure.ac
@@ -142,7 +142,7 @@ AS_IF([test x"$have_smartcard" = "xyes"], [
     AS_VAR_APPEND([SPICE_REQUIRES], [" libcacard >= 0.1.2"])
 ])
 
-SPICE_PROTOCOL_MIN_VER=0.12.12
+SPICE_PROTOCOL_MIN_VER=0.12.13
 PKG_CHECK_MODULES([SPICE_PROTOCOL], [spice-protocol >= $SPICE_PROTOCOL_MIN_VER])
 AC_SUBST([SPICE_PROTOCOL_MIN_VER])
 
diff --git a/server/reds.c b/server/reds.c
index 3127b188..02e7e702 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -733,6 +733,18 @@ static void vdi_port_read_buf_free(RedPipeItem *base)
     }
 }
 
+static void reds_update_agent_caps(RedsState *reds, VDAgentAnnounceCapabilities *capabilities)
+{
+    if (!reds->config->agent_file_xfer) {
+        VD_AGENT_SET_CAPABILITY(capabilities->caps, VD_AGENT_CAP_FILE_XFER_DISABLED);
+    }
+    if (!reds->config->agent_copypaste) {
+        VD_AGENT_CLEAR_CAPABILITY(capabilities->caps, VD_AGENT_CAP_CLIPBOARD);
+        VD_AGENT_CLEAR_CAPABILITY(capabilities->caps, VD_AGENT_CAP_CLIPBOARD_BY_DEMAND);
+        VD_AGENT_CLEAR_CAPABILITY(capabilities->caps, VD_AGENT_CAP_CLIPBOARD_SELECTION);
+    }
+}
+
 /* reads from the device till completes reading a message that is addressed to the client,
  * or otherwise, when reading from the device fails */
 static RedPipeItem *vdi_port_read_one_msg_from_device(RedCharDevice *self,
@@ -795,7 +807,10 @@ static RedPipeItem *vdi_port_read_one_msg_from_device(RedCharDevice *self,
                 dev->priv->read_state = VDI_PORT_READ_STATE_GET_BUFF;
             }
             switch (vdi_port_read_buf_process(reds->agent_dev, dispatch_buf)) {
-            case AGENT_MSG_FILTER_CAPABILITIES:
+            case AGENT_MSG_FILTER_CAPABILITIES: {
+                VDAgentMessage *agent_message = (VDAgentMessage *) dispatch_buf->data;
+                reds_update_agent_caps(reds, (VDAgentAnnounceCapabilities *) agent_message->data);
+            }
                 /* fall through */
             case AGENT_MSG_FILTER_OK:
                 return &dispatch_buf->base;
-- 
2.11.0



More information about the Spice-devel mailing list