[PATCH 41/42] Remove LocalClient checks from local-only extensions

Daniel Stone daniel at fooishbar.org
Fri Dec 2 03:27:49 PST 2011


We already hide the extension from clients and deny their requests, so I
doubt we'll be needing the LocalClient() check anymore.

Signed-off-by: Daniel Stone <daniel at fooishbar.org>
---
 hw/kdrive/ephyr/ephyrdriext.c |   62 +-----------------
 hw/xfree86/common/xf86DGA.c   |    5 +-
 hw/xfree86/dri/xf86dri.c      |   59 +----------------
 hw/xfree86/dri2/dri2ext.c     |   54 +--------------
 hw/xquartz/applewm.c          |   35 +---------
 hw/xquartz/xpr/appledri.c     |  151 +----------------------------------------
 hw/xwin/winwindowswm.c        |   22 +------
 7 files changed, 8 insertions(+), 380 deletions(-)

diff --git a/hw/kdrive/ephyr/ephyrdriext.c b/hw/kdrive/ephyr/ephyrdriext.c
index 0bd11d2..d2f5381 100644
--- a/hw/kdrive/ephyr/ephyrdriext.c
+++ b/hw/kdrive/ephyr/ephyrdriext.c
@@ -551,13 +551,6 @@ ProcXF86DRIQueryVersion (register ClientPtr client)
     rep.majorVersion = SERVER_XF86DRI_MAJOR_VERSION;
     rep.minorVersion = SERVER_XF86DRI_MINOR_VERSION;
     rep.patchVersion = SERVER_XF86DRI_PATCH_VERSION;
-    if (client->swapped) {
-    swaps(&rep.sequenceNumber);
-    swapl(&rep.length);
-	swaps(&rep.majorVersion);
-	swaps(&rep.minorVersion);
-	swapl(&rep.patchVersion);
-    }
     WriteToClient(client, sizeof(xXF86DRIQueryVersionReply), (char *)&rep);
     EPHYR_LOG ("leave\n") ;
     return Success;
@@ -586,14 +579,6 @@ ProcXF86DRIQueryDirectRenderingCapable (register ClientPtr client)
     }
     rep.isCapable = isCapable;
 
-    if (!LocalClient(client) || client->swapped)
-	rep.isCapable = 0;
-
-    if (client->swapped) {
-	swaps(&rep.sequenceNumber);
-	swapl(&rep.length);
-    }
-
     WriteToClient(client, sizeof(xXF86DRIQueryDirectRenderingCapableReply), (char *)&rep);
     EPHYR_LOG ("leave\n") ;
 
@@ -1251,13 +1236,6 @@ ProcXF86DRIDispatch (register ClientPtr	client)
                 EPHYR_LOG ("leave\n") ;
                 return ProcXF86DRIQueryDirectRenderingCapable(client);
         }
