]> git.saurik.com Git - apple/libc.git/blame - os/variant_private.h
Libc-1353.11.2.tar.gz
[apple/libc.git] / os / variant_private.h
CommitLineData
b061a43b
A
1/*
2 * Copyright (c) 2017 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 __OS_VARIANT_H__
22#define __OS_VARIANT_H__
23
24#include <stdbool.h>
25
26#include <os/base.h>
27#include <os/availability.h>
28
29/*! @header
30 * OS Variant SPI
31 *
32 * Provides a mechanism to determine the currently running OS variant.
33 *
34 * Any of these APIs may be overridden to its non-internal behavior on a
507116e3
A
35 * device by creating on override file. On macOS, the path of this file
36 * is:
b061a43b 37 * /var/db/os_variant_override
507116e3 38 * On embedded platforms, the path of the override file is:
b061a43b
A
39 * /usr/share/misc/os_variant_override
40 *
41 * Individual internal behaviors can be selectively disabled (ie.
42 * individual os_variant_has_internal_*() predicates can be overriden to
43 * false) by writing the file with a comma- or newline-delimited list of
507116e3
A
44 * behaviors to disable. To disable all internal behaviors, empty the file.
45 *
46 * There is currently no support for configuring per-subsystem overrides.
47 *
48 * Examples:
49 * This will disable internal diagnostics and UI on macOS:
50 * sudo sh -c 'echo "diagnostics,ui" > /var/db/os_variant_override'
51 * This will disable internal UI on iOS (assuming logged in as root):
52 * echo "ui" > /usr/share/misc/os_variant_override
53 * This will disable all internal behaviors on macOS:
54 * sudo sh -c '/bin/echo -n > /var/db/os_variant_override'
55 *
56 * Note that the values returned by these APIs are cached in the kernel at
57 * system boot. A reboot will be required after changing the overrides
58 * before the new settings will take effect.
b061a43b
A
59 *
60 * Each of these functions takes a constant string argument for the requesting
61 * subsystem. This should be a reverse-DNS string describing the subsystem
62 * performing the check. This may be used in the future for auditing and
63 * selective overriding of checks.
64 *
65 */
66
67__BEGIN_DECLS
68
69/*!
70 * @function os_variant_has_internal_content
71 *
72 * @abstract returns whether this system variant has internal content installed
73 * ("content")
74 *
75 * @result
76 * Returns true if this build has this property. False otherwise or upon error.
77 */
78API_AVAILABLE(macosx(10.13), ios(11.0), tvos(11.0), watchos(4.0))
79OS_EXPORT OS_WARN_RESULT
80bool
81os_variant_has_internal_content(const char *subsystem);
82
83/*!
84 * @function os_variant_has_internal_diagnostics
85 *
86 * @abstract returns whether this system variant has internal diagnostics
87 * enabled ("diagnostics")
88 *
89 * @description
90 *
91 * Internal diagnostics include behaviors that emit extra diagnostic or
92 * debugging information when an error occurs.
93 *
94 * On macOS, this check will look for presence of AppleInternal content or the
95 * AppleInternalDiagnostics profile to be installed.
96 *
97 * On embedded platforms, this check will look for an internal install variant
98 * in a manner similar to the MobileGestalt check for InternalBuild.
99 *
100 * @result
101 * Returns true if this build has this property. False otherwise or upon error.
102 */
103API_AVAILABLE(macosx(10.13), ios(11.0), tvos(11.0), watchos(4.0))
104OS_EXPORT OS_WARN_RESULT
105bool
106os_variant_has_internal_diagnostics(const char *subsystem);
107
108/*!
109 * @function os_variant_has_internal_ui
110 *
111 * @abstract returns whether this system variant has internal UI visible ("ui")
112 *
113 * @description
114 *
115 * Internal UI includes debug menus and internal settings.
116 *
117 * On macOS, this will check for the presence of AppleInternal content. On
118 * embedded platforms, this check will look for an internal install variant in
507116e3 119 * a manner similar to the MobileGestalt check for InternalBuild.
b061a43b
A
120 *
121 * @result
122 * Returns true if this build has this property. False otherwise or upon error.
123 */
124API_AVAILABLE(macosx(10.13), ios(11.0), tvos(11.0), watchos(4.0))
125OS_EXPORT OS_WARN_RESULT
126bool
127os_variant_has_internal_ui(const char *subsystem);
128
129/*!
130 * @function os_variant_allows_internal_security_policies
131 *
132 * @abstract returns whether this system variant allows internal security policies
133 * ("security")
134 *
135 * @description
136 *
137 * On macOS, this will check the CSR status for whether AppleInternal policies
138 * are enabled.
139 *
140 * On embedded platforms, this will check for a build/device combination that
141 * allows for removal of codesigning and debugging restrictions. This usually
142 * returns whether the hardware is development fused and may return true on
143 * such hardware even if a customer build is installed.
144 *
145 * n.b. The result of this API should /not/ be used to automatically enable
146 * relaxed security policies, only to signal that other mechanisms to enable
147 * them are allowed, e.g. a "defaults write".
148 *
149 * @result
150 * Returns true if this build has this property. False otherwise or upon error.
151 */
152API_AVAILABLE(macosx(10.13), ios(11.0), tvos(11.0), watchos(4.0))
153OS_EXPORT OS_WARN_RESULT
154bool
155os_variant_allows_internal_security_policies(const char *subsystem);
156
6dccf0e0
A
157/*!
158 * @function os_variant_has_factory_content
159 *
160 * @abstract returns whether this system has factory diagnostics content
161 *
162 * @description
163 *
164 * On macOS, this checks for a AppleFactoryVariant.plist that is present in the
165 * factory diagnostics image.
166 *
167 * On embedded platforms, this will check for the NonUI variant.
168 *
169 * @result
170 * Returns true if this build has this property. False otherwise or upon error.
171 */
507116e3 172API_AVAILABLE(macosx(10.14.4), ios(12.2), tvos(12.2), watchos(5.2))
6dccf0e0
A
173OS_EXPORT OS_WARN_RESULT
174bool
175os_variant_has_factory_content(const char *subsystem);
176
507116e3
A
177/*!
178 * @function os_variant_is_darwinos
179 *
180 * @abstract returns whether this system variant is a darwinOS variant
181 *
182 * @result
183 * Returns true if this variant is a darwinOS variant.
184 */
185API_AVAILABLE(macosx(10.15), ios(13.0), tvos(13.0), watchos(6.0))
186OS_EXPORT OS_WARN_RESULT
187bool
188os_variant_is_darwinos(const char *subsystem);
189
190/*!
191 * @function os_variant_uses_ephemeral_storage
192 *
193 * @abstract returns whether the system is booted from an ephermeral volume
194 *
195 * @result
196 * Returns true if the system is booted with ephemeral storage for the data volume.
197 */
198API_AVAILABLE(macosx(10.15), ios(13.0), tvos(13.0), watchos(6.0))
199OS_EXPORT OS_WARN_RESULT
200bool
201os_variant_uses_ephemeral_storage(const char *subsystem);
202
203/*!
204 * @function os_variant_is_recovery
205 *
206 * @abstract returns whether this system variant is the recovery OS.
207 *
208 * @description
209 * On macOS, this returns whether the running environment is the BaseSystem.
210 * This will be true in the installer and recovery environments. On embedded
211 * platforms, this returns whether this is the NeRD (Network Recovery on
212 * Device) OS.
213 *
214 * @result
215 * Returns true if this variant is a recoveryOS
216 */
217API_AVAILABLE(macosx(10.15), ios(13.0), tvos(13.0), watchos(6.0))
218OS_EXPORT OS_WARN_RESULT
219bool
220os_variant_is_recovery(const char *subsystem);
221
222/*!
223 * @function os_variant_check
224 *
225 * @abstract returns whether the system is of the specified variant
226 *
227 * @description
228 * This check checks against below known variants. False is returned if the
229 * variant passed in is not in the list.
230 *
231 * HasInternalContent
232 * HasInternalDiagnostics
233 * HasInternalUI
234 * AllowsInternalSecurityPolicies
235 * HasFactoryContent
236 * IsDarwinOS
237 * UsesEphemeralStorage
238 * IsRecovery
239 *
240 * @result
241 * Returns true if the system is of the specified variant.
242 */
243API_AVAILABLE(macosx(10.15), ios(13.0), tvos(13.0), watchos(6.0))
244OS_EXPORT OS_WARN_RESULT
245bool
246os_variant_check(const char *subsystem, const char *variant);
247
b061a43b
A
248__END_DECLS
249
250#endif // __os_variant_H__