-
Notifications
You must be signed in to change notification settings - Fork 8
/
writeable_root.c
41 lines (38 loc) · 1.04 KB
/
writeable_root.c
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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// INFO:
// authenticated-root, SIP and FileVault must be disabled
// program will create new directory ~/temp
// program will require your password
// use with caution!
int main(int argc, char *argv[]) {
FILE *fpipe;
if ((fpipe = (FILE*)popen("mount", "r")) == 0) {
perror("ERROR: failed to execute command");
exit(EXIT_FAILURE);
}
char c;
char disk[32];
unsigned int i = 0;
while (fread(&c, sizeof(char), 1, fpipe)) {
if (c == ' ') {
disk[i-2] = '\0';
break;
}
disk[i] = c;
i++;
}
pclose(fpipe);
system("mkdir ~/temp");
char mount[72] = "sudo mount -o nobrowse -t apfs ";
strncat(mount, disk, 32);
strncat(mount, " ~/temp", 8);
system(mount);
printf("make changes in the set directory and exit the shell when you're done\n");
printf("WARNING: system will reboot on exit\n");
system("cd ~/temp && sudo `echo $SHELL`");
system("sudo bless --folder ~/temp/System/Library/CoreServices --bootefi --create-snapshot");
system("sudo reboot");
return EXIT_SUCCESS;
}