xace: add hooks + new access codes: MIT-SCREEN-SAVER extension

This commit is contained in:
Eamon Walsh 2007-08-30 13:06:28 -04:00 committed by Eamon Walsh
parent cda92bbf12
commit 766c693ef3

View File

@ -48,6 +48,7 @@ in this Software without prior written authorization from the X Consortium.
#include "gcstruct.h" #include "gcstruct.h"
#include "cursorstr.h" #include "cursorstr.h"
#include "colormapst.h" #include "colormapst.h"
#include "xace.h"
#ifdef PANORAMIX #ifdef PANORAMIX
#include "panoramiX.h" #include "panoramiX.h"
#include "panoramiXsrv.h" #include "panoramiXsrv.h"
@ -789,7 +790,11 @@ ProcScreenSaverQueryInfo (client)
REQUEST_SIZE_MATCH (xScreenSaverQueryInfoReq); REQUEST_SIZE_MATCH (xScreenSaverQueryInfoReq);
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0,
DixUnknownAccess); DixGetAttrAccess);
if (rc != Success)
return rc;
rc = XaceHook(XACE_SCREENSAVER_ACCESS, client, pDraw->pScreen,
DixGetAttrAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
@ -858,9 +863,15 @@ ProcScreenSaverSelectInput (client)
REQUEST_SIZE_MATCH (xScreenSaverSelectInputReq); REQUEST_SIZE_MATCH (xScreenSaverSelectInputReq);
rc = dixLookupDrawable (&pDraw, stuff->drawable, client, 0, rc = dixLookupDrawable (&pDraw, stuff->drawable, client, 0,
DixUnknownAccess); DixGetAttrAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
rc = XaceHook(XACE_SCREENSAVER_ACCESS, client, pDraw->pScreen,
DixSetAttrAccess);
if (rc != Success)
return rc;
if (!setEventMask (pDraw->pScreen, client, stuff->eventMask)) if (!setEventMask (pDraw->pScreen, client, stuff->eventMask))
return BadAlloc; return BadAlloc;
return Success; return Success;
@ -894,12 +905,16 @@ ScreenSaverSetAttributes (ClientPtr client)
REQUEST_AT_LEAST_SIZE (xScreenSaverSetAttributesReq); REQUEST_AT_LEAST_SIZE (xScreenSaverSetAttributesReq);
ret = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, ret = dixLookupDrawable(&pDraw, stuff->drawable, client, 0,
DixUnknownAccess); DixGetAttrAccess);
if (ret != Success) if (ret != Success)
return ret; return ret;
pScreen = pDraw->pScreen; pScreen = pDraw->pScreen;
pParent = WindowTable[pScreen->myNum]; pParent = WindowTable[pScreen->myNum];
ret = XaceHook(XACE_SCREENSAVER_ACCESS, client, pScreen, DixSetAttrAccess);
if (ret != Success)
return ret;
len = stuff->length - (sizeof(xScreenSaverSetAttributesReq) >> 2); len = stuff->length - (sizeof(xScreenSaverSetAttributesReq) >> 2);
if (Ones(stuff->mask) != len) if (Ones(stuff->mask) != len)
return BadLength; return BadLength;
@ -1055,8 +1070,9 @@ ScreenSaverSetAttributes (ClientPtr client)
} }
else else
{ {
pPixmap = (PixmapPtr)LookupIDByType(pixID, RT_PIXMAP); ret = dixLookupResource((pointer *)&pPixmap, pixID, RT_PIXMAP,
if (pPixmap != (PixmapPtr) NULL) client, DixReadAccess);
if (ret == Success)
{ {
if ((pPixmap->drawable.depth != depth) || if ((pPixmap->drawable.depth != depth) ||
(pPixmap->drawable.pScreen != pScreen)) (pPixmap->drawable.pScreen != pScreen))
@ -1070,7 +1086,7 @@ ScreenSaverSetAttributes (ClientPtr client)
} }
else else
{ {
ret = BadPixmap; ret = (ret == BadValue) ? BadPixmap : ret;
client->errorValue = pixID; client->errorValue = pixID;
goto PatchUp; goto PatchUp;
} }
@ -1092,8 +1108,9 @@ ScreenSaverSetAttributes (ClientPtr client)
} }
else else
{ {
pPixmap = (PixmapPtr)LookupIDByType(pixID, RT_PIXMAP); ret = dixLookupResource((pointer *)&pPixmap, pixID, RT_PIXMAP,
if (pPixmap) client, DixReadAccess);
if (ret == Success)
{ {
if ((pPixmap->drawable.depth != depth) || if ((pPixmap->drawable.depth != depth) ||
(pPixmap->drawable.pScreen != pScreen)) (pPixmap->drawable.pScreen != pScreen))
@ -1107,7 +1124,7 @@ ScreenSaverSetAttributes (ClientPtr client)
} }
else else
{ {
ret = BadPixmap; ret = (ret == BadValue) ? BadPixmap : ret;
client->errorValue = pixID; client->errorValue = pixID;
goto PatchUp; goto PatchUp;
} }
@ -1185,10 +1202,11 @@ ScreenSaverSetAttributes (ClientPtr client)
break; break;
case CWColormap: case CWColormap:
cmap = (Colormap) *pVlist; cmap = (Colormap) *pVlist;
pCmap = (ColormapPtr)LookupIDByType(cmap, RT_COLORMAP); ret = dixLookupResource((pointer *)&pCmap, cmap, RT_COLORMAP,
if (!pCmap) client, DixUseAccess);
if (ret != Success)
{ {
ret = BadColor; ret = (ret == BadValue) ? BadColor : ret;
client->errorValue = cmap; client->errorValue = cmap;
goto PatchUp; goto PatchUp;
} }
@ -1208,10 +1226,11 @@ ScreenSaverSetAttributes (ClientPtr client)
} }
else else
{ {
pCursor = (CursorPtr)LookupIDByType(cursorID, RT_CURSOR); ret = dixLookupResource((pointer *)&pCursor, cursorID,
if (!pCursor) RT_CURSOR, client, DixUseAccess);
if (ret != Success)
{ {
ret = BadCursor; ret = (ret == BadValue) ? BadCursor : ret;
client->errorValue = cursorID; client->errorValue = cursorID;
goto PatchUp; goto PatchUp;
} }
@ -1253,7 +1272,7 @@ ScreenSaverUnsetAttributes (ClientPtr client)
REQUEST_SIZE_MATCH (xScreenSaverUnsetAttributesReq); REQUEST_SIZE_MATCH (xScreenSaverUnsetAttributesReq);
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0,
DixUnknownAccess); DixGetAttrAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
pPriv = GetScreenPrivate (pDraw->pScreen); pPriv = GetScreenPrivate (pDraw->pScreen);