Deprecate path /sbin/.core, switch to /sbin/.magisk

Symlink is preserved for backwards compatibility
This commit is contained in:
topjohnwu 2018-11-15 01:36:03 -05:00
parent 83ae66daea
commit 376e7977f0
7 changed files with 21 additions and 15 deletions

View File

@ -27,7 +27,7 @@ public class Const {
MAGISK_PATH = MAGISK_DISABLE_FILE = MAGISK_HOST_FILE = new File("xxx");
}
public static final String BUSYBOX_PATH = "/sbin/.core/busybox";
public static final String BUSYBOX_PATH = "/sbin/.magisk/busybox";
public static final String TMP_FOLDER_PATH = "/dev/tmp";
public static final String MAGISK_LOG = "/cache/magisk.log";
public static final String MANAGER_CONFIGS = ".tmp.magisk.config";

View File

@ -20,7 +20,7 @@ public class MagiskDB {
static final String SETTINGS_TABLE = "settings";
static final String STRINGS_TABLE = "strings";
static final File LEGACY_MANAGER_DB =
new File(Utils.fmt("/sbin/.core/db-%d/magisk.db", Const.USER_ID));
new File(Utils.fmt("/sbin/.magisk/db-%d/magisk.db", Const.USER_ID));
@NonNull
public static MagiskDB getInstance() {

View File

@ -29,12 +29,15 @@ public class RootUtils extends Shell.Initializer {
public boolean onInit(Context context, @NonNull Shell shell) {
Shell.Job job = shell.newJob();
if (shell.isRoot()) {
if (!new SuFile("/sbin/.magisk").exists())
job.add("ln -s /sbin/.core /sbin/.magisk");
InputStream magiskUtils = context.getResources().openRawResource(R.raw.util_functions);
InputStream managerUtils = context.getResources().openRawResource(R.raw.utils);
job.add(magiskUtils).add(managerUtils);
Const.MAGISK_DISABLE_FILE = new SuFile("/cache/.disable_magisk");
SuFile file = new SuFile("/sbin/.core/img");
SuFile file = new SuFile("/sbin/.magisk/img");
if (file.exists()) {
Const.MAGISK_PATH = file;
} else if ((file = new SuFile("/dev/magisk/img")).exists()) {

View File

@ -6,7 +6,7 @@ db_sepatch() {
db_clean() {
local USERID=$1
local DIR="/sbin/.core/db-${USERID}"
local DIR="/sbin/.magisk/db-${USERID}"
umount -l /data/user*/*/*/databases/su.db $DIR $DIR/*
rm -rf $DIR
[ "$USERID" = "*" ] && rm -fv /data/adb/magisk.db*
@ -26,7 +26,7 @@ db_restore() {
db_setup() {
local USER=$1
local USERID=$(($USER / 100000))
local DIR=/sbin/.core/db-${USERID}
local DIR=/sbin/.magisk/db-${USERID}
mkdir -p $DIR
touch $DIR/magisk.db
mount -o bind /data/adb/magisk.db $DIR/magisk.db
@ -49,8 +49,8 @@ fix_env() {
sh update-binary extract
rm -f update-binary magisk.apk
cd /
rm -rf /sbin/.core/busybox/*
/sbin/.core/mirror/bin/busybox --install -s /sbin/.core/busybox
rm -rf /sbin/.magisk/busybox/*
/sbin/.magisk/mirror/bin/busybox --install -s /sbin/.magisk/busybox
}
direct_install() {

View File

@ -417,6 +417,9 @@ static bool magisk_env() {
unlink("/data/magisk.img");
unlink("/data/magisk_debug.log");
// Symlink for legacy path users
symlink(MAGISKTMP, "/sbin/.core");
// Create directories in tmpfs overlay
xmkdirs(MIRRDIR "/system", 0755);
xmkdir(MIRRDIR "/bin", 0755);

View File

@ -12,7 +12,7 @@
#define LOGFILE "/cache/magisk.log"
#define UNBLOCKFILE "/dev/.magisk.unblock"
#define DISABLEFILE "/cache/.disable_magisk"
#define MAGISKTMP "/sbin/.core"
#define MAGISKTMP "/sbin/.magisk"
#define BLOCKDIR MAGISKTMP "/block"
#define MIRRDIR MAGISKTMP "/mirror"
#define BBPATH MAGISKTMP "/busybox"

View File

@ -15,10 +15,10 @@ $BOOTMODE || ps | grep zygote | grep -qv grep && BOOTMODE=true
$BOOTMODE || ps -A | grep zygote | grep -qv grep && BOOTMODE=true
# Presets
MAGISKTMP=/sbin/.magisk
[ -z $NVBASE ] && NVBASE=/data/adb
[ -z $MAGISKBIN ] && MAGISKBIN=$NVBASE/magisk
[ -z $IMG ] && IMG=$NVBASE/magisk.img
[ -z $MOUNTPATH ] && MOUNTPATH=/sbin/.core/img
# Bootsigner related stuff
BOOTSIGNERCLASS=a.a
@ -306,9 +306,9 @@ check_data() {
}
setup_bb() {
if [ -x /sbin/.core/busybox/busybox ]; then
if [ -x $MAGISKTMP/busybox/busybox ]; then
# Make sure this path is in the front
echo $PATH | grep -q '^/sbin/.core/busybox' || export PATH=/sbin/.core/busybox:$PATH
echo $PATH | grep -q "^$MAGISKTMP/busybox" || export PATH=$MAGISKTMP/busybox:$PATH
elif [ -x $TMPDIR/bin/busybox ]; then
# Make sure this path is in the front
echo $PATH | grep -q "^$TMPDIR/bin" || export PATH=$TMPDIR/bin:$PATH
@ -322,11 +322,11 @@ setup_bb() {
}
boot_actions() {
if [ ! -d /sbin/.core/mirror/bin ]; then
mkdir -p /sbin/.core/mirror/bin
mount -o bind $MAGISKBIN /sbin/.core/mirror/bin
if [ ! -d $MAGISKTMP/mirror/bin ]; then
mkdir -p $MAGISKTMP/mirror/bin
mount -o bind $MAGISKBIN $MAGISKTMP/mirror/bin
fi
MAGISKBIN=/sbin/.core/mirror/bin
MAGISKBIN=$MAGISKTMP/mirror/bin
setup_bb
}