Skip to content

Commit 77e34f9

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 3a7b94c commit 77e34f9

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)
@@ -1312,7 +1312,7 @@ static int is_special_keypress(Ghandles * g, const XKeyEvent * ev, XID remote_wi
13121312
if (len > 0) {
13131313
/* MSG_CLIPBOARD_DATA used to use the window field to pass the length
13141314
of the blob, be aware when working with old implementations. */
1315-
if (g->agent_version < 0x00010002)
1315+
if (g->protocol_version < PROTOCOL_VERSION(1, 2))
13161316
hdr.window = len;
13171317
else
13181318
hdr.window = remote_winid;
@@ -3603,6 +3603,10 @@ static void send_xconf(Ghandles * g)
36033603
XWindowAttributes attr;
36043604
if (!XGetWindowAttributes(g->display, g->root_win, &attr))
36053605
errx(1, "Cannot query root window attributes!");
3606+
if (g->protocol_version >= PROTOCOL_VERSION(1, 4)) {
3607+
/* Bidirectional protocol negotiation is supported */
3608+
write_struct(g->vchan, g->protocol_version);
3609+
}
36063610
xconf.w = _VIRTUALX(attr.width);
36073611
xconf.h = attr.height;
36083612
xconf.depth = attr.depth;
@@ -3621,10 +3625,9 @@ static void get_protocol_version(Ghandles * g)
36213625
version_major = untrusted_version >> 16;
36223626
version_minor = untrusted_version & 0xffff;
36233627

3624-
if (version_major == PROTOCOL_VERSION_MAJOR &&
3625-
version_minor <= PROTOCOL_VERSION_MINOR) {
3628+
if (version_major == PROTOCOL_VERSION_MAJOR) {
36263629
/* agent is compatible */
3627-
g->agent_version = version_major << 16 | version_minor;
3630+
g->protocol_version = PROTOCOL_VERSION(version_major, min(version_minor, PROTOCOL_VERSION_MINOR));
36283631
return;
36293632
}
36303633
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)