Skip to content

Commit dbedc23

Browse files
committed
Bidirectional GUI protocol negotiation
This implements GUI protocol v1.4, which includes bidirectional protocol negotiation. This means that not only does the agent tell the daemon what protocol version it supports, the daemon also tells the agent what protocol version it decided to actually use. This may be less than the version supported by the agent. As a result, a GUI daemon including this patch may be used with any version of the GUI agent supporting protocol major version 1, even ones that support higher minor versions than the daemon does.
1 parent d7169ce commit dbedc23

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

gui-daemon/xside.c

+9-6
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@
6969
/* Supported protocol version */
7070

7171
#define PROTOCOL_VERSION_MAJOR 1
72-
#define PROTOCOL_VERSION_MINOR 3
73-
#define PROTOCOL_VERSION (PROTOCOL_VERSION_MAJOR << 16 | PROTOCOL_VERSION_MINOR)
72+
#define PROTOCOL_VERSION_MINOR 4
73+
#define PROTOCOL_VERSION(x, y) ((x) << 16 | (y))
7474

7575
#if !(PROTOCOL_VERSION_MAJOR == QUBES_GUID_PROTOCOL_VERSION_MAJOR && \
7676
PROTOCOL_VERSION_MINOR <= QUBES_GUID_PROTOCOL_VERSION_MINOR)
@@ -1311,7 +1311,7 @@ static int is_special_keypress(Ghandles * g, const XKeyEvent * ev, XID remote_wi
13111311
if (len > 0) {
13121312
/* MSG_CLIPBOARD_DATA used to use the window field to pass the length
13131313
of the blob, be aware when working with old implementations. */
1314-
if (g->agent_version < 0x00010002)
1314+
if (g->protocol_version < PROTOCOL_VERSION(1, 2))
13151315
hdr.window = len;
13161316
else
13171317
hdr.window = remote_winid;
@@ -3602,6 +3602,10 @@ static void send_xconf(Ghandles * g)
36023602
XWindowAttributes attr;
36033603
if (XGetWindowAttributes(g->display, g->root_win, &attr) != Success)
36043604
err(1, "XGetWindowAttributes");
3605+
if (g->protocol_version >= PROTOCOL_VERSION(1, 4)) {
3606+
/* Bidirectional protocol negotiation is supported */
3607+
write_struct(g->vchan, g->protocol_version);
3608+
}
36053609
xconf.w = _VIRTUALX(attr.width);
36063610
xconf.h = attr.height;
36073611
xconf.depth = attr.depth;
@@ -3620,10 +3624,9 @@ static void get_protocol_version(Ghandles * g)
36203624
version_major = untrusted_version >> 16;
36213625
version_minor = untrusted_version & 0xffff;
36223626

3623-
if (version_major == PROTOCOL_VERSION_MAJOR &&
3624-
version_minor <= PROTOCOL_VERSION_MINOR) {
3627+
if (version_major == PROTOCOL_VERSION_MAJOR) {
36253628
/* agent is compatible */
3626-
g->agent_version = version_major << 16 | version_minor;
3629+
g->protocol_version = version_major << 16 | min(version_minor, PROTOCOL_VERSION_MINOR);
36273630
return;
36283631
}
36293632
if (version_major < PROTOCOL_VERSION_MAJOR) {

gui-daemon/xside.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ struct _global_handles {
181181
char vmname[32]; /* name of VM */
182182
int domid; /* Xen domain id (GUI) */
183183
int target_domid; /* Xen domain id (VM) - can differ from domid when GUI is stubdom */
184-
uint32_t agent_version; /* gui-agent (protocol) version */
184+
uint32_t protocol_version; /* gui-agent (protocol) version */
185185
char *cmdline_color; /* color of frame */
186186
uint32_t label_color_rgb; /* color of the frame in RGB */
187187
char *cmdline_icon; /* icon hint for WM */

0 commit comments

Comments
 (0)