Skip to content

Commit d60f714

Browse files
committed
[PR #1066] xselinux: inline SProc*()'s
PR: #1066
1 parent f8cc6e9 commit d60f714

File tree

1 file changed

+58
-170
lines changed

1 file changed

+58
-170
lines changed

Xext/xselinux_ext.c

Lines changed: 58 additions & 170 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,20 @@ SELinuxSendContextReply(ClientPtr client, security_id_t sid)
109109
static int
110110
ProcSELinuxSetCreateContext(ClientPtr client, unsigned offset)
111111
{
112+
REQUEST(SELinuxSetCreateContextReq);
113+
REQUEST_AT_LEAST_SIZE(SELinuxSetCreateContextReq);
114+
115+
if (client->swapped)
116+
swapl(&stuff->context_len);
117+
118+
REQUEST_FIXED_SIZE(SELinuxSetCreateContextReq, stuff->context_len);
119+
112120
PrivateRec **privPtr = &client->devPrivates;
113121
security_id_t *pSid;
114122
char *ctx = NULL;
115123
char *ptr;
116124
int rc;
117125

118-
REQUEST(SELinuxSetCreateContextReq);
119-
REQUEST_FIXED_SIZE(SELinuxSetCreateContextReq, stuff->context_len);
120-
121126
if (stuff->context_len > 0) {
122127
ctx = SELinuxCopyContext((char *) (stuff + 1), stuff->context_len);
123128
if (!ctx)
@@ -159,16 +164,23 @@ ProcSELinuxGetCreateContext(ClientPtr client, unsigned offset)
159164
static int
160165
ProcSELinuxSetDeviceContext(ClientPtr client)
161166
{
167+
REQUEST(SELinuxSetContextReq);
168+
REQUEST_AT_LEAST_SIZE(SELinuxSetContextReq);
169+
170+
if (client->swapped) {
171+
swapl(&stuff->id);
172+
swapl(&stuff->context_len);
173+
}
174+
175+
REQUEST_FIXED_SIZE(SELinuxSetContextReq, stuff->context_len);
176+
162177
char *ctx;
163178
security_id_t sid;
164179
DeviceIntPtr dev;
165180
SELinuxSubjectRec *subj;
166181
SELinuxObjectRec *obj;
167182
int rc;
168183

169-
REQUEST(SELinuxSetContextReq);
170-
REQUEST_FIXED_SIZE(SELinuxSetContextReq, stuff->context_len);
171-
172184
if (stuff->context_len < 1)
173185
return BadLength;
174186
ctx = SELinuxCopyContext((char *) (stuff + 1), stuff->context_len);
@@ -199,13 +211,17 @@ ProcSELinuxSetDeviceContext(ClientPtr client)
199211
static int
200212
ProcSELinuxGetDeviceContext(ClientPtr client)
201213
{
214+
REQUEST(SELinuxGetContextReq);
215+
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
216+
217+
if (client->swapped) {
218+
swapl(&stuff->id);
219+
}
220+
202221
DeviceIntPtr dev;
203222
SELinuxSubjectRec *subj;
204223
int rc;
205224

206-
REQUEST(SELinuxGetContextReq);
207-
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
208-
209225
rc = dixLookupDevice(&dev, stuff->id, client, DixGetAttrAccess);
210226
if (rc != Success)
211227
return rc;
@@ -217,14 +233,17 @@ ProcSELinuxGetDeviceContext(ClientPtr client)
217233
static int
218234
ProcSELinuxGetDrawableContext(ClientPtr client)
219235
{
236+
REQUEST(SELinuxGetContextReq);
237+
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
238+
239+
if (client->swapped)
240+
swapl(&stuff->id);
241+
220242
DrawablePtr pDraw;
221243
PrivateRec **privatePtr;
222244
SELinuxObjectRec *obj;
223245
int rc;
224246

225-
REQUEST(SELinuxGetContextReq);
226-
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
227-
228247
rc = dixLookupDrawable(&pDraw, stuff->id, client, 0, DixGetAttrAccess);
229248
if (rc != Success)
230249
return rc;
@@ -241,14 +260,19 @@ ProcSELinuxGetDrawableContext(ClientPtr client)
241260
static int
242261
ProcSELinuxGetPropertyContext(ClientPtr client, void *privKey)
243262
{
263+
REQUEST(SELinuxGetPropertyContextReq);
264+
REQUEST_SIZE_MATCH(SELinuxGetPropertyContextReq);
265+
266+
if (client->swapped) {
267+
swapl(&stuff->window);
268+
swapl(&stuff->property);
269+
}
270+
244271
WindowPtr pWin;
245272
PropertyPtr pProp;
246273
SELinuxObjectRec *obj;
247274
int rc;
248275

249-
REQUEST(SELinuxGetPropertyContextReq);
250-
REQUEST_SIZE_MATCH(SELinuxGetPropertyContextReq);
251-
252276
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetPropAccess);
253277
if (rc != Success)
254278
return rc;
@@ -265,13 +289,16 @@ ProcSELinuxGetPropertyContext(ClientPtr client, void *privKey)
265289
static int
266290
ProcSELinuxGetSelectionContext(ClientPtr client, void *privKey)
267291
{
292+
REQUEST(SELinuxGetContextReq);
293+
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
294+
295+
if (client->swapped)
296+
swapl(&stuff->id);
297+
268298
Selection *pSel;
269299
SELinuxObjectRec *obj;
270300
int rc;
271301

272-
REQUEST(SELinuxGetContextReq);
273-
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
274-
275302
rc = dixLookupSelection(&pSel, stuff->id, client, DixGetAttrAccess);
276303
if (rc != Success)
277304
return rc;
@@ -283,13 +310,16 @@ ProcSELinuxGetSelectionContext(ClientPtr client, void *privKey)
283310
static int
284311
ProcSELinuxGetClientContext(ClientPtr client)
285312
{
313+
REQUEST(SELinuxGetContextReq);
314+
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
315+
316+
if (client->swapped)
317+
swapl(&stuff->id);
318+
286319
ClientPtr target;
287320
SELinuxSubjectRec *subj;
288321
int rc;
289322

290-
REQUEST(SELinuxGetContextReq);
291-
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
292-
293323
rc = dixLookupResourceOwner(&target, stuff->id, client, DixGetAttrAccess);
294324
if (rc != Success)
295325
return rc;
@@ -366,15 +396,18 @@ SELinuxSendItemsToClient(ClientPtr client, SELinuxListItemRec * items,
366396
static int
367397
ProcSELinuxListProperties(ClientPtr client)
368398
{
399+
REQUEST(SELinuxGetContextReq);
400+
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
401+
402+
if (client->swapped)
403+
swapl(&stuff->id);
404+
369405
WindowPtr pWin;
370406
PropertyPtr pProp;
371407
SELinuxListItemRec *items;
372408
int rc, count, size, i;
373409
CARD32 id;
374410

375-
REQUEST(SELinuxGetContextReq);
376-
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
377-
378411
rc = dixLookupWindow(&pWin, stuff->id, client, DixListPropAccess);
379412
if (rc != Success)
380413
return rc;
@@ -493,151 +526,6 @@ ProcSELinuxDispatch(ClientPtr client)
493526
}
494527
}
495528

496-
static int _X_COLD
497-
SProcSELinuxQueryVersion(ClientPtr client)
498-
{
499-
return ProcSELinuxQueryVersion(client);
500-
}
501-
502-
static int _X_COLD
503-
SProcSELinuxSetCreateContext(ClientPtr client, unsigned offset)
504-
{
505-
REQUEST(SELinuxSetCreateContextReq);
506-
507-
REQUEST_AT_LEAST_SIZE(SELinuxSetCreateContextReq);
508-
swapl(&stuff->context_len);
509-
return ProcSELinuxSetCreateContext(client, offset);
510-
}
511-
512-
static int _X_COLD
513-
SProcSELinuxSetDeviceContext(ClientPtr client)
514-
{
515-
REQUEST(SELinuxSetContextReq);
516-
517-
REQUEST_AT_LEAST_SIZE(SELinuxSetContextReq);
518-
swapl(&stuff->id);
519-
swapl(&stuff->context_len);
520-
return ProcSELinuxSetDeviceContext(client);
521-
}
522-
523-
static int _X_COLD
524-
SProcSELinuxGetDeviceContext(ClientPtr client)
525-
{
526-
REQUEST(SELinuxGetContextReq);
527-
528-
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
529-
swapl(&stuff->id);
530-
return ProcSELinuxGetDeviceContext(client);
531-
}
532-
533-
static int _X_COLD
534-
SProcSELinuxGetDrawableContext(ClientPtr client)
535-
{
536-
REQUEST(SELinuxGetContextReq);
537-
538-
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
539-
swapl(&stuff->id);
540-
return ProcSELinuxGetDrawableContext(client);
541-
}
542-
543-
static int _X_COLD
544-
SProcSELinuxGetPropertyContext(ClientPtr client, void *privKey)
545-
{
546-
REQUEST(SELinuxGetPropertyContextReq);
547-
548-
REQUEST_SIZE_MATCH(SELinuxGetPropertyContextReq);
549-
swapl(&stuff->window);
550-
swapl(&stuff->property);
551-
return ProcSELinuxGetPropertyContext(client, privKey);
552-
}
553-
554-
static int _X_COLD
555-
SProcSELinuxGetSelectionContext(ClientPtr client, void *privKey)
556-
{
557-
REQUEST(SELinuxGetContextReq);
558-
559-
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
560-
swapl(&stuff->id);
561-
return ProcSELinuxGetSelectionContext(client, privKey);
562-
}
563-
564-
static int _X_COLD
565-
SProcSELinuxListProperties(ClientPtr client)
566-
{
567-
REQUEST(SELinuxGetContextReq);
568-
569-
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
570-
swapl(&stuff->id);
571-
return ProcSELinuxListProperties(client);
572-
}
573-
574-
static int _X_COLD
575-
SProcSELinuxGetClientContext(ClientPtr client)
576-
{
577-
REQUEST(SELinuxGetContextReq);
578-
579-
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
580-
swapl(&stuff->id);
581-
return ProcSELinuxGetClientContext(client);
582-
}
583-
584-
static int _X_COLD
585-
SProcSELinuxDispatch(ClientPtr client)
586-
{
587-
REQUEST(xReq);
588-
589-
switch (stuff->data) {
590-
case X_SELinuxQueryVersion:
591-
return SProcSELinuxQueryVersion(client);
592-
case X_SELinuxSetDeviceCreateContext:
593-
return SProcSELinuxSetCreateContext(client, CTX_DEV);
594-
case X_SELinuxGetDeviceCreateContext:
595-
return ProcSELinuxGetCreateContext(client, CTX_DEV);
596-
case X_SELinuxSetDeviceContext:
597-
return SProcSELinuxSetDeviceContext(client);
598-
case X_SELinuxGetDeviceContext:
599-
return SProcSELinuxGetDeviceContext(client);
600-
case X_SELinuxSetDrawableCreateContext:
601-
return SProcSELinuxSetCreateContext(client, CTX_WIN);
602-
case X_SELinuxGetDrawableCreateContext:
603-
return ProcSELinuxGetCreateContext(client, CTX_WIN);
604-
case X_SELinuxGetDrawableContext:
605-
return SProcSELinuxGetDrawableContext(client);
606-
case X_SELinuxSetPropertyCreateContext:
607-
return SProcSELinuxSetCreateContext(client, CTX_PRP);
608-
case X_SELinuxGetPropertyCreateContext:
609-
return ProcSELinuxGetCreateContext(client, CTX_PRP);
610-
case X_SELinuxSetPropertyUseContext:
611-
return SProcSELinuxSetCreateContext(client, USE_PRP);
612-
case X_SELinuxGetPropertyUseContext:
613-
return ProcSELinuxGetCreateContext(client, USE_PRP);
614-
case X_SELinuxGetPropertyContext:
615-
return SProcSELinuxGetPropertyContext(client, objectKey);
616-
case X_SELinuxGetPropertyDataContext:
617-
return SProcSELinuxGetPropertyContext(client, dataKey);
618-
case X_SELinuxListProperties:
619-
return SProcSELinuxListProperties(client);
620-
case X_SELinuxSetSelectionCreateContext:
621-
return SProcSELinuxSetCreateContext(client, CTX_SEL);
622-
case X_SELinuxGetSelectionCreateContext:
623-
return ProcSELinuxGetCreateContext(client, CTX_SEL);
624-
case X_SELinuxSetSelectionUseContext:
625-
return SProcSELinuxSetCreateContext(client, USE_SEL);
626-
case X_SELinuxGetSelectionUseContext:
627-
return ProcSELinuxGetCreateContext(client, USE_SEL);
628-
case X_SELinuxGetSelectionContext:
629-
return SProcSELinuxGetSelectionContext(client, objectKey);
630-
case X_SELinuxGetSelectionDataContext:
631-
return SProcSELinuxGetSelectionContext(client, dataKey);
632-
case X_SELinuxListSelections:
633-
return ProcSELinuxListSelections(client);
634-
case X_SELinuxGetClientContext:
635-
return SProcSELinuxGetClientContext(client);
636-
default:
637-
return BadRequest;
638-
}
639-
}
640-
641529
/*
642530
* Extension Setup / Teardown
643531
*/
@@ -673,5 +561,5 @@ SELinuxExtensionInit(void)
673561
/* Add extension to server */
674562
AddExtension(SELINUX_EXTENSION_NAME, SELinuxNumberEvents,
675563
SELinuxNumberErrors, ProcSELinuxDispatch,
676-
SProcSELinuxDispatch, SELinuxResetProc, StandardMinorOpcode);
564+
ProcSELinuxDispatch, SELinuxResetProc, StandardMinorOpcode);
677565
}

0 commit comments

Comments
 (0)