fix: magisk file detection

This commit fixes the detection for the "magisk" file which can be in 2 different folders, with 3 possible different names.
This commit is contained in:
ThePedroo
2024-12-12 20:10:38 -03:00
parent 060a1f3cf9
commit 8fb5d9197a

View File

@@ -24,6 +24,7 @@ char *magisk_managers[] = {
};
#define SBIN_MAGISK lp_select("/sbin/magisk32", "/sbin/magisk64")
#define BITLESS_SBIN_MAGISK "/sbin/magisk"
#define DEBUG_RAMDISK_MAGISK lp_select("/debug_ramdisk/magisk32", "/debug_ramdisk/magisk64")
#define BITLESS_DEBUG_RAMDISK_MAGISK "/debug_ramdisk/magisk"
@@ -39,6 +40,12 @@ void magisk_get_existence(struct root_impl_state *state) {
}
errno = 0;
if (stat(BITLESS_SBIN_MAGISK, &s) != 0) {
if (errno != ENOENT) {
LOGE("Failed to stat Magisk %s binary: %s\n", BITLESS_SBIN_MAGISK, strerror(errno));
}
errno = 0;
if (stat(DEBUG_RAMDISK_MAGISK, &s) != 0) {
if (errno != ENOENT) {
LOGE("Failed to stat Magisk %s binary: %s\n", DEBUG_RAMDISK_MAGISK, strerror(errno));
@@ -63,7 +70,11 @@ void magisk_get_existence(struct root_impl_state *state) {
strcpy(path_to_magisk, DEBUG_RAMDISK_MAGISK);
}
} else {
/* INFO: /sbin/magisk exists */
/* INFO: /sbin/magisk64 (or 32) doesn't exist but /sbin/magisk does */
strcpy(path_to_magisk, BITLESS_SBIN_MAGISK);
}
} else {
/* INFO: /sbin/magisk64 (or 32) exists */
strcpy(path_to_magisk, SBIN_MAGISK);
}