mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-29 05:07:38 +00:00
Unlock all blocks to non-read-only
Check more info: https://android.googlesource.com/platform/system/core/+/e18c0d5%5E!/ Should fix all root apps with issue gaining rw access to /system
This commit is contained in:
parent
f269695d4a
commit
6bf19ecc34
31
daemon.c
31
daemon.c
@ -24,6 +24,7 @@
|
||||
#include <sys/wait.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
#include <fcntl.h>
|
||||
@ -42,6 +43,7 @@
|
||||
#include <termios.h>
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
#include <dirent.h>
|
||||
#include <selinux/selinux.h>
|
||||
|
||||
#ifdef SUPERUSER_EMBEDDED
|
||||
@ -451,6 +453,33 @@ static int daemon_accept(int fd) {
|
||||
return run_daemon_child(infd, outfd, errfd, argc, argv);
|
||||
}
|
||||
|
||||
static void unlock_blocks() {
|
||||
#define DEV_BLOCKS "/dev/block"
|
||||
char path[PATH_MAX];
|
||||
DIR *dir;
|
||||
struct dirent *entry;
|
||||
int fd, OFF = 0;
|
||||
|
||||
if (!(dir = opendir(DEV_BLOCKS)))
|
||||
return;
|
||||
|
||||
while((entry = readdir(dir))) {
|
||||
if (entry->d_type == DT_BLK && strstr(entry->d_name, "mmc") != NULL) {
|
||||
sprintf(path, "%s/%s", DEV_BLOCKS, entry->d_name);
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
PLOGE("open");
|
||||
continue;
|
||||
}
|
||||
if (ioctl(fd, BLKROSET, &OFF) == -1)
|
||||
PLOGE("ioctl");
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
}
|
||||
|
||||
int run_daemon() {
|
||||
if (getuid() != AID_ROOT || getgid() != AID_ROOT) {
|
||||
PLOGE("daemon requires root. uid/gid not root");
|
||||
@ -476,6 +505,8 @@ int run_daemon() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
unlock_blocks();
|
||||
|
||||
int fd;
|
||||
struct sockaddr_un sun;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user