Xext: selinux: use REQUEST_HEAD_STRUCT and REQUEST_FIELD_* macros
Use the new macros to make request struct parsing / field swapping much easier. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
a45230afac
commit
105ee0f8ac
|
@ -21,6 +21,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#include "dix/dix_priv.h"
|
#include "dix/dix_priv.h"
|
||||||
#include "dix/property_priv.h"
|
#include "dix/property_priv.h"
|
||||||
|
#include "dix/request_priv.h"
|
||||||
|
|
||||||
#include "selection.h"
|
#include "selection.h"
|
||||||
#include "inputstr.h"
|
#include "inputstr.h"
|
||||||
|
@ -123,7 +124,8 @@ ProcSELinuxSetCreateContext(ClientPtr client, unsigned offset)
|
||||||
char *ptr;
|
char *ptr;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
REQUEST(SELinuxSetCreateContextReq);
|
REQUEST_HEAD_AT_LEAST(SELinuxSetCreateContextReq);
|
||||||
|
REQUEST_FIELD_CARD32(context_len);
|
||||||
REQUEST_FIXED_SIZE(SELinuxSetCreateContextReq, stuff->context_len);
|
REQUEST_FIXED_SIZE(SELinuxSetCreateContextReq, stuff->context_len);
|
||||||
|
|
||||||
if (stuff->context_len > 0) {
|
if (stuff->context_len > 0) {
|
||||||
|
@ -153,7 +155,7 @@ ProcSELinuxGetCreateContext(ClientPtr client, unsigned offset)
|
||||||
security_id_t *pSid;
|
security_id_t *pSid;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(SELinuxGetCreateContextReq);
|
REQUEST_HEAD_STRUCT(SELinuxGetCreateContextReq);
|
||||||
|
|
||||||
if (offset == CTX_DEV)
|
if (offset == CTX_DEV)
|
||||||
ptr = dixLookupPrivate(&serverClient->devPrivates, subjectKey);
|
ptr = dixLookupPrivate(&serverClient->devPrivates, subjectKey);
|
||||||
|
@ -174,7 +176,9 @@ ProcSELinuxSetDeviceContext(ClientPtr client)
|
||||||
SELinuxObjectRec *obj;
|
SELinuxObjectRec *obj;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
REQUEST(SELinuxSetContextReq);
|
REQUEST_HEAD_AT_LEAST(SELinuxSetContextReq);
|
||||||
|
REQUEST_FIELD_CARD32(id);
|
||||||
|
REQUEST_FIELD_CARD32(context_len);
|
||||||
REQUEST_FIXED_SIZE(SELinuxSetContextReq, stuff->context_len);
|
REQUEST_FIXED_SIZE(SELinuxSetContextReq, stuff->context_len);
|
||||||
|
|
||||||
if (stuff->context_len < 1)
|
if (stuff->context_len < 1)
|
||||||
|
@ -211,8 +215,8 @@ ProcSELinuxGetDeviceContext(ClientPtr client)
|
||||||
SELinuxSubjectRec *subj;
|
SELinuxSubjectRec *subj;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
REQUEST(SELinuxGetContextReq);
|
REQUEST_HEAD_STRUCT(SELinuxGetContextReq);
|
||||||
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
|
REQUEST_FIELD_CARD32(id);
|
||||||
|
|
||||||
rc = dixLookupDevice(&dev, stuff->id, client, DixGetAttrAccess);
|
rc = dixLookupDevice(&dev, stuff->id, client, DixGetAttrAccess);
|
||||||
if (rc != Success)
|
if (rc != Success)
|
||||||
|
@ -230,8 +234,8 @@ ProcSELinuxGetDrawableContext(ClientPtr client)
|
||||||
SELinuxObjectRec *obj;
|
SELinuxObjectRec *obj;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
REQUEST(SELinuxGetContextReq);
|
REQUEST_HEAD_STRUCT(SELinuxGetContextReq);
|
||||||
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
|
REQUEST_FIELD_CARD32(id);
|
||||||
|
|
||||||
rc = dixLookupDrawable(&pDraw, stuff->id, client, 0, DixGetAttrAccess);
|
rc = dixLookupDrawable(&pDraw, stuff->id, client, 0, DixGetAttrAccess);
|
||||||
if (rc != Success)
|
if (rc != Success)
|
||||||
|
@ -254,8 +258,9 @@ ProcSELinuxGetPropertyContext(ClientPtr client, void *privKey)
|
||||||
SELinuxObjectRec *obj;
|
SELinuxObjectRec *obj;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
REQUEST(SELinuxGetPropertyContextReq);
|
REQUEST_HEAD_STRUCT(SELinuxGetPropertyContextReq);
|
||||||
REQUEST_SIZE_MATCH(SELinuxGetPropertyContextReq);
|
REQUEST_FIELD_CARD32(window);
|
||||||
|
REQUEST_FIELD_CARD32(property);
|
||||||
|
|
||||||
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetPropAccess);
|
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetPropAccess);
|
||||||
if (rc != Success)
|
if (rc != Success)
|
||||||
|
@ -277,8 +282,8 @@ ProcSELinuxGetSelectionContext(ClientPtr client, void *privKey)
|
||||||
SELinuxObjectRec *obj;
|
SELinuxObjectRec *obj;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
REQUEST(SELinuxGetContextReq);
|
REQUEST_HEAD_STRUCT(SELinuxGetContextReq);
|
||||||
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
|
REQUEST_FIELD_CARD32(id);
|
||||||
|
|
||||||
rc = dixLookupSelection(&pSel, stuff->id, client, DixGetAttrAccess);
|
rc = dixLookupSelection(&pSel, stuff->id, client, DixGetAttrAccess);
|
||||||
if (rc != Success)
|
if (rc != Success)
|
||||||
|
@ -295,8 +300,8 @@ ProcSELinuxGetClientContext(ClientPtr client)
|
||||||
SELinuxSubjectRec *subj;
|
SELinuxSubjectRec *subj;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
REQUEST(SELinuxGetContextReq);
|
REQUEST_HEAD_STRUCT(SELinuxGetContextReq);
|
||||||
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
|
REQUEST_FIELD_CARD32(id);
|
||||||
|
|
||||||
rc = dixLookupResourceOwner(&target, stuff->id, client, DixGetAttrAccess);
|
rc = dixLookupResourceOwner(&target, stuff->id, client, DixGetAttrAccess);
|
||||||
if (rc != Success)
|
if (rc != Success)
|
||||||
|
@ -408,8 +413,8 @@ ProcSELinuxListProperties(ClientPtr client)
|
||||||
int rc, count, size, i;
|
int rc, count, size, i;
|
||||||
CARD32 id;
|
CARD32 id;
|
||||||
|
|
||||||
REQUEST(SELinuxGetContextReq);
|
REQUEST_HEAD_STRUCT(SELinuxGetContextReq);
|
||||||
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
|
REQUEST_FIELD_CARD32(id);
|
||||||
|
|
||||||
rc = dixLookupWindow(&pWin, stuff->id, client, DixListPropAccess);
|
rc = dixLookupWindow(&pWin, stuff->id, client, DixListPropAccess);
|
||||||
if (rc != Success)
|
if (rc != Success)
|
||||||
|
@ -447,7 +452,7 @@ ProcSELinuxListSelections(ClientPtr client)
|
||||||
int rc, count, size, i;
|
int rc, count, size, i;
|
||||||
CARD32 id;
|
CARD32 id;
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(SELinuxGetCreateContextReq);
|
REQUEST_HEAD_STRUCT(SELinuxGetCreateContextReq);
|
||||||
|
|
||||||
/* Count the number of selections and allocate items */
|
/* Count the number of selections and allocate items */
|
||||||
count = 0;
|
count = 0;
|
||||||
|
@ -529,151 +534,6 @@ ProcSELinuxDispatch(ClientPtr client)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _X_COLD
|
|
||||||
SProcSELinuxQueryVersion(ClientPtr client)
|
|
||||||
{
|
|
||||||
return ProcSELinuxQueryVersion(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int _X_COLD
|
|
||||||
SProcSELinuxSetCreateContext(ClientPtr client, unsigned offset)
|
|
||||||
{
|
|
||||||
REQUEST(SELinuxSetCreateContextReq);
|
|
||||||
|
|
||||||
REQUEST_AT_LEAST_SIZE(SELinuxSetCreateContextReq);
|
|
||||||
swapl(&stuff->context_len);
|
|
||||||
return ProcSELinuxSetCreateContext(client, offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int _X_COLD
|
|
||||||
SProcSELinuxSetDeviceContext(ClientPtr client)
|
|
||||||
{
|
|
||||||
REQUEST(SELinuxSetContextReq);
|
|
||||||
|
|
||||||
REQUEST_AT_LEAST_SIZE(SELinuxSetContextReq);
|
|
||||||
swapl(&stuff->id);
|
|
||||||
swapl(&stuff->context_len);
|
|
||||||
return ProcSELinuxSetDeviceContext(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int _X_COLD
|
|
||||||
SProcSELinuxGetDeviceContext(ClientPtr client)
|
|
||||||
{
|
|
||||||
REQUEST(SELinuxGetContextReq);
|
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
|
|
||||||
swapl(&stuff->id);
|
|
||||||
return ProcSELinuxGetDeviceContext(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int _X_COLD
|
|
||||||
SProcSELinuxGetDrawableContext(ClientPtr client)
|
|
||||||
{
|
|
||||||
REQUEST(SELinuxGetContextReq);
|
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
|
|
||||||
swapl(&stuff->id);
|
|
||||||
return ProcSELinuxGetDrawableContext(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int _X_COLD
|
|
||||||
SProcSELinuxGetPropertyContext(ClientPtr client, void *privKey)
|
|
||||||
{
|
|
||||||
REQUEST(SELinuxGetPropertyContextReq);
|
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(SELinuxGetPropertyContextReq);
|
|
||||||
swapl(&stuff->window);
|
|
||||||
swapl(&stuff->property);
|
|
||||||
return ProcSELinuxGetPropertyContext(client, privKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int _X_COLD
|
|
||||||
SProcSELinuxGetSelectionContext(ClientPtr client, void *privKey)
|
|
||||||
{
|
|
||||||
REQUEST(SELinuxGetContextReq);
|
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
|
|
||||||
swapl(&stuff->id);
|
|
||||||
return ProcSELinuxGetSelectionContext(client, privKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int _X_COLD
|
|
||||||
SProcSELinuxListProperties(ClientPtr client)
|
|
||||||
{
|
|
||||||
REQUEST(SELinuxGetContextReq);
|
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
|
|
||||||
swapl(&stuff->id);
|
|
||||||
return ProcSELinuxListProperties(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int _X_COLD
|
|
||||||
SProcSELinuxGetClientContext(ClientPtr client)
|
|
||||||
{
|
|
||||||
REQUEST(SELinuxGetContextReq);
|
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
|
|
||||||
swapl(&stuff->id);
|
|
||||||
return ProcSELinuxGetClientContext(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int _X_COLD
|
|
||||||
SProcSELinuxDispatch(ClientPtr client)
|
|
||||||
{
|
|
||||||
REQUEST(xReq);
|
|
||||||
|
|
||||||
switch (stuff->data) {
|
|
||||||
case X_SELinuxQueryVersion:
|
|
||||||
return SProcSELinuxQueryVersion(client);
|
|
||||||
case X_SELinuxSetDeviceCreateContext:
|
|
||||||
return SProcSELinuxSetCreateContext(client, CTX_DEV);
|
|
||||||
case X_SELinuxGetDeviceCreateContext:
|
|
||||||
return ProcSELinuxGetCreateContext(client, CTX_DEV);
|
|
||||||
case X_SELinuxSetDeviceContext:
|
|
||||||
return SProcSELinuxSetDeviceContext(client);
|
|
||||||
case X_SELinuxGetDeviceContext:
|
|
||||||
return SProcSELinuxGetDeviceContext(client);
|
|
||||||
case X_SELinuxSetDrawableCreateContext:
|
|
||||||
return SProcSELinuxSetCreateContext(client, CTX_WIN);
|
|
||||||
case X_SELinuxGetDrawableCreateContext:
|
|
||||||
return ProcSELinuxGetCreateContext(client, CTX_WIN);
|
|
||||||
case X_SELinuxGetDrawableContext:
|
|
||||||
return SProcSELinuxGetDrawableContext(client);
|
|
||||||
case X_SELinuxSetPropertyCreateContext:
|
|
||||||
return SProcSELinuxSetCreateContext(client, CTX_PRP);
|
|
||||||
case X_SELinuxGetPropertyCreateContext:
|
|
||||||
return ProcSELinuxGetCreateContext(client, CTX_PRP);
|
|
||||||
case X_SELinuxSetPropertyUseContext:
|
|
||||||
return SProcSELinuxSetCreateContext(client, USE_PRP);
|
|
||||||
case X_SELinuxGetPropertyUseContext:
|
|
||||||
return ProcSELinuxGetCreateContext(client, USE_PRP);
|
|
||||||
case X_SELinuxGetPropertyContext:
|
|
||||||
return SProcSELinuxGetPropertyContext(client, objectKey);
|
|
||||||
case X_SELinuxGetPropertyDataContext:
|
|
||||||
return SProcSELinuxGetPropertyContext(client, dataKey);
|
|
||||||
case X_SELinuxListProperties:
|
|
||||||
return SProcSELinuxListProperties(client);
|
|
||||||
case X_SELinuxSetSelectionCreateContext:
|
|
||||||
return SProcSELinuxSetCreateContext(client, CTX_SEL);
|
|
||||||
case X_SELinuxGetSelectionCreateContext:
|
|
||||||
return ProcSELinuxGetCreateContext(client, CTX_SEL);
|
|
||||||
case X_SELinuxSetSelectionUseContext:
|
|
||||||
return SProcSELinuxSetCreateContext(client, USE_SEL);
|
|
||||||
case X_SELinuxGetSelectionUseContext:
|
|
||||||
return ProcSELinuxGetCreateContext(client, USE_SEL);
|
|
||||||
case X_SELinuxGetSelectionContext:
|
|
||||||
return SProcSELinuxGetSelectionContext(client, objectKey);
|
|
||||||
case X_SELinuxGetSelectionDataContext:
|
|
||||||
return SProcSELinuxGetSelectionContext(client, dataKey);
|
|
||||||
case X_SELinuxListSelections:
|
|
||||||
return ProcSELinuxListSelections(client);
|
|
||||||
case X_SELinuxGetClientContext:
|
|
||||||
return SProcSELinuxGetClientContext(client);
|
|
||||||
default:
|
|
||||||
return BadRequest;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Extension Setup / Teardown
|
* Extension Setup / Teardown
|
||||||
*/
|
*/
|
||||||
|
@ -709,5 +569,5 @@ SELinuxExtensionInit(void)
|
||||||
/* Add extension to server */
|
/* Add extension to server */
|
||||||
AddExtension(SELINUX_EXTENSION_NAME, SELinuxNumberEvents,
|
AddExtension(SELINUX_EXTENSION_NAME, SELinuxNumberEvents,
|
||||||
SELinuxNumberErrors, ProcSELinuxDispatch,
|
SELinuxNumberErrors, ProcSELinuxDispatch,
|
||||||
SProcSELinuxDispatch, SELinuxResetProc, StandardMinorOpcode);
|
ProcSELinuxDispatch, SELinuxResetProc, StandardMinorOpcode);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue