xserver: Branch 'XACE-SELINUX' - 4 commits
Eamon Walsh
ewalsh at kemper.freedesktop.org
Fri Apr 6 00:32:07 EEST 2007
afb/afb.h | 1
afb/afbpixmap.c | 1
cfb/cfb.h | 1
cfb/cfbpixmap.c | 1
dix/Makefile.am | 1
dix/colormap.c | 2
dix/deprecated.c | 162 +++++++++++++++++++++++++++++++++++++++++++++
dix/devices.c | 5 -
dix/dispatch.c | 2
dix/dixutils.c | 65 +-----------------
dix/extension.c | 2
dix/gc.c | 2
dix/main.c | 16 ++--
dix/privates.c | 6 -
dix/resource.c | 88 +++++-------------------
dix/window.c | 2
fb/fb.h | 1
fb/fbpixmap.c | 1
hw/dmx/dmxpixmap.c | 2
hw/xfree86/loader/dixsym.c | 22 +++---
hw/xgl/xglpixmap.c | 1
hw/xnest/Pixmap.c | 2
hw/xprint/ps/PsPixmap.c | 8 +-
include/dix.h | 43 ++++++++---
include/resource.h | 55 +++++++++------
mfb/mfb.h | 1
mfb/mfbpixmap.c | 1
27 files changed, 308 insertions(+), 186 deletions(-)
New commits:
diff-tree 5ad562565ac8ef9257da3afb0de1ae4f90f80fe9 (from 1d550bb2c5cb5b3e588f0e0b68a421dc1cb8bd7c)
Author: Eamon Walsh <ewalsh at tycho.nsa.gov>
Date: Thu Apr 5 14:18:05 2007 -0400
devPrivates rework: properly free devPrivates on compatibility structures,
type pixmap. Requires ddx'es to call the free function from DestroyPixmap.
diff --git a/afb/afb.h b/afb/afb.h
index 5aa2b0c..b3ed1ee 100644
--- a/afb/afb.h
+++ b/afb/afb.h
@@ -55,6 +55,7 @@ SOFTWARE.
#include "gc.h"
#include "colormap.h"
#include "regionstr.h"
+#include "privates.h"
#include "mibstore.h"
#include "mfb.h"
diff --git a/afb/afbpixmap.c b/afb/afbpixmap.c
index 77ba535..5a81679 100644
--- a/afb/afbpixmap.c
+++ b/afb/afbpixmap.c
@@ -113,6 +113,7 @@ afbDestroyPixmap(pPixmap)
{
if(--pPixmap->refcnt)
return(TRUE);
+ dixFreePrivates(*DEVPRIV_PTR(pPixmap));
xfree(pPixmap);
return(TRUE);
}
diff --git a/cfb/cfb.h b/cfb/cfb.h
index 8c682ae..15332ff 100644
--- a/cfb/cfb.h
+++ b/cfb/cfb.h
@@ -37,6 +37,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "colormap.h"
#include "miscstruct.h"
#include "servermd.h"
+#include "privates.h"
#include "windowstr.h"
#include "mfb.h"
#undef PixelType
diff --git a/cfb/cfbpixmap.c b/cfb/cfbpixmap.c
index 6fdf3ea..ed01316 100644
--- a/cfb/cfbpixmap.c
+++ b/cfb/cfbpixmap.c
@@ -107,6 +107,7 @@ cfbDestroyPixmap(pPixmap)
{
if(--pPixmap->refcnt)
return TRUE;
+ dixFreePrivates(*DEVPRIV_PTR(pPixmap));
xfree(pPixmap);
return TRUE;
}
diff --git a/fb/fb.h b/fb/fb.h
index e605078..9e88667 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -38,6 +38,7 @@
#include "mi.h"
#include "migc.h"
#include "mibstore.h"
+#include "privates.h"
#ifdef RENDER
#include "picturestr.h"
#else
diff --git a/fb/fbpixmap.c b/fb/fbpixmap.c
index 18c1204..8c3216a 100644
--- a/fb/fbpixmap.c
+++ b/fb/fbpixmap.c
@@ -98,6 +98,7 @@ fbDestroyPixmap (PixmapPtr pPixmap)
{
if(--pPixmap->refcnt)
return TRUE;
+ dixFreePrivates(*DEVPRIV_PTR(pPixmap));
xfree(pPixmap);
return TRUE;
}
diff --git a/hw/dmx/dmxpixmap.c b/hw/dmx/dmxpixmap.c
index 9340606..e617134 100644
--- a/hw/dmx/dmxpixmap.c
+++ b/hw/dmx/dmxpixmap.c
@@ -45,6 +45,7 @@
#include "pixmapstr.h"
#include "servermd.h"
+#include "privates.h"
/** Initialize a private area in \a pScreen for pixmap information. */
Bool dmxInitPixmap(ScreenPtr pScreen)
@@ -173,6 +174,7 @@ Bool dmxDestroyPixmap(PixmapPtr pPixmap)
dmxSync(dmxScreen, FALSE);
}
}
+ dixFreePrivates(*DEVPRIV_PTR(pPixmap));
xfree(pPixmap);
#if 0
diff --git a/hw/xgl/xglpixmap.c b/hw/xgl/xglpixmap.c
index 368c3ea..166c33e 100644
--- a/hw/xgl/xglpixmap.c
+++ b/hw/xgl/xglpixmap.c
@@ -310,6 +310,7 @@ xglDestroyPixmap (PixmapPtr pPixmap)
xglFiniPixmap (pPixmap);
+ dixFreePrivates(*DEVPRIV_PTR(pPixmap));
xfree (pPixmap);
return TRUE;
diff --git a/hw/xnest/Pixmap.c b/hw/xnest/Pixmap.c
index 612df8d..c4b8aa6 100644
--- a/hw/xnest/Pixmap.c
+++ b/hw/xnest/Pixmap.c
@@ -24,6 +24,7 @@ is" without express or implied warranty.
#include "regionstr.h"
#include "gc.h"
#include "servermd.h"
+#include "privates.h"
#include "mi.h"
#include "Xnest.h"
@@ -74,6 +75,7 @@ xnestDestroyPixmap(PixmapPtr pPixmap)
if(--pPixmap->refcnt)
return TRUE;
XFreePixmap(xnestDisplay, xnestPixmap(pPixmap));
+ dixFreePrivates(*DEVPRIV_PTR(pPixmap));
xfree(pPixmap);
return TRUE;
}
diff --git a/hw/xprint/ps/PsPixmap.c b/hw/xprint/ps/PsPixmap.c
index c3259c9..220feab 100644
--- a/hw/xprint/ps/PsPixmap.c
+++ b/hw/xprint/ps/PsPixmap.c
@@ -79,6 +79,7 @@ in this Software without prior written a
#include "windowstr.h"
#include "gcstruct.h"
+#include "privates.h"
#include "Ps.h"
@@ -111,9 +112,13 @@ PsCreatePixmap(
pPixmap->devKind = 0;
pPixmap->refcnt = 1;
+ pPixmap->devPrivates = (DevUnion *)xcalloc(1, sizeof(DevUnion));
+ if( !pPixmap->devPrivates )
+ { xfree(pPixmap); return NullPixmap; }
+
pPixmap->devPrivate.ptr = (PsPixmapPrivPtr)xcalloc(1, sizeof(PsPixmapPrivRec));
if( !pPixmap->devPrivate.ptr )
- { xfree(pPixmap); return NullPixmap; }
+ { xfree(pPixmap->devPrivates); xfree(pPixmap); return NullPixmap; }
return pPixmap;
}
@@ -196,6 +201,7 @@ PsDestroyPixmap(PixmapPtr pPixmap)
PsScrubPixmap(pPixmap);
xfree(priv);
+ dixFreePrivates(*DEVPRIV_PTR(pPixmap));
xfree(pPixmap);
return TRUE;
}
diff --git a/mfb/mfb.h b/mfb/mfb.h
index f597b16..3cded7b 100644
--- a/mfb/mfb.h
+++ b/mfb/mfb.h
@@ -58,6 +58,7 @@ SOFTWARE.
#include "region.h"
#include "gc.h"
#include "colormap.h"
+#include "privates.h"
#include "miscstruct.h"
#include "mibstore.h"
diff --git a/mfb/mfbpixmap.c b/mfb/mfbpixmap.c
index e349724..b13e3af 100644
--- a/mfb/mfbpixmap.c
+++ b/mfb/mfbpixmap.c
@@ -113,6 +113,7 @@ mfbDestroyPixmap(pPixmap)
{
if(--pPixmap->refcnt)
return TRUE;
+ dixFreePrivates(*DEVPRIV_PTR(pPixmap));
xfree(pPixmap);
return TRUE;
}
diff-tree 1d550bb2c5cb5b3e588f0e0b68a421dc1cb8bd7c (from ed75b056511ccb429c48c6c55d14dc7ae79e75a3)
Author: Eamon Walsh <ewalsh at tycho.nsa.gov>
Date: Thu Apr 5 12:12:58 2007 -0400
devPrivates rework: minor fix; use calloc and avoid initialization.
diff --git a/dix/devices.c b/dix/devices.c
index 4a7ec4d..ab64fcb 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -128,12 +128,11 @@ AddInputDevice(DeviceProc deviceProc, Bo
#endif
/* must pre-allocate one private for the new devPrivates support */
dev->nPrivates = 1;
- dev->devPrivates = (DevUnion *)xalloc(sizeof(DevUnion));
+ dev->devPrivates = (DevUnion *)xcalloc(1, sizeof(DevUnion));
if (!dev->devPrivates) {
xfree(dev);
return NULL;
}
- dev->devPrivates[0].ptr = NULL;
dev->unwrapProc = NULL;
dev->coreEvents = TRUE;
diff --git a/dix/main.c b/dix/main.c
index b5db193..cae50c8 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -720,20 +720,17 @@ AddScreen(
/* must pre-allocate one private for the new devPrivates support */
pScreen->WindowPrivateLen = 1;
- pScreen->WindowPrivateSizes = (unsigned *)xalloc(sizeof(unsigned));
+ pScreen->WindowPrivateSizes = (unsigned *)xcalloc(1, sizeof(unsigned));
pScreen->totalWindowSize = PadToLong(sizeof(WindowRec)) + sizeof(DevUnion);
pScreen->GCPrivateLen = 1;
- pScreen->GCPrivateSizes = (unsigned *)xalloc(sizeof(unsigned));
+ pScreen->GCPrivateSizes = (unsigned *)xcalloc(1, sizeof(unsigned));
pScreen->totalGCSize = PadToLong(sizeof(GC)) + sizeof(DevUnion);
pScreen->PixmapPrivateLen = 1;
- pScreen->PixmapPrivateSizes = (unsigned *)xalloc(sizeof(unsigned));
+ pScreen->PixmapPrivateSizes = (unsigned *)xcalloc(1, sizeof(unsigned));
pScreen->totalPixmapSize = BitmapBytePad(8 * (sizeof(PixmapRec) +
sizeof(DevUnion)));
- if (pScreen->WindowPrivateSizes && pScreen->GCPrivateSizes &&
- pScreen->PixmapPrivateSizes)
- *pScreen->WindowPrivateSizes = *pScreen->GCPrivateSizes =
- *pScreen->PixmapPrivateSizes = 0;
- else {
+ if (!pScreen->WindowPrivateSizes || !pScreen->GCPrivateSizes ||
+ !pScreen->PixmapPrivateSizes) {
xfree(pScreen);
return -1;
}
diff --git a/dix/privates.c b/dix/privates.c
index 8a39437..4cb2e35 100644
--- a/dix/privates.c
+++ b/dix/privates.c
@@ -298,10 +298,9 @@ ResetExtensionPrivates()
extensionPrivateCount = 1;
extensionPrivateLen = 1;
xfree(extensionPrivateSizes);
- extensionPrivateSizes = (unsigned *)xalloc(sizeof(unsigned));
+ extensionPrivateSizes = (unsigned *)xcalloc(1, sizeof(unsigned));
if (!extensionPrivateSizes)
return FALSE;
- *extensionPrivateSizes = 0;
totalExtensionSize = PadToLong(sizeof(ExtensionEntry)) + sizeof(DevUnion);
return TRUE;
}
@@ -358,10 +357,9 @@ ResetClientPrivates()
clientPrivateCount = 1;
clientPrivateLen = 1;
xfree(clientPrivateSizes);
- clientPrivateSizes = (unsigned *)xalloc(sizeof(unsigned));
+ clientPrivateSizes = (unsigned *)xcalloc(1, sizeof(unsigned));
if (!clientPrivateSizes)
return FALSE;
- *clientPrivateSizes = 0;
totalClientSize = PadToLong(sizeof(ClientRec)) + sizeof(DevUnion);
return TRUE;
}
diff-tree ed75b056511ccb429c48c6c55d14dc7ae79e75a3 (from 63e46e4fc3e98751f2edbed9c79ef3d5dc2dadc6)
Author: Eamon Walsh <ewalsh at tycho.nsa.gov>
Date: Wed Apr 4 12:00:15 2007 -0400
dix: add new, combined resource lookup function. Move all dix lookup API
deprecated so far to a new file dix/deprecated.c. Remove the deprecation
warnings for the time being.
diff --git a/dix/Makefile.am b/dix/Makefile.am
index a1f02c1..ff0d5d6 100644
--- a/dix/Makefile.am
+++ b/dix/Makefile.am
@@ -8,6 +8,7 @@ libdix_la_SOURCES = \
atom.c \
colormap.c \
cursor.c \
+ deprecated.c \
devices.c \
dispatch.c \
dispatch.h \
diff --git a/dix/deprecated.c b/dix/deprecated.c
new file mode 100644
index 0000000..2bb8119
--- /dev/null
+++ b/dix/deprecated.c
@@ -0,0 +1,162 @@
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice 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
+OPEN GROUP 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.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "dix.h"
+#include "misc.h"
+#include "dixstruct.h"
+
+/*
+ * These are deprecated compatibility functions and will be marked as such
+ * and removed soon!
+ *
+ * Please use the noted replacements instead.
+ */
+
+/* replaced by dixLookupWindow */
+_X_EXPORT WindowPtr
+SecurityLookupWindow(XID id, ClientPtr client, Mask access_mode)
+{
+ WindowPtr pWin;
+ int i = dixLookupWindow(&pWin, id, client, access_mode);
+ static int warn = 1;
+ if (warn > 0 && --warn)
+ ErrorF("Warning: LookupWindow()/SecurityLookupWindow() "
+ "are deprecated. Please convert your driver/module "
+ "to use dixLookupWindow().\n");
+ return (i == Success) ? pWin : NULL;
+}
+
+/* replaced by dixLookupWindow */
+_X_EXPORT WindowPtr
+LookupWindow(XID id, ClientPtr client)
+{
+ return SecurityLookupWindow(id, client, DixUnknownAccess);
+}
+
+/* replaced by dixLookupDrawable */
+_X_EXPORT pointer
+SecurityLookupDrawable(XID id, ClientPtr client, Mask access_mode)
+{
+ DrawablePtr pDraw;
+ int i = dixLookupDrawable(&pDraw, id, client, M_DRAWABLE, access_mode);
+ static int warn = 1;
+ if (warn > 0 && --warn)
+ ErrorF("Warning: LookupDrawable()/SecurityLookupDrawable() "
+ "are deprecated. Please convert your driver/module "
+ "to use dixLookupDrawable().\n");
+ return (i == Success) ? pDraw : NULL;
+}
+
+/* replaced by dixLookupDrawable */
+_X_EXPORT pointer
+LookupDrawable(XID id, ClientPtr client)
+{
+ return SecurityLookupDrawable(id, client, DixUnknownAccess);
+}
+
+/* replaced by dixLookupClient */
+_X_EXPORT ClientPtr
+LookupClient(XID id, ClientPtr client)
+{
+ ClientPtr pClient;
+ int i = dixLookupClient(&pClient, id, client, DixUnknownAccess);
+ static int warn = 1;
+ if (warn > 0 && --warn)
+ ErrorF("Warning: LookupClient() is deprecated. Please convert your "
+ "driver/module to use dixLookupClient().\n");
+ return (i == Success) ? pClient : NULL;
+}
+
+/* replaced by dixLookupResource */
+_X_EXPORT pointer
+SecurityLookupIDByType(ClientPtr client, XID id, RESTYPE rtype,
+ Mask access_mode)
+{
+ pointer retval;
+ int i = dixLookupResource(&retval, id, rtype, client, access_mode);
+ static int warn = 1;
+ if (warn > 0 && --warn)
+ ErrorF("Warning: LookupIDByType()/SecurityLookupIDByType() "
+ "are deprecated. Please convert your driver/module "
+ "to use dixLookupResource().\n");
+ return (i == Success) ? retval : NULL;
+}
+
+/* replaced by dixLookupResource */
+_X_EXPORT pointer
+SecurityLookupIDByClass(ClientPtr client, XID id, RESTYPE classes,
+ Mask access_mode)
+{
+ pointer retval;
+ int i = dixLookupResource(&retval, id, classes, client, access_mode);
+ static int warn = 1;
+ if (warn > 0 && --warn)
+ ErrorF("Warning: LookupIDByClass()/SecurityLookupIDByClass() "
+ "are deprecated. Please convert your driver/module "
+ "to use dixLookupResource().\n");
+ return (i == Success) ? retval : NULL;
+}
+
+/* replaced by dixLookupResource */
+_X_EXPORT pointer
+LookupIDByType(XID id, RESTYPE rtype)
+{
+ return SecurityLookupIDByType(NullClient, id, rtype, DixUnknownAccess);
+}
+
+/* replaced by dixLookupResource */
+_X_EXPORT pointer
+LookupIDByClass(XID id, RESTYPE classes)
+{
+ return SecurityLookupIDByClass(NullClient, id, classes, DixUnknownAccess);
+}
+
+/* end deprecated functions */
diff --git a/dix/dixutils.c b/dix/dixutils.c
index 44d82c9..94e0f2c 100644
--- a/dix/dixutils.c
+++ b/dix/dixutils.c
@@ -223,8 +223,8 @@ dixLookupDrawable(DrawablePtr *pDraw, XI
if (!XaceHook(XACE_RESOURCE_ACCESS, client, id, rtype, access, pTmp))
return BadDrawable;
} else
- pTmp = (DrawablePtr)SecurityLookupIDByClass(client, id, RC_DRAWABLE,
- access);
+ dixLookupResource((void **)&pTmp, id, RC_DRAWABLE, client, access);
+
if (!pTmp)
return BadDrawable;
if (!((1 << pTmp->type) & (type ? type : M_DRAWABLE)))
@@ -264,11 +264,12 @@ dixLookupGC(GCPtr *pGC, XID id, ClientPt
_X_EXPORT int
dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client, Mask access)
{
- pointer pRes = (pointer)SecurityLookupIDByClass(client, rid, RC_ANY,
- DixReadAccess);
+ pointer pRes;
int clientIndex = CLIENT_ID(rid);
client->errorValue = rid;
+ dixLookupResource(&pRes, rid, RC_ANY, client, DixReadAccess);
+
if (clientIndex && pRes && clients[clientIndex] && !(rid & SERVER_BIT)) {
*pClient = clients[clientIndex];
return Success;
@@ -277,62 +278,6 @@ dixLookupClient(ClientPtr *pClient, XID
return BadValue;
}
-/*
- * These are deprecated compatibility functions and will be removed soon!
- * Please use the new dixLookup*() functions above.
- */
-_X_EXPORT _X_DEPRECATED WindowPtr
-SecurityLookupWindow(XID id, ClientPtr client, Mask access_mode)
-{
- WindowPtr pWin;
- int i = dixLookupWindow(&pWin, id, client, access_mode);
- static int warn = 1;
- if (warn-- > 0)
- ErrorF("Warning: LookupWindow()/SecurityLookupWindow() "
- "are deprecated. Please convert your driver/module "
- "to use dixLookupWindow().\n");
- return (i == Success) ? pWin : NULL;
-}
-
-_X_EXPORT _X_DEPRECATED WindowPtr
-LookupWindow(XID id, ClientPtr client)
-{
- return SecurityLookupWindow(id, client, DixUnknownAccess);
-}
-
-_X_EXPORT _X_DEPRECATED pointer
-SecurityLookupDrawable(XID id, ClientPtr client, Mask access_mode)
-{
- DrawablePtr pDraw;
- int i = dixLookupDrawable(&pDraw, id, client, M_DRAWABLE, access_mode);
- static int warn = 1;
- if (warn-- > 0)
- ErrorF("Warning: LookupDrawable()/SecurityLookupDrawable() "
- "are deprecated. Please convert your driver/module "
- "to use dixLookupDrawable().\n");
- return (i == Success) ? pDraw : NULL;
-}
-
-_X_EXPORT _X_DEPRECATED pointer
-LookupDrawable(XID id, ClientPtr client)
-{
- return SecurityLookupDrawable(id, client, DixUnknownAccess);
-}
-
-_X_EXPORT _X_DEPRECATED ClientPtr
-LookupClient(XID id, ClientPtr client)
-{
- ClientPtr pClient;
- int i = dixLookupClient(&pClient, id, client, DixUnknownAccess);
- static int warn = 1;
- if (warn-- > 0)
- ErrorF("Warning: LookupClient() is deprecated. Please convert your "
- "driver/module to use dixLookupClient().\n");
- return (i == Success) ? pClient : NULL;
-}
-
-/* end deprecated functions */
-
int
AlterSaveSetForClient(ClientPtr client, WindowPtr pWin, unsigned mode,
Bool toRoot, Bool remap)
diff --git a/dix/resource.c b/dix/resource.c
index 81269c3..7530e86 100644
--- a/dix/resource.c
+++ b/dix/resource.c
@@ -899,81 +899,31 @@ LegalNewID(XID id, ClientPtr client)
!LookupIDByClass(id, RC_ANY)));
}
-/* SecurityLookupIDByType and SecurityLookupIDByClass:
- * These are the heart of the resource ID security system. They take
- * two additional arguments compared to the old LookupID functions:
- * the client doing the lookup, and the access mode (see resource.h).
- * The resource is returned if it exists and the client is allowed access,
- * else NULL is returned.
- */
-
-_X_EXPORT pointer
-SecurityLookupIDByType(ClientPtr client, XID id, RESTYPE rtype, Mask mode)
-{
- int cid;
- ResourcePtr res;
- pointer retval = NULL;
-
- if (((cid = CLIENT_ID(id)) < MAXCLIENTS) &&
- clientTable[cid].buckets)
- {
- res = clientTable[cid].resources[Hash(cid, id)];
-
- for (; res; res = res->next)
- if ((res->id == id) && (res->type == rtype))
- {
- retval = res->value;
- break;
- }
- }
- if (retval && client &&
- !XaceHook(XACE_RESOURCE_ACCESS, client, id, rtype, mode, retval))
- retval = NULL;
-
- return retval;
-}
-
-
-_X_EXPORT pointer
-SecurityLookupIDByClass(ClientPtr client, XID id, RESTYPE classes, Mask mode)
+_X_EXPORT int
+dixLookupResource(pointer *result, XID id, RESTYPE rtype,
+ ClientPtr client, Mask mode)
{
- int cid;
+ int cid = CLIENT_ID(id);
+ int istype = (rtype & TypeMask) && (rtype != RC_ANY);
ResourcePtr res = NULL;
- pointer retval = NULL;
- if (((cid = CLIENT_ID(id)) < MAXCLIENTS) &&
- clientTable[cid].buckets)
- {
+ *result = NULL;
+ client->errorValue = id;
+
+ if ((cid < MAXCLIENTS) && clientTable[cid].buckets) {
res = clientTable[cid].resources[Hash(cid, id)];
for (; res; res = res->next)
- if ((res->id == id) && (res->type & classes))
- {
- retval = res->value;
+ if ((res->id == id) && ((istype && res->type == rtype) ||
+ (!istype && res->type & rtype)))
break;
- }
}
- if (retval && client &&
- !XaceHook(XACE_RESOURCE_ACCESS, client, id, res->type, mode, retval))
- retval = NULL;
-
- return retval;
-}
-
-/* We can't replace the LookupIDByType and LookupIDByClass functions with
- * macros because of compatibility with loadable servers.
- */
-
-_X_EXPORT pointer
-LookupIDByType(XID id, RESTYPE rtype)
-{
- return SecurityLookupIDByType(NullClient, id, rtype,
- DixUnknownAccess);
-}
-
-_X_EXPORT pointer
-LookupIDByClass(XID id, RESTYPE classes)
-{
- return SecurityLookupIDByClass(NullClient, id, classes,
- DixUnknownAccess);
+ if (res) {
+ if (client && !XaceHook(XACE_RESOURCE_ACCESS, client, id, res->type,
+ mode, res->value))
+ return BadAccess;
+ *result = res->value;
+ return Success;
+ }
+ return BadValue;
}
diff --git a/hw/xfree86/loader/dixsym.c b/hw/xfree86/loader/dixsym.c
index 2991c18..043f2db 100644
--- a/hw/xfree86/loader/dixsym.c
+++ b/hw/xfree86/loader/dixsym.c
@@ -114,6 +114,16 @@ _X_HIDDEN void *dixLookupTab[] = {
SYMFUNC(QueryColors)
/* cursor.c */
SYMFUNC(FreeCursor)
+ /* deprecated.c */
+ SYMFUNC(LookupClient)
+ SYMFUNC(LookupDrawable)
+ SYMFUNC(LookupWindow)
+ SYMFUNC(SecurityLookupDrawable)
+ SYMFUNC(SecurityLookupWindow)
+ SYMFUNC(LookupIDByType)
+ SYMFUNC(LookupIDByClass)
+ SYMFUNC(SecurityLookupIDByClass)
+ SYMFUNC(SecurityLookupIDByType)
/* devices.c */
SYMFUNC(Ones)
SYMFUNC(InitButtonClassDeviceStruct)
@@ -160,13 +170,6 @@ _X_HIDDEN void *dixLookupTab[] = {
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)
@@ -287,16 +290,13 @@ _X_HIDDEN void *dixLookupTab[] = {
SYMFUNC(ChangeResourceValue)
SYMFUNC(CreateNewResourceClass)
SYMFUNC(CreateNewResourceType)
+ SYMFUNC(dixLookupResource)
SYMFUNC(FakeClientID)
SYMFUNC(FreeResource)
SYMFUNC(FreeResourceByType)
SYMFUNC(GetXIDList)
SYMFUNC(GetXIDRange)
- SYMFUNC(LookupIDByType)
- SYMFUNC(LookupIDByClass)
SYMFUNC(LegalNewID)
- SYMFUNC(SecurityLookupIDByClass)
- SYMFUNC(SecurityLookupIDByType)
SYMFUNC(FindClientResourcesByType)
SYMFUNC(FindAllClientResources)
SYMVAR(lastResourceType)
diff --git a/include/dix.h b/include/dix.h
index 798d617..41240b1 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -233,17 +233,6 @@ extern int dixLookupClient(
ClientPtr client,
Mask access_mode);
-/*
- * 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);
extern int AlterSaveSetForClient(
@@ -641,4 +630,36 @@ extern int xstrcasecmp(char *s1, char *s
/* ffs.c */
extern int ffs(int i);
+/*
+ * These are deprecated compatibility functions and will be removed soon!
+ * Please use the noted replacements instead.
+ */
+
+/* replaced by dixLookupWindow */
+extern WindowPtr SecurityLookupWindow(
+ XID id,
+ ClientPtr client,
+ Mask access_mode);
+
+/* replaced by dixLookupWindow */
+extern WindowPtr LookupWindow(
+ XID id,
+ ClientPtr client);
+
+/* replaced by dixLookupDrawable */
+extern pointer SecurityLookupDrawable(
+ XID id,
+ ClientPtr client,
+ Mask access_mode);
+
+/* replaced by dixLookupDrawable */
+extern pointer LookupDrawable(
+ XID id,
+ ClientPtr client);
+
+/* replaced by dixLookupClient */
+extern ClientPtr LookupClient(
+ XID id,
+ ClientPtr client);
+
#endif /* DIX_H */
diff --git a/include/resource.h b/include/resource.h
index f7fa5f1..d2ecfde 100644
--- a/include/resource.h
+++ b/include/resource.h
@@ -212,32 +212,18 @@ extern Bool LegalNewID(
XID /*id*/,
ClientPtr /*client*/);
-extern pointer LookupIDByType(
- XID /*id*/,
- RESTYPE /*rtype*/);
-
-extern pointer LookupIDByClass(
- XID /*id*/,
- RESTYPE /*classes*/);
-
extern pointer LookupClientResourceComplex(
ClientPtr client,
RESTYPE type,
FindComplexResType func,
pointer cdata);
-extern pointer SecurityLookupIDByType(
- ClientPtr /*client*/,
- XID /*id*/,
- RESTYPE /*rtype*/,
- Mask /*access_mode*/);
-
-extern pointer SecurityLookupIDByClass(
- ClientPtr /*client*/,
- XID /*id*/,
- RESTYPE /*classes*/,
- Mask /*access_mode*/);
-
+extern int dixLookupResource(
+ pointer *result,
+ XID id,
+ RESTYPE rtype,
+ ClientPtr client,
+ Mask access_mode);
extern void GetXIDRange(
int /*client*/,
@@ -258,5 +244,34 @@ extern Atom *ResourceNames;
void RegisterResourceName(RESTYPE type, char* name);
#endif
+/*
+ * These are deprecated compatibility functions and will be removed soon!
+ * Please use the noted replacements instead.
+ */
+
+/* replaced by dixLookupResource */
+extern pointer SecurityLookupIDByType(
+ ClientPtr client,
+ XID id,
+ RESTYPE rtype,
+ Mask access_mode);
+
+/* replaced by dixLookupResource */
+extern pointer SecurityLookupIDByClass(
+ ClientPtr client,
+ XID id,
+ RESTYPE classes,
+ Mask access_mode);
+
+/* replaced by dixLookupResource */
+extern pointer LookupIDByType(
+ XID id,
+ RESTYPE rtype);
+
+/* replaced by dixLookupResource */
+extern pointer LookupIDByClass(
+ XID id,
+ RESTYPE classes);
+
#endif /* RESOURCE_H */
diff-tree 63e46e4fc3e98751f2edbed9c79ef3d5dc2dadc6 (from 1cb84768f376b477a08a558854609b0743f2bd29)
Author: Eamon Walsh <ewalsh at tycho.nsa.gov>
Date: Wed Apr 4 15:59:51 2007 -0400
devPrivates rework: properly free devPrivates on compatibility structures,
excluding pixmap.
diff --git a/dix/colormap.c b/dix/colormap.c
index 73b6669..5155570 100644
--- a/dix/colormap.c
+++ b/dix/colormap.c
@@ -63,6 +63,7 @@ SOFTWARE.
#include "scrnintstr.h"
#include "resource.h"
#include "windowstr.h"
+#include "privates.h"
extern XID clientErrorValue;
extern int colormapPrivateCount;
@@ -474,6 +475,7 @@ FreeColormap (pointer value, XID mid)
}
}
+ dixFreePrivates(*DEVPRIV_PTR(pmap));
if (pmap->devPrivates)
xfree(pmap->devPrivates);
diff --git a/dix/devices.c b/dix/devices.c
index e51d1b3..4a7ec4d 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -69,6 +69,7 @@ SOFTWARE.
#ifdef XKB
#include <xkbsrv.h>
#endif
+#include "privates.h"
#include "xace.h"
#include "dispatch.h"
@@ -502,6 +503,7 @@ CloseDevice(DeviceIntPtr dev)
XkbRemoveResourceClient((DevicePtr)dev,dev->xkb_interest->resource);
#endif
+ dixFreePrivates(*DEVPRIV_PTR(dev));
if (dev->devPrivates)
xfree(dev->devPrivates);
diff --git a/dix/dispatch.c b/dix/dispatch.c
index 68499f1..4fb680f 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -134,6 +134,7 @@ int ProcInitialConnection();
#include "panoramiX.h"
#include "panoramiXsrv.h"
#endif
+#include "privates.h"
#include "xace.h"
#ifdef XAPPGROUP
#include "appgroup.h"
@@ -3651,6 +3652,7 @@ CloseDownClient(ClientPtr client)
#ifdef SMART_SCHEDULE
SmartLastClient = NullClient;
#endif
+ dixFreePrivates(*DEVPRIV_PTR(client));
xfree(client);
while (!clients[currentMaxClients-1])
diff --git a/dix/extension.c b/dix/extension.c
index 88dff15..b338c81 100644
--- a/dix/extension.c
+++ b/dix/extension.c
@@ -59,6 +59,7 @@ SOFTWARE.
#include "gcstruct.h"
#include "scrnintstr.h"
#include "dispatch.h"
+#include "privates.h"
#include "xace.h"
#define EXTENSION_BASE 128
@@ -290,6 +291,7 @@ CloseDownExtensions()
for (j = extensions[i]->num_aliases; --j >= 0;)
xfree(extensions[i]->aliases[j]);
xfree(extensions[i]->aliases);
+ dixFreePrivates(*DEVPRIV_PTR(extensions[i]));
xfree(extensions[i]);
}
xfree(extensions);
diff --git a/dix/gc.c b/dix/gc.c
index 7a76dd9..e7c4849 100644
--- a/dix/gc.c
+++ b/dix/gc.c
@@ -61,6 +61,7 @@ SOFTWARE.
#include "scrnintstr.h"
#include "region.h"
+#include "privates.h"
#include "dix.h"
#include <assert.h>
@@ -903,6 +904,7 @@ FreeGC(pointer value, XID gid)
(*pGC->funcs->DestroyGC) (pGC);
if (pGC->dash != DefaultDash)
xfree(pGC->dash);
+ dixFreePrivates(*DEVPRIV_PTR(pGC));
xfree(pGC);
return(Success);
}
diff --git a/dix/main.c b/dix/main.c
index 852cbcb..b5db193 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -103,6 +103,7 @@ Equipment Corporation.
#include "site.h"
#include "dixfont.h"
#include "extnsionst.h"
+#include "privates.h"
#ifdef XPRINT
#include "DiPrint.h"
#endif
@@ -496,6 +497,7 @@ main(int argc, char *argv[], char *envp[
FreeAuditTimer();
+ dixFreePrivates(*DEVPRIV_PTR(serverClient));
xfree(serverClient->devPrivates);
serverClient->devPrivates = NULL;
@@ -801,6 +803,7 @@ FreeScreen(ScreenPtr pScreen)
xfree(pScreen->WindowPrivateSizes);
xfree(pScreen->GCPrivateSizes);
xfree(pScreen->PixmapPrivateSizes);
+ dixFreePrivates(*DEVPRIV_PTR(pScreen));
xfree(pScreen->devPrivates);
xfree(pScreen);
}
diff --git a/dix/window.c b/dix/window.c
index 9967053..b505947 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -126,6 +126,7 @@ Equipment Corporation.
#ifdef XAPPGROUP
#include "appgroup.h"
#endif
+#include "privates.h"
#include "xace.h"
/******
@@ -975,6 +976,7 @@ DeleteWindow(pointer value, XID wid)
if (pWin->prevSib)
pWin->prevSib->nextSib = pWin->nextSib;
}
+ dixFreePrivates(*DEVPRIV_PTR(pWin));
xfree(pWin);
return Success;
}
More information about the xorg-commit
mailing list