]> git.saurik.com Git - apple/launchd.git/blob - liblaunch/vproc_internal.h
a47553ee80f1ea871293b8ffe15c2b5cb8871e35
[apple/launchd.git] / liblaunch / vproc_internal.h
1 /*
2 * Copyright (c) 2006-2007 Apple Inc. All rights reserved.
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * @APPLE_APACHE_LICENSE_HEADER_END@
19 */
20
21 #ifndef __VPROC_INTERNAL_H__
22 #define __VPROC_INTERNAL_H__
23
24 #include <mach/mach.h>
25 #include <sys/queue.h>
26 #include <sys/time.h>
27 #include <stdarg.h>
28 #include <sys/syscall.h>
29 #include <bsm/audit.h>
30 #include "launch.h"
31 #include "bootstrap_priv.h"
32 #include "vproc.h"
33
34 typedef char * _internal_string_t;
35 typedef char * logmsg_t;
36 typedef pid_t * pid_array_t;
37 typedef mach_port_t vproc_mig_t;
38
39 #if defined(job_MSG_COUNT) || defined (xpc_domain_MSG_COUNT)
40 /* HACK */
41 #include "core.h"
42 #endif
43
44 #define VPROC_ERR_TRY_PER_USER 1099
45
46 #pragma GCC visibility push(default)
47
48 vproc_err_t _vprocmgr_init(const char *session_type);
49 vproc_err_t _vproc_post_fork_ping(void);
50
51 #if !TARGET_OS_EMBEDDED
52 #define _audit_session_self(v) (mach_port_t)syscall(SYS_audit_session_self)
53 #define _audit_session_join(s) (au_asid_t)syscall(SYS_audit_session_join, session)
54 #else
55 #define _audit_session_self(v) MACH_PORT_NULL
56 #define _audit_session_join(s) 0
57 #endif
58
59 #if __arm__
60 #define __LAUNCH_MACH_PORT_CONTEXT_T_DEFINED__ 1
61 #else
62 #define __LAUNCH_MACH_PORT_CONTEXT_T_DEFINED__ 0
63 #endif
64
65 #define SPAWN_HAS_PATH 0x0001
66 #define SPAWN_HAS_WDIR 0x0002
67 #define SPAWN_HAS_UMASK 0x0004
68 #define SPAWN_WANTS_WAIT4DEBUGGER 0x0008
69
70 kern_return_t
71 _vproc_grab_subset(mach_port_t bp, mach_port_t *reqport, mach_port_t *rcvright, launch_data_t *outval,
72 mach_port_array_t *ports, mach_msg_type_number_t *portCnt);
73
74 kern_return_t _vprocmgr_getsocket(name_t);
75
76 struct logmsg_s {
77 union {
78 STAILQ_ENTRY(logmsg_s) sqe;
79 uint64_t __pad;
80 };
81 int64_t when;
82 pid_t from_pid;
83 pid_t about_pid;
84 uid_t sender_uid;
85 gid_t sender_gid;
86 int err_num;
87 int pri;
88 union {
89 const char *from_name;
90 uint64_t from_name_offset;
91 };
92 union {
93 const char *about_name;
94 uint64_t about_name_offset;
95 };
96 union {
97 const char *session_name;
98 uint64_t session_name_offset;
99 };
100 union {
101 const char *msg;
102 uint64_t msg_offset;
103 };
104 uint64_t obj_sz;
105 char data[0];
106 };
107
108
109 vproc_err_t _vprocmgr_log_forward(mach_port_t mp, void *data, size_t len);
110
111 kern_return_t
112 bootstrap_info(mach_port_t bp,
113 name_array_t *service_names,
114 mach_msg_type_number_t *service_namesCnt,
115 name_array_t *service_jobs,
116 mach_msg_type_number_t *service_jobsCnt,
117 bootstrap_status_array_t *service_active,
118 mach_msg_type_number_t *service_activeCnt,
119 uint64_t flags);
120
121 #pragma GCC visibility pop
122
123 #endif /* __VPROC_INTERNAL_H__ */