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 ( (TRUSTLEVEL(client) == XSecurityClientTrusted) ||
if (!client || (TRUSTLEVEL(client) == XSecurityClientTrusted) ||
(TRUSTLEVEL(wClient(pWin)) != XSecurityClientTrusted) )
return;

View File

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

View File

@ -230,19 +230,9 @@ ProcChangeProperty(ClientPtr client)
return(BadAtom);
}
switch (XaceHook(XACE_PROPERTY_ACCESS, client, pWin,
FindProperty(pWin, stuff->property), stuff->property,
DixWriteAccess))
{
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);
err = dixChangeWindowProperty(client, pWin, stuff->property, stuff->type,
(int)format, (int)mode, len, &stuff[1],
TRUE);
if (err != Success)
return err;
else
@ -250,9 +240,9 @@ ProcChangeProperty(ClientPtr client)
}
_X_EXPORT int
ChangeWindowProperty(WindowPtr pWin, Atom property, Atom type, int format,
int mode, unsigned long len, pointer value,
Bool sendevent)
dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property,
Atom type, int format, int mode, unsigned long len,
pointer value, Bool sendevent)
{
PropertyPtr pProp;
xEvent event;
@ -286,12 +276,34 @@ ChangeWindowProperty(WindowPtr pWin, Atom property, Atom type, int format,
if (len)
memmove((char *)data, (char *)value, totalSize);
pProp->size = len;
pProp->next = pWin->optional->userProps;
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;
}
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
must match those of the already defined property. The
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);
}
_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
DeleteProperty(WindowPtr pWin, Atom propName)
{

View File

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

View File

@ -52,6 +52,17 @@ SOFTWARE.
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(
WindowPtr /*pWin*/,
Atom /*property*/,