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.

Signed-off-by: Eamon Walsh <ewalsh@tycho.nsa.gov>
This commit is contained in:
Eamon Walsh 2009-09-15 19:29:34 -04:00
commit 8502c06e19
5 changed files with 55 additions and 24 deletions

View file

@ -2221,12 +2221,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;

View file

@ -4974,7 +4974,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;
keyboard = GetPairedDevice(mouse);
@ -5022,6 +5022,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);