]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Copyright (c) 2006-2012 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_PRIVATE_H__ | |
22 | #define __VPROC_PRIVATE_H__ | |
23 | ||
24 | #include <Availability.h> | |
25 | #include <sys/types.h> | |
26 | #include <sys/cdefs.h> | |
27 | #include <sys/syslog.h> | |
28 | #include <sys/time.h> | |
29 | #include <stdbool.h> | |
30 | #include <launch.h> | |
31 | #include <vproc.h> | |
32 | #include <uuid/uuid.h> | |
33 | #include <servers/bootstrap.h> | |
34 | #include <dispatch/dispatch.h> | |
35 | ||
36 | #ifndef VPROC_HAS_TRANSACTIONS | |
37 | #define VPROC_HAS_TRANSACTIONS 1 | |
38 | #endif | |
39 | ||
40 | __BEGIN_DECLS | |
41 | ||
42 | #define VPROCMGR_SESSION_LOGINWINDOW "LoginWindow" | |
43 | #define VPROCMGR_SESSION_BACKGROUND "Background" | |
44 | #define VPROCMGR_SESSION_AQUA "Aqua" | |
45 | #define VPROCMGR_SESSION_STANDARDIO "StandardIO" | |
46 | #define VPROCMGR_SESSION_SYSTEM "System" | |
47 | ||
48 | #define XPC_DOMAIN_TYPE_SYSTEM "XPCSystem" | |
49 | #define XPC_DOMAIN_TYPE_PERUSER "XPCPerUser" | |
50 | #define XPC_DOMAIN_TYPE_PERSESSION "XPCPerSession" | |
51 | #define XPC_DOMAIN_TYPE_PERAPPLICATION "XPCPerApplication" | |
52 | ||
53 | #pragma GCC visibility push(default) | |
54 | ||
55 | /* DO NOT use this. This is a hack for 'launchctl' */ | |
56 | #define VPROC_MAGIC_UNLOAD_SIGNAL 0x4141504C | |
57 | ||
58 | typedef void (*_vproc_transaction_callout)(void *); | |
59 | ||
60 | typedef enum { | |
61 | VPROC_GSK_ZERO, | |
62 | VPROC_GSK_LAST_EXIT_STATUS, | |
63 | VPROC_GSK_GLOBAL_ON_DEMAND, | |
64 | VPROC_GSK_MGR_UID, | |
65 | VPROC_GSK_MGR_PID, | |
66 | VPROC_GSK_IS_MANAGED, | |
67 | VPROC_GSK_MGR_NAME, | |
68 | VPROC_GSK_BASIC_KEEPALIVE, | |
69 | VPROC_GSK_START_INTERVAL, | |
70 | VPROC_GSK_IDLE_TIMEOUT, | |
71 | VPROC_GSK_EXIT_TIMEOUT, | |
72 | VPROC_GSK_ENVIRONMENT, | |
73 | VPROC_GSK_ALLJOBS, | |
74 | VPROC_GSK_GLOBAL_LOG_MASK, | |
75 | VPROC_GSK_GLOBAL_UMASK, | |
76 | VPROC_GSK_ABANDON_PROCESS_GROUP, | |
77 | VPROC_GSK_TRANSACTIONS_ENABLED, | |
78 | VPROC_GSK_WEIRD_BOOTSTRAP, | |
79 | VPROC_GSK_WAITFORDEBUGGER, | |
80 | VPROC_GSK_SECURITYSESSION, | |
81 | VPROC_GSK_SHUTDOWN_DEBUGGING, | |
82 | VPROC_GSK_VERBOSE_BOOT, | |
83 | VPROC_GSK_PERUSER_SUSPEND, | |
84 | VPROC_GSK_PERUSER_RESUME, | |
85 | VPROC_GSK_JOB_OVERRIDES_DB, | |
86 | VPROC_GSK_JOB_CACHE_DB, | |
87 | VPROC_GSK_EMBEDDEDROOTEQUIVALENT, | |
88 | } vproc_gsk_t; | |
89 | ||
90 | typedef unsigned int vproc_flags_t; | |
91 | /* For _vproc_kickstart_by_label() -- instructs launchd to kickstart the job to stall before exec(2). */ | |
92 | #define VPROCFLAG_STALL_JOB_EXEC 1 << 1 | |
93 | ||
94 | __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_0) | |
95 | vproc_t | |
96 | vprocmgr_lookup_vproc(const char *label); | |
97 | ||
98 | __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_0) | |
99 | vproc_t | |
100 | vproc_retain(vproc_t vp); | |
101 | ||
102 | __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_0) | |
103 | void | |
104 | vproc_release(vproc_t vp); | |
105 | ||
106 | __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_0) | |
107 | vproc_err_t | |
108 | vproc_swap_integer(vproc_t vp, vproc_gsk_t key, | |
109 | int64_t *inval, int64_t *outval); | |
110 | ||
111 | __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_0) | |
112 | vproc_err_t | |
113 | vproc_swap_complex(vproc_t vp, vproc_gsk_t key, | |
114 | launch_data_t inval, launch_data_t *outval); | |
115 | ||
116 | __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_4_0) | |
117 | vproc_err_t | |
118 | vproc_swap_string(vproc_t vp, vproc_gsk_t key, | |
119 | const char *instr, char **outstr); | |
120 | ||
121 | __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_NA) | |
122 | vproc_err_t | |
123 | _vproc_get_last_exit_status(int *wstatus); | |
124 | ||
125 | __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_0) | |
126 | vproc_err_t | |
127 | _vproc_set_global_on_demand(bool val); | |
128 | ||
129 | __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_0) | |
130 | vproc_err_t | |
131 | _vproc_send_signal_by_label(const char *label, int sig); | |
132 | ||
133 | __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_0) | |
134 | vproc_err_t | |
135 | _vproc_kickstart_by_label(const char *label, pid_t *out_pid, | |
136 | mach_port_t *out_port_name, mach_port_t *out_obsrvr_port, | |
137 | vproc_flags_t flags); | |
138 | ||
139 | /* _vprocmgr_log_drain() is specific to syslogd. It is not for general use. */ | |
140 | typedef void (*_vprocmgr_log_drain_callback_t)(struct timeval *when, pid_t | |
141 | from_pid, pid_t about_pid, uid_t sender_uid, gid_t sender_gid, int priority, | |
142 | const char *from_name, const char *about_name, const char *session_name, | |
143 | const char *msg); | |
144 | ||
145 | vproc_err_t | |
146 | _vprocmgr_log_drain(vproc_t vp, pthread_mutex_t *optional_mutex_around_callback, | |
147 | _vprocmgr_log_drain_callback_t func); | |
148 | ||
149 | __attribute__((format(printf, 2, 3))) | |
150 | void | |
151 | _vproc_log(int pri, const char *msg, ...); | |
152 | ||
153 | __attribute__((format(printf, 2, 3))) | |
154 | void | |
155 | _vproc_log_error(int pri, const char *msg, ...); | |
156 | ||
157 | __attribute__((format(printf, 3, 0))) | |
158 | void | |
159 | _vproc_logv(int pri, int err, const char *msg, va_list ap); | |
160 | ||
161 | /* One day, we'll be able to get rid of this... */ | |
162 | vproc_err_t | |
163 | _vprocmgr_move_subset_to_user(uid_t target_user, const char *session_type, | |
164 | uint64_t flags); | |
165 | ||
166 | vproc_err_t | |
167 | _vprocmgr_switch_to_session(const char *target_session, vproc_flags_t flags); | |
168 | ||
169 | vproc_err_t | |
170 | _vprocmgr_detach_from_console(vproc_flags_t flags); | |
171 | ||
172 | __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) | |
173 | void | |
174 | _vproc_standby_begin(void); | |
175 | ||
176 | __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) | |
177 | void | |
178 | _vproc_standby_end(void); | |
179 | ||
180 | __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) | |
181 | size_t | |
182 | _vproc_standby_count(void); | |
183 | ||
184 | __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) | |
185 | size_t | |
186 | _vproc_standby_timeout(void); | |
187 | ||
188 | __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) | |
189 | kern_return_t | |
190 | _vproc_transaction_count_for_pid(pid_t p, int32_t *count, bool *condemned); | |
191 | ||
192 | __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) | |
193 | bool | |
194 | _vproc_pid_is_managed(pid_t p); | |
195 | ||
196 | __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) | |
197 | void | |
198 | _vproc_transaction_try_exit(int status); | |
199 | ||
200 | __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_5_0) | |
201 | void | |
202 | _vproc_transaction_begin(void); | |
203 | ||
204 | __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_5_0) | |
205 | void | |
206 | _vproc_transaction_end(void); | |
207 | ||
208 | __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) | |
209 | size_t | |
210 | _vproc_transaction_count(void); | |
211 | ||
212 | void | |
213 | _vproc_transaction_set_clean_callback(dispatch_queue_t targetq, void *ctx, | |
214 | dispatch_function_t func); | |
215 | ||
216 | void | |
217 | _vproc_transactions_enable(void); | |
218 | ||
219 | #pragma GCC visibility pop | |
220 | ||
221 | __END_DECLS | |
222 | ||
223 | #endif /* __VPROC_PRIVATE_H__ */ |