xace: Still more changes to selection code. Removed the SelectionPtr from

the hook - the hook only needs the Atom to control access to the selection
object.  Upgraded the SelectionCallback to take a client argument and
additional type codes so that it can be used for redirection.
This commit is contained in:
Eamon Walsh 2007-10-23 17:12:57 -04:00 committed by Eamon Walsh
parent 660557593e
commit 825f09dffd
4 changed files with 37 additions and 26 deletions

View File

@ -177,7 +177,6 @@ int XaceHook(int hook, ...)
XaceSelectionAccessRec rec = { XaceSelectionAccessRec rec = {
va_arg(ap, ClientPtr), va_arg(ap, ClientPtr),
va_arg(ap, Atom), va_arg(ap, Atom),
va_arg(ap, Selection*),
va_arg(ap, Mask), va_arg(ap, Mask),
Success /* default allow */ Success /* default allow */
}; };

View File

@ -112,7 +112,6 @@ typedef struct {
typedef struct { typedef struct {
ClientPtr client; ClientPtr client;
Atom name; Atom name;
Selection *selection;
Mask access_mode; Mask access_mode;
int status; int status;
} XaceSelectionAccessRec; } XaceSelectionAccessRec;

View File

@ -1005,6 +1005,11 @@ ProcSetSelectionOwner(ClientPtr client)
{ {
int i = 0; int i = 0;
rc = XaceHook(XACE_SELECTION_ACCESS, client, stuff->selection,
DixSetAttrAccess);
if (rc != Success)
return rc;
/* /*
* First, see if the selection is already set... * First, see if the selection is already set...
*/ */
@ -1022,12 +1027,6 @@ ProcSetSelectionOwner(ClientPtr client)
if (CompareTimeStamps(time, CurrentSelections[i].lastTimeChanged) if (CompareTimeStamps(time, CurrentSelections[i].lastTimeChanged)
== EARLIER) == EARLIER)
return Success; return Success;
rc = XaceHook(XACE_SELECTION_ACCESS, client, stuff->selection,
CurrentSelections + i, DixSetAttrAccess);
if (rc != Success)
return rc;
if (CurrentSelections[i].client && if (CurrentSelections[i].client &&
(!pWin || (CurrentSelections[i].client != client))) (!pWin || (CurrentSelections[i].client != client)))
{ {
@ -1058,10 +1057,6 @@ ProcSetSelectionOwner(ClientPtr client)
CurrentSelections = newsels; CurrentSelections = newsels;
CurrentSelections[i].selection = stuff->selection; CurrentSelections[i].selection = stuff->selection;
CurrentSelections[i].devPrivates = NULL; CurrentSelections[i].devPrivates = NULL;
rc = XaceHook(XACE_SELECTION_ACCESS, client, stuff->selection,
CurrentSelections + i, DixSetAttrAccess);
if (rc != Success)
return rc;
} }
CurrentSelections[i].lastTimeChanged = time; CurrentSelections[i].lastTimeChanged = time;
CurrentSelections[i].window = stuff->window; CurrentSelections[i].window = stuff->window;
@ -1072,6 +1067,7 @@ ProcSetSelectionOwner(ClientPtr client)
SelectionInfoRec info; SelectionInfoRec info;
info.selection = &CurrentSelections[i]; info.selection = &CurrentSelections[i];
info.client = client;
info.kind= SelectionSetOwner; info.kind= SelectionSetOwner;
CallCallbacks(&SelectionCallback, &info); CallCallbacks(&SelectionCallback, &info);
} }
@ -1095,23 +1091,29 @@ ProcGetSelectionOwner(ClientPtr client)
int rc, i; int rc, i;
xGetSelectionOwnerReply reply; xGetSelectionOwnerReply reply;
i = 0;
while ((i < NumCurrentSelections) &&
CurrentSelections[i].selection != stuff->id) i++;
rc = XaceHook(XACE_SELECTION_ACCESS, client, stuff->id, rc = XaceHook(XACE_SELECTION_ACCESS, client, stuff->id,
CurrentSelections + i, DixGetAttrAccess); DixGetAttrAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
i = 0;
while ((i < NumCurrentSelections) &&
CurrentSelections[i].selection != stuff->id) i++;
reply.type = X_Reply; reply.type = X_Reply;
reply.length = 0; reply.length = 0;
reply.sequenceNumber = client->sequence; reply.sequenceNumber = client->sequence;
if (i < NumCurrentSelections) if (i < NumCurrentSelections) {
reply.owner = CurrentSelections[i].window; if (SelectionCallback) {
else SelectionInfoRec info;
reply.owner = None;
info.selection = &CurrentSelections[i];
info.client = client;
info.kind= SelectionGetOwner;
CallCallbacks(&SelectionCallback, &info);
}
reply.owner = CurrentSelections[i].window;
} else
reply.owner = None;
WriteReplyToClient(client, sizeof(xGetSelectionOwnerReply), &reply); WriteReplyToClient(client, sizeof(xGetSelectionOwnerReply), &reply);
return(client->noClientException); return(client->noClientException);
} }
@ -1135,6 +1137,10 @@ ProcConvertSelection(ClientPtr client)
rc = dixLookupWindow(&pWin, stuff->requestor, client, DixSetAttrAccess); rc = dixLookupWindow(&pWin, stuff->requestor, client, DixSetAttrAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
rc = XaceHook(XACE_SELECTION_ACCESS, client, stuff->selection,
DixReadAccess);
if (rc != Success)
return rc;
paramsOkay = (ValidAtom(stuff->selection) && ValidAtom(stuff->target)); paramsOkay = (ValidAtom(stuff->selection) && ValidAtom(stuff->target));
if (stuff->property != None) if (stuff->property != None)
@ -1146,11 +1152,15 @@ ProcConvertSelection(ClientPtr client)
i = 0; i = 0;
while ((i < NumCurrentSelections) && while ((i < NumCurrentSelections) &&
CurrentSelections[i].selection != stuff->selection) i++; CurrentSelections[i].selection != stuff->selection) i++;
if ((i < NumCurrentSelections) && if (i < NumCurrentSelections && CurrentSelections[i].window != None) {
(CurrentSelections[i].window != None) && if (SelectionCallback) {
XaceHook(XACE_SELECTION_ACCESS, client, stuff->selection, SelectionInfoRec info;
CurrentSelections + i, DixReadAccess) == Success)
{ info.selection = &CurrentSelections[i];
info.client = client;
info.kind= SelectionConvertSelection;
CallCallbacks(&SelectionCallback, &info);
}
event.u.u.type = SelectionRequest; event.u.u.type = SelectionRequest;
event.u.selectionRequest.time = stuff->time; event.u.selectionRequest.time = stuff->time;
event.u.selectionRequest.owner = CurrentSelections[i].window; event.u.selectionRequest.owner = CurrentSelections[i].window;

View File

@ -594,12 +594,15 @@ extern CallbackListPtr SelectionCallback;
typedef enum { typedef enum {
SelectionSetOwner, SelectionSetOwner,
SelectionGetOwner,
SelectionConvertSelection,
SelectionWindowDestroy, SelectionWindowDestroy,
SelectionClientClose SelectionClientClose
} SelectionCallbackKind; } SelectionCallbackKind;
typedef struct { typedef struct {
struct _Selection *selection; struct _Selection *selection;
ClientPtr client;
SelectionCallbackKind kind; SelectionCallbackKind kind;
} SelectionInfoRec; } SelectionInfoRec;