]>
Commit | Line | Data |
---|---|---|
507116e3 A |
1 | #include <stdio.h> |
2 | #include <stdint.h> | |
3 | #include <stdlib.h> | |
4 | #include <os/variant_private.h> | |
5 | ||
6 | #include "../libdarwin/variant.c" | |
7 | ||
8 | #define bool2str(b) (b ? "true" : "false") | |
9 | ||
10 | static void __dead2 | |
11 | usage(void) | |
12 | { | |
13 | printf("osvariantutil status\n"); | |
14 | printf("osvariantutil parse <kern.osvariant_status>\n"); | |
15 | exit(1); | |
16 | } | |
17 | ||
18 | int | |
19 | main(int argc, char *argv[]) { | |
20 | // Warm up the dispatch_once | |
21 | _check_disabled(VP_CONTENT); | |
22 | ||
23 | if (argc == 2 && strcmp(argv[1], "status") == 0) { | |
24 | uint64_t status = _get_cached_check_status(); | |
25 | printf("Cached status: %llx\n", status); | |
26 | } else if (argc == 3 && strcmp(argv[1], "parse") == 0) { | |
27 | uint64_t status = strtoull(argv[2], NULL, 0); | |
28 | if ((status & STATUS_INITIAL_BITS) != STATUS_INITIAL_BITS) { | |
29 | printf("Invalid status: 0x%llx\n", status); | |
30 | exit(1); | |
31 | } | |
32 | _restore_cached_check_status(status); | |
33 | printf("Using status: %llx\n", status); | |
34 | } else { | |
35 | usage(); | |
36 | } | |
37 | ||
38 | printf("\nOS Variants:\n"); | |
39 | printf("\tos_variant_has_internal_content: %s\n", | |
40 | bool2str(os_variant_has_internal_content("com.apple.osvariantutil"))); | |
41 | printf("\tos_variant_has_internal_diagnostics: %s\n", | |
42 | bool2str(os_variant_has_internal_diagnostics("com.apple.osvariantutil"))); | |
43 | printf("\tos_variant_has_internal_ui: %s\n", | |
44 | bool2str(os_variant_has_internal_ui("com.apple.osvariantutil"))); | |
45 | printf("\tos_variant_allows_internal_security_properties: %s\n", | |
46 | bool2str(os_variant_allows_internal_security_policies("com.apple.osvariantutil"))); | |
47 | printf("\tos_variant_has_factory_content: %s\n", | |
48 | bool2str(os_variant_has_factory_content("com.apple.osvariantutil"))); | |
49 | printf("\tos_variant_is_darwinos: %s\n", | |
50 | bool2str(os_variant_is_darwinos("com.apple.osvariantutil"))); | |
51 | printf("\tos_variant_uses_ephemeral_storage: %s\n", | |
52 | bool2str(os_variant_uses_ephemeral_storage("com.apple.osvariantutil"))); | |
53 | printf("\tos_variant_is_recovery: %s\n", | |
54 | bool2str(os_variant_is_recovery("com.apple.osvariantutil"))); | |
55 | ||
56 | printf("\nOS Variant Overrides:\n"); | |
57 | printf("\tCONTENT: %s\n", bool2str(_check_disabled(VP_CONTENT))); | |
58 | printf("\tDIAGNOSTICS: %s\n", bool2str(_check_disabled(VP_DIAGNOSTICS))); | |
59 | printf("\tUI: %s\n", bool2str(_check_disabled(VP_UI))); | |
60 | printf("\tSECURITY: %s\n", bool2str(_check_disabled(VP_SECURITY))); | |
61 | ||
62 | printf("\nOS Variant Inputs:\n"); | |
63 | #if !TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR | |
64 | printf("\tInternal Content: %s\n", bool2str(_check_internal_content())); | |
65 | #endif | |
66 | #if TARGET_OS_IPHONE | |
67 | printf("\tInternal Release Type: %s\n", bool2str(_check_internal_release_type())); | |
68 | printf("\tFactory Release Type: %s\n", bool2str(_check_factory_release_type())); | |
69 | printf("\tDarwin Release Type: %s\n", bool2str(_check_darwin_release_type())); | |
70 | printf("\tRecovery Release Type: %s\n", bool2str(_check_recovery_release_type())); | |
71 | printf("\tDevelopment Kernel: %s\n", bool2str(_check_development_kernel())); | |
72 | #else | |
73 | printf("\tInternal Diags Profile: %s\n", bool2str(_check_internal_diags_profile())); | |
74 | printf("\tFactory Content: %s\n", bool2str(_check_factory_content())); | |
75 | printf("\tBaseSystem Content: %s\n", bool2str(_check_base_system_content())); | |
76 | #endif | |
77 | printf("\tCan Has Debugger: %s\n", bool2str(_check_can_has_debugger())); | |
78 | ||
79 | return 0; | |
80 | } |