diff options
author | Peter Hutterer <peter@cs.unisa.edu.au> | 2008-04-26 19:03:13 +0930 |
---|---|---|
committer | Peter Hutterer <peter@cs.unisa.edu.au> | 2008-04-26 19:03:13 +0930 |
commit | 7447a30fb27ed50a20a85b5a2de9afe7dea8cfa5 (patch) | |
tree | 0596d9c93dc1368f01dc6d7ea261360ea987dd11 | |
parent | 8973a3f7983240407dd6da59b3643f40e6a3d83a (diff) |
Xi: if a pre-XI2 client tries to list the devices, pretend we don't have any.
XI 1.x isn't supported anymore, so let's pretend we don't have any devices.
This stops clients from opening them and thus stops interference.
-rw-r--r-- | Xi/listdev.c | 64 |
1 files changed, 47 insertions, 17 deletions
diff --git a/Xi/listdev.c b/Xi/listdev.c index 3fb0ab314..fc2748e41 100644 --- a/Xi/listdev.c +++ b/Xi/listdev.c @@ -64,6 +64,7 @@ SOFTWARE. #include "XIstubs.h" #include "extnsionst.h" #include "exglobals.h" /* FIXME */ +#include "exevents.h" #include "xace.h" #include "listdev.h" @@ -313,12 +314,17 @@ CopySwapClasses(ClientPtr client, DeviceIntPtr dev, CARD8 *num_classes, * * This procedure lists the input devices available to the server. * + * If this request is called by a client that has not issued a + * GetExtensionVersion request with major/minor version set, we pretend no + * devices are available. It's the only thing we can do to stop pre-XI 2 + * clients. */ int ProcXListInputDevices(ClientPtr client) { xListInputDevicesReply rep; + XIClientPtr pXIClient; int numdevs = 0; int namesize = 1; /* need 1 extra byte for strcpy */ int rc, size = 0; @@ -337,21 +343,38 @@ ProcXListInputDevices(ClientPtr client) rep.length = 0; rep.sequenceNumber = client->sequence; + pXIClient = dixLookupPrivate(&client->devPrivates, XIClientPrivateKey); + AddOtherInputDevices(); - for (d = inputInfo.devices; d; d = d->next) { - rc = XaceHook(XACE_DEVICE_ACCESS, client, d, DixGetAttrAccess); - if (rc != Success) - return rc; - SizeDeviceInfo(d, &namesize, &size); - numdevs++; - } - for (d = inputInfo.off_devices; d; d = d->next) { - rc = XaceHook(XACE_DEVICE_ACCESS, client, d, DixGetAttrAccess); - if (rc != Success) - return rc; - SizeDeviceInfo(d, &namesize, &size); - numdevs++; + if (!pXIClient->major_version >= XI_2_Major) { + for (d = inputInfo.devices; d; d = d->next) { + rc = XaceHook(XACE_DEVICE_ACCESS, client, d, DixGetAttrAccess); + if (rc != Success) + return rc; + SizeDeviceInfo(d, &namesize, &size); + numdevs++; + } + for (d = inputInfo.off_devices; d; d = d->next) { + rc = XaceHook(XACE_DEVICE_ACCESS, client, d, DixGetAttrAccess); + if (rc != Success) + return rc; + SizeDeviceInfo(d, &namesize, &size); + numdevs++; + } + } else + { + /* Pretend we don't have XI devices connected */ + rc = XaceHook(XACE_DEVICE_ACCESS, client, inputInfo.pointer, DixGetAttrAccess); + if (rc != Success) + return rc; + rc = XaceHook(XACE_DEVICE_ACCESS, client, inputInfo.keyboard, DixGetAttrAccess); + if (rc != Success) + return rc; + + SizeDeviceInfo(inputInfo.pointer, &namesize, &size); + SizeDeviceInfo(inputInfo.keyboard, &namesize, &size); + numdevs = 2; } total_length = numdevs * sizeof(xDeviceInfo) + size + namesize; @@ -361,10 +384,17 @@ ProcXListInputDevices(ClientPtr client) savbuf = devbuf; dev = (xDeviceInfoPtr) devbuf; - for (d = inputInfo.devices; d; d = d->next, dev++) - ListDeviceInfo(client, d, dev, &devbuf, &classbuf, &namebuf); - for (d = inputInfo.off_devices; d; d = d->next, dev++) - ListDeviceInfo(client, d, dev, &devbuf, &classbuf, &namebuf); + if (pXIClient->major_version >= XI_2_Major) + { + for (d = inputInfo.devices; d; d = d->next, dev++) + ListDeviceInfo(client, d, dev, &devbuf, &classbuf, &namebuf); + for (d = inputInfo.off_devices; d; d = d->next, dev++) + ListDeviceInfo(client, d, dev, &devbuf, &classbuf, &namebuf); + } else + { + ListDeviceInfo(client, inputInfo.pointer, dev, &devbuf, &classbuf, &namebuf); + ListDeviceInfo(client, inputInfo.keyboard, dev, &devbuf, &classbuf, &namebuf); + } rep.ndevices = numdevs; rep.length = (total_length + 3) >> 2; |