Add new, combined dix lookup functions.
This commit is contained in:
parent
6c46645cfc
commit
60cdc592fe
186
dix/dixutils.c
186
dix/dixutils.c
|
@ -194,115 +194,129 @@ CompareISOLatin1Lowered(unsigned char *s1, int s1len,
|
|||
return (int) c1 - (int) c2;
|
||||
}
|
||||
|
||||
#ifdef XACE
|
||||
|
||||
/* SecurityLookupWindow and SecurityLookupDrawable:
|
||||
* Look up the window/drawable taking into account the client doing
|
||||
* the lookup and the type of access desired. Return the window/drawable
|
||||
* if it exists and the client is allowed access, else return NULL.
|
||||
* Most Proc* functions should be calling these instead of
|
||||
* LookupWindow and LookupDrawable, which do no access checks.
|
||||
* XACE note: need to see if client->lastDrawableID can still be used here.
|
||||
/*
|
||||
* dixLookupWindow and dixLookupDrawable:
|
||||
* Look up the window/drawable taking into account the client doing the
|
||||
* lookup, the type of drawable desired, and the type of access desired.
|
||||
* Return Success with *pDraw set if the window/drawable exists and the client
|
||||
* is allowed access, else return an error code with *pDraw set to NULL. The
|
||||
* access mask values are defined in resource.h. The type mask values are
|
||||
* defined in pixmap.h, with zero equivalent to M_DRAWABLE.
|
||||
*/
|
||||
|
||||
_X_EXPORT WindowPtr
|
||||
SecurityLookupWindow(XID rid, ClientPtr client, Mask access_mode)
|
||||
_X_EXPORT int
|
||||
dixLookupDrawable(DrawablePtr *pDraw, XID id, ClientPtr client,
|
||||
Mask type, Mask access)
|
||||
{
|
||||
client->errorValue = rid;
|
||||
if(rid == INVALID)
|
||||
return NULL;
|
||||
return (WindowPtr)SecurityLookupIDByType(client, rid, RT_WINDOW, access_mode);
|
||||
}
|
||||
DrawablePtr pTmp;
|
||||
RESTYPE rtype;
|
||||
*pDraw = NULL;
|
||||
client->errorValue = id;
|
||||
|
||||
if (id == INVALID)
|
||||
return BadDrawable;
|
||||
|
||||
_X_EXPORT pointer
|
||||
SecurityLookupDrawable(XID rid, ClientPtr client, Mask access_mode)
|
||||
{
|
||||
register DrawablePtr pDraw;
|
||||
if (id == client->lastDrawableID) {
|
||||
pTmp = client->lastDrawable;
|
||||
|
||||
if(rid == INVALID)
|
||||
return (pointer) NULL;
|
||||
pDraw = (DrawablePtr)SecurityLookupIDByClass(client, rid, RC_DRAWABLE,
|
||||
access_mode);
|
||||
if (pDraw && (pDraw->type != UNDRAWABLE_WINDOW))
|
||||
return (pointer)pDraw;
|
||||
return (pointer)NULL;
|
||||
}
|
||||
/* an access check is required for cached drawables */
|
||||
rtype = (pTmp->type | M_WINDOW) ? RT_WINDOW : RT_PIXMAP;
|
||||
if (!XaceHook(XACE_RESOURCE_ACCESS, client, id, rtype, access, pTmp))
|
||||
return BadDrawable;
|
||||
} else
|
||||
pTmp = (DrawablePtr)SecurityLookupIDByClass(client, id, RC_DRAWABLE,
|
||||
access);
|
||||
if (!pTmp)
|
||||
return BadDrawable;
|
||||
if (!((1 << pTmp->type) | (type ? type : M_DRAWABLE)))
|
||||
return BadMatch;
|
||||
|
||||
/* We can't replace the LookupWindow and LookupDrawable functions with
|
||||
* macros because of compatibility with loadable servers.
|
||||
*/
|
||||
|
||||
_X_EXPORT WindowPtr
|
||||
LookupWindow(XID rid, ClientPtr client)
|
||||
{
|
||||
return SecurityLookupWindow(rid, client, DixUnknownAccess);
|
||||
}
|
||||
|
||||
_X_EXPORT pointer
|
||||
LookupDrawable(XID rid, ClientPtr client)
|
||||
{
|
||||
return SecurityLookupDrawable(rid, client, DixUnknownAccess);
|
||||
}
|
||||
|
||||
#else /* not XACE */
|
||||
|
||||
WindowPtr
|
||||
LookupWindow(XID rid, ClientPtr client)
|
||||
{
|
||||
WindowPtr pWin;
|
||||
|
||||
client->errorValue = rid;
|
||||
if(rid == INVALID)
|
||||
return NULL;
|
||||
if (client->lastDrawableID == rid)
|
||||
{
|
||||
if (client->lastDrawable->type == DRAWABLE_WINDOW)
|
||||
return ((WindowPtr) client->lastDrawable);
|
||||
return (WindowPtr) NULL;
|
||||
}
|
||||
pWin = (WindowPtr)LookupIDByType(rid, RT_WINDOW);
|
||||
if (pWin && pWin->drawable.type == DRAWABLE_WINDOW) {
|
||||
client->lastDrawable = (DrawablePtr) pWin;
|
||||
client->lastDrawableID = rid;
|
||||
if (pTmp->type | M_DRAWABLE) {
|
||||
client->lastDrawable = pTmp;
|
||||
client->lastDrawableID = id;
|
||||
client->lastGCID = INVALID;
|
||||
client->lastGC = (GCPtr)NULL;
|
||||
}
|
||||
return pWin;
|
||||
*pDraw = pTmp;
|
||||
return Success;
|
||||
}
|
||||
|
||||
|
||||
pointer
|
||||
LookupDrawable(XID rid, ClientPtr client)
|
||||
_X_EXPORT int
|
||||
dixLookupWindow(WindowPtr *pWin, XID id, ClientPtr client, Mask access)
|
||||
{
|
||||
register DrawablePtr pDraw;
|
||||
|
||||
if(rid == INVALID)
|
||||
return (pointer) NULL;
|
||||
if (client->lastDrawableID == rid)
|
||||
return ((pointer) client->lastDrawable);
|
||||
pDraw = (DrawablePtr)LookupIDByClass(rid, RC_DRAWABLE);
|
||||
if (pDraw && (pDraw->type != UNDRAWABLE_WINDOW))
|
||||
return (pointer)pDraw;
|
||||
return (pointer)NULL;
|
||||
int rc;
|
||||
rc = dixLookupDrawable((DrawablePtr*)pWin, id, client, M_WINDOW, access);
|
||||
return (rc == BadDrawable) ? BadWindow : rc;
|
||||
}
|
||||
|
||||
#endif /* XACE */
|
||||
_X_EXPORT int
|
||||
dixLookupGC(GCPtr *pGC, XID id, ClientPtr client, Mask access)
|
||||
{
|
||||
GCPtr pTmp = (GCPtr)SecurityLookupIDByType(client, id, RT_GC, access);
|
||||
if (pTmp) {
|
||||
*pGC = pTmp;
|
||||
return Success;
|
||||
}
|
||||
client->errorValue = id;
|
||||
*pGC = NULL;
|
||||
return BadGC;
|
||||
}
|
||||
|
||||
_X_EXPORT ClientPtr
|
||||
LookupClient(XID rid, ClientPtr client)
|
||||
_X_EXPORT int
|
||||
dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client)
|
||||
{
|
||||
pointer pRes = (pointer)SecurityLookupIDByClass(client, rid, RC_ANY,
|
||||
DixReadAccess);
|
||||
int clientIndex = CLIENT_ID(rid);
|
||||
|
||||
if (clientIndex && pRes && clients[clientIndex] && !(rid & SERVER_BIT))
|
||||
{
|
||||
return clients[clientIndex];
|
||||
if (clientIndex && pRes && clients[clientIndex] && !(rid & SERVER_BIT)) {
|
||||
*pClient = clients[clientIndex];
|
||||
return Success;
|
||||
}
|
||||
return (ClientPtr)NULL;
|
||||
*pClient = NULL;
|
||||
return BadValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* These are deprecated compatibility functions and will be removed soon!
|
||||
* Please use the new dixLookup*() functions above.
|
||||
*/
|
||||
_X_EXPORT WindowPtr
|
||||
SecurityLookupWindow(XID id, ClientPtr client, Mask access_mode)
|
||||
{
|
||||
WindowPtr pWin;
|
||||
int i = dixLookupWindow(&pWin, id, client, access_mode);
|
||||
return (i == Success) ? pWin : NULL;
|
||||
}
|
||||
|
||||
_X_EXPORT WindowPtr
|
||||
LookupWindow(XID id, ClientPtr client)
|
||||
{
|
||||
return SecurityLookupWindow(id, client, DixUnknownAccess);
|
||||
}
|
||||
|
||||
_X_EXPORT pointer
|
||||
SecurityLookupDrawable(XID id, ClientPtr client, Mask access_mode)
|
||||
{
|
||||
DrawablePtr pDraw;
|
||||
int i = dixLookupDrawable(&pDraw, id, client, access_mode, TRUE);
|
||||
return (i == Success) ? pDraw : NULL;
|
||||
}
|
||||
|
||||
_X_EXPORT pointer
|
||||
LookupDrawable(XID id, ClientPtr client)
|
||||
{
|
||||
return SecurityLookupDrawable(id, client, DixUnknownAccess);
|
||||
}
|
||||
|
||||
_X_EXPORT ClientPtr
|
||||
LookupClient(XID id, ClientPtr client)
|
||||
{
|
||||
ClientPtr pClient;
|
||||
int i = dixLookupClient(&pClient, id, client);
|
||||
return (i == Success) ? pClient : NULL;
|
||||
}
|
||||
|
||||
/* end deprecated functions */
|
||||
|
||||
int
|
||||
AlterSaveSetForClient(ClientPtr client, WindowPtr pWin, unsigned mode,
|
||||
|
|
|
@ -155,17 +155,21 @@ _X_HIDDEN void *dixLookupTab[] = {
|
|||
SYMFUNC(CompareTimeStamps)
|
||||
SYMFUNC(CopyISOLatin1Lowered)
|
||||
SYMFUNC(DeleteCallback)
|
||||
SYMFUNC(dixLookupDrawable)
|
||||
SYMFUNC(dixLookupWindow)
|
||||
SYMFUNC(dixLookupClient)
|
||||
SYMFUNC(dixLookupGC)
|
||||
/* following are deprecated */
|
||||
SYMFUNC(LookupClient)
|
||||
SYMFUNC(LookupDrawable)
|
||||
SYMFUNC(LookupWindow)
|
||||
SYMFUNC(SecurityLookupDrawable)
|
||||
SYMFUNC(SecurityLookupWindow)
|
||||
/* end deprecated */
|
||||
SYMFUNC(NoopDDA)
|
||||
SYMFUNC(QueueWorkProc)
|
||||
SYMFUNC(RegisterBlockAndWakeupHandlers)
|
||||
SYMFUNC(RemoveBlockAndWakeupHandlers)
|
||||
#ifdef XACE
|
||||
SYMFUNC(SecurityLookupDrawable)
|
||||
SYMFUNC(SecurityLookupWindow)
|
||||
#endif
|
||||
/* events.c */
|
||||
SYMFUNC(CheckCursorConfinement)
|
||||
SYMFUNC(DeliverEvents)
|
||||
|
|
|
@ -375,47 +375,40 @@ extern int CompareISOLatin1Lowered(
|
|||
unsigned char * /*b*/,
|
||||
int blen);
|
||||
|
||||
#ifdef XACE
|
||||
extern int dixLookupWindow(
|
||||
WindowPtr *result,
|
||||
XID id,
|
||||
ClientPtr client,
|
||||
Mask access_mode);
|
||||
|
||||
extern WindowPtr SecurityLookupWindow(
|
||||
XID /*rid*/,
|
||||
ClientPtr /*client*/,
|
||||
Mask /*access_mode*/);
|
||||
extern int dixLookupDrawable(
|
||||
DrawablePtr *result,
|
||||
XID id,
|
||||
ClientPtr client,
|
||||
Mask type_mask,
|
||||
Mask access_mode);
|
||||
|
||||
extern pointer SecurityLookupDrawable(
|
||||
XID /*rid*/,
|
||||
ClientPtr /*client*/,
|
||||
Mask /*access_mode*/);
|
||||
extern int dixLookupGC(
|
||||
GCPtr *result,
|
||||
XID id,
|
||||
ClientPtr client,
|
||||
Mask access_mode);
|
||||
|
||||
extern WindowPtr LookupWindow(
|
||||
XID /*rid*/,
|
||||
ClientPtr /*client*/);
|
||||
extern int dixLookupClient(
|
||||
ClientPtr *result,
|
||||
XID id,
|
||||
ClientPtr client);
|
||||
|
||||
extern pointer LookupDrawable(
|
||||
XID /*rid*/,
|
||||
ClientPtr /*client*/);
|
||||
|
||||
#else
|
||||
|
||||
extern WindowPtr LookupWindow(
|
||||
XID /*rid*/,
|
||||
ClientPtr /*client*/);
|
||||
|
||||
extern pointer LookupDrawable(
|
||||
XID /*rid*/,
|
||||
ClientPtr /*client*/);
|
||||
|
||||
#define SecurityLookupWindow(rid, client, access_mode) \
|
||||
LookupWindow(rid, client)
|
||||
|
||||
#define SecurityLookupDrawable(rid, client, access_mode) \
|
||||
LookupDrawable(rid, client)
|
||||
|
||||
#endif /* XACE */
|
||||
|
||||
extern ClientPtr LookupClient(
|
||||
XID /*rid*/,
|
||||
ClientPtr /*client*/);
|
||||
/*
|
||||
* These are deprecated compatibility functions and will be removed soon!
|
||||
* Please use the new dixLookup*() functions above.
|
||||
*/
|
||||
extern WindowPtr SecurityLookupWindow(XID, ClientPtr, Mask);
|
||||
extern WindowPtr LookupWindow(XID, ClientPtr);
|
||||
extern pointer SecurityLookupDrawable(XID, ClientPtr, Mask);
|
||||
extern pointer LookupDrawable(XID, ClientPtr);
|
||||
extern ClientPtr LookupClient(XID, ClientPtr);
|
||||
/* end deprecated functions */
|
||||
|
||||
extern void NoopDDA(void);
|
||||
|
||||
|
|
|
@ -58,6 +58,16 @@ SOFTWARE.
|
|||
#define UNDRAWABLE_WINDOW 2
|
||||
#define DRAWABLE_BUFFER 3
|
||||
|
||||
/* corresponding type masks for dixLookupDrawable() */
|
||||
#define M_DRAWABLE_WINDOW (1<<0)
|
||||
#define M_DRAWABLE_PIXMAP (1<<1)
|
||||
#define M_UNDRAWABLE_WINDOW (1<<2)
|
||||
#define M_DRAWABLE_BUFFER (1<<3)
|
||||
#define M_ANY (-1)
|
||||
#define M_WINDOW (M_DRAWABLE_WINDOW|M_UNDRAWABLE_WINDOW)
|
||||
#define M_DRAWABLE (M_DRAWABLE_WINDOW|M_DRAWABLE_PIXMAP|M_DRAWABLE_BUFFER)
|
||||
#define M_UNDRAWABLE (M_UNDRAWABLE_WINDOW)
|
||||
|
||||
/* flags to PaintWindow() */
|
||||
#define PW_BACKGROUND 0
|
||||
#define PW_BORDER 1
|
||||
|
|
Loading…
Reference in New Issue
Block a user