-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTimeMachine.c
More file actions
51 lines (45 loc) · 1.97 KB
/
TimeMachine.c
File metadata and controls
51 lines (45 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <CoreFoundation/CoreFoundation.h>
#include "utils.h"
int main() {
if (getuid() != 0) {
setuid(0);
}
if (getuid() != 0) {
printf("Can't set uid as 0.\n");
return 1;
}
run_system("/etc/rc.d/snapshotcheck");
CFDictionaryRef settings = loadPrefs();
if (settings == NULL) {
settings = CFDictionaryCreate(NULL, NULL, NULL, 0, NULL, NULL);
}
if (!is_sealed("/") && (!CFDictionaryContainsKey(settings, CFSTR("rootfs_enabled")) || CFBooleanGetValue(CFDictionaryGetValue(settings, CFSTR("rootfs_enabled"))))) {
int max_snapshot = 3;
if (CFDictionaryContainsKey(settings, CFSTR("max_rootfs_snapshot"))) {
CFTypeRef num = CFDictionaryGetValue(settings, CFSTR("max_rootfs_snapshot"));
if (CFGetTypeID(num) == CFNumberGetTypeID()) {
CFNumberGetValue(num, kCFNumberIntType, &max_snapshot);
} else {
CFPreferencesSetValue(CFSTR("max_rootfs_snapshot"), NULL, bundleID, CFSTR("mobile"), kCFPreferencesAnyHost);
}
CFRelease(num);
}
do_timemachine("/", true, max_snapshot);
}
if (!CFDictionaryContainsKey(settings, CFSTR("datafs_enabled")) || CFBooleanGetValue(CFDictionaryGetValue(settings, CFSTR("datafs_enabled")))) {
int max_snapshot = 3;
if (CFDictionaryContainsKey(settings, CFSTR("max_datafs_snapshot"))) {
CFTypeRef num = CFDictionaryGetValue(settings, CFSTR("max_datafs_snapshot"));
if (CFGetTypeID(num) == CFNumberGetTypeID()) {
CFNumberGetValue(num, kCFNumberIntType, &max_snapshot);
} else {
CFPreferencesSetValue(CFSTR("max_datafs_snapshot"), NULL, bundleID, CFSTR("mobile"), kCFPreferencesAnyHost);
}
CFRelease(num);
}
do_timemachine("/private/var", true, max_snapshot);
}
CFRelease(settings);
printf("TimeMachine on iOS's work is down, enjoy safety.\n\n");
return 0;
}