Magisk/src/full/res/raw/utils.sh

55 lines
1.2 KiB
Bash
Raw Normal View History

2018-04-14 10:08:53 +00:00
db_sepatch() {
magiskpolicy --live 'create magisk_file' 'attradd magisk_file mlstrustedobject' \
'allow * magisk_file file *' 'allow * magisk_file dir *' \
'allow magisk_file * filesystem associate'
}
2018-04-05 17:54:09 +00:00
db_clean() {
2018-02-18 04:41:58 +00:00
local USERID=$1
local DIR="/sbin/.core/db-${USERID}"
umount -l /data/user*/*/*/databases/su.db $DIR $DIR/*
rm -rf $DIR
2018-04-22 05:53:25 +00:00
[ "$USERID" = "*" ] && rm -fv /data/adb/magisk.db*
2018-02-18 10:12:12 +00:00
}
2018-04-05 17:54:09 +00:00
db_init() {
2018-06-11 16:04:36 +00:00
# Temporary let the folder rw by anyone
2018-04-14 10:08:53 +00:00
chcon u:object_r:magisk_file:s0 /data/adb
2018-02-18 10:12:12 +00:00
chmod 777 /data/adb
}
2018-04-05 17:54:09 +00:00
db_restore() {
2018-02-18 10:12:12 +00:00
chmod 700 /data/adb
2018-06-11 16:04:36 +00:00
magisk --restorecon
2018-02-18 04:41:58 +00:00
}
2018-04-05 17:54:09 +00:00
db_setup() {
2018-02-18 04:41:58 +00:00
local USER=$1
local USERID=$(($USER / 100000))
local DIR=/sbin/.core/db-${USERID}
mkdir -p $DIR
touch $DIR/magisk.db
2018-02-18 10:12:12 +00:00
mount -o bind /data/adb/magisk.db $DIR/magisk.db
2018-04-22 05:53:25 +00:00
rm -f /data/adb/magisk.db-*
2018-04-14 10:08:53 +00:00
chcon u:object_r:magisk_file:s0 $DIR $DIR/*
2018-02-18 04:41:58 +00:00
chmod 700 $DIR
chown $USER.$USER $DIR
chmod 666 $DIR/*
}
2018-05-13 10:14:10 +00:00
env_check() {
for file in busybox magisk magiskboot magiskinit util_functions.sh boot_patch.sh; do
2018-06-25 16:29:01 +00:00
[ -f /data/adb/magisk/$file ] || return 1
2018-05-13 10:14:10 +00:00
done
return 0
}
2018-06-25 16:29:01 +00:00
mm_patch_dtbo() {
if $KEEPVERITY; then
echo false
else
find_dtbo_image
patch_dtbo_image >/dev/null 2>&1 && echo true || echo false
fi
}