1/*
2 * IDENTIFICATION:
3 * stub generated Tue Apr 9 11:33:41 2019
4 * with a MiG generated by bootstrap_cmds-96.20.2.200.4
5 * OPTIONS:
6 * KernelServer
7 */
8
9/* Module host_security */
10
11#define __MIG_check__Request__host_security_subsystem__ 1
12
13#include "host_security_server.h"
14
15#ifndef mig_internal
16#define mig_internal static __inline__
17#endif /* mig_internal */
18
19#ifndef mig_external
20#define mig_external
21#endif /* mig_external */
22
23#if !defined(__MigTypeCheck) && defined(TypeCheck)
24#define __MigTypeCheck TypeCheck /* Legacy setting */
25#endif /* !defined(__MigTypeCheck) */
26
27#if !defined(__MigKernelSpecificCode) && defined(_MIG_KERNEL_SPECIFIC_CODE_)
28#define __MigKernelSpecificCode _MIG_KERNEL_SPECIFIC_CODE_ /* Legacy setting */
29#endif /* !defined(__MigKernelSpecificCode) */
30
31#ifndef LimitCheck
32#define LimitCheck 0
33#endif /* LimitCheck */
34
35#ifndef min
36#define min(a,b) ( ((a) < (b))? (a): (b) )
37#endif /* min */
38
39#if !defined(_WALIGN_)
40#define _WALIGN_(x) (((x) + 3) & ~3)
41#endif /* !defined(_WALIGN_) */
42
43#if !defined(_WALIGNSZ_)
44#define _WALIGNSZ_(x) _WALIGN_(sizeof(x))
45#endif /* !defined(_WALIGNSZ_) */
46
47#ifndef UseStaticTemplates
48#define UseStaticTemplates 0
49#endif /* UseStaticTemplates */
50
51#ifndef __DeclareRcvRpc
52#define __DeclareRcvRpc(_NUM_, _NAME_)
53#endif /* __DeclareRcvRpc */
54
55#ifndef __BeforeRcvRpc
56#define __BeforeRcvRpc(_NUM_, _NAME_)
57#endif /* __BeforeRcvRpc */
58
59#ifndef __AfterRcvRpc
60#define __AfterRcvRpc(_NUM_, _NAME_)
61#endif /* __AfterRcvRpc */
62
63#ifndef __DeclareRcvSimple
64#define __DeclareRcvSimple(_NUM_, _NAME_)
65#endif /* __DeclareRcvSimple */
66
67#ifndef __BeforeRcvSimple
68#define __BeforeRcvSimple(_NUM_, _NAME_)
69#endif /* __BeforeRcvSimple */
70
71#ifndef __AfterRcvSimple
72#define __AfterRcvSimple(_NUM_, _NAME_)
73#endif /* __AfterRcvSimple */
74
75#define novalue void
76
77#if __MigKernelSpecificCode
78#define msgh_request_port msgh_remote_port
79#define MACH_MSGH_BITS_REQUEST(bits) MACH_MSGH_BITS_REMOTE(bits)
80#define msgh_reply_port msgh_local_port
81#define MACH_MSGH_BITS_REPLY(bits) MACH_MSGH_BITS_LOCAL(bits)
82#else
83#define msgh_request_port msgh_local_port
84#define MACH_MSGH_BITS_REQUEST(bits) MACH_MSGH_BITS_LOCAL(bits)
85#define msgh_reply_port msgh_remote_port
86#define MACH_MSGH_BITS_REPLY(bits) MACH_MSGH_BITS_REMOTE(bits)
87#endif /* __MigKernelSpecificCode */
88
89#define MIG_RETURN_ERROR(X, code) {\
90 ((mig_reply_error_t *)X)->RetCode = code;\
91 ((mig_reply_error_t *)X)->NDR = NDR_record;\
92 return;\
93 }
94
95/* Forward Declarations */
96
97
98mig_internal novalue _Xhost_security_create_task_token
99 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP);
100
101mig_internal novalue _Xhost_security_set_task_token
102 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP);
103
104
105#if ( __MigTypeCheck )
106#if __MIG_check__Request__host_security_subsystem__
107#if !defined(__MIG_check__Request__host_security_create_task_token_t__defined)
108#define __MIG_check__Request__host_security_create_task_token_t__defined
109
110mig_internal kern_return_t __MIG_check__Request__host_security_create_task_token_t(__attribute__((__unused__)) __Request__host_security_create_task_token_t *In0P)
111{
112
113 typedef __Request__host_security_create_task_token_t __Request;
114#if __MigTypeCheck
115 if (!(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) ||
116 (In0P->msgh_body.msgh_descriptor_count != 3) ||
117 (In0P->Head.msgh_size != (mach_msg_size_t)sizeof(__Request)))
118 return MIG_BAD_ARGUMENTS;
119#endif /* __MigTypeCheck */
120
121#if __MigTypeCheck
122 if (In0P->parent_task.type != MACH_MSG_PORT_DESCRIPTOR ||
123 In0P->parent_task.disposition != 17)
124 return MIG_TYPE_ERROR;
125#endif /* __MigTypeCheck */
126
127#if __MigTypeCheck
128 if (In0P->host.type != MACH_MSG_PORT_DESCRIPTOR ||
129 In0P->host.disposition != 17)
130 return MIG_TYPE_ERROR;
131#endif /* __MigTypeCheck */
132
133#if __MigTypeCheck
134 if (In0P->ledgers.type != MACH_MSG_OOL_PORTS_DESCRIPTOR ||
135 In0P->ledgers.disposition != 17)
136 return MIG_TYPE_ERROR;
137#endif /* __MigTypeCheck */
138
139 return MACH_MSG_SUCCESS;
140}
141#endif /* !defined(__MIG_check__Request__host_security_create_task_token_t__defined) */
142#endif /* __MIG_check__Request__host_security_subsystem__ */
143#endif /* ( __MigTypeCheck ) */
144
145
146/* Routine host_security_create_task_token */
147mig_internal novalue _Xhost_security_create_task_token
148 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
149{
150
151#ifdef __MigPackStructs
152#pragma pack(4)
153#endif
154 typedef struct {
155 mach_msg_header_t Head;
156 /* start of the kernel processed data */
157 mach_msg_body_t msgh_body;
158 mach_msg_port_descriptor_t parent_task;
159 mach_msg_port_descriptor_t host;
160 mach_msg_ool_ports_descriptor_t ledgers;
161 /* end of the kernel processed data */
162 NDR_record_t NDR;
163 security_token_t sec_token;
164 audit_token_t audit_token;
165 mach_msg_type_number_t ledgersCnt;
166 boolean_t inherit_memory;
167 mach_msg_trailer_t trailer;
168 } Request __attribute__((unused));
169#ifdef __MigPackStructs
170#pragma pack()
171#endif
172 typedef __Request__host_security_create_task_token_t __Request;
173 typedef __Reply__host_security_create_task_token_t Reply __attribute__((unused));
174
175 /*
176 * typedef struct {
177 * mach_msg_header_t Head;
178 * NDR_record_t NDR;
179 * kern_return_t RetCode;
180 * } mig_reply_error_t;
181 */
182
183 Request *In0P = (Request *) InHeadP;
184 Reply *OutP = (Reply *) OutHeadP;
185#ifdef __MIG_check__Request__host_security_create_task_token_t__defined
186 kern_return_t check_result;
187#endif /* __MIG_check__Request__host_security_create_task_token_t__defined */
188
189#if __MigKernelSpecificCode
190#if UseStaticTemplates
191 const static mach_msg_port_descriptor_t child_taskTemplate = {
192 /* name = */ MACH_PORT_NULL,
193 /* pad1 = */ 0,
194 /* pad2 = */ 0,
195 /* disp = */ 17,
196 /* type = */ MACH_MSG_PORT_DESCRIPTOR,
197 };
198#endif /* UseStaticTemplates */
199
200#else
201#if UseStaticTemplates
202 const static mach_msg_port_descriptor_t child_taskTemplate = {
203 /* name = */ MACH_PORT_NULL,
204 /* pad1 = */ 0,
205 /* pad2 = */ 0,
206 /* disp = */ 19,
207 /* type = */ MACH_MSG_PORT_DESCRIPTOR,
208 };
209#endif /* UseStaticTemplates */
210
211#endif /* __MigKernelSpecificCode */
212 kern_return_t RetCode;
213 task_t parent_task;
214 task_t child_task;
215
216 __DeclareRcvRpc(600, "host_security_create_task_token")
217 __BeforeRcvRpc(600, "host_security_create_task_token")
218
219#if defined(__MIG_check__Request__host_security_create_task_token_t__defined)
220 check_result = __MIG_check__Request__host_security_create_task_token_t((__Request *)In0P);
221 if (check_result != MACH_MSG_SUCCESS)
222 { MIG_RETURN_ERROR(OutP, check_result); }
223#endif /* defined(__MIG_check__Request__host_security_create_task_token_t__defined) */
224
225#if UseStaticTemplates
226 OutP->child_task = child_taskTemplate;
227#else /* UseStaticTemplates */
228#if __MigKernelSpecificCode
229 OutP->child_task.disposition = 17;
230#else
231 OutP->child_task.disposition = 19;
232#endif /* __MigKernelSpecificCode */
233#if !(defined(KERNEL) && defined(__LP64__))
234 OutP->child_task.pad1 = 0;
235#endif
236 OutP->child_task.pad2 = 0;
237 OutP->child_task.type = MACH_MSG_PORT_DESCRIPTOR;
238#if defined(KERNEL)
239 OutP->child_task.pad_end = 0;
240#endif
241#endif /* UseStaticTemplates */
242
243
244 parent_task = convert_port_to_task(In0P->parent_task.name);
245
246 RetCode = host_security_create_task_token(convert_port_to_host_security(In0P->Head.msgh_request_port), parent_task, In0P->sec_token, In0P->audit_token, convert_port_to_host(In0P->host.name), (ledger_array_t)(In0P->ledgers.address), In0P->ledgers.count, In0P->inherit_memory, &child_task);
247 task_deallocate(parent_task);
248 if (RetCode != KERN_SUCCESS) {
249 MIG_RETURN_ERROR(OutP, RetCode);
250 }
251#if __MigKernelSpecificCode
252
253 if (IP_VALID((ipc_port_t)In0P->host.name))
254 ipc_port_release_send((ipc_port_t)In0P->host.name);
255
256 if (IP_VALID((ipc_port_t)In0P->parent_task.name))
257 ipc_port_release_send((ipc_port_t)In0P->parent_task.name);
258#endif /* __MigKernelSpecificCode */
259 OutP->child_task.name = (mach_port_t)convert_task_to_port(child_task);
260
261
262 OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX;
263 OutP->Head.msgh_size = (mach_msg_size_t)(sizeof(Reply));
264 OutP->msgh_body.msgh_descriptor_count = 1;
265 __AfterRcvRpc(600, "host_security_create_task_token")
266}
267
268#if ( __MigTypeCheck )
269#if __MIG_check__Request__host_security_subsystem__
270#if !defined(__MIG_check__Request__host_security_set_task_token_t__defined)
271#define __MIG_check__Request__host_security_set_task_token_t__defined
272
273mig_internal kern_return_t __MIG_check__Request__host_security_set_task_token_t(__attribute__((__unused__)) __Request__host_security_set_task_token_t *In0P)
274{
275
276 typedef __Request__host_security_set_task_token_t __Request;
277#if __MigTypeCheck
278 if (!(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) ||
279 (In0P->msgh_body.msgh_descriptor_count != 2) ||
280 (In0P->Head.msgh_size != (mach_msg_size_t)sizeof(__Request)))
281 return MIG_BAD_ARGUMENTS;
282#endif /* __MigTypeCheck */
283
284#if __MigTypeCheck
285 if (In0P->target_task.type != MACH_MSG_PORT_DESCRIPTOR ||
286 In0P->target_task.disposition != 17)
287 return MIG_TYPE_ERROR;
288#endif /* __MigTypeCheck */
289
290#if __MigTypeCheck
291 if (In0P->host.type != MACH_MSG_PORT_DESCRIPTOR ||
292 In0P->host.disposition != 17)
293 return MIG_TYPE_ERROR;
294#endif /* __MigTypeCheck */
295
296 return MACH_MSG_SUCCESS;
297}
298#endif /* !defined(__MIG_check__Request__host_security_set_task_token_t__defined) */
299#endif /* __MIG_check__Request__host_security_subsystem__ */
300#endif /* ( __MigTypeCheck ) */
301
302
303/* Routine host_security_set_task_token */
304mig_internal novalue _Xhost_security_set_task_token
305 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
306{
307
308#ifdef __MigPackStructs
309#pragma pack(4)
310#endif
311 typedef struct {
312 mach_msg_header_t Head;
313 /* start of the kernel processed data */
314 mach_msg_body_t msgh_body;
315 mach_msg_port_descriptor_t target_task;
316 mach_msg_port_descriptor_t host;
317 /* end of the kernel processed data */
318 NDR_record_t NDR;
319 security_token_t sec_token;
320 audit_token_t audit_token;
321 mach_msg_trailer_t trailer;
322 } Request __attribute__((unused));
323#ifdef __MigPackStructs
324#pragma pack()
325#endif
326 typedef __Request__host_security_set_task_token_t __Request;
327 typedef __Reply__host_security_set_task_token_t Reply __attribute__((unused));
328
329 /*
330 * typedef struct {
331 * mach_msg_header_t Head;
332 * NDR_record_t NDR;
333 * kern_return_t RetCode;
334 * } mig_reply_error_t;
335 */
336
337 Request *In0P = (Request *) InHeadP;
338 Reply *OutP = (Reply *) OutHeadP;
339#ifdef __MIG_check__Request__host_security_set_task_token_t__defined
340 kern_return_t check_result;
341#endif /* __MIG_check__Request__host_security_set_task_token_t__defined */
342
343#if __MigKernelSpecificCode
344#else
345#endif /* __MigKernelSpecificCode */
346 task_t target_task;
347
348 __DeclareRcvRpc(601, "host_security_set_task_token")
349 __BeforeRcvRpc(601, "host_security_set_task_token")
350
351#if defined(__MIG_check__Request__host_security_set_task_token_t__defined)
352 check_result = __MIG_check__Request__host_security_set_task_token_t((__Request *)In0P);
353 if (check_result != MACH_MSG_SUCCESS)
354 { MIG_RETURN_ERROR(OutP, check_result); }
355#endif /* defined(__MIG_check__Request__host_security_set_task_token_t__defined) */
356
357 target_task = convert_port_to_task(In0P->target_task.name);
358
359 OutP->RetCode = host_security_set_task_token(convert_port_to_host_security(In0P->Head.msgh_request_port), target_task, In0P->sec_token, In0P->audit_token, convert_port_to_host(In0P->host.name));
360 task_deallocate(target_task);
361#if __MigKernelSpecificCode
362 if (OutP->RetCode != KERN_SUCCESS) {
363 MIG_RETURN_ERROR(OutP, OutP->RetCode);
364 }
365
366 if (IP_VALID((ipc_port_t)In0P->host.name))
367 ipc_port_release_send((ipc_port_t)In0P->host.name);
368
369 if (IP_VALID((ipc_port_t)In0P->target_task.name))
370 ipc_port_release_send((ipc_port_t)In0P->target_task.name);
371#endif /* __MigKernelSpecificCode */
372
373 OutP->NDR = NDR_record;
374
375
376 __AfterRcvRpc(601, "host_security_set_task_token")
377}
378
379
380
381/* Description of this subsystem, for use in direct RPC */
382const struct host_security_subsystem host_security_subsystem = {
383 host_security_server_routine,
384 600,
385 602,
386 (mach_msg_size_t)sizeof(union __ReplyUnion__host_security_subsystem),
387 (vm_address_t)0,
388 {
389 { (mig_impl_routine_t) 0,
390 (mig_stub_routine_t) _Xhost_security_create_task_token, 17, 0, (routine_arg_descriptor_t)0, (mach_msg_size_t)sizeof(__Reply__host_security_create_task_token_t)},
391 { (mig_impl_routine_t) 0,
392 (mig_stub_routine_t) _Xhost_security_set_task_token, 13, 0, (routine_arg_descriptor_t)0, (mach_msg_size_t)sizeof(__Reply__host_security_set_task_token_t)},
393 }
394};
395
396mig_external boolean_t host_security_server
397 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
398{
399 /*
400 * typedef struct {
401 * mach_msg_header_t Head;
402 * NDR_record_t NDR;
403 * kern_return_t RetCode;
404 * } mig_reply_error_t;
405 */
406
407 register mig_routine_t routine;
408
409 OutHeadP->msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InHeadP->msgh_bits), 0);
410 OutHeadP->msgh_remote_port = InHeadP->msgh_reply_port;
411 /* Minimal size: routine() will update it if different */
412 OutHeadP->msgh_size = (mach_msg_size_t)sizeof(mig_reply_error_t);
413 OutHeadP->msgh_local_port = MACH_PORT_NULL;
414 OutHeadP->msgh_id = InHeadP->msgh_id + 100;
415 OutHeadP->msgh_reserved = 0;
416
417 if ((InHeadP->msgh_id > 601) || (InHeadP->msgh_id < 600) ||
418 ((routine = host_security_subsystem.routine[InHeadP->msgh_id - 600].stub_routine) == 0)) {
419 ((mig_reply_error_t *)OutHeadP)->NDR = NDR_record;
420 ((mig_reply_error_t *)OutHeadP)->RetCode = MIG_BAD_ID;
421 return FALSE;
422 }
423 (*routine) (InHeadP, OutHeadP);
424 return TRUE;
425}
426
427mig_external mig_routine_t host_security_server_routine
428 (mach_msg_header_t *InHeadP)
429{
430 register int msgh_id;
431
432 msgh_id = InHeadP->msgh_id - 600;
433
434 if ((msgh_id > 1) || (msgh_id < 0))
435 return 0;
436
437 return host_security_subsystem.routine[msgh_id].stub_routine;
438}
439