]>
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"); | |
a9aaacca A |
15 | printf("osvariantutil check <OS_VARIANT_STRING\n"); |
16 | printf(" For Example: osvariantutil check IsDarwinOS\n"); | |
17 | printf(" Refer variant_private.h for valid OS_VARIANT_STRING\n"); | |
507116e3 A |
18 | exit(1); |
19 | } | |
20 | ||
21 | int | |
22 | main(int argc, char *argv[]) { | |
23 | // Warm up the dispatch_once | |
24 | _check_disabled(VP_CONTENT); | |
25 | ||
26 | if (argc == 2 && strcmp(argv[1], "status") == 0) { | |
27 | uint64_t status = _get_cached_check_status(); | |
28 | printf("Cached status: %llx\n", status); | |
29 | } else if (argc == 3 && strcmp(argv[1], "parse") == 0) { | |
30 | uint64_t status = strtoull(argv[2], NULL, 0); | |
31 | if ((status & STATUS_INITIAL_BITS) != STATUS_INITIAL_BITS) { | |
32 | printf("Invalid status: 0x%llx\n", status); | |
33 | exit(1); | |
34 | } | |
35 | _restore_cached_check_status(status); | |
36 | printf("Using status: %llx\n", status); | |
a9aaacca A |
37 | } else if (argc == 3 && strcmp(argv[1], "check") == 0) { |
38 | if (os_variant_check("com.apple.osvariantutil", argv[2]) == true) { | |
39 | printf("%s: true\n", argv[2]); | |
40 | exit(0); | |
41 | } else { | |
42 | printf("%s: false\n", argv[2]); | |
43 | exit(1); | |
44 | } | |
45 | } else { | |
507116e3 A |
46 | usage(); |
47 | } | |
48 | ||
49 | printf("\nOS Variants:\n"); | |
50 | printf("\tos_variant_has_internal_content: %s\n", | |
51 | bool2str(os_variant_has_internal_content("com.apple.osvariantutil"))); | |
52 | printf("\tos_variant_has_internal_diagnostics: %s\n", | |
53 | bool2str(os_variant_has_internal_diagnostics("com.apple.osvariantutil"))); | |
54 | printf("\tos_variant_has_internal_ui: %s\n", | |
55 | bool2str(os_variant_has_internal_ui("com.apple.osvariantutil"))); | |
56 | printf("\tos_variant_allows_internal_security_properties: %s\n", | |
57 | bool2str(os_variant_allows_internal_security_policies("com.apple.osvariantutil"))); | |
58 | printf("\tos_variant_has_factory_content: %s\n", | |
59 | bool2str(os_variant_has_factory_content("com.apple.osvariantutil"))); | |
60 | printf("\tos_variant_is_darwinos: %s\n", | |
61 | bool2str(os_variant_is_darwinos("com.apple.osvariantutil"))); | |
62 | printf("\tos_variant_uses_ephemeral_storage: %s\n", | |
63 | bool2str(os_variant_uses_ephemeral_storage("com.apple.osvariantutil"))); | |
64 | printf("\tos_variant_is_recovery: %s\n", | |
65 | bool2str(os_variant_is_recovery("com.apple.osvariantutil"))); | |
a9aaacca A |
66 | #if TARGET_OS_OSX |
67 | printf("\tos_variant_is_basesystem: %s\n", | |
68 | bool2str(os_variant_is_basesystem("com.apple.osvariantutil"))); | |
69 | #endif | |
70 | printf("\tos_variant_has_full_logging: %s\n", | |
71 | bool2str(os_variant_check("com.apple.osvariantutil", "HasFullLogging"))); | |
507116e3 A |
72 | |
73 | printf("\nOS Variant Overrides:\n"); | |
74 | printf("\tCONTENT: %s\n", bool2str(_check_disabled(VP_CONTENT))); | |
75 | printf("\tDIAGNOSTICS: %s\n", bool2str(_check_disabled(VP_DIAGNOSTICS))); | |
76 | printf("\tUI: %s\n", bool2str(_check_disabled(VP_UI))); | |
77 | printf("\tSECURITY: %s\n", bool2str(_check_disabled(VP_SECURITY))); | |
78 | ||
79 | printf("\nOS Variant Inputs:\n"); | |
80 | #if !TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR | |
81 | printf("\tInternal Content: %s\n", bool2str(_check_internal_content())); | |
82 | #endif | |
83 | #if TARGET_OS_IPHONE | |
84 | printf("\tInternal Release Type: %s\n", bool2str(_check_internal_release_type())); | |
85 | printf("\tFactory Release Type: %s\n", bool2str(_check_factory_release_type())); | |
86 | printf("\tDarwin Release Type: %s\n", bool2str(_check_darwin_release_type())); | |
87 | printf("\tRecovery Release Type: %s\n", bool2str(_check_recovery_release_type())); | |
88 | printf("\tDevelopment Kernel: %s\n", bool2str(_check_development_kernel())); | |
89 | #else | |
90 | printf("\tInternal Diags Profile: %s\n", bool2str(_check_internal_diags_profile())); | |
91 | printf("\tFactory Content: %s\n", bool2str(_check_factory_content())); | |
92 | printf("\tBaseSystem Content: %s\n", bool2str(_check_base_system_content())); | |
a9aaacca | 93 | printf("\tdarwinOS Content: %s\n", bool2str(_check_darwinos_content())); |
507116e3 A |
94 | #endif |
95 | printf("\tCan Has Debugger: %s\n", bool2str(_check_can_has_debugger())); | |
96 | ||
97 | return 0; | |
98 | } |