]> git.saurik.com Git - apple/launchd.git/blob - liblaunch/launch_priv.h
518cf958effd72f48f7bb766b1ca8f81b8f93fd7
[apple/launchd.git] / liblaunch / launch_priv.h
1 /*
2 * Copyright (c) 2005 Apple Computer, 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 __LAUNCH_PRIVATE_H__
22 #define __LAUNCH_PRIVATE_H__
23
24 #include <mach/mach.h>
25 #include <sys/types.h>
26 #include <launch.h>
27 #include <unistd.h>
28 #include <paths.h>
29 #include <uuid/uuid.h>
30
31 #pragma GCC visibility push(default)
32
33 __BEGIN_DECLS
34
35 #define LAUNCH_EXITSTATUS_FAIRPLAY_FAIL (INT64_MAX)
36
37 #define LAUNCH_KEY_SETUSERENVIRONMENT "SetUserEnvironment"
38 #define LAUNCH_KEY_UNSETUSERENVIRONMENT "UnsetUserEnvironment"
39 #define LAUNCH_KEY_SHUTDOWN "Shutdown"
40 #define LAUNCH_KEY_SINGLEUSER "SingleUser"
41 #define LAUNCH_KEY_GETRESOURCELIMITS "GetResourceLimits"
42 #define LAUNCH_KEY_SETRESOURCELIMITS "SetResourceLimits"
43 #define LAUNCH_KEY_GETRUSAGESELF "GetResourceUsageSelf"
44 #define LAUNCH_KEY_GETRUSAGECHILDREN "GetResourceUsageChildren"
45
46 #define LAUNCHD_SOCKET_ENV "LAUNCHD_SOCKET"
47 #define LAUNCHD_SOCK_PREFIX _PATH_VARTMP "launchd"
48 #define LAUNCHD_TRUSTED_FD_ENV "__LAUNCHD_FD"
49 #define LAUNCHD_ASYNC_MSG_KEY "_AsyncMessage"
50 #define LAUNCH_KEY_BATCHCONTROL "BatchControl"
51 #define LAUNCH_KEY_BATCHQUERY "BatchQuery"
52
53 #define LAUNCH_JOBKEY_TRANSACTIONCOUNT "TransactionCount"
54 #define LAUNCH_JOBKEY_QUARANTINEDATA "QuarantineData"
55 #define LAUNCH_JOBKEY_SANDBOXPROFILE "SandboxProfile"
56 #define LAUNCH_JOBKEY_SANDBOXFLAGS "SandboxFlags"
57 #define LAUNCH_JOBKEY_SANDBOX_NAMED "Named"
58 #define LAUNCH_JOBKEY_SANDBOXCONTAINER "SandboxContainer"
59 #define LAUNCH_JOBKEY_JETSAMPROPERTIES "JetsamProperties"
60 #define LAUNCH_JOBKEY_JETSAMPRIORITY "JetsamPriority"
61 #define LAUNCH_JOBKEY_JETSAMMEMORYLIMIT "JetsamMemoryLimit"
62 #define LAUNCH_JOBKEY_JETSAMMEMORYLIMITBACKGROUND "JetsamMemoryLimitBackground"
63 #define LAUNCH_JOBKEY_SECURITYSESSIONUUID "SecuritySessionUUID"
64 #define LAUNCH_JOBKEY_DISABLEASLR "DisableASLR"
65 #define LAUNCH_JOBKEY_XPCDOMAIN "XPCDomain"
66 #define LAUNCH_JOBKEY_POSIXSPAWNTYPE "POSIXSpawnType"
67
68 #define LAUNCH_KEY_JETSAMLABEL "JetsamLabel"
69 #define LAUNCH_KEY_JETSAMFRONTMOST "JetsamFrontmost"
70 #define LAUNCH_KEY_JETSAMACTIVE "JetsamActive"
71 #define LAUNCH_KEY_JETSAMPRIORITY LAUNCH_JOBKEY_JETSAMPRIORITY
72 #define LAUNCH_KEY_JETSAMMEMORYLIMIT LAUNCH_JOBKEY_JETSAMMEMORYLIMIT
73
74 #define LAUNCH_KEY_POSIXSPAWNTYPE_APP LAUNCH_KEY_PROCESSTYPE_APP
75 #define LAUNCH_KEY_POSIXSPAWNTYPE_SYSTEMAPP "SystemApp"
76 #define LAUNCH_KEY_POSIXSPAWNTYPE_STANDARD LAUNCH_KEY_PROCESSTYPE_STANDARD
77 #define LAUNCH_KEY_POSIXSPAWNTYPE_BACKGROUND LAUNCH_KEY_PROCESSTYPE_BACKGROUND
78 #define LAUNCH_KEY_POSIXSPAWNTYPE_INTERACTIVE LAUNCH_KEY_PROCESSTYPE_INTERACTIVE
79 #define LAUNCH_KEY_POSIXSPAWNTYPE_ADAPTIVE LAUNCH_KEY_PROCESSTYPE_ADAPTIVE
80 #define LAUNCH_KEY_POSIXSPAWNTYPE_TALAPP "TALApp"
81
82 #define LAUNCH_JOBKEY_EMBEDDEDPRIVILEGEDISPENSATION "EmbeddedPrivilegeDispensation"
83 #define LAUNCH_JOBKEY_EMBEDDEDHOMESCREEN "EmbeddedHomeScreen"
84 #define LAUNCH_JOBKEY_EMBEDDEDMAINTHREADPRIORITY "EmbeddedMainThreadPriority"
85
86 #define LAUNCH_JOBKEY_ENTERKERNELDEBUGGERBEFOREKILL "EnterKernelDebuggerBeforeKill"
87 #define LAUNCH_JOBKEY_PERJOBMACHSERVICES "PerJobMachServices"
88 #define LAUNCH_JOBKEY_SERVICEIPC "ServiceIPC"
89 #define LAUNCH_JOBKEY_BINARYORDERPREFERENCE "BinaryOrderPreference"
90 #define LAUNCH_JOBKEY_MACHEXCEPTIONHANDLER "MachExceptionHandler"
91 #define LAUNCH_JOBKEY_MULTIPLEINSTANCES "MultipleInstances"
92 #define LAUNCH_JOBKEY_EVENTMONITOR "EventMonitor"
93 #define LAUNCH_JOBKEY_SHUTDOWNMONITOR "ShutdownMonitor"
94 #define LAUNCH_JOBKEY_BEGINTRANSACTIONATSHUTDOWN "BeginTransactionAtShutdown"
95 #define LAUNCH_JOBKEY_XPCDOMAINBOOTSTRAPPER "XPCDomainBootstrapper"
96 #define LAUNCH_JOBKEY_ASID "AuditSessionID"
97 #define LAUNCH_JOBKEY_JOINGUISESSION "JoinGUISession"
98
99 #define LAUNCH_JOBKEY_MACH_KUNCSERVER "kUNCServer"
100 #define LAUNCH_JOBKEY_MACH_EXCEPTIONSERVER "ExceptionServer"
101 #define LAUNCH_JOBKEY_MACH_TASKSPECIALPORT "TaskSpecialPort"
102 #define LAUNCH_JOBKEY_MACH_HOSTSPECIALPORT "HostSpecialPort"
103 #define LAUNCH_JOBKEY_MACH_ENTERKERNELDEBUGGERONCLOSE "EnterKernelDebuggerOnClose"
104 #define LAUNCH_JOBKEY_LOWPRIORITYBACKGROUNDIO "LowPriorityBackgroundIO"
105
106 #define LAUNCH_ENV_INSTANCEID "LaunchInstanceID"
107
108 #define JETSAM_PROPERTY_PRIORITY "Priority"
109 #define JETSAM_PROPERTY_MEMORYLIMIT "MemoryLimitMB"
110
111 /* For LoginWindow.
112 *
113 * After this call, the task's bootstrap port is set to the per session launchd.
114 *
115 * This returns 1 on success (it used to return otherwise), and -1 on failure.
116 */
117 #define LOAD_ONLY_SAFEMODE_LAUNCHAGENTS (1 << 0)
118 #define LAUNCH_GLOBAL_ON_DEMAND (1 << 1)
119 pid_t
120 create_and_switch_to_per_session_launchd(const char *, int flags, ...);
121
122 /* Also for LoginWindow.
123 *
124 * This is will load jobs at the LoginWindow prompt.
125 */
126 void
127 load_launchd_jobs_at_loginwindow_prompt(int flags, ...);
128
129 /* For CoreProcesses */
130 #define SPAWN_VIA_LAUNCHD_STOPPED 0x0001
131 #define SPAWN_VIA_LAUNCHD_TALAPP 0x0002
132 #define SPAWN_VIA_LAUNCHD_WIDGET 0x0004
133 #define SPAWN_VIA_LAUNCHD_DISABLE_ASLR 0x0008
134
135 struct spawn_via_launchd_attr {
136 uint64_t spawn_flags;
137 const char *spawn_path;
138 const char *spawn_chdir;
139 const char * const * spawn_env;
140 const mode_t *spawn_umask;
141 mach_port_t *spawn_observer_port;
142 const cpu_type_t *spawn_binpref;
143 size_t spawn_binpref_cnt;
144 void * spawn_quarantine;
145 const char *spawn_seatbelt_profile;
146 const uint64_t *spawn_seatbelt_flags;
147 };
148
149 #define spawn_via_launchd(a, b, c) _spawn_via_launchd(a, b, c, 3)
150 pid_t
151 _spawn_via_launchd(const char *label, const char * const *argv,
152 const struct spawn_via_launchd_attr *spawn_attrs, int struct_version);
153
154 int
155 launch_wait(mach_port_t port);
156
157 /* The mpm_*() APIs no longer do anything. */
158 kern_return_t
159 mpm_wait(mach_port_t ajob, int *wstatus);
160
161 kern_return_t
162 mpm_uncork_fork(mach_port_t ajob);
163
164 launch_data_t
165 launch_socket_service_check_in(void);
166
167 __END_DECLS
168
169 #pragma GCC visibility pop
170
171
172 #endif /* __LAUNCH_PRIVATE_H__ */