From 8b548657204000e18c7a38706a0071ae2f93159f Mon Sep 17 00:00:00 2001 From: Eamon Walsh Date: Fri, 28 Sep 2007 13:34:18 -0400 Subject: xace: add hooks + new access codes: XKB extension. Removes "LookupKeyboardDevice" and "LookupPointerDevice" in favor of inputInfo.keyboard and inputInfo.pointer, respectively; all use cases are non-XI compliant anyway. --- XTrap/xtrapddmi.c | 6 +- XTrap/xtrapdi.c | 6 +- Xext/xtest.c | 6 +- Xi/grabdevb.c | 9 ++- Xi/grabdevk.c | 9 ++- Xi/ungrdevb.c | 2 +- Xi/ungrdevk.c | 2 +- dix/devices.c | 12 ---- hw/kdrive/ephyr/ephyr.c | 2 +- hw/kdrive/vxworks/vxkbd.c | 2 +- hw/xfree86/loader/dixsym.c | 2 - hw/xgl/egl/kinput.c | 2 +- hw/xgl/glx/xglx.c | 2 +- hw/xgl/xglinput.c | 2 +- include/input.h | 4 -- include/xkbsrv.h | 46 +++++++++----- xkb/ddxDevBtn.c | 2 +- xkb/ddxFakeBtn.c | 2 +- xkb/xkb.c | 101 +++++++++++++++++-------------- xkb/xkbAccessX.c | 2 +- xkb/xkbActions.c | 10 +-- xkb/xkbEvents.c | 2 +- xkb/xkbLEDs.c | 10 +-- xkb/xkbPrOtherEv.c | 2 +- xkb/xkbUtils.c | 147 ++++++++++++++++++++++++++------------------- 25 files changed, 217 insertions(+), 175 deletions(-) diff --git a/XTrap/xtrapddmi.c b/XTrap/xtrapddmi.c index 73a20c1f6..3f1a72ab8 100644 --- a/XTrap/xtrapddmi.c +++ b/XTrap/xtrapddmi.c @@ -52,7 +52,7 @@ SOFTWARE. #define NEED_REPLIES #define NEED_EVENTS #include /* From library include environment */ -#include "input.h" /* From server include env. (must be before Xlib.h!) */ +#include "inputstr.h" /* From server include env. (must be before Xlib.h!) */ #ifdef PC # include "scrintst.h" /* Screen struct */ # include "extnsist.h" @@ -96,8 +96,8 @@ int XETrapSimulateXEvent(register xXTrapInputReq *request, xEvent xev; register int x = request->input.x; register int y = request->input.y; - DevicePtr keydev = LookupKeyboardDevice(); - DevicePtr ptrdev = LookupPointerDevice(); + DevicePtr keydev = (DevicePtr)inputInfo.keyboard; + DevicePtr ptrdev = (DevicePtr)inputInfo.pointer; if (request->input.screen < screenInfo.numScreens) { diff --git a/XTrap/xtrapdi.c b/XTrap/xtrapdi.c index 23d3bde7f..efad36f7a 100644 --- a/XTrap/xtrapdi.c +++ b/XTrap/xtrapdi.c @@ -58,7 +58,7 @@ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include "input.h" /* Server DevicePtr definitions */ +#include "inputstr.h" /* Server DevicePtr definitions */ #include "misc.h" /* Server swapping macros */ #include "dixstruct.h" /* Server ClientRec definitions */ #include "resource.h" /* Used with the MakeAtom call */ @@ -277,7 +277,7 @@ Bool XETrapRedirectDevices() /* Do we need to redirect the keyboard device? */ if (XETrapKbdDev == NULL) { - if ((XETrapKbdDev = LookupKeyboardDevice()) == NULL) + if ((XETrapKbdDev = (DevicePtr)inputInfo.keyboard) == NULL) { retval = False; } @@ -302,7 +302,7 @@ Bool XETrapRedirectDevices() #ifndef VECTORED_EVENTS if (XETrapPtrDev == NULL) { - if ((XETrapPtrDev = LookupPointerDevice()) == 0L) + if ((XETrapPtrDev = (DevicePtr)inputInfo.pointer) == 0L) { retval = False; } diff --git a/Xext/xtest.c b/Xext/xtest.c index 42cf8178f..add996655 100644 --- a/Xext/xtest.c +++ b/Xext/xtest.c @@ -316,7 +316,7 @@ ProcXTestFakeInput(client) #ifdef XINPUT if (!extension) #endif /* XINPUT */ - dev = (DeviceIntPtr)LookupKeyboardDevice(); + dev = inputInfo.keyboard; if (ev->u.u.detail < dev->key->curKeySyms.minKeyCode || ev->u.u.detail > dev->key->curKeySyms.maxKeyCode) { @@ -360,7 +360,7 @@ ProcXTestFakeInput(client) break; } #endif /* XINPUT */ - dev = (DeviceIntPtr)LookupPointerDevice(); + dev = inputInfo.pointer; if (ev->u.keyButtonPointer.root == None) root = GetCurrentRootWindow(); else @@ -449,7 +449,7 @@ ProcXTestFakeInput(client) #ifdef XINPUT if (!extension) #endif /* XINPUT */ - dev = (DeviceIntPtr)LookupPointerDevice(); + dev = inputInfo.pointer; if (!ev->u.u.detail || ev->u.u.detail > dev->button->numButtons) { client->errorValue = ev->u.u.detail; diff --git a/Xi/grabdevb.c b/Xi/grabdevb.c index 7eb542232..c2661e85b 100644 --- a/Xi/grabdevb.c +++ b/Xi/grabdevb.c @@ -62,6 +62,7 @@ SOFTWARE. #include #include "exevents.h" #include "exglobals.h" +#include "xace.h" #include "grabdev.h" #include "grabdevb.h" @@ -127,8 +128,12 @@ ProcXGrabDeviceButton(ClientPtr client) return ret; if (mdev->key == NULL) return BadMatch; - } else - mdev = (DeviceIntPtr) LookupKeyboardDevice(); + } else { + mdev = inputInfo.keyboard; + ret = XaceHook(XACE_DEVICE_ACCESS, client, mdev, DixReadAccess); + if (ret != Success) + return ret; + } class = (XEventClass *) (&stuff[1]); /* first word of values */ diff --git a/Xi/grabdevk.c b/Xi/grabdevk.c index e187a4f7b..43b19280d 100644 --- a/Xi/grabdevk.c +++ b/Xi/grabdevk.c @@ -62,6 +62,7 @@ SOFTWARE. #include #include "exevents.h" #include "exglobals.h" +#include "xace.h" #include "grabdev.h" #include "grabdevk.h" @@ -125,8 +126,12 @@ ProcXGrabDeviceKey(ClientPtr client) return ret; if (mdev->key == NULL) return BadMatch; - } else - mdev = (DeviceIntPtr) LookupKeyboardDevice(); + } else { + mdev = inputInfo.keyboard; + ret = XaceHook(XACE_DEVICE_ACCESS, client, mdev, DixReadAccess); + if (ret != Success) + return ret; + } class = (XEventClass *) (&stuff[1]); /* first word of values */ diff --git a/Xi/ungrdevb.c b/Xi/ungrdevb.c index 85ca5c6ce..590699f05 100644 --- a/Xi/ungrdevb.c +++ b/Xi/ungrdevb.c @@ -120,7 +120,7 @@ ProcXUngrabDeviceButton(ClientPtr client) if (mdev->key == NULL) return BadMatch; } else - mdev = (DeviceIntPtr) LookupKeyboardDevice(); + mdev = inputInfo.keyboard; rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixSetAttrAccess); if (rc != Success) diff --git a/Xi/ungrdevk.c b/Xi/ungrdevk.c index ac4003569..521765ea3 100644 --- a/Xi/ungrdevk.c +++ b/Xi/ungrdevk.c @@ -120,7 +120,7 @@ ProcXUngrabDeviceKey(ClientPtr client) if (mdev->key == NULL) return BadMatch; } else - mdev = (DeviceIntPtr) LookupKeyboardDevice(); + mdev = inputInfo.keyboard; rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixSetAttrAccess); if (rc != Success) diff --git a/dix/devices.c b/dix/devices.c index bd1bef722..b6cb4a5c0 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -705,18 +705,6 @@ RegisterKeyboardDevice(DeviceIntPtr device) RegisterOtherDevice(device); } -_X_EXPORT DevicePtr -LookupKeyboardDevice(void) -{ - return inputInfo.keyboard ? &inputInfo.keyboard->public : NULL; -} - -_X_EXPORT DevicePtr -LookupPointerDevice(void) -{ - return inputInfo.pointer ? &inputInfo.pointer->public : NULL; -} - int dixLookupDevice(DeviceIntPtr *pDev, int id, ClientPtr client, Mask access_mode) { diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c index e8001df73..2e0c00491 100644 --- a/hw/kdrive/ephyr/ephyr.c +++ b/hw/kdrive/ephyr/ephyr.c @@ -691,7 +691,7 @@ ephyrUpdateModifierState(unsigned int state) int i; CARD8 mask; - pkeydev = (DeviceIntPtr)LookupKeyboardDevice(); + pkeydev = inputInfo.keyboard; if (!pkeydev) return; diff --git a/hw/kdrive/vxworks/vxkbd.c b/hw/kdrive/vxworks/vxkbd.c index be528c78a..ac83ef729 100644 --- a/hw/kdrive/vxworks/vxkbd.c +++ b/hw/kdrive/vxworks/vxkbd.c @@ -232,7 +232,7 @@ VxWorksKeyboardRead (int fd) void VxWorksKeyboardLeds (int leds) { - DeviceIntPtr pKeyboard = (DeviceIntPtr) LookupKeyboardDevice (); + DeviceIntPtr pKeyboard = inputInfo.keyboard; KeyboardCtrl *ctrl = &pKeyboard->kbdfeed->ctrl; led_ioctl_info led_info; int i; diff --git a/hw/xfree86/loader/dixsym.c b/hw/xfree86/loader/dixsym.c index 4b3b66a89..0eaa2d3a6 100644 --- a/hw/xfree86/loader/dixsym.c +++ b/hw/xfree86/loader/dixsym.c @@ -139,8 +139,6 @@ _X_HIDDEN void *dixLookupTab[] = { SYMFUNC(InitKeyboardDeviceStruct) SYMFUNC(SendMappingNotify) SYMFUNC(InitPointerDeviceStruct) - SYMFUNC(LookupKeyboardDevice) - SYMFUNC(LookupPointerDevice) /* dispatch.c */ SYMFUNC(SetInputCheck) SYMFUNC(SendErrorToClient) diff --git a/hw/xgl/egl/kinput.c b/hw/xgl/egl/kinput.c index 981cffcfa..774e00eb5 100644 --- a/hw/xgl/egl/kinput.c +++ b/hw/xgl/egl/kinput.c @@ -439,7 +439,7 @@ KdKeybdProc(DeviceIntPtr pDevice, int onoff) switch (onoff) { case DEVICE_INIT: - if (pDev != LookupKeyboardDevice()) + if (pDev != (DevicePtr)inputInfo.keyboard) { return !Success; } diff --git a/hw/xgl/glx/xglx.c b/hw/xgl/glx/xglx.c index 89bd72e41..33b276b74 100644 --- a/hw/xgl/glx/xglx.c +++ b/hw/xgl/glx/xglx.c @@ -1100,7 +1100,7 @@ xglxKeybdProc (DeviceIntPtr pDevice, int xkbOp, xkbEvent, xkbError, xkbMajor, xkbMinor; #endif - if (pDev != LookupKeyboardDevice ()) + if (pDev != (DevicePtr)inputInfo.keyboard) return !Success; xmodMap = XGetModifierMapping (xdisplay); diff --git a/hw/xgl/xglinput.c b/hw/xgl/xglinput.c index cda21ad49..9499fcf1f 100644 --- a/hw/xgl/xglinput.c +++ b/hw/xgl/xglinput.c @@ -224,7 +224,7 @@ xglKeybdProc (DeviceIntPtr pDevice, switch (onoff) { case DEVICE_INIT: - if (pDev != LookupKeyboardDevice ()) + if (pDev != (DevicePtr)inputInfo.keyboard) return !Success; ret = InitKeyboardDeviceStruct (pDev, diff --git a/include/input.h b/include/input.h index d8a9fe852..ca67cfac5 100644 --- a/include/input.h +++ b/include/input.h @@ -197,10 +197,6 @@ extern void RegisterPointerDevice( extern void RegisterKeyboardDevice( DeviceIntPtr /*device*/); -extern DevicePtr LookupKeyboardDevice(void); - -extern DevicePtr LookupPointerDevice(void); - extern int dixLookupDevice( DeviceIntPtr * /* dev */, int /* id */, diff --git a/include/xkbsrv.h b/include/xkbsrv.h index 71ea115e6..e4a1db3c5 100644 --- a/include/xkbsrv.h +++ b/include/xkbsrv.h @@ -262,6 +262,7 @@ typedef struct extern int XkbReqCode; extern int XkbEventBase; extern int XkbDisableLockActions; +extern int XkbKeyboardErrorCode; extern char * XkbBaseDirectory; extern char * XkbBinDirectory; extern char * XkbInitialMap; @@ -352,29 +353,44 @@ extern void XkbFreeNames( Bool /* freeMap */ ); -extern DeviceIntPtr _XkbLookupAnyDevice( - int /* id */, - int * /* why_rtrn */ +extern int _XkbLookupAnyDevice( + DeviceIntPtr *pDev, + int id, + ClientPtr client, + Mask access_mode, + int *xkb_err ); -extern DeviceIntPtr _XkbLookupKeyboard( - int /* id */, - int * /* why_rtrn */ +extern int _XkbLookupKeyboard( + DeviceIntPtr *pDev, + int id, + ClientPtr client, + Mask access_mode, + int *xkb_err ); -extern DeviceIntPtr _XkbLookupBellDevice( - int /* id */, - int * /* why_rtrn */ +extern int _XkbLookupBellDevice( + DeviceIntPtr *pDev, + int id, + ClientPtr client, + Mask access_mode, + int *xkb_err ); -extern DeviceIntPtr _XkbLookupLedDevice( - int /* id */, - int * /* why_rtrn */ +extern int _XkbLookupLedDevice( + DeviceIntPtr *pDev, + int id, + ClientPtr client, + Mask access_mode, + int *xkb_err ); -extern DeviceIntPtr _XkbLookupButtonDevice( - int /* id */, - int * /* why_rtrn */ +extern int _XkbLookupButtonDevice( + DeviceIntPtr *pDev, + int id, + ClientPtr client, + Mask access_mode, + int *xkb_err ); extern XkbDescPtr XkbAllocKeyboard( diff --git a/xkb/ddxDevBtn.c b/xkb/ddxDevBtn.c index 7e27c5189..5313a1ec5 100644 --- a/xkb/ddxDevBtn.c +++ b/xkb/ddxDevBtn.c @@ -53,7 +53,7 @@ deviceValuator * val; int x,y; int nAxes, i, count; - if ((dev==(DeviceIntPtr)LookupPointerDevice())||(!dev->public.on)) + if (dev == inputInfo.pointer || !dev->public.on) return; nAxes = (dev->valuator?dev->valuator->numAxes:0); diff --git a/xkb/ddxFakeBtn.c b/xkb/ddxFakeBtn.c index 8144fd2c5..2dad54fea 100644 --- a/xkb/ddxFakeBtn.c +++ b/xkb/ddxFakeBtn.c @@ -46,7 +46,7 @@ xEvent ev; int x,y; DevicePtr ptr; - if ((ptr = LookupPointerDevice())==NULL) + if ((ptr = (DevicePtr)inputInfo.pointer)==NULL) return; GetSpritePosition(&x,&y); ev.u.u.type = event; diff --git a/xkb/xkb.c b/xkb/xkb.c index cf4243070..9efdfb6b5 100644 --- a/xkb/xkb.c +++ b/xkb/xkb.c @@ -38,6 +38,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #define XKBSRV_NEED_FILE_FUNCS #include #include "extnsionst.h" +#include "xace.h" #include "xkb.h" #include @@ -45,7 +46,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. int XkbEventBase; static int XkbErrorBase; int XkbReqCode; -static int XkbKeyboardErrorCode; + int XkbKeyboardErrorCode; CARD32 xkbDebugFlags = 0; static CARD32 xkbDebugCtrls = 0; @@ -53,19 +54,23 @@ static RESTYPE RT_XKBCLIENT; /***====================================================================***/ -#define CHK_DEVICE(d,sp,lf) {\ +#define CHK_DEVICE(dev, id, client, access_mode, lf) {\ int why;\ - d = (DeviceIntPtr)lf((sp),&why);\ - if (!dev) {\ - client->errorValue = _XkbErrCode2(why,(sp));\ - return XkbKeyboardErrorCode;\ + int rc = lf(&(dev), id, client, access_mode, &why);\ + if (rc != Success) {\ + client->errorValue = _XkbErrCode2(why, id);\ + return rc;\ }\ } -#define CHK_KBD_DEVICE(d,sp) CHK_DEVICE(d,sp,_XkbLookupKeyboard) -#define CHK_LED_DEVICE(d,sp) CHK_DEVICE(d,sp,_XkbLookupLedDevice) -#define CHK_BELL_DEVICE(d,sp) CHK_DEVICE(d,sp,_XkbLookupBellDevice) -#define CHK_ANY_DEVICE(d,sp) CHK_DEVICE(d,sp,_XkbLookupAnyDevice) +#define CHK_KBD_DEVICE(dev, id, client, mode) \ + CHK_DEVICE(dev, id, client, mode, _XkbLookupKeyboard) +#define CHK_LED_DEVICE(dev, id, client, mode) \ + CHK_DEVICE(dev, id, client, mode, _XkbLookupLedDevice) +#define CHK_BELL_DEVICE(dev, id, client, mode) \ + CHK_DEVICE(dev, id, client, mode, _XkbLookupBellDevice) +#define CHK_ANY_DEVICE(dev, id, client, mode) \ + CHK_DEVICE(dev, id, client, mode, _XkbLookupAnyDevice) #define CHK_ATOM_ONLY2(a,ev,er) {\ if (((a)==None)||(!ValidAtom((a)))) {\ @@ -206,7 +211,7 @@ ProcXkbSelectEvents(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_ANY_DEVICE(dev,stuff->deviceSpec); + CHK_ANY_DEVICE(dev, stuff->deviceSpec, client, DixReadAccess); if (((stuff->affectWhich&XkbMapNotifyMask)!=0)&&(stuff->affectMap)) { client->mapNotifyMask&= ~stuff->affectMap; @@ -351,7 +356,7 @@ ProcXkbBell(ClientPtr client) REQUEST(xkbBellReq); DeviceIntPtr dev; WindowPtr pWin; - int base; + int rc, base; int newPercent,oldPitch,oldDuration; pointer ctrl; @@ -360,7 +365,7 @@ ProcXkbBell(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_BELL_DEVICE(dev,stuff->deviceSpec); + CHK_BELL_DEVICE(dev, stuff->deviceSpec, client, DixBellAccess); CHK_ATOM_OR_NONE(stuff->name); if ((stuff->forceSound)&&(stuff->eventOnly)) { @@ -448,10 +453,10 @@ ProcXkbBell(ClientPtr client) return BadValue; } if (stuff->window!=None) { - pWin= (WindowPtr)LookupIDByType(stuff->window,RT_WINDOW); - if (pWin==NULL) { + rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); + if (rc != Success) { client->errorValue= stuff->window; - return BadValue; + return rc; } } else pWin= NULL; @@ -499,7 +504,7 @@ ProcXkbGetState(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev,stuff->deviceSpec); + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixReadAccess); xkb= &dev->key->xkbInfo->state; bzero(&rep,sizeof(xkbGetStateReply)); @@ -544,7 +549,7 @@ ProcXkbLatchLockState(ClientPtr client) if (!(client->xkbClientFlags & _XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev, stuff->deviceSpec); + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixSetAttrAccess); CHK_MASK_MATCH(0x01, stuff->affectModLocks, stuff->modLocks); CHK_MASK_MATCH(0x01, stuff->affectModLatches, stuff->modLatches); @@ -612,7 +617,7 @@ ProcXkbGetControls(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev,stuff->deviceSpec); + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess); xkb = dev->key->xkbInfo->desc->ctrls; rep.type = X_Reply; @@ -689,7 +694,7 @@ ProcXkbSetControls(ClientPtr client) if (!(client->xkbClientFlags & _XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev, stuff->deviceSpec); + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixSetAttrAccess); CHK_MASK_LEGAL(0x01, stuff->changeCtrls, XkbAllControlsMask); for (tmpd = inputInfo.keyboard; tmpd; tmpd = tmpd->next) { @@ -1370,7 +1375,7 @@ ProcXkbGetMap(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev,stuff->deviceSpec); + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess); CHK_MASK_OVERLAP(0x01,stuff->full,stuff->partial); CHK_MASK_LEGAL(0x02,stuff->full,XkbAllMapComponentsMask); CHK_MASK_LEGAL(0x03,stuff->partial,XkbAllMapComponentsMask); @@ -2299,7 +2304,7 @@ ProcXkbSetMap(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev,stuff->deviceSpec); + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixSetAttrAccess); CHK_MASK_LEGAL(0x01,stuff->present,XkbAllMapComponentsMask); XkbSetCauseXkbReq(&cause,X_kbSetMap,client); @@ -2569,7 +2574,7 @@ ProcXkbGetCompatMap(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev,stuff->deviceSpec); + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess); xkb = dev->key->xkbInfo->desc; compat= xkb->compat; @@ -2613,7 +2618,7 @@ ProcXkbSetCompatMap(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev,stuff->deviceSpec); + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixSetAttrAccess); data = (char *)&stuff[1]; xkbi = dev->key->xkbInfo; @@ -2748,7 +2753,7 @@ ProcXkbGetIndicatorState(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev,stuff->deviceSpec); + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixReadAccess); sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId, XkbXI_IndicatorStateMask); @@ -2859,7 +2864,7 @@ XkbIndicatorPtr leds; if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev,stuff->deviceSpec); + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess); xkb= dev->key->xkbInfo->desc; leds= xkb->indicators; @@ -2878,7 +2883,7 @@ int ProcXkbSetIndicatorMap(ClientPtr client) { register int i,bit; - int nIndicators,why; + int nIndicators; DeviceIntPtr dev; XkbSrvInfoPtr xkbi; xkbIndicatorMapWireDesc *from; @@ -2891,11 +2896,8 @@ ProcXkbSetIndicatorMap(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - dev = _XkbLookupKeyboard(stuff->deviceSpec,&why); - if (!dev) { - client->errorValue = _XkbErrCode2(why,stuff->deviceSpec); - return XkbKeyboardErrorCode; - } + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixSetAttrAccess); + xkbi= dev->key->xkbInfo; if (stuff->which==0) @@ -2971,7 +2973,7 @@ ProcXkbGetNamedIndicator(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_LED_DEVICE(dev,stuff->deviceSpec); + CHK_LED_DEVICE(dev, stuff->deviceSpec, client, DixReadAccess); CHK_ATOM_ONLY(stuff->indicator); sli= XkbFindSrvLedInfo(dev,stuff->ledClass,stuff->ledID,0); @@ -3057,7 +3059,7 @@ ProcXkbSetNamedIndicator(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_LED_DEVICE(dev,stuff->deviceSpec); + CHK_LED_DEVICE(dev, stuff->deviceSpec, client, DixSetAttrAccess); CHK_ATOM_ONLY(stuff->indicator); CHK_MASK_LEGAL(0x10,stuff->whichGroups,XkbIM_UseAnyGroup); CHK_MASK_LEGAL(0x11,stuff->whichMods,XkbIM_UseAnyMods); @@ -3125,7 +3127,7 @@ ProcXkbSetNamedIndicator(ClientPtr client) kbd= dev; if ((sli->flags&XkbSLI_HasOwnState)==0) - kbd= (DeviceIntPtr)LookupKeyboardDevice(); + kbd = inputInfo.keyboard; XkbFlushLedEvents(dev,kbd,sli,&ed,&changes,&cause); return client->noClientException; } @@ -3433,7 +3435,7 @@ ProcXkbGetNames(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev,stuff->deviceSpec); + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess); CHK_MASK_LEGAL(0x01,stuff->which,XkbAllNamesMask); xkb = dev->key->xkbInfo->desc; @@ -3543,7 +3545,7 @@ ProcXkbSetNames(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev,stuff->deviceSpec); + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixUnknownAccess); CHK_MASK_LEGAL(0x01,stuff->which,XkbAllNamesMask); xkb = dev->key->xkbInfo->desc; @@ -4379,7 +4381,7 @@ ProcXkbGetGeometry(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev,stuff->deviceSpec); + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess); CHK_ATOM_OR_NONE(stuff->name); geom= XkbLookupNamedGeometry(dev,stuff->name,&shouldFree); @@ -4842,7 +4844,7 @@ ProcXkbSetGeometry(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev,stuff->deviceSpec); + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixSetAttrAccess); CHK_ATOM_OR_NONE(stuff->name); xkb= dev->key->xkbInfo->desc; @@ -4897,6 +4899,7 @@ ProcXkbPerClientFlags(ClientPtr client) DeviceIntPtr dev; xkbPerClientFlagsReply rep; XkbInterestPtr interest; + Mask access_mode = DixGetAttrAccess | DixSetAttrAccess; REQUEST(xkbPerClientFlagsReq); REQUEST_SIZE_MATCH(xkbPerClientFlagsReq); @@ -4904,7 +4907,7 @@ ProcXkbPerClientFlags(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev,stuff->deviceSpec); + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, access_mode); CHK_MASK_LEGAL(0x01,stuff->change,XkbPCF_AllFlagsMask); CHK_MASK_MATCH(0x02,stuff->change,stuff->value); @@ -5040,7 +5043,7 @@ ProcXkbListComponents(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev,stuff->deviceSpec); + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess); status= Success; str= (unsigned char *)&stuff[1]; @@ -5123,6 +5126,7 @@ ProcXkbGetKbdByName(ClientPtr client) Bool geom_changed; XkbSrvLedInfoPtr old_sli; XkbSrvLedInfoPtr sli; + Mask access_mode = DixGetAttrAccess | DixSetAttrAccess; REQUEST(xkbGetKbdByNameReq); REQUEST_AT_LEAST_SIZE(xkbGetKbdByNameReq); @@ -5130,7 +5134,7 @@ ProcXkbGetKbdByName(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev,stuff->deviceSpec); + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, access_mode); xkb = dev->key->xkbInfo->desc; status= Success; @@ -5664,7 +5668,7 @@ char * str; wanted= stuff->wanted; - CHK_ANY_DEVICE(dev,stuff->deviceSpec); + CHK_ANY_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess); CHK_MASK_LEGAL(0x01,wanted,XkbXI_AllDeviceFeaturesMask); if ((!dev->button)||((stuff->nBtns<1)&&(!stuff->allBtns))) @@ -5968,7 +5972,7 @@ DeviceIntPtr kbd; kbd= dev; if ((sli->flags&XkbSLI_HasOwnState)==0) - kbd= (DeviceIntPtr)LookupKeyboardDevice(); + kbd = inputInfo.keyboard; XkbFlushLedEvents(dev,kbd,sli,&ed,&changes,&cause); ledWire= (xkbDeviceLedsWireDesc *)mapWire; @@ -5993,7 +5997,7 @@ xkbExtensionDeviceNotify ed; change= stuff->change; - CHK_ANY_DEVICE(dev,stuff->deviceSpec); + CHK_ANY_DEVICE(dev, stuff->deviceSpec, client, DixSetAttrAccess); CHK_MASK_LEGAL(0x01,change,XkbXI_AllFeaturesMask); wire= (char *)&stuff[1]; @@ -6043,7 +6047,7 @@ xkbExtensionDeviceNotify ed; ed.nBtns= stuff->nBtns; if (dev->key) kbd= dev; - else kbd= (DeviceIntPtr)LookupKeyboardDevice(); + else kbd= inputInfo.keyboard; acts= &dev->button->xkb_acts[stuff->firstBtn]; for (i=0;inBtns;i++,acts++) { if (acts->type!=XkbSA_NoAction) @@ -6069,10 +6073,15 @@ ProcXkbSetDebuggingFlags(ClientPtr client) { CARD32 newFlags,newCtrls,extraLength; xkbSetDebuggingFlagsReply rep; +int rc; REQUEST(xkbSetDebuggingFlagsReq); REQUEST_AT_LEAST_SIZE(xkbSetDebuggingFlagsReq); + rc = XaceHook(XACE_SERVER_ACCESS, client, DixDebugAccess); + if (rc != Success) + return rc; + newFlags= xkbDebugFlags&(~stuff->affectFlags); newFlags|= (stuff->flags&stuff->affectFlags); newCtrls= xkbDebugCtrls&(~stuff->affectCtrls); diff --git a/xkb/xkbAccessX.c b/xkb/xkbAccessX.c index 2954a0c0e..fbd281536 100644 --- a/xkb/xkbAccessX.c +++ b/xkb/xkbAccessX.c @@ -689,7 +689,7 @@ ProcessPointerEvent( register xEvent * xE, register DeviceIntPtr mouse, int count) { -DeviceIntPtr dev = (DeviceIntPtr)LookupKeyboardDevice(); +DeviceIntPtr dev = inputInfo.keyboard; XkbSrvInfoPtr xkbi = dev->key->xkbInfo; unsigned changed = 0; diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c index 7f0f74db1..822afffcb 100644 --- a/xkb/xkbActions.c +++ b/xkb/xkbActions.c @@ -1026,8 +1026,9 @@ DeviceIntPtr dev; int button; if (filter->keycode==0) { /* initial press */ - dev= _XkbLookupButtonDevice(pAction->devbtn.device,NULL); - if ((!dev)||(!dev->public.on)||(&dev->public==LookupPointerDevice())) + _XkbLookupButtonDevice(&dev, pAction->devbtn.device, serverClient, + DixUnknownAccess, &button); + if (!dev || !dev->public.on || dev == inputInfo.pointer) return 1; button= pAction->devbtn.button; @@ -1066,8 +1067,9 @@ int button; int button; filter->active= 0; - dev= _XkbLookupButtonDevice(filter->upAction.devbtn.device,NULL); - if ((!dev)||(!dev->public.on)||(&dev->public==LookupPointerDevice())) + _XkbLookupButtonDevice(&dev, filter->upAction.devbtn.device, + serverClient, DixUnknownAccess, &button); + if (!dev || !dev->public.on || dev == inputInfo.pointer) return 1; button= filter->upAction.btn.button; diff --git a/xkb/xkbEvents.c b/xkb/xkbEvents.c index 11dc17ad3..15b4949e5 100644 --- a/xkb/xkbEvents.c +++ b/xkb/xkbEvents.c @@ -806,7 +806,7 @@ Bool XkbFilterEvents(ClientPtr pClient,int nEvents,xEvent *xE) { int i, button_mask; -DeviceIntPtr pXDev = (DeviceIntPtr)LookupKeyboardDevice(); +DeviceIntPtr pXDev = inputInfo.keyboard; XkbSrvInfoPtr xkbi; xkbi= pXDev->key->xkbInfo; diff --git a/xkb/xkbLEDs.c b/xkb/xkbLEDs.c index d607d9066..2877af0c4 100644 --- a/xkb/xkbLEDs.c +++ b/xkb/xkbLEDs.c @@ -239,7 +239,7 @@ unsigned oldState; if (dev->key && dev->key->xkbInfo) kbd= dev; - else kbd= (DeviceIntPtr)LookupKeyboardDevice(); + else kbd= inputInfo.keyboard; state= &kbd->key->xkbInfo->state; ctrls= kbd->key->xkbInfo->desc->ctrls; @@ -444,7 +444,7 @@ XkbIndicatorMapPtr map; XkbDescPtr xkb; if ((sli->flags&XkbSLI_HasOwnState)==0) - dev= (DeviceIntPtr)LookupKeyboardDevice(); + dev= inputInfo.keyboard; sli->usesBase&= ~which; sli->usesLatched&= ~which; @@ -731,7 +731,7 @@ xkbExtensionDeviceNotify my_ed; return; if (dev->key && dev->key->xkbInfo) kbd= dev; - else kbd= (DeviceIntPtr)LookupKeyboardDevice(); + else kbd= inputInfo.keyboard; if (ed==NULL) { ed= &my_ed; @@ -808,7 +808,7 @@ xkbExtensionDeviceNotify my_ed; return; if (dev->key && dev->key->xkbInfo) kbd= dev; - else kbd= (DeviceIntPtr)LookupKeyboardDevice(); + else kbd= inputInfo.keyboard; if (ed==NULL) { ed= &my_ed; @@ -869,7 +869,7 @@ Bool kb_changed; return; if (dev->key && dev->key->xkbInfo) kbd= dev; - else kbd= (DeviceIntPtr)LookupKeyboardDevice(); + else kbd= inputInfo.keyboard; xkbi= kbd->key->xkbInfo; if (changes==NULL) { diff --git a/xkb/xkbPrOtherEv.c b/xkb/xkbPrOtherEv.c index a2ea0909a..d65107cdc 100644 --- a/xkb/xkbPrOtherEv.c +++ b/xkb/xkbPrOtherEv.c @@ -71,7 +71,7 @@ Bool xkbCares,isBtn; if ((!isBtn)||((dev->button)&&(dev->button->xkb_acts))) { DeviceIntPtr kbd; if (dev->key) kbd= dev; - else kbd= (DeviceIntPtr)LookupKeyboardDevice(); + else kbd= inputInfo.keyboard; XkbHandleActions(dev,kbd,xE,count); return; } diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c index 877d4d242..31c1a9fa9 100644 --- a/xkb/xkbUtils.c +++ b/xkb/xkbUtils.c @@ -49,92 +49,115 @@ int XkbDisableLockActions = 0; /***====================================================================***/ -DeviceIntPtr -_XkbLookupAnyDevice(int id,int *why_rtrn) +int +_XkbLookupAnyDevice(DeviceIntPtr *pDev, int id, ClientPtr client, + Mask access_mode, int *xkb_err) { -DeviceIntPtr dev = NULL; + int rc = XkbKeyboardErrorCode; - dev= (DeviceIntPtr)LookupKeyboardDevice(); - if ((id==XkbUseCoreKbd)||(dev->id==id)) - return dev; - - dev= (DeviceIntPtr)LookupPointerDevice(); - if ((id==XkbUseCorePtr)||(dev->id==id)) - return dev; - - if (id&(~0xff)) - dev = NULL; - - dixLookupDevice(&dev, id, serverClient, DixUnknownAccess); - if (dev!=NULL) - return dev; - if ((!dev)&&(why_rtrn)) - *why_rtrn= XkbErr_BadDevice; - return dev; + if (id == XkbUseCoreKbd) { + if (inputInfo.keyboard) + id = inputInfo.keyboard->id; + else + goto out; + } + if (id == XkbUseCorePtr) { + if (inputInfo.pointer) + id = inputInfo.pointer->id; + else + goto out; + } + rc = dixLookupDevice(pDev, id, client, access_mode); +out: + if (rc != Success) + *xkb_err = XkbErr_BadDevice; + return rc; } -DeviceIntPtr -_XkbLookupKeyboard(int id,int *why_rtrn) +int +_XkbLookupKeyboard(DeviceIntPtr *pDev, int id, ClientPtr client, + Mask access_mode, int *xkb_err) { -DeviceIntPtr dev = NULL; + DeviceIntPtr dev; + int rc; if (id == XkbDfltXIId) id = XkbUseCoreKbd; - if ((dev= _XkbLookupAnyDevice(id,why_rtrn))==NULL) - return NULL; - else if ((!dev->key)||(!dev->key->xkbInfo)) { - if (why_rtrn) - *why_rtrn= XkbErr_BadClass; - return NULL; + + rc = _XkbLookupAnyDevice(pDev, id, client, access_mode, xkb_err); + if (rc != Success) + return rc; + + dev = *pDev; + if (!dev->key || !dev->key->xkbInfo) { + *pDev = NULL; + *xkb_err= XkbErr_BadClass; + return XkbKeyboardErrorCode; } - return dev; + return Success; } -DeviceIntPtr -_XkbLookupBellDevice(int id,int *why_rtrn) +int +_XkbLookupBellDevice(DeviceIntPtr *pDev, int id, ClientPtr client, + Mask access_mode, int *xkb_err) { -DeviceIntPtr dev = NULL; - - if ((dev= _XkbLookupAnyDevice(id,why_rtrn))==NULL) - return NULL; - else if ((!dev->kbdfeed)&&(!dev->bell)) { - if (why_rtrn) - *why_rtrn= XkbErr_BadClass; - return NULL; + DeviceIntPtr dev; + int rc; + + rc = _XkbLookupAnyDevice(pDev, id, client, access_mode, xkb_err); + if (rc != Success) + return rc; + + dev = *pDev; + if (!dev->kbdfeed && !dev->bell) { + *pDev = NULL; + *xkb_err= XkbErr_BadClass; + return XkbKeyboardErrorCode; } - return dev; + return Success; } -DeviceIntPtr -_XkbLookupLedDevice(int id,int *why_rtrn) +int +_XkbLookupLedDevice(DeviceIntPtr *pDev, int id, ClientPtr client, + Mask access_mode, int *xkb_err) { -DeviceIntPtr dev = NULL; + DeviceIntPtr dev; + int rc; if (id == XkbDfltXIId) id = XkbUseCorePtr; - if ((dev= _XkbLookupAnyDevice(id,why_rtrn))==NULL) - return NULL; - else if ((!dev->kbdfeed)&&(!dev->leds)) { - if (why_rtrn) - *why_rtrn= XkbErr_BadClass; - return NULL; + + rc = _XkbLookupAnyDevice(pDev, id, client, access_mode, xkb_err); + if (rc != Success) + return rc; + + dev = *pDev; + if (!dev->kbdfeed && !dev->leds) { + *pDev = NULL; + *xkb_err= XkbErr_BadClass; + return XkbKeyboardErrorCode; } - return dev; + return Success; } -DeviceIntPtr -_XkbLookupButtonDevice(int id,int *why_rtrn) +int +_XkbLookupButtonDevice(DeviceIntPtr *pDev, int id, ClientPtr client, + Mask access_mode, int *xkb_err) { -DeviceIntPtr dev = NULL; - - if ((dev= _XkbLookupAnyDevice(id,why_rtrn))==NULL) - return NULL; - else if (!dev->button) { - if (why_rtrn) - *why_rtrn= XkbErr_BadClass; - return NULL; + DeviceIntPtr dev; + int rc; + + rc = _XkbLookupAnyDevice(pDev, id, client, access_mode, xkb_err); + if (rc != Success) + return rc; + + dev = *pDev; + if (!dev->button) { + *pDev = NULL; + *xkb_err= XkbErr_BadClass; + return XkbKeyboardErrorCode; } - return dev; + return Success; } void -- cgit v1.2.3