Xi: check for Use permission on the device in SetClientPointer().

Presumably, some intelligent, XI2-aware management app will be calling
XISetClientPointer on behalf of other clients; this check makes sure
the target client has permission on the device.

Requires changing the prototype to return status code instead of Bool.

Signed-off-by: Eamon Walsh <ewalsh@tycho.nsa.gov>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Eamon Walsh 2009-06-18 21:41:17 -04:00
parent 119b966677
commit 00bc8d34c6
3 changed files with 12 additions and 7 deletions

View File

@ -98,10 +98,11 @@ ProcXISetClientPointer(ClientPtr client)
} else
targetClient = client;
if (!SetClientPointer(targetClient, pDev))
rc = SetClientPointer(targetClient, pDev);
if (rc != Success)
{
client->errorValue = stuff->deviceid;
return BadDevice;
return rc;
}
return Success;

View File

@ -5699,21 +5699,25 @@ WriteEventsToClient(ClientPtr pClient, int count, xEvent *events)
* PickPointer()).
* If a keyboard is needed, the first keyboard paired with the CP is used.
*/
Bool
int
SetClientPointer(ClientPtr client, DeviceIntPtr device)
{
int rc = XaceHook(XACE_DEVICE_ACCESS, client, device, DixUseAccess);
if (rc != Success)
return rc;
if (!IsMaster(device))
{
ErrorF("[dix] Need master device for ClientPointer. This is a bug.\n");
return FALSE;
return BadDevice;
} else if (!device->spriteInfo->spriteOwner)
{
ErrorF("[dix] Device %d does not have a sprite. "
"Cannot be ClientPointer\n", device->id);
return FALSE;
return BadDevice;
}
client->clientPtr = device;
return TRUE;
return Success;
}
/* PickPointer will pick an appropriate pointer for the given client.

View File

@ -485,7 +485,7 @@ extern _X_EXPORT int TryClientEvents(
extern _X_EXPORT void WindowsRestructured(void);
extern Bool SetClientPointer(
extern int SetClientPointer(
ClientPtr /* client */,
DeviceIntPtr /* device */);