summaryrefslogtreecommitdiff
path: root/Xext/appgroup.c
diff options
context:
space:
mode:
Diffstat (limited to 'Xext/appgroup.c')
-rw-r--r--Xext/appgroup.c125
1 files changed, 40 insertions, 85 deletions
diff --git a/Xext/appgroup.c b/Xext/appgroup.c
index 86bd36ecd..bb7a73ce1 100644
--- a/Xext/appgroup.c
+++ b/Xext/appgroup.c
@@ -1,4 +1,3 @@
-/* $XFree86: xc/programs/Xserver/Xext/appgroup.c,v 1.10tsi Exp $ */
/*
Copyright 1996, 1998, 2001 The Open Group
@@ -24,7 +23,6 @@ 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.
*/
-/* $Xorg: appgroup.c,v 1.6 2001/02/09 02:04:32 xorgcvs Exp $ */
#define NEED_REPLIES
#define NEED_EVENTS
@@ -43,9 +41,8 @@ from The Open Group.
#include "servermd.h"
#define _XAG_SERVER_
#include <X11/extensions/Xagstr.h>
-#include <X11/extensions/Xagsrv.h>
-#define _SECURITY_SERVER
-#include <X11/extensions/security.h>
+#include "xacestr.h"
+#include "securitysrv.h"
#include <X11/Xfuncproto.h>
#define XSERV_t
@@ -77,10 +74,6 @@ static int ProcXagDispatch(ClientPtr client);
static int SProcXagDispatch(ClientPtr client);
static void XagResetProc(ExtensionEntry* extEntry);
-#if 0
-static unsigned char XagReqCode = 0;
-static int XagErrorBase;
-#endif
static int XagCallbackRefCount = 0;
static RESTYPE RT_APPGROUP;
@@ -129,62 +122,11 @@ void XagClientStateChange(
pointer nulldata,
pointer calldata)
{
- SecurityAuthorizationPtr pAuth;
NewClientInfoRec* pci = (NewClientInfoRec*) calldata;
ClientPtr pClient = pci->client;
- AppGroupPtr pAppGrp;
- XID authId = 0;
+ AppGroupPtr pAppGrp = pClient->appgroup;
int slot;
- if (!pClient->appgroup) {
- switch (pClient->clientState) {
-
- case ClientStateAuthenticating:
- case ClientStateRunning:
- case ClientStateCheckingSecurity:
- return;
-
- case ClientStateInitial:
- case ClientStateCheckedSecurity:
- /*
- * If the client is connecting via a firewall proxy (which
- * uses XC-QUERY-SECURITY-1, then the authId is available
- * during ClientStateCheckedSecurity, otherwise it's
- * available during ClientStateInitial.
- *
- * Don't get it from pClient because can't guarantee the order
- * of the callbacks and the security extension might not have
- * plugged it in yet.
- */
- authId = AuthorizationIDOfClient(pClient);
- break;
-
- case ClientStateGone:
- case ClientStateRetained:
- /*
- * Don't get if from AuthorizationIDOfClient because can't
- * guarantee the order of the callbacks and the security
- * extension may have torn down the client's private data
- */
- authId = pClient->authId;
- break;
- }
-
- if (authId == None)
- return;
-
- pAuth = (SecurityAuthorizationPtr)SecurityLookupIDByType(pClient,
- authId, SecurityAuthorizationResType, SecurityReadAccess);
-
- if (pAuth == NULL)
- return;
-
- for (pAppGrp = appGrpList; pAppGrp != NULL; pAppGrp = pAppGrp->next)
- if (pAppGrp->appgroupId == pAuth->group) break;
- } else {
- pAppGrp = pClient->appgroup;
- }
-
if (!pAppGrp)
return;
@@ -233,19 +175,6 @@ void XagClientStateChange(
void
XagExtensionInit(INITARGS)
{
-#if 0
- ExtensionEntry* extEntry;
-
- if ((extEntry = AddExtension (XAGNAME,
- 0,
- XagNumberErrors,
- ProcXagDispatch,
- SProcXagDispatch,
- XagResetProc,
- StandardMinorOpcode))) {
- XagReqCode = (unsigned char)extEntry->base;
- XagErrorBase = extEntry->errorBase;
-#else
if (AddExtension (XAGNAME,
0,
XagNumberErrors,
@@ -253,8 +182,8 @@ XagExtensionInit(INITARGS)
SProcXagDispatch,
XagResetProc,
StandardMinorOpcode)) {
-#endif
RT_APPGROUP = CreateNewResourceType (XagAppGroupFree);
+ XaceRegisterCallback(XACE_AUTH_AVAIL, XagCallClientStateChange, NULL);
}
}
@@ -426,13 +355,15 @@ int AttrValidate(
AppGroupPtr pAppGrp)
{
WindowPtr pWin;
- int idepth, ivids, found;
+ int idepth, ivids, found, rc;
ScreenPtr pScreen;
DepthPtr pDepth;
ColormapPtr pColormap;
- pWin = LookupWindow (pAppGrp->default_root, client);
- /* XXX check that pWin is not NULL */
+ rc = dixLookupWindow(&pWin, pAppGrp->default_root, client,
+ DixUnknownAccess);
+ if (rc != Success)
+ return rc;
pScreen = pWin->drawable.pScreen;
if (WindowTable[pScreen->myNum]->drawable.id != pAppGrp->default_root)
return BadWindow;
@@ -503,7 +434,7 @@ int ProcXagDestroy(
REQUEST_SIZE_MATCH (xXagDestroyReq);
pAppGrp = (AppGroupPtr)SecurityLookupIDByType (client,
- (XID)stuff->app_group, RT_APPGROUP, SecurityReadAccess);
+ (XID)stuff->app_group, RT_APPGROUP, DixReadAccess);
if (!pAppGrp) return XagBadAppGroup;
FreeResource ((XID)stuff->app_group, RT_NONE);
if (--XagCallbackRefCount == 0)
@@ -522,7 +453,7 @@ int ProcXagGetAttr(
REQUEST_SIZE_MATCH (xXagGetAttrReq);
pAppGrp = (AppGroupPtr)SecurityLookupIDByType (client,
- (XID)stuff->app_group, RT_APPGROUP, SecurityReadAccess);
+ (XID)stuff->app_group, RT_APPGROUP, DixReadAccess);
if (!pAppGrp) return XagBadAppGroup;
rep.type = X_Reply;
rep.length = 0;
@@ -554,10 +485,13 @@ int ProcXagQuery(
ClientPtr pClient;
AppGroupPtr pAppGrp;
REQUEST (xXagQueryReq);
- int n;
+ int n, rc;
REQUEST_SIZE_MATCH (xXagQueryReq);
- pClient = LookupClient (stuff->resource, client);
+ rc = dixLookupClient(&pClient, stuff->resource, client, DixUnknownAccess);
+ if (rc != Success)
+ return rc;
+
for (pAppGrp = appGrpList; pAppGrp != NULL; pAppGrp = pAppGrp->next)
for (n = 0; n < pAppGrp->nclients; n++)
if (pAppGrp->clients[n] == pClient) {
@@ -821,12 +755,33 @@ void XagGetDeltaInfo(
}
void XagCallClientStateChange(
- ClientPtr client)
+ CallbackListPtr *pcbl,
+ pointer nulldata,
+ pointer calldata)
{
- if (appGrpList) {
+ XaceAuthAvailRec* rec = (XaceAuthAvailRec*) calldata;
+ ClientPtr pClient = rec->client;
+
+ if (!pClient->appgroup) {
+ SecurityAuthorizationPtr pAuth;
+ XID authId = rec->authId;
+
+ /* can't use SecurityLookupIDByType here -- client
+ * security state hasn't been setup yet.
+ */
+ pAuth = (SecurityAuthorizationPtr)LookupIDByType(authId,
+ SecurityAuthorizationResType);
+ if (!pAuth)
+ return;
+
+ pClient->appgroup = (AppGroupPtr)LookupIDByType(pAuth->group,
+ RT_APPGROUP);
+ }
+
+ if (pClient->appgroup) {
NewClientInfoRec clientinfo;
- clientinfo.client = client;
+ clientinfo.client = pClient;
XagClientStateChange (NULL, NULL, (pointer)&clientinfo);
}
}