]>
Commit | Line | Data |
---|---|---|
e91b9f68 A |
1 | /* |
2 | * Copyright (c) 2005 Apple Computer, Inc. All rights reserved. | |
3 | * | |
ed34e3c3 | 4 | * @APPLE_APACHE_LICENSE_HEADER_START@ |
e91b9f68 | 5 | * |
ed34e3c3 A |
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 | |
e91b9f68 | 9 | * |
ed34e3c3 A |
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 | |
e91b9f68 A |
16 | * limitations under the License. |
17 | * | |
ed34e3c3 | 18 | * @APPLE_APACHE_LICENSE_HEADER_END@ |
e91b9f68 A |
19 | */ |
20 | #ifndef _LAUNCH_PRIV_H_ | |
21 | #define _LAUNCH_PRIV_H_ | |
22 | ||
5b0a4722 A |
23 | #include <mach/mach.h> |
24 | #include <sys/types.h> | |
ed34e3c3 | 25 | #include <launch.h> |
5b0a4722 A |
26 | #include <unistd.h> |
27 | #include <quarantine.h> | |
28 | ||
29 | #pragma GCC visibility push(default) | |
ed34e3c3 A |
30 | |
31 | __BEGIN_DECLS | |
32 | ||
ed34e3c3 A |
33 | #define LAUNCH_KEY_SETUSERENVIRONMENT "SetUserEnvironment" |
34 | #define LAUNCH_KEY_UNSETUSERENVIRONMENT "UnsetUserEnvironment" | |
ed34e3c3 A |
35 | #define LAUNCH_KEY_SHUTDOWN "Shutdown" |
36 | #define LAUNCH_KEY_SINGLEUSER "SingleUser" | |
37 | #define LAUNCH_KEY_GETRESOURCELIMITS "GetResourceLimits" | |
38 | #define LAUNCH_KEY_SETRESOURCELIMITS "SetResourceLimits" | |
ed34e3c3 A |
39 | #define LAUNCH_KEY_GETRUSAGESELF "GetResourceUsageSelf" |
40 | #define LAUNCH_KEY_GETRUSAGECHILDREN "GetResourceUsageChildren" | |
6a39f10b | 41 | |
e91b9f68 | 42 | #define LAUNCHD_SOCKET_ENV "LAUNCHD_SOCKET" |
ed34e3c3 | 43 | #define LAUNCHD_SOCK_PREFIX "/var/tmp/launchd" |
e91b9f68 A |
44 | #define LAUNCHD_TRUSTED_FD_ENV "__LAUNCHD_FD" |
45 | #define LAUNCHD_ASYNC_MSG_KEY "_AsyncMessage" | |
46 | #define LAUNCH_KEY_BATCHCONTROL "BatchControl" | |
47 | #define LAUNCH_KEY_BATCHQUERY "BatchQuery" | |
48 | ||
5b0a4722 A |
49 | #define LAUNCH_JOBKEY_QUARANTINEDATA "QuarantineData" |
50 | #define LAUNCH_JOBKEY_SANDBOXPROFILE "SandboxProfile" | |
51 | #define LAUNCH_JOBKEY_SANDBOXFLAGS "SandboxFlags" | |
52 | #define LAUNCH_JOBKEY_SANDBOX_NAMED "Named" | |
53 | ||
54 | #define LAUNCH_JOBKEY_ENTERKERNELDEBUGGERBEFOREKILL "EnterKernelDebuggerBeforeKill" | |
55 | #define LAUNCH_JOBKEY_PERJOBMACHSERVICES "PerJobMachServices" | |
56 | #define LAUNCH_JOBKEY_SERVICEIPC "ServiceIPC" | |
57 | #define LAUNCH_JOBKEY_BINARYORDERPREFERENCE "BinaryOrderPreference" | |
58 | ||
ed34e3c3 A |
59 | #define LAUNCH_JOBKEY_MACH_KUNCSERVER "kUNCServer" |
60 | #define LAUNCH_JOBKEY_MACH_EXCEPTIONSERVER "ExceptionServer" | |
61 | #define LAUNCH_JOBKEY_MACH_TASKSPECIALPORT "TaskSpecialPort" | |
62 | #define LAUNCH_JOBKEY_MACH_HOSTSPECIALPORT "HostSpecialPort" | |
5b0a4722 | 63 | #define LAUNCH_JOBKEY_MACH_ENTERKERNELDEBUGGERONCLOSE "EnterKernelDebuggerOnClose" |
e91b9f68 | 64 | |
ed34e3c3 | 65 | typedef struct _launch *launch_t; |
fc89531e | 66 | |
e91b9f68 A |
67 | launch_t launchd_fdopen(int); |
68 | int launchd_getfd(launch_t); | |
5b0a4722 | 69 | void launchd_close(launch_t, typeof(close) closefunc); |
e91b9f68 A |
70 | |
71 | launch_data_t launch_data_new_errno(int); | |
ed34e3c3 | 72 | bool launch_data_set_errno(launch_data_t, int); |
e91b9f68 A |
73 | |
74 | int launchd_msg_send(launch_t, launch_data_t); | |
75 | int launchd_msg_recv(launch_t, void (*)(launch_data_t, void *), void *); | |
76 | ||
ed34e3c3 A |
77 | /* For LoginWindow. |
78 | * | |
79 | * After this call, the task's bootstrap port is set to the per session launchd. | |
80 | * | |
5b0a4722 | 81 | * This returns 1 on success (it used to return otherwise), and -1 on failure. |
ed34e3c3 A |
82 | */ |
83 | #define LOAD_ONLY_SAFEMODE_LAUNCHAGENTS 1 | |
5b0a4722 A |
84 | pid_t create_and_switch_to_per_session_launchd(const char * /* loginname */, int flags, ...); |
85 | ||
86 | /* Also for LoginWindow. | |
87 | * | |
88 | * This is will load jobs at the LoginWindow prompt. | |
89 | */ | |
90 | void load_launchd_jobs_at_loginwindow_prompt(int flags, ...); | |
91 | ||
ed34e3c3 | 92 | |
e91b9f68 | 93 | /* batch jobs will be implicity re-enabled when the last application who |
ed34e3c3 A |
94 | * disabled them exits. |
95 | * | |
96 | * This API is really a hack to work around the lack of real-time APIs | |
97 | * at the VFS layer. | |
98 | */ | |
e91b9f68 A |
99 | void launchd_batch_enable(bool); |
100 | bool launchd_batch_query(void); | |
101 | ||
ed34e3c3 A |
102 | /* For CoreProcesses |
103 | */ | |
104 | ||
105 | #define SPAWN_VIA_LAUNCHD_STOPPED 0x0001 | |
ed34e3c3 A |
106 | |
107 | struct spawn_via_launchd_attr { | |
108 | uint64_t spawn_flags; | |
109 | const char * spawn_path; | |
110 | const char * spawn_chdir; | |
111 | const char *const * spawn_env; | |
112 | const mode_t * spawn_umask; | |
113 | mach_port_t * spawn_observer_port; | |
5b0a4722 A |
114 | const cpu_type_t * spawn_binpref; |
115 | size_t spawn_binpref_cnt; | |
116 | qtn_proc_t spawn_quarantine; | |
117 | const char * spawn_seatbelt_profile; | |
118 | const uint64_t * spawn_seatbelt_flags; | |
ed34e3c3 A |
119 | }; |
120 | ||
5b0a4722 | 121 | #define spawn_via_launchd(a, b, c) _spawn_via_launchd(a, b, c, 2) |
ed34e3c3 A |
122 | pid_t _spawn_via_launchd( |
123 | const char *label, | |
124 | const char *const *argv, | |
125 | const struct spawn_via_launchd_attr *spawn_attrs, | |
126 | int struct_version); | |
127 | ||
128 | kern_return_t mpm_wait(mach_port_t ajob, int *wstatus); | |
129 | ||
130 | kern_return_t mpm_uncork_fork(mach_port_t ajob); | |
131 | ||
132 | ||
133 | __END_DECLS | |
134 | ||
5b0a4722 A |
135 | #pragma GCC visibility pop |
136 | ||
137 | ||
e91b9f68 | 138 | #endif |