Purge device-based WindowAccess code.

Really, this was a bad idea. It's not security, the UI features that would
have been cool (e.g. clicking through windows) aren't implemented anyway, and
there's nothing you can't achieve just by using plain XI anyway.

Requires inputproto 1.9.99.6.
This commit is contained in:
Peter Hutterer 2008-10-31 16:40:41 +10:30
parent cbc6f98395
commit d972399566
12 changed files with 73 additions and 790 deletions

View File

@ -21,8 +21,6 @@ libXi_la_SOURCES = \
chgprop.h \
chgptr.c \
chgptr.h \
chaccess.c \
chaccess.h \
closedev.c \
closedev.h \
devbell.c \
@ -68,8 +66,6 @@ libXi_la_SOURCES = \
querydp.h \
queryst.c \
queryst.h \
qryacces.c \
qryacces.h \
selectev.c \
selectev.h \
sendexev.c \

View File

@ -1,158 +0,0 @@
/*
* Copyright 2007-2008 Peter Hutterer
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Author: Peter Hutterer, University of South Australia, NICTA
*/
#define NEED_EVENTS
#define NEED_REPLIES
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <X11/X.h> /* for inputstr.h */
#include <X11/Xproto.h> /* Request macro */
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window structure */
#include "scrnintstr.h" /* screen structure */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "extnsionst.h"
#include "exevents.h"
#include "exglobals.h"
#include "chaccess.h"
/***********************************************************************
* This procedure allows a client to change window access control.
*/
int
SProcXChangeWindowAccess(ClientPtr client)
{
char n;
REQUEST(xChangeWindowAccessReq);
swaps(&stuff->length, n);
swapl(&stuff->win, n);
return ProcXChangeWindowAccess(client);
}
int
ProcXChangeWindowAccess(ClientPtr client)
{
int padding, rc, i;
XID* deviceids = NULL;
WindowPtr win;
DeviceIntPtr* perm_devices = NULL;
DeviceIntPtr* deny_devices = NULL;
REQUEST(xChangeWindowAccessReq);
REQUEST_AT_LEAST_SIZE(xChangeWindowAccessReq);
padding = (4 - (((stuff->npermit + stuff->ndeny) * sizeof(XID)) % 4)) % 4;
if (stuff->length != ((sizeof(xChangeWindowAccessReq) +
(((stuff->npermit + stuff->ndeny) * sizeof(XID)) + padding)) >> 2))
{
return BadLength;
}
rc = dixLookupWindow(&win, stuff->win, client, DixWriteAccess);
if (rc != Success)
{
return rc;
}
/* Are we clearing? if so, ignore the rest */
if (stuff->clear)
{
rc = ACClearWindowAccess(client, win, stuff->clear);
return rc;
}
if (stuff->npermit || stuff->ndeny)
deviceids = (XID*)&stuff[1];
if (stuff->npermit)
{
perm_devices =
(DeviceIntPtr*)xalloc(stuff->npermit * sizeof(DeviceIntPtr));
if (!perm_devices)
{
ErrorF("[Xi] ProcXChangeWindowAccess: alloc failure.\n");
return BadImplementation;
}
/* if one of the devices cannot be accessed, we don't do anything.*/
for (i = 0; i < stuff->npermit; i++)
{
rc = dixLookupDevice(&perm_devices[i], deviceids[i], client,
DixWriteAccess);
if (rc != Success)
{
xfree(perm_devices);
return rc;
}
}
}
if (stuff->ndeny)
{
deny_devices =
(DeviceIntPtr*)xalloc(stuff->ndeny * sizeof(DeviceIntPtr));
if (!deny_devices)
{
ErrorF("[Xi] ProcXChangeWindowAccecss: alloc failure.\n");
xfree(perm_devices);
return BadImplementation;
}
for (i = 0; i < stuff->ndeny; i++)
{
rc = dixLookupDevice(&deny_devices[i],
deviceids[i+stuff->npermit],
client,
DixWriteAccess);
if (rc != Success)
{
xfree(perm_devices);
xfree(deny_devices);
return rc;
}
}
}
rc = ACChangeWindowAccess(client, win, stuff->defaultRule,
perm_devices, stuff->npermit,
deny_devices, stuff->ndeny);
if (rc != Success)
{
return rc;
}
xfree(perm_devices);
xfree(deny_devices);
return Success;
}

View File

