diff options
author | Eamon Walsh <ewalsh@tycho.nsa.gov> | 2009-09-15 19:29:34 -0400 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2009-10-27 14:27:47 -0700 |
commit | c1c7feec90be7494a23f97e5a1dda0e140abeac2 (patch) | |
tree | 7f9396b707c860748323c1fc8c537fdc6ac901c9 | |
parent | 439c58849304907900e4dc7429aedb0192749c02 (diff) |
xace: Fake return values on denials in input polling requests.
Instead of returning BadAccess when "read" permission is denied
on a device, falsify the device state (buttons down, keys pressed).
This is nicer to applications, but may still have undesired side
effects. The long-term solution is not to use these requests in
event-driven code!
Requests affected: QueryPointer, QueryKeymap, XiQueryDevice.
[Backport to 1.6]
Signed-off-by: Eamon Walsh <ewalsh@tycho.nsa.gov>
Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r-- | Xi/queryst.c | 14 | ||||
-rw-r--r-- | dix/devices.c | 5 | ||||
-rw-r--r-- | dix/events.c | 11 |
3 files changed, 23 insertions, 7 deletions
diff --git a/Xi/queryst.c b/Xi/queryst.c index 21de843f3..2d5402027 100644 --- a/Xi/queryst.c +++ b/Xi/queryst.c @@ -96,7 +96,7 @@ ProcXQueryDeviceState(ClientPtr client) rep.sequenceNumber = client->sequence; rc = dixLookupDevice(&dev, stuff->deviceid, client, DixReadAccess); - if (rc != Success) + if (rc != Success && rc != BadAccess) return rc; v = dev->valuator; @@ -129,8 +129,9 @@ ProcXQueryDeviceState(ClientPtr client) tk->class = KeyClass; tk->length = sizeof(xKeyState); tk->num_keys = k->curKeySyms.maxKeyCode - k->curKeySyms.minKeyCode + 1; - for (i = 0; i < 32; i++) - tk->keys[i] = k->down[i]; + if (rc != BadAccess) + for (i = 0; i < 32; i++) + tk->keys[i] = k->down[i]; buf += sizeof(xKeyState); } @@ -139,7 +140,8 @@ ProcXQueryDeviceState(ClientPtr client) tb->class = ButtonClass; tb->length = sizeof(xButtonState); tb->num_buttons = b->numButtons; - memcpy(tb->buttons, b->down, sizeof(b->down)); + if (rc != BadAccess) + memcpy(tb->buttons, b->down, sizeof(b->down)); buf += sizeof(xButtonState); } @@ -151,7 +153,9 @@ ProcXQueryDeviceState(ClientPtr client) tv->mode = v->mode; buf += sizeof(xValuatorState); for (i = 0, values = v->axisVal; i < v->numAxes; i++) { - *((int *)buf) = *values++; + if (rc != BadAccess) + *((int *)buf) = *values; + values++; if (client->swapped) { swapl((int *)buf, n); /* macro - braces needed */ } diff --git a/dix/devices.c b/dix/devices.c index 3b8d544da..9e3542d6e 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -2477,12 +2477,15 @@ ProcQueryKeymap(ClientPtr client) rep.length = 2; rc = XaceHook(XACE_DEVICE_ACCESS, client, keybd, DixReadAccess); - if (rc != Success) + if (rc != Success && rc != BadAccess) return rc; for (i = 0; i<32; i++) rep.map[i] = down[i]; + if (rc == BadAccess) + memset(rep.map, 0, 32); + WriteReplyToClient(client, sizeof(xQueryKeymapReply), &rep); return Success; diff --git a/dix/events.c b/dix/events.c index f9448ba76..9b0ff55a8 100644 --- a/dix/events.c +++ b/dix/events.c @@ -4771,7 +4771,7 @@ ProcQueryPointer(ClientPtr client) if (rc != Success) return rc; rc = XaceHook(XACE_DEVICE_ACCESS, client, mouse, DixReadAccess); - if (rc != Success) + if (rc != Success && rc != BadAccess) return rc; pSprite = mouse->spriteInfo->sprite; @@ -4815,6 +4815,15 @@ ProcQueryPointer(ClientPtr client) } #endif + if (rc == BadAccess) { + rep.mask = 0; + rep.child = None; + rep.rootX = 0; + rep.rootY = 0; + rep.winX = 0; + rep.winY = 0; + } + WriteReplyToClient(client, sizeof(xQueryPointerReply), &rep); return(Success); |