-    }
-
-    if (!LocalClient(client))
-        return DRIErrorBase + XF86DRIClientNotLocal;
-
-    switch (stuff->data)
-    {
         case X_XF86DRIOpenConnection: {
             EPHYR_LOG ("leave\n") ;
             return ProcXF86DRIOpenConnection(client);
@@ -1307,47 +1285,9 @@ ProcXF86DRIDispatch (register ClientPtr	client)
 }
 
 static int
-SProcXF86DRIQueryVersion (register ClientPtr	client)
-{
-    REQUEST(xXF86DRIQueryVersionReq);
-    swaps(&stuff->length);
-    return ProcXF86DRIQueryVersion(client);
-}
-
-static int
-SProcXF86DRIQueryDirectRenderingCapable (register ClientPtr client)
-{
-    REQUEST(xXF86DRIQueryDirectRenderingCapableReq);
-    swaps(&stuff->length);
-    swapl(&stuff->screen);
-    return ProcXF86DRIQueryDirectRenderingCapable(client);
-}
-
-static int
 SProcXF86DRIDispatch (register ClientPtr client)
 {
-    REQUEST(xReq);
-
-    EPHYR_LOG ("enter\n") ;
-    /*
-     * Only local clients are allowed DRI access, but remote clients still need
-     * these requests to find out cleanly.
-     */
-    switch (stuff->data)
-    {
-        case X_XF86DRIQueryVersion: {
-            EPHYR_LOG ("leave\n") ;
-            return SProcXF86DRIQueryVersion(client);
-        }
-        case X_XF86DRIQueryDirectRenderingCapable: {
-            EPHYR_LOG ("leave\n") ;
-            return SProcXF86DRIQueryDirectRenderingCapable(client);
-        }
-        default: {
-            EPHYR_LOG ("leave\n") ;
-            return DRIErrorBase + XF86DRIClientNotLocal;
-        }
-    }
+    return BadRequest;
 }
 
 Bool
diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c
index b983a9b..8bb7755 100644
--- a/hw/xfree86/common/xf86DGA.c
+++ b/hw/xfree86/common/xf86DGA.c
@@ -2093,7 +2093,7 @@ ProcXF86DGAViewPortChanged(ClientPtr client)
 static int
 SProcXDGADispatch (ClientPtr client)
 {
-   return DGAErrorBase + XF86DGAClientNotLocal;
+   return BadRequest;
 }
 
 #if 0
@@ -2137,9 +2137,6 @@ ProcXDGADispatch (ClientPtr client)
 {
     REQUEST(xReq);
 
-    if (!LocalClient(client))
-	return DGAErrorBase + XF86DGAClientNotLocal;
-
 #ifdef DGA_REQ_DEBUG
     if (stuff->data <= X_XDGACreateColormap)
 	fprintf (stderr, "    DGA %s\n", dgaMinor[stuff->data]);
diff --git a/hw/xfree86/dri/xf86dri.c b/hw/xfree86/dri/xf86dri.c
index e9a592a..e2b312a 100644
--- a/hw/xfree86/dri/xf86dri.c
+++ b/hw/xfree86/dri/xf86dri.c
@@ -94,13 +94,6 @@ ProcXF86DRIQueryVersion(
     rep.majorVersion = SERVER_XF86DRI_MAJOR_VERSION;
     rep.minorVersion = SERVER_XF86DRI_MINOR_VERSION;
     rep.patchVersion = SERVER_XF86DRI_PATCH_VERSION;
-    if (client->swapped) {
-	swaps(&rep.sequenceNumber);
-	swapl(&rep.length);
-	swaps(&rep.majorVersion);
-	swaps(&rep.minorVersion);
-	swapl(&rep.patchVersion);
-    }
     WriteToClient(client, sizeof(xXF86DRIQueryVersionReply), (char *)&rep);
     return Success;
 }
@@ -130,14 +123,6 @@ ProcXF86DRIQueryDirectRenderingCapable(
     }
     rep.isCapable = isCapable;
 
-    if (!LocalClient(client) || client->swapped)
-	rep.isCapable = 0;
-
-    if (client->swapped) {
-	swaps(&rep.sequenceNumber);
-	swapl(&rep.length);
-    }
-
     WriteToClient(client, 
 	sizeof(xXF86DRIQueryDirectRenderingCapableReply), (char *)&rep);
     return Success;
@@ -555,13 +540,6 @@ ProcXF86DRIDispatch (
 	return ProcXF86DRIQueryVersion(client);
     case X_XF86DRIQueryDirectRenderingCapable:
 	return ProcXF86DRIQueryDirectRenderingCapable(client);
-    }
-
-    if (!LocalClient(client))
-	return DRIErrorBase + XF86DRIClientNotLocal;
-
-    switch (stuff->data)
-    {
     case X_XF86DRIOpenConnection:
 	return ProcXF86DRIOpenConnection(client);
     case X_XF86DRICloseConnection:
@@ -589,46 +567,11 @@ ProcXF86DRIDispatch (
 }
 
 static int
-SProcXF86DRIQueryVersion(
-    register ClientPtr	client
-)
-{
-    REQUEST(xXF86DRIQueryVersionReq);
-    swaps(&stuff->length);
-    return ProcXF86DRIQueryVersion(client);
-}
-
-static int
-SProcXF86DRIQueryDirectRenderingCapable(
-    register ClientPtr client
-)
-{
-    REQUEST(xXF86DRIQueryDirectRenderingCapableReq);
-    swaps(&stuff->length);
-    swapl(&stuff->screen);
-    return ProcXF86DRIQueryDirectRenderingCapable(client);
-}
-
-static int
 SProcXF86DRIDispatch (
     register ClientPtr	client
 )
 {
-    REQUEST(xReq);
-
-    /*
-     * Only local clients are allowed DRI access, but remote clients still need
-     * these requests to find out cleanly.
-     */
-    switch (stuff->data)
-    {
-    case X_XF86DRIQueryVersion:
-	return SProcXF86DRIQueryVersion(client);
-    case X_XF86DRIQueryDirectRenderingCapable:
-	return SProcXF86DRIQueryDirectRenderingCapable(client);
-    default:
-	return DRIErrorBase + XF86DRIClientNotLocal;
-    }
+    return BadRequest;
 }
 
 void
diff --git a/hw/xfree86/dri2/dri2ext.c b/hw/xfree86/dri2/dri2ext.c
index 64cd8bc..e54e08f 100644
--- a/hw/xfree86/dri2/dri2ext.c
+++ b/hw/xfree86/dri2/dri2ext.c
@@ -71,9 +71,6 @@ ProcDRI2QueryVersion(ClientPtr client)
     REQUEST(xDRI2QueryVersionReq);
     xDRI2QueryVersionReply rep;
 
-    if (client->swapped)
-	swaps(&stuff->length);
-
     REQUEST_SIZE_MATCH(xDRI2QueryVersionReq);
     rep.type = X_Reply;
     rep.length = 0;
@@ -81,13 +78,6 @@ ProcDRI2QueryVersion(ClientPtr client)
     rep.majorVersion = dri2_major;
     rep.minorVersion = dri2_minor;
 
-    if (client->swapped) {
-	swaps(&rep.sequenceNumber);
-	swapl(&rep.length);
-	swapl(&rep.majorVersion);
-	swapl(&rep.minorVersion);
-    }
-
     WriteToClient(client, sizeof(xDRI2QueryVersionReply), &rep);
 
     return Success;
@@ -543,12 +533,6 @@ ProcDRI2Dispatch (ClientPtr client)
     switch (stuff->data) {
     case X_DRI2QueryVersion:
 	return ProcDRI2QueryVersion(client);
-    }
-
-    if (!LocalClient(client))
-	return BadRequest;
-
-    switch (stuff->data) {
     case X_DRI2Connect:
 	return ProcDRI2Connect(client);
     case X_DRI2Authenticate:
@@ -579,44 +563,10 @@ ProcDRI2Dispatch (ClientPtr client)
 }
 
 static int
-SProcDRI2Connect(ClientPtr client)
-{
-    REQUEST(xDRI2ConnectReq);
-    xDRI2ConnectReply rep;
-
-    /* If the client is swapped, it's not local.  Talk to the hand. */
-
-    swaps(&stuff->length);
-    if (sizeof(*stuff) / 4 != client->req_len)
-	return BadLength;
-
-    rep.sequenceNumber = client->sequence;
-    swaps(&rep.sequenceNumber);
-    rep.length = 0;
-    rep.driverNameLength = 0;
-    rep.deviceNameLength = 0;
-
-    return Success;
-}
-
-static int
 SProcDRI2Dispatch (ClientPtr client)
 {
-    REQUEST(xReq);
-
-    /*
-     * Only local clients are allowed DRI access, but remote clients
-     * still need these requests to find out cleanly.
-     */
-    switch (stuff->data)
-    {
-    case X_DRI2QueryVersion:
-	return ProcDRI2QueryVersion(client);
-    case X_DRI2Connect:
-	return SProcDRI2Connect(client);
-    default:
-	return BadRequest;
-    }
+    /* If the client is swapped, it's not local.  Talk to the hand. */
+    return BadRequest;
 }
 
 int DRI2EventBase;
diff --git a/hw/xquartz/applewm.c b/hw/xquartz/applewm.c
index 04dedf1..be5d1c1 100644
--- a/hw/xquartz/applewm.c
+++ b/hw/xquartz/applewm.c
@@ -155,10 +155,6 @@ ProcAppleWMQueryVersion(
     rep.majorVersion = SERVER_APPLEWM_MAJOR_VERSION;
     rep.minorVersion = SERVER_APPLEWM_MINOR_VERSION;
     rep.patchVersion = SERVER_APPLEWM_PATCH_VERSION;
-    if (client->swapped) {
-        swaps(&rep.sequenceNumber);
-        swapl(&rep.length);
-    }
     WriteToClient(client, sizeof(xAppleWMQueryVersionReply), (char *)&rep);
     return Success;
 }
@@ -628,13 +624,6 @@ ProcAppleWMDispatch (
     {
     case X_AppleWMQueryVersion:
         return ProcAppleWMQueryVersion(client);
-    }
-
-    if (!LocalClient(client))
-        return WMErrorBase + AppleWMClientNotLocal;
-
-    switch (stuff->data)
-    {
     case X_AppleWMSelectInput:
         return ProcAppleWMSelectInput(client);
     case X_AppleWMDisableUpdate:
@@ -676,34 +665,12 @@ SNotifyEvent(xAppleWMNotifyEvent *from, xAppleWMNotifyEvent *to) {
 }
 
 static int
-SProcAppleWMQueryVersion(
-    register ClientPtr  client
-)
-{
-    REQUEST(xAppleWMQueryVersionReq);
-    swaps(&stuff->length);
-    return ProcAppleWMQueryVersion(client);
-}
-
-static int
 SProcAppleWMDispatch (
     register ClientPtr  client
 )
 {
-    REQUEST(xReq);
-
-    /* It is bound to be non-local when there is byte swapping */
-    if (!LocalClient(client))
-        return WMErrorBase + AppleWMClientNotLocal;
-
     /* only local clients are allowed WM access */
-    switch (stuff->data)
-    {
-    case X_AppleWMQueryVersion:
-        return SProcAppleWMQueryVersion(client);
-    default:
-        return BadRequest;
-    }
+    return BadRequest;
 }
 
 void
diff --git a/hw/xquartz/xpr/appledri.c b/hw/xquartz/xpr/appledri.c
index a8d0e08..2fe338a 100644
--- a/hw/xquartz/xpr/appledri.c
+++ b/hw/xquartz/xpr/appledri.c
@@ -66,8 +66,6 @@ static int ProcAppleDRICreatePixmap(ClientPtr client);
 static unsigned char DRIReqCode = 0;
 static int DRIEventBase = 0;
 
-static void SNotifyEvent(xAppleDRINotifyEvent *from, xAppleDRINotifyEvent *to);
-
 typedef struct _DRIEvent *DRIEventPtr;
 typedef struct _DRIEvent {
     DRIEventPtr     next;
@@ -99,13 +97,6 @@ ProcAppleDRIQueryVersion(
     rep.majorVersion = SERVER_APPLEDRI_MAJOR_VERSION;
     rep.minorVersion = SERVER_APPLEDRI_MINOR_VERSION;
     rep.patchVersion = SERVER_APPLEDRI_PATCH_VERSION;
-    if (client->swapped) {
-        swaps(&rep.sequenceNumber);
-        swapl(&rep.length);
-        swaps(&rep.majorVersion);
-        swaps(&rep.minorVersion);
-        swapl(&rep.patchVersion);
-    }
     WriteToClient(client, sizeof(xAppleDRIQueryVersionReply), (char *)&rep);
     return Success;
 }
@@ -133,14 +124,6 @@ ProcAppleDRIQueryDirectRenderingCapable(
     }
     rep.isCapable = isCapable;
 
-    if (!LocalClient(client))
-        rep.isCapable = 0;
-
-    if (client->swapped) {
-        swaps(&rep.sequenceNumber);
-        swapl(&rep.length);
-    }
-
     WriteToClient(client, 
         sizeof(xAppleDRIQueryDirectRenderingCapableReply), (char *)&rep);
     return Success;
@@ -363,13 +346,6 @@ ProcAppleDRIDispatch (
         return ProcAppleDRIQueryVersion(client);
     case X_AppleDRIQueryDirectRenderingCapable:
         return ProcAppleDRIQueryDirectRenderingCapable(client);
-    }
-
-    if (!LocalClient(client))
-        return DRIErrorBase + AppleDRIClientNotLocal;
-
-    switch (stuff->data)
-    {
     case X_AppleDRIAuthConnection:
         return ProcAppleDRIAuthConnection(client);
     case X_AppleDRICreateSurface:
@@ -386,134 +362,12 @@ ProcAppleDRIDispatch (
     }
 }
 
-static void
-SNotifyEvent(
-    xAppleDRINotifyEvent *from,
-    xAppleDRINotifyEvent *to
-)
-{
-    to->type = from->type;
-    to->kind = from->kind;
-    cpswaps (from->sequenceNumber, to->sequenceNumber);
-    cpswapl (from->time, to->time);
-    cpswapl (from->arg, to->arg);
-}
-
-static int
-SProcAppleDRIQueryVersion(
-    register ClientPtr client
-)
-{
-    REQUEST(xAppleDRIQueryVersionReq);
-    swaps(&stuff->length);
-    return ProcAppleDRIQueryVersion(client);
-}
-
-static int
-SProcAppleDRIQueryDirectRenderingCapable(
-    register ClientPtr client
-)
-{
-    REQUEST(xAppleDRIQueryDirectRenderingCapableReq);
-    swaps(&stuff->length);
-    swapl(&stuff->screen);
-    return ProcAppleDRIQueryDirectRenderingCapable(client);
-}
-
-static int
-SProcAppleDRIAuthConnection(
-    register ClientPtr client
-)
-{
-    REQUEST(xAppleDRIAuthConnectionReq);
-    swaps(&stuff->length);
-    swapl(&stuff->screen);
-    swapl(&stuff->magic);
-    return ProcAppleDRIAuthConnection(client);
-}
-
-static int
-SProcAppleDRICreateSurface(
-    register ClientPtr client
-)
-{
-    REQUEST(xAppleDRICreateSurfaceReq);
-    swaps(&stuff->length);
-    swapl(&stuff->screen);
-    swapl(&stuff->drawable);
-    swapl(&stuff->client_id);
-    return ProcAppleDRICreateSurface(client);
-}
-
-static int
-SProcAppleDRIDestroySurface(
-    register ClientPtr client
-)
-{
-    REQUEST(xAppleDRIDestroySurfaceReq);
-    swaps(&stuff->length);
-    swapl(&stuff->screen);
-    swapl(&stuff->drawable);
-    return ProcAppleDRIDestroySurface(client);
-}
-
-static int
-SProcAppleDRICreatePixmap(
-    register ClientPtr client
-)
-{
-    REQUEST(xAppleDRICreatePixmapReq);
-    swaps(&stuff->length);
-    swapl(&stuff->screen);
-    swapl(&stuff->drawable);
-    return ProcAppleDRICreatePixmap(client);
-}
-
-static int
-SProcAppleDRIDestroyPixmap(
-    register ClientPtr client
-)
-{
-    REQUEST(xAppleDRIDestroyPixmapReq);
-    swaps(&stuff->length);
-    swapl(&stuff->drawable);
-    return ProcAppleDRIDestroyPixmap(client);
-}
-
 static int
 SProcAppleDRIDispatch (
     register ClientPtr client
 )
 {
-    REQUEST(xReq);
-
-    switch (stuff->data)
-    {
-    case X_AppleDRIQueryVersion:
-        return SProcAppleDRIQueryVersion(client);
-    case X_AppleDRIQueryDirectRenderingCapable:
-        return SProcAppleDRIQueryDirectRenderingCapable(client);
-    }
-
-    if (!LocalClient(client))
-        return DRIErrorBase + AppleDRIClientNotLocal;
-
-    switch (stuff->data)
-    {
-    case X_AppleDRIAuthConnection:
-        return SProcAppleDRIAuthConnection(client);
-    case X_AppleDRICreateSurface:
-        return SProcAppleDRICreateSurface(client);
-    case X_AppleDRIDestroySurface:
-        return SProcAppleDRIDestroySurface(client);
-    case X_AppleDRICreatePixmap:
-	return SProcAppleDRICreatePixmap(client);
-    case X_AppleDRIDestroyPixmap:
-	return SProcAppleDRIDestroyPixmap(client);
-
-    default:
-        return BadRequest;
-    }
+    return BadRequest;
 }
 
 void
@@ -530,11 +384,8 @@ AppleDRIExtensionInit(void)
                                  AppleDRIResetProc,
                                  StandardMinorOpcode,
                                  TRUE))) {
-        size_t i;
         DRIReqCode = (unsigned char)extEntry->base;
         DRIErrorBase = extEntry->errorBase;
         DRIEventBase = extEntry->eventBase;
-        for (i=0; i < AppleDRINumberEvents; i++)
-            EventSwapVector[DRIEventBase + i] = (EventSwapPtr) SNotifyEvent;
     }
 }
diff --git a/hw/xwin/winwindowswm.c b/hw/xwin/winwindowswm.c
index 000ebff..a5d6845 100644
--- a/hw/xwin/winwindowswm.c
+++ b/hw/xwin/winwindowswm.c
@@ -546,13 +546,6 @@ ProcWindowsWMDispatch (ClientPtr client)
     {
     case X_WindowsWMQueryVersion:
       return ProcWindowsWMQueryVersion(client);
-    }
-
-  if (!LocalClient(client))
-    return WMErrorBase + WindowsWMClientNotLocal;
-
-  switch (stuff->data)
-    {
     case X_WindowsWMSelectInput:
       return ProcWindowsWMSelectInput(client);
     case X_WindowsWMDisableUpdate:
@@ -595,20 +588,7 @@ SProcWindowsWMQueryVersion (ClientPtr client)
 static int
 SProcWindowsWMDispatch (ClientPtr client)
 {
-  REQUEST(xReq);
-
-  /* It is bound to be non-local when there is byte swapping */
-  if (!LocalClient(client))
-    return WMErrorBase + WindowsWMClientNotLocal;
-
-  /* only local clients are allowed WM access */
-  switch (stuff->data)
-    {
-    case X_WindowsWMQueryVersion:
-      return SProcWindowsWMQueryVersion(client);
-    default:
-      return BadRequest;
-    }
+  return BadRequest;
 }
 
 void
-- 
1.7.7.3



More information about the xorg-devel mailing list