xace: add XACE_SELECTION_ACCESS hook for selection redirection/access.

This commit is contained in:
Eamon Walsh 2007-03-21 14:39:00 -04:00 committed by Eamon Walsh
parent 2945deba1d
commit 9c144f8ac5
4 changed files with 29 additions and 11 deletions

View File

@ -147,6 +147,16 @@ int XaceHook(int hook, ...)
prv = &rec.rval; prv = &rec.rval;
break; break;
} }
case XACE_SELECTION_ACCESS: {
XaceSelectionAccessRec rec = {
va_arg(ap, ClientPtr),
va_arg(ap, Selection*),
TRUE /* default allow */
};
calldata = &rec;
prv = &rec.rval;
break;
}
case XACE_SITE_POLICY: { case XACE_SITE_POLICY: {
XaceSitePolicyRec rec = { XaceSitePolicyRec rec = {
va_arg(ap, char*), va_arg(ap, char*),

View File

@ -50,13 +50,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define XACE_BACKGRND_ACCESS 7 #define XACE_BACKGRND_ACCESS 7
#define XACE_EXT_ACCESS 8 #define XACE_EXT_ACCESS 8
#define XACE_HOSTLIST_ACCESS 9 #define XACE_HOSTLIST_ACCESS 9
#define XACE_SITE_POLICY 10 #define XACE_SELECTION_ACCESS 10
#define XACE_DECLARE_EXT_SECURE 11 #define XACE_SITE_POLICY 11
#define XACE_AUTH_AVAIL 12 #define XACE_DECLARE_EXT_SECURE 12
#define XACE_KEY_AVAIL 13 #define XACE_AUTH_AVAIL 13
#define XACE_AUDIT_BEGIN 14 #define XACE_KEY_AVAIL 14
#define XACE_AUDIT_END 15 #define XACE_AUDIT_BEGIN 15
#define XACE_NUM_HOOKS 16 #define XACE_AUDIT_END 16
#define XACE_NUM_HOOKS 17
extern CallbackListPtr XaceHooks[XACE_NUM_HOOKS]; extern CallbackListPtr XaceHooks[XACE_NUM_HOOKS];

View File

@ -27,6 +27,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "gcstruct.h" #include "gcstruct.h"
#include "windowstr.h" #include "windowstr.h"
#include "inputstr.h" #include "inputstr.h"
#include "selection.h"
#include "xace.h" #include "xace.h"
/* XACE_CORE_DISPATCH */ /* XACE_CORE_DISPATCH */
@ -93,6 +94,13 @@ typedef struct {
int rval; int rval;
} XaceHostlistAccessRec; } XaceHostlistAccessRec;
/* XACE_SELECTION_ACCESS */
typedef struct {
ClientPtr client;
Selection *selection;
int rval;
} XaceSelectionAccessRec;
/* XACE_SITE_POLICY */ /* XACE_SITE_POLICY */
typedef struct { typedef struct {
char *policyString; char *policyString;

View File

@ -1113,7 +1113,8 @@ ProcGetSelectionOwner(register ClientPtr client)
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 &&
XaceHook(XACE_SELECTION_ACCESS, client, &CurrentSelections[i]))
reply.owner = CurrentSelections[i].window; reply.owner = CurrentSelections[i].window;
else else
reply.owner = None; reply.owner = None;
@ -1153,9 +1154,7 @@ ProcConvertSelection(register ClientPtr client)
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) &&
XaceHook(XACE_RESOURCE_ACCESS, client, XaceHook(XACE_SELECTION_ACCESS, client, &CurrentSelections[i]))
CurrentSelections[i].window, RT_WINDOW,
DixReadAccess, CurrentSelections[i].pWin))
{ {
event.u.u.type = SelectionRequest; event.u.u.type = SelectionRequest;
event.u.selectionRequest.time = stuff->time; event.u.selectionRequest.time = stuff->time;