@@ -109,15 +109,20 @@ SELinuxSendContextReply(ClientPtr client, security_id_t sid)
109
109
static int
110
110
ProcSELinuxSetCreateContext (ClientPtr client , unsigned offset )
111
111
{
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
+
112
120
PrivateRec * * privPtr = & client -> devPrivates ;
113
121
security_id_t * pSid ;
114
122
char * ctx = NULL ;
115
123
char * ptr ;
116
124
int rc ;
117
125
118
- REQUEST (SELinuxSetCreateContextReq );
119
- REQUEST_FIXED_SIZE (SELinuxSetCreateContextReq , stuff -> context_len );
120
-
121
126
if (stuff -> context_len > 0 ) {
122
127
ctx = SELinuxCopyContext ((char * ) (stuff + 1 ), stuff -> context_len );
123
128
if (!ctx )
@@ -159,16 +164,23 @@ ProcSELinuxGetCreateContext(ClientPtr client, unsigned offset)
159
164
static int
160
165
ProcSELinuxSetDeviceContext (ClientPtr client )
161
166
{
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
+
162
177
char * ctx ;
163
178
security_id_t sid ;
164
179
DeviceIntPtr dev ;
165
180
SELinuxSubjectRec * subj ;
166
181
SELinuxObjectRec * obj ;
167
182
int rc ;
168
183
169
- REQUEST (SELinuxSetContextReq );
170
- REQUEST_FIXED_SIZE (SELinuxSetContextReq , stuff -> context_len );
171
-
172
184
if (stuff -> context_len < 1 )
173
185
return BadLength ;
174
186
ctx = SELinuxCopyContext ((char * ) (stuff + 1 ), stuff -> context_len );
@@ -199,13 +211,17 @@ ProcSELinuxSetDeviceContext(ClientPtr client)
199
211
static int
200
212
ProcSELinuxGetDeviceContext (ClientPtr client )
201
213
{
214
+ REQUEST (SELinuxGetContextReq );
215
+ REQUEST_SIZE_MATCH (SELinuxGetContextReq );
216
+
217
+ if (client -> swapped ) {
218
+ swapl (& stuff -> id );
219
+ }
220
+
202
221
DeviceIntPtr dev ;
203
222
SELinuxSubjectRec * subj ;
204
223
int rc ;
205
224
206
- REQUEST (SELinuxGetContextReq );
207
- REQUEST_SIZE_MATCH (SELinuxGetContextReq );
208
-
209
225
rc = dixLookupDevice (& dev , stuff -> id , client , DixGetAttrAccess );
210
226
if (rc != Success )
211
227
return rc ;
@@ -217,14 +233,17 @@ ProcSELinuxGetDeviceContext(ClientPtr client)
217
233
static int
218
234
ProcSELinuxGetDrawableContext (ClientPtr client )
219
235
{
236
+ REQUEST (SELinuxGetContextReq );
237
+ REQUEST_SIZE_MATCH (SELinuxGetContextReq );
238
+
239
+ if (client -> swapped )
240
+ swapl (& stuff -> id );
241
+
220
242
DrawablePtr pDraw ;
221
243
PrivateRec * * privatePtr ;
222
244
SELinuxObjectRec * obj ;
223
245
int rc ;
224
246
225
- REQUEST (SELinuxGetContextReq );
226
- REQUEST_SIZE_MATCH (SELinuxGetContextReq );
227
-
228
247
rc = dixLookupDrawable (& pDraw , stuff -> id , client , 0 , DixGetAttrAccess );
229
248
if (rc != Success )
230
249
return rc ;
@@ -241,14 +260,19 @@ ProcSELinuxGetDrawableContext(ClientPtr client)
241
260
static int
242
261
ProcSELinuxGetPropertyContext (ClientPtr client , void * privKey )
243
262
{
263
+ REQUEST (SELinuxGetPropertyContextReq );
264
+ REQUEST_SIZE_MATCH (SELinuxGetPropertyContextReq );
265
+
266
+ if (client -> swapped ) {
267
+ swapl (& stuff -> window );
268
+ swapl (& stuff -> property );
269
+ }
270
+
244
271
WindowPtr pWin ;
245
272
PropertyPtr pProp ;
246
273
SELinuxObjectRec * obj ;
247
274
int rc ;
248
275
249
- REQUEST (SELinuxGetPropertyContextReq );
250
- REQUEST_SIZE_MATCH (SELinuxGetPropertyContextReq );
251
-
252
276
rc = dixLookupWindow (& pWin , stuff -> window , client , DixGetPropAccess );
253
277
if (rc != Success )
254
278
return rc ;
@@ -265,13 +289,16 @@ ProcSELinuxGetPropertyContext(ClientPtr client, void *privKey)
265
289
static int
266
290
ProcSELinuxGetSelectionContext (ClientPtr client , void * privKey )
267
291
{
292
+ REQUEST (SELinuxGetContextReq );
293
+ REQUEST_SIZE_MATCH (SELinuxGetContextReq );
294
+
295
+ if (client -> swapped )
296
+ swapl (& stuff -> id );
297
+
268
298
Selection * pSel ;
269
299
SELinuxObjectRec * obj ;
270
300
int rc ;
271
301
272
- REQUEST (SELinuxGetContextReq );
273
- REQUEST_SIZE_MATCH (SELinuxGetContextReq );
274
-
275
302
rc = dixLookupSelection (& pSel , stuff -> id , client , DixGetAttrAccess );
276
303
if (rc != Success )
277
304
return rc ;
@@ -283,13 +310,16 @@ ProcSELinuxGetSelectionContext(ClientPtr client, void *privKey)
283
310
static int
284
311
ProcSELinuxGetClientContext (ClientPtr client )
285
312
{
313
+ REQUEST (SELinuxGetContextReq );
314
+ REQUEST_SIZE_MATCH (SELinuxGetContextReq );
315
+
316
+ if (client -> swapped )
317
+ swapl (& stuff -> id );
318
+
286
319
ClientPtr target ;
287
320
SELinuxSubjectRec * subj ;
288
321
int rc ;
289
322
290
- REQUEST (SELinuxGetContextReq );
291
- REQUEST_SIZE_MATCH (SELinuxGetContextReq );
292
-
293
323
rc = dixLookupResourceOwner (& target , stuff -> id , client , DixGetAttrAccess );
294
324
if (rc != Success )
295
325
return rc ;
@@ -366,15 +396,18 @@ SELinuxSendItemsToClient(ClientPtr client, SELinuxListItemRec * items,
366
396
static int
367
397
ProcSELinuxListProperties (ClientPtr client )
368
398
{
399
+ REQUEST (SELinuxGetContextReq );
400
+ REQUEST_SIZE_MATCH (SELinuxGetContextReq );
401
+
402
+ if (client -> swapped )
403
+ swapl (& stuff -> id );
404
+
369
405
WindowPtr pWin ;
370
406
PropertyPtr pProp ;
371
407
SELinuxListItemRec * items ;
372
408
int rc , count , size , i ;
373
409
CARD32 id ;
374
410
375
- REQUEST (SELinuxGetContextReq );
376
- REQUEST_SIZE_MATCH (SELinuxGetContextReq );
377
-
378
411
rc = dixLookupWindow (& pWin , stuff -> id , client , DixListPropAccess );
379
412
if (rc != Success )
380
413
return rc ;
@@ -493,151 +526,6 @@ ProcSELinuxDispatch(ClientPtr client)
493
526
}
494
527
}
495
528
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
-
641
529
/*
642
530
* Extension Setup / Teardown
643
531
*/
@@ -673,5 +561,5 @@ SELinuxExtensionInit(void)
673
561
/* Add extension to server */
674
562
AddExtension (SELINUX_EXTENSION_NAME , SELinuxNumberEvents ,
675
563
SELinuxNumberErrors , ProcSELinuxDispatch ,
676
- SProcSELinuxDispatch , SELinuxResetProc , StandardMinorOpcode );
564
+ ProcSELinuxDispatch , SELinuxResetProc , StandardMinorOpcode );
677
565
}
0 commit comments