@ -1,36 +0,0 @@
/*
* Copyright 2007-2008 Peter Hutterer
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Author: Peter Hutterer, University of South Australia, NICTA
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#ifndef CHACCESS_H
#define CHACCESS_H 1
int SProcXChangeWindowAccess(ClientPtr /* client */);
int ProcXChangeWindowAccess(ClientPtr /* client */);
#endif /* CHACCESS_H */

View File

@ -76,7 +76,6 @@ SOFTWARE.
/* modules local to Xi */
#include "allowev.h"
#include "chaccess.h"
#include "chdevcur.h"
#include "chgdctl.h"
#include "chdevhier.h"
@ -105,7 +104,6 @@ SOFTWARE.
#include "gtmotion.h"
#include "listdev.h"
#include "opendev.h"
#include "qryacces.h"
#include "querydp.h"
#include "queryst.h"
#include "selectev.h"
@ -219,12 +217,10 @@ static int (*ProcIVector[])(ClientPtr) = {
ProcXWarpDevicePointer, /* 41 */
ProcXChangeDeviceCursor, /* 42 */
ProcXChangeDeviceHierarchy, /* 43 */
ProcXChangeWindowAccess, /* 44 */
ProcXQueryWindowAccess, /* 45 */
ProcXSetClientPointer, /* 46 */
ProcXGetClientPointer, /* 47 */
ProcXiSelectEvent, /* 48 */
ProcXExtendedGrabDevice /* 49 */
ProcXSetClientPointer, /* 44 */
ProcXGetClientPointer, /* 45 */
ProcXiSelectEvent, /* 46 */
ProcXExtendedGrabDevice /* 47 */
};
/* For swapped clients */
@ -273,12 +269,10 @@ static int (*SProcIVector[])(ClientPtr) = {
SProcXWarpDevicePointer, /* 41 */
SProcXChangeDeviceCursor, /* 42 */
SProcXChangeDeviceHierarchy, /* 43 */
SProcXChangeWindowAccess, /* 44 */
SProcXQueryWindowAccess, /* 45 */
SProcXSetClientPointer, /* 46 */
SProcXGetClientPointer, /* 47 */
SProcXiSelectEvent, /* 48 */
SProcXExtendedGrabDevice /* 49 */
SProcXSetClientPointer, /* 44 */
SProcXGetClientPointer, /* 45 */
SProcXiSelectEvent, /* 46 */
SProcXExtendedGrabDevice /* 47 */
};
/*****************************************************************
@ -481,9 +475,6 @@ SReplyIDispatch(ClientPtr client, int len, xGrabDeviceReply * rep)
else if (rep->RepType == X_QueryDevicePointer)
SRepXQueryDevicePointer(client, len,
(xQueryDevicePointerReply *) rep);
else if (rep->RepType == X_QueryWindowAccess)
SRepXQueryWindowAccess(client, len,
(xQueryWindowAccessReply*) rep);
else if (rep->RepType == X_GetClientPointer)
SRepXGetClientPointer(client, len, (xGetClientPointerReply*) rep);
else if (rep->RepType == X_ExtendedGrabDevice)

View File

@ -1,121 +0,0 @@
/*
* Copyright 2007-2008 Peter Hutterer
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Author: Peter Hutterer, University of South Australia, NICTA
*/
#define NEED_EVENTS
#define NEED_REPLIES
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <X11/X.h> /* for inputstr.h */
#include <X11/Xproto.h> /* Request macro */
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window structure */
#include "scrnintstr.h" /* screen structure */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "extnsionst.h"
#include "extinit.h" /* LookupDeviceIntRec */
#include "exevents.h"
#include "exglobals.h"
#include "qryacces.h"
/***********************************************************************
* This procedure allows a client to query window access control.
*/
int
SProcXQueryWindowAccess(ClientPtr client)
{
char n;
REQUEST(xQueryWindowAccessReq);
swaps(&stuff->length, n);
swapl(&stuff->win, n);
return ProcXQueryWindowAccess(client);
}
int
ProcXQueryWindowAccess(ClientPtr client)
{
int rc;
WindowPtr win;
DeviceIntPtr *perm, *deny;
int nperm, ndeny, i;
int defaultRule;
XID* deviceids;
xQueryWindowAccessReply rep;
REQUEST(xQueryWindowAccessReq);
REQUEST_SIZE_MATCH(xQueryWindowAccessReq);
rc = dixLookupWindow(&win, stuff->win, client, DixReadAccess);
if (rc != Success)
{
return rc;
}
ACQueryWindowAccess(win, &defaultRule, &perm, &nperm, &deny, &ndeny);
rep.repType = X_Reply;
rep.RepType = X_QueryWindowAccess;
rep.sequenceNumber = client->sequence;
rep.length = ((nperm + ndeny) * sizeof(XID) + 3) >> 2;
rep.defaultRule = defaultRule;
rep.npermit = nperm;
rep.ndeny = ndeny;
WriteReplyToClient(client, sizeof(xQueryWindowAccessReply), &rep);
if (nperm + ndeny)
{
deviceids = (XID*)xalloc((nperm + ndeny) * sizeof(XID));
if (!deviceids)
{
ErrorF("[Xi] ProcXQueryWindowAccess: xalloc failure.\n");
return BadImplementation;
}
for (i = 0; i < nperm; i++)
deviceids[i] = perm[i]->id;
for (i = 0; i < ndeny; i++)
deviceids[i + nperm] = deny[i]->id;
WriteToClient(client, (nperm + ndeny) * sizeof(XID), (char*)deviceids);
xfree(deviceids);
}
return Success;
}
void
SRepXQueryWindowAccess(ClientPtr client,
int size,
xQueryWindowAccessReply* rep)
{
char n;
swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
WriteToClient(client, size, (char*)rep);
}

View File

@ -1,38 +0,0 @@
/*
* Copyright 2007-2008 Peter Hutterer
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Author: Peter Hutterer, University of South Australia, NICTA
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#ifndef QRYACCES_H
#define QRYACCES_H 1
int SProcXQueryWindowAccess(ClientPtr /* client */);
int ProcXQueryWindowAccess(ClientPtr /* client */);
void SRepXQueryWindowAccess(ClientPtr /* client */,
int /* size */,
xQueryWindowAccessReply* /* rep */);
#endif

View File

@ -657,7 +657,7 @@ XEXT_LIB='$(top_builddir)/Xext/libXext.la'
XEXTXORG_LIB='$(top_builddir)/Xext/libXextbuiltin.la'
dnl Core modules for most extensions, et al.
REQUIRED_MODULES="[randrproto >= 1.2] [renderproto >= 0.9.3] [fixesproto >= 4.0] [damageproto >= 1.1] xcmiscproto [xextproto >= 7.0.3] [xproto >= 7.0.13] [xtrans >= 1.2.2] bigreqsproto resourceproto fontsproto [inputproto >= 1.9.99.5] [kbproto >= 1.0.3]"
REQUIRED_MODULES="[randrproto >= 1.2] [renderproto >= 0.9.3] [fixesproto >= 4.0] [damageproto >= 1.1] xcmiscproto [xextproto >= 7.0.3] [xproto >= 7.0.13] [xtrans >= 1.2.2] bigreqsproto resourceproto fontsproto [inputproto >= 1.9.99.6] [kbproto >= 1.0.3]"
REQUIRED_LIBS="xfont xau fontenc [pixman-1 >= 0.9.5]"
dnl HAVE_DBUS is true if we actually have the D-Bus library, whereas

View File

@ -5,7 +5,6 @@ AM_CFLAGS = $(DIX_CFLAGS) \
-DVENDOR_RELEASE="@VENDOR_RELEASE@"
libdix_la_SOURCES = \
access.c \
atom.c \
colormap.c \
cursor.c \

View File

@ -1,315 +0,0 @@
/*
* Copyright 2007-2008 Peter Hutterer
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Author: Peter Hutterer, University of South Australia, NICTA
*/
/* This file controls the access control lists for each window.
* Each device can be explicitely allowed or denied access to a given window.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <X11/Xlib.h>
#include <X11/extensions/XI.h>
#include "exglobals.h"
#include "input.h"
#include "inputstr.h"
#include "windowstr.h"
/* Only one single client can be responsible for window access control. */
static ClientPtr ACClient = NULL;
/* Forward declarations */
static void acReplaceList(DeviceIntPtr** list,
int* count,
DeviceIntPtr* devices,
int ndevices);
/* Register global window access control client
* Return True on success or False otherwise.
*/
Bool
ACRegisterClient(ClientPtr client)
{
if (ACClient && ACClient != client)
return False;
ACClient = client;
return True;
}
/* Unregister global client. If client is not the registered client, nothing
* happens and False is returned. If no client is registered, return True.
* Returns True if client was registred and is now unregistered.
*/
Bool
ACUnregisterClient(ClientPtr client)
{
if (ACClient && ACClient != client)
return False;
ACClient = NULL;
return True;
}
/* Clears all access control for the window and remove the default rule,
* depending on what is set. */
int ACClearWindowAccess(ClientPtr client,
WindowPtr win,
int what)
{
if (client != ACClient && client != wClient(win))
return BadAccess;
if (!win->optional)
{
/* we shouldn't get here if programmers know what they're doing.
* A client should not request to clear a window's access controls
* if they've never been set before anyway. If they do, do nothing and
* let the client figure out what to do next.
*/
return Success;
}
if (what & WindowAccessClearPerm)
{
xfree(win->optional->access.perm);
win->optional->access.perm = NULL;
win->optional->access.nperm = 0;
}
if (what & WindowAccessClearDeny)
{
xfree(win->optional->access.deny);
win->optional->access.deny = NULL;
win->optional->access.ndeny = 0;
}
if (what & WindowAccessClearRule)
win->optional->access.defaultRule = WindowAccessNoRule;
return Success;
}
/*
* Changes window access control.
*
* Returns Success or BadAccess if the client is not allowed to change
* anything.
*/
int
ACChangeWindowAccess(ClientPtr client,
WindowPtr win,
int defaultRule,
DeviceIntPtr* perm_devices,
int nperm,
DeviceIntPtr* deny_devices,
int ndeny)
{
if (client != ACClient && client != wClient(win))
return BadAccess;
if (!win->optional && !MakeWindowOptional(win))
{
ErrorF("[dix] ACChangeWindowAcccess: Failed to make window optional.\n");
return BadImplementation;
}
if (defaultRule != WindowAccessKeepRule)
win->optional->access.defaultRule = defaultRule;
if (nperm)
{
acReplaceList(&win->optional->access.perm,
&win->optional->access.nperm,
perm_devices, nperm);
}
if (ndeny)
{
acReplaceList(&win->optional->access.deny,
&win->optional->access.ndeny,
deny_devices, ndeny);
}
return Success;
}
static void
acReplaceList(DeviceIntPtr** list,
int* count,
DeviceIntPtr* devices,
int ndevices)
{
xfree(*list);
*list = NULL;
*count = 0;
if (ndevices)
{
*list =
xalloc(ndevices * sizeof(DeviceIntPtr*));
if (!*list)
{
ErrorF("[dix] ACChangeWindowAccess: out of memory\n");
return;
}
memcpy(*list,
devices,
ndevices * sizeof(DeviceIntPtr));
*count = ndevices;
}
return;
}
/*
* Query the given window for the devices allowed to access a window.
* The caller is responsible for freeing perm and deny.
*/
void
ACQueryWindowAccess(WindowPtr win,
int* defaultRule,
DeviceIntPtr** perm,
int* nperm,
DeviceIntPtr** deny,
int* ndeny)
{
*defaultRule = WindowAccessNoRule;
*perm = NULL;
*nperm = 0;
*deny = NULL;
*ndeny = 0;
if (!win->optional)
return;
*defaultRule = win->optional->access.defaultRule;
if (win->optional->access.nperm)
{
*nperm = win->optional->access.nperm;
*perm = (DeviceIntPtr*)xalloc(*nperm * sizeof(DeviceIntPtr));
if (!*perm)
{
ErrorF("[dix] ACQuerywinAccess: xalloc failure\n");
return;
}
memcpy(*perm,
win->optional->access.perm,
*nperm * sizeof(DeviceIntPtr));
}
if (win->optional->access.ndeny)
{
*ndeny = win->optional->access.ndeny;
*deny = (DeviceIntPtr*)xalloc(*ndeny * sizeof(DeviceIntPtr));
if (!*deny)
{
ErrorF("[dix] ACQuerywinAccess: xalloc failure\n");
return;
}
memcpy(*deny,
win->optional->access.deny,
*ndeny * sizeof(DeviceIntPtr));
}
}
/*
* Check if the given device is allowed to send events to the window. Returns
* true if device is allowed or false otherwise.
*
* Checks are done in the following order until a result is found:
* If the device is explicitely permitted, allow.
* If the window has a default of DenyAll, do not allow.
* If the device is explicitely denied, do not allow.
* If the window has a default of AllowAll, allow.
* Check parent window. Rinse, wash, repeat.
* If no rule could be found, allow.
*/
Bool
ACDeviceAllowed(WindowPtr win, DeviceIntPtr dev, xEvent* xE)
{
int i;
if (!win) /* happens for parent of RootWindow */
return True;
/* there's a number of events we don't care about */
switch (xE->u.u.type)
{
case ButtonPress:
case ButtonRelease:
case MotionNotify:
case EnterNotify:
case LeaveNotify:
case KeyPress:
case KeyRelease:
break;
default:
if (xE->u.u.type == DeviceMotionNotify ||
xE->u.u.type == DeviceButtonPress ||
xE->u.u.type == DeviceButtonRelease ||
xE->u.u.type == DeviceKeyPress ||
xE->u.u.type == DeviceKeyRelease ||
xE->u.u.type == DeviceEnterNotify ||
xE->u.u.type == DeviceLeaveNotify)
{
break;
}
return True;
}
if (!win->optional) /* no list, check parent */
return ACDeviceAllowed(win->parent, dev, xE);
for (i = 0; i < win->optional->access.nperm; i++)
{
if (win->optional->access.perm[i]->id == dev->id)
return True;
}
if (win->optional->access.defaultRule == WindowAccessDenyAll)
return False;
for (i = 0; i < win->optional->access.ndeny; i++)
{
if (win->optional->access.deny[i]->id == dev->id)
return False;
}
if (win->optional->access.defaultRule == WindowAccessAllowAll)
return True;
return ACDeviceAllowed(win->parent, dev, xE);
}

View File

@ -3375,7 +3375,6 @@ CloseDownClient(ClientPtr client)
DeleteClientFromAnySelections(client);
ReleaseActiveGrabs(client);
DeleteClientFontStuff(client);
ACUnregisterClient(client);
if (!really_close_down)
{
/* This frees resources that should never be retained

View File

@ -2030,13 +2030,6 @@ DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent
this mask is the mask of the grab. */
int type = pEvents->u.u.type;
/* if a is denied, we return 0. This could cause the caller to
* traverse the parent. May be bad! (whot) */
if (!ACDeviceAllowed(pWin, pDev, pEvents))
{
return 0;
}
/* CantBeFiltered means only window owner gets the event */
if ((filter == CantBeFiltered) ||
(!(type & EXTENSION_EVENT_BASE) && type != GenericEvent))
@ -3633,83 +3626,80 @@ DeliverGrabbedEvent(xEvent *xE, DeviceIntPtr thisDev,
}
if (!deliveries)
{
if (ACDeviceAllowed(grab->window, thisDev, xE))
if (xE->u.u.type == GenericEvent)
{
if (xE->u.u.type == GenericEvent)
/* find evmask for event's extension */
xGenericEvent* ge = ((xGenericEvent*)xE);
GenericMaskPtr gemask = grab->genericMasks;
if (!gemask || !gemask->eventMask[GEEXTIDX(ge)])
return;
if (GEEventFill(xE))
GEEventFill(xE)(ge, thisDev, grab->window, grab);
deliveries = TryClientEvents(rClient(grab), thisDev, xE,
count, gemask->eventMask[GEEXTIDX(ge)],
generic_filters[GEEXTIDX(ge)][ge->evtype],
grab);
} else
{
Mask mask = grab->eventMask;
sendCore = (thisDev->isMaster && thisDev->coreEvents);
/* try core event */
if (sendCore && grab->coreGrab)
{
/* find evmask for event's extension */
xGenericEvent* ge = ((xGenericEvent*)xE);
GenericMaskPtr gemask = grab->genericMasks;
if (!gemask || !gemask->eventMask[GEEXTIDX(ge)])
return;
if (GEEventFill(xE))
GEEventFill(xE)(ge, thisDev, grab->window, grab);
deliveries = TryClientEvents(rClient(grab), thisDev, xE,
count, gemask->eventMask[GEEXTIDX(ge)],
generic_filters[GEEXTIDX(ge)][ge->evtype],
grab);
} else
{
Mask mask = grab->eventMask;
sendCore = (thisDev->isMaster && thisDev->coreEvents);
/* try core event */
if (sendCore && grab->coreGrab)
{
core = *xE;
core.u.u.type = XItoCoreType(xE->u.u.type);
if(core.u.u.type) {
FixUpEventFromWindow(thisDev, &core, grab->window,
None, TRUE);
if (XaceHook(XACE_SEND_ACCESS, 0, thisDev,
grab->window, &core, 1) ||
XaceHook(XACE_RECEIVE_ACCESS, rClient(grab),
grab->window, &core, 1))
deliveries = 1; /* don't send, but pretend we did */
else if (!IsInterferingGrab(rClient(grab), thisDev,
&core))
{
deliveries = TryClientEvents(rClient(grab), thisDev,
&core, 1, mask,
filters[thisDev->id][core.u.u.type],
grab);
}
}
}
if (!deliveries)
{
/* try XI event */
if (grabinfo->fromPassiveGrab &&
grabinfo->implicitGrab &&
(xE->u.u.type & EXTENSION_EVENT_BASE))
mask = grab->deviceMask;
FixUpEventFromWindow(thisDev, xE, grab->window,
None, TRUE);
core = *xE;
core.u.u.type = XItoCoreType(xE->u.u.type);
if(core.u.u.type) {
FixUpEventFromWindow(thisDev, &core, grab->window,
None, TRUE);
if (XaceHook(XACE_SEND_ACCESS, 0, thisDev,
grab->window, xE, count) ||
grab->window, &core, 1) ||
XaceHook(XACE_RECEIVE_ACCESS, rClient(grab),
grab->window, xE, count))
grab->window, &core, 1))
deliveries = 1; /* don't send, but pretend we did */
else
else if (!IsInterferingGrab(rClient(grab), thisDev,
&core))
{
deliveries =
TryClientEvents(rClient(grab), thisDev,
xE, count,
mask,
filters[thisDev->id][xE->u.u.type],
grab);
deliveries = TryClientEvents(rClient(grab), thisDev,
&core, 1, mask,
filters[thisDev->id][core.u.u.type],
grab);
}
}
}
if (deliveries && (xE->u.u.type == MotionNotify
|| xE->u.u.type == DeviceMotionNotify))
thisDev->valuator->motionHintWindow = grab->window;
if (!deliveries)
{
/* try XI event */
if (grabinfo->fromPassiveGrab &&
grabinfo->implicitGrab &&
(xE->u.u.type & EXTENSION_EVENT_BASE))
mask = grab->deviceMask;
FixUpEventFromWindow(thisDev, xE, grab->window,
None, TRUE);
if (XaceHook(XACE_SEND_ACCESS, 0, thisDev,
grab->window, xE, count) ||
XaceHook(XACE_RECEIVE_ACCESS, rClient(grab),
grab->window, xE, count))
deliveries = 1; /* don't send, but pretend we did */
else
{
deliveries =
TryClientEvents(rClient(grab), thisDev,
xE, count,
mask,
filters[thisDev->id][xE->u.u.type],
grab);
}
}
}
if (deliveries && (xE->u.u.type == MotionNotify
|| xE->u.u.type == DeviceMotionNotify))
thisDev->valuator->motionHintWindow = grab->window;
}
if (deliveries && !deactivateGrab &&
(xE->u.u.type != MotionNotify && xE->u.u.type != DeviceMotionNotify))

View File

@ -526,30 +526,6 @@ extern void DeepCopyDeviceClasses(DeviceIntPtr from,
extern int EnterLeaveSemaphoresIsset(WindowPtr win);
extern int FocusSemaphoresIsset(WindowPtr win);
/* Window/device based access control */
extern Bool ACRegisterClient(ClientPtr client);
extern Bool ACUnregisterClient(ClientPtr client);
extern int ACClearWindowAccess(ClientPtr client,
WindowPtr win,
int what);
extern int ACChangeWindowAccess(ClientPtr client,
WindowPtr win,
int defaultRule,
DeviceIntPtr* perm_devices,
int npermit,
DeviceIntPtr* deny_devices,
int ndeny);
extern void ACQueryWindowAccess(WindowPtr win,
int* defaultRule,
DeviceIntPtr** perm,
int* nperm,
DeviceIntPtr** deny,
int* ndeny);
extern Bool ACDeviceAllowed(WindowPtr win,
DeviceIntPtr dev,
xEvent* xE);
/* Implemented by the DDX. */
extern int NewInputDeviceRequest(
InputOption *options,