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