xace: add new argument to property hook for property structure itself.

This commit is contained in:
Eamon Walsh 2007-03-22 13:06:50 -04:00 committed by Eamon Walsh
parent 5486be4898
commit 1b58304ac8
4 changed files with 40 additions and 38 deletions

View File

@ -28,14 +28,8 @@ in this Software without prior written authorization from The Open Group.
#include <dix-config.h> #include <dix-config.h>
#endif #endif
#include "dixstruct.h"
#include "extnsionst.h"
#include "windowstr.h"
#include "inputstr.h"
#include "scrnintstr.h" #include "scrnintstr.h"
#include "gcstruct.h"
#include "colormapst.h" #include "colormapst.h"
#include "propertyst.h"
#include "xacestr.h" #include "xacestr.h"
#include "securitysrv.h" #include "securitysrv.h"
#include <X11/extensions/securstr.h> #include <X11/extensions/securstr.h>

View File

@ -22,9 +22,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#endif #endif
#include <stdarg.h> #include <stdarg.h>
#include "windowstr.h"
#include "scrnintstr.h" #include "scrnintstr.h"
#include "gcstruct.h"
#include "xacestr.h" #include "xacestr.h"
#include "modinit.h" #include "modinit.h"
@ -97,6 +95,7 @@ int XaceHook(int hook, ...)
XacePropertyAccessRec rec = { XacePropertyAccessRec rec = {
va_arg(ap, ClientPtr), va_arg(ap, ClientPtr),
va_arg(ap, WindowPtr), va_arg(ap, WindowPtr),
va_arg(ap, PropertyPtr),
va_arg(ap, Atom), va_arg(ap, Atom),
va_arg(ap, Mask), va_arg(ap, Mask),
XaceAllowOperation /* default allow */ XaceAllowOperation /* default allow */

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 "propertyst.h"
#include "selection.h" #include "selection.h"
#include "xace.h" #include "xace.h"
@ -59,6 +60,7 @@ typedef struct {
typedef struct { typedef struct {
ClientPtr client; ClientPtr client;
WindowPtr pWin; WindowPtr pWin;
PropertyPtr pProp;
Atom propertyName; Atom propertyName;
Mask access_mode; Mask access_mode;
int rval; int rval;

View File

@ -91,6 +91,19 @@ PrintPropertys(WindowPtr pWin)
} }
#endif #endif
static _X_INLINE PropertyPtr
FindProperty(WindowPtr pWin, Atom propertyName)
{
PropertyPtr pProp = wUserProps(pWin);
while (pProp)
{
if (pProp->propertyName == propertyName)
break;
pProp = pProp->next;
}
return pProp;
}
int int
ProcRotateProperties(ClientPtr client) ProcRotateProperties(ClientPtr client)
{ {
@ -115,35 +128,33 @@ ProcRotateProperties(ClientPtr client)
return(BadAlloc); return(BadAlloc);
for (i = 0; i < stuff->nAtoms; i++) for (i = 0; i < stuff->nAtoms; i++)
{ {
char action = XaceHook(XACE_PROPERTY_ACCESS, client, pWin, atoms[i], if (!ValidAtom(atoms[i])) {
DixReadAccess|DixWriteAccess);
if (!ValidAtom(atoms[i]) || (XaceErrorOperation == action)) {
DEALLOCATE_LOCAL(props); DEALLOCATE_LOCAL(props);
client->errorValue = atoms[i]; client->errorValue = atoms[i];
return BadAtom; return BadAtom;
} }
if (XaceIgnoreOperation == action) {
DEALLOCATE_LOCAL(props);
return Success;
}
for (j = i + 1; j < stuff->nAtoms; j++) for (j = i + 1; j < stuff->nAtoms; j++)
if (atoms[j] == atoms[i]) if (atoms[j] == atoms[i])
{ {
DEALLOCATE_LOCAL(props); DEALLOCATE_LOCAL(props);
return BadMatch; return BadMatch;
} }
pProp = wUserProps (pWin); pProp = FindProperty(pWin, atoms[i]);
while (pProp) if (!pProp) {
{ DEALLOCATE_LOCAL(props);
if (pProp->propertyName == atoms[i]) return BadMatch;
goto found; }
pProp = pProp->next; switch (XaceHook(XACE_PROPERTY_ACCESS, client, pWin, pProp, atoms[i],
} DixReadAccess|DixWriteAccess))
DEALLOCATE_LOCAL(props); {
return BadMatch; case XaceErrorOperation:
found: DEALLOCATE_LOCAL(props);
client->errorValue = atoms[i];
return BadAtom;
case XaceIgnoreOperation:
DEALLOCATE_LOCAL(props);
return Success;
}
props[i] = pProp; props[i] = pProp;
} }
delta = stuff->nPositions; delta = stuff->nPositions;
@ -219,7 +230,8 @@ ProcChangeProperty(ClientPtr client)
return(BadAtom); return(BadAtom);
} }
switch (XaceHook(XACE_PROPERTY_ACCESS, client, pWin, stuff->property, switch (XaceHook(XACE_PROPERTY_ACCESS, client, pWin,
FindProperty(pWin, stuff->property), stuff->property,
DixWriteAccess)) DixWriteAccess))
{ {
case XaceErrorOperation: case XaceErrorOperation:
@ -252,14 +264,8 @@ ChangeWindowProperty(WindowPtr pWin, Atom property, Atom type, int format,
totalSize = len * sizeInBytes; totalSize = len * sizeInBytes;
/* first see if property already exists */ /* first see if property already exists */
pProp = FindProperty(pWin, property);
pProp = wUserProps (pWin);
while (pProp)
{
if (pProp->propertyName == property)
break;
pProp = pProp->next;
}
if (!pProp) /* just add to list */ if (!pProp) /* just add to list */
{ {
if (!pWin->optional && !MakeWindowOptional (pWin)) if (!pWin->optional && !MakeWindowOptional (pWin))
@ -490,8 +496,8 @@ ProcGetProperty(ClientPtr client)
if (stuff->delete) if (stuff->delete)
access_mode |= DixDestroyAccess; access_mode |= DixDestroyAccess;
switch (XaceHook(XACE_PROPERTY_ACCESS, client, pWin, stuff->property, switch (XaceHook(XACE_PROPERTY_ACCESS, client, pWin, pProp,
access_mode)) stuff->property, access_mode))
{ {
case XaceErrorOperation: case XaceErrorOperation:
client->errorValue = stuff->property; client->errorValue = stuff->property;
@ -643,7 +649,8 @@ ProcDeleteProperty(register ClientPtr client)
return (BadAtom); return (BadAtom);
} }
switch (XaceHook(XACE_PROPERTY_ACCESS, client, pWin, stuff->property, switch (XaceHook(XACE_PROPERTY_ACCESS, client, pWin,
FindProperty(pWin, stuff->property), stuff->property,
DixDestroyAccess)) DixDestroyAccess))
{ {
case XaceErrorOperation: case XaceErrorOperation: