dix: reorganize property code to better support xace hook; requires new API for

changing a property, dixChangeWindowProperty, taking an additional client argument.
This commit is contained in:
Eamon Walsh 2007-03-22 15:55:35 -04:00 committed by Eamon Walsh
parent 1b58304ac8
commit 1b766ffc06
5 changed files with 52 additions and 19 deletions

View File

@ -1715,7 +1715,7 @@ SecurityCheckPropertyAccess(CallbackListPtr *pcbl, pointer unused,
/* if client trusted or window untrusted, allow operation */ /* if client trusted or window untrusted, allow operation */
if ( (TRUSTLEVEL(client) == XSecurityClientTrusted) || if (!client || (TRUSTLEVEL(client) == XSecurityClientTrusted) ||
(TRUSTLEVEL(wClient(pWin)) != XSecurityClientTrusted) ) (TRUSTLEVEL(wClient(pWin)) != XSecurityClientTrusted) )
return; return;

View File

@ -1070,7 +1070,7 @@ XSELinuxProperty(CallbackListPtr *pcbl, pointer unused, pointer calldata)
char *propname = NameForAtom(rec->propertyName); char *propname = NameForAtom(rec->propertyName);
tclient = wClient(pWin); tclient = wClient(pWin);
if (!tclient || !HAVESTATE(tclient)) if (!client || !tclient || !HAVESTATE(tclient))
return; return;
propsid = GetPropertySID(SID(tclient)->ctx, propname); propsid = GetPropertySID(SID(tclient)->ctx, propname);

View File

@ -230,19 +230,9 @@ ProcChangeProperty(ClientPtr client)
return(BadAtom); return(BadAtom);
} }
switch (XaceHook(XACE_PROPERTY_ACCESS, client, pWin, err = dixChangeWindowProperty(client, pWin, stuff->property, stuff->type,
FindProperty(pWin, stuff->property), stuff->property, (int)format, (int)mode, len, &stuff[1],
DixWriteAccess)) TRUE);
{
case XaceErrorOperation:
client->errorValue = stuff->property;
return BadAtom;
case XaceIgnoreOperation:
return Success;
}
err = ChangeWindowProperty(pWin, stuff->property, stuff->type, (int)format,
(int)mode, len, (pointer)&stuff[1], TRUE);
if (err != Success) if (err != Success)
return err; return err;
else else
@ -250,9 +240,9 @@ ProcChangeProperty(ClientPtr client)
} }
_X_EXPORT int _X_EXPORT int
ChangeWindowProperty(WindowPtr pWin, Atom property, Atom type, int format, dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property,
int mode, unsigned long len, pointer value, Atom type, int format, int mode, unsigned long len,
Bool sendevent) pointer value, Bool sendevent)
{ {
PropertyPtr pProp; PropertyPtr pProp;
xEvent event; xEvent event;
@ -286,12 +276,34 @@ ChangeWindowProperty(WindowPtr pWin, Atom property, Atom type, int format,
if (len) if (len)
memmove((char *)data, (char *)value, totalSize); memmove((char *)data, (char *)value, totalSize);
pProp->size = len; pProp->size = len;
pProp->next = pWin->optional->userProps;
pProp->devPrivates = NULL; pProp->devPrivates = NULL;
switch (XaceHook(XACE_PROPERTY_ACCESS, pClient, pWin, pProp, property,
DixWriteAccess))
{
case XaceErrorOperation:
xfree(data);
xfree(pProp);
pClient->errorValue = property;
return BadAtom;
case XaceIgnoreOperation:
xfree(data);
xfree(pProp);
return Success;
}
pProp->next = pWin->optional->userProps;
pWin->optional->userProps = pProp; pWin->optional->userProps = pProp;
} }
else else
{ {
switch (XaceHook(XACE_PROPERTY_ACCESS, pClient, pWin, pProp, property,
DixWriteAccess))
{
case XaceErrorOperation:
pClient->errorValue = property;
return BadAtom;
case XaceIgnoreOperation:
return Success;
}
/* To append or prepend to a property the request format and type /* To append or prepend to a property the request format and type
must match those of the already defined property. The must match those of the already defined property. The
existing format and type are irrelevant when using the mode existing format and type are irrelevant when using the mode
@ -357,6 +369,15 @@ ChangeWindowProperty(WindowPtr pWin, Atom property, Atom type, int format,
return(Success); return(Success);
} }
_X_EXPORT int
ChangeWindowProperty(WindowPtr pWin, Atom property, Atom type, int format,
int mode, unsigned long len, pointer value,
Bool sendevent)
{
return dixChangeWindowProperty(NullClient, pWin, property, type, format,
mode, len, value, sendevent);
}
int int
DeleteProperty(WindowPtr pWin, Atom propName) DeleteProperty(WindowPtr pWin, Atom propName)
{ {

View File

@ -192,6 +192,7 @@ _X_HIDDEN void *dixLookupTab[] = {
#endif #endif
/* property.c */ /* property.c */
SYMFUNC(ChangeWindowProperty) SYMFUNC(ChangeWindowProperty)
SYMFUNC(dixChangeWindowProperty)
/* extension.c */ /* extension.c */
SYMFUNC(AddExtension) SYMFUNC(AddExtension)
SYMFUNC(AddExtensionAlias) SYMFUNC(AddExtensionAlias)

View File

@ -52,6 +52,17 @@ SOFTWARE.
typedef struct _Property *PropertyPtr; typedef struct _Property *PropertyPtr;
extern int dixChangeWindowProperty(
ClientPtr /*pClient*/,
WindowPtr /*pWin*/,
Atom /*property*/,
Atom /*type*/,
int /*format*/,
int /*mode*/,
unsigned long /*len*/,
pointer /*value*/,
Bool /*sendevent*/);
extern int ChangeWindowProperty( extern int ChangeWindowProperty(
WindowPtr /*pWin*/, WindowPtr /*pWin*/,
Atom /*property*/, Atom /*property*/,