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