Fix SELinux context

This commit is contained in:
Howard Wu 2023-06-03 01:19:51 +08:00
parent d5ed25eddd
commit c622109277
2 changed files with 9 additions and 7 deletions

View File

@ -47,7 +47,7 @@ Function Test-CommandExist {
Finally { $ErrorActionPreference = $OldPreference }
} #end function Test-CommandExist
function Finish {
Function Finish {
Clear-Host
If (Test-CommandExist Optimize-VHD) {
Write-Output "Optimizing VHDX size...."

View File

@ -779,17 +779,17 @@ on post-fs-data
mount none none /dev/debug_ramdisk_mirror private
mount tmpfs magisk /debug_ramdisk mode=0755
copy /dev/debug_ramdisk_mirror/magisk64 /debug_ramdisk/magisk64
chmod 0711 /debug_ramdisk/magisk64
chmod 0755 /debug_ramdisk/magisk64
symlink ./magisk64 /debug_ramdisk/magisk
symlink ./magisk64 /debug_ramdisk/su
symlink ./magisk64 /debug_ramdisk/resetprop
start adbd
copy /dev/debug_ramdisk_mirror/magisk32 /debug_ramdisk/magisk32
chmod 0711 /debug_ramdisk/magisk32
chmod 0755 /debug_ramdisk/magisk32
copy /dev/debug_ramdisk_mirror/magiskinit /debug_ramdisk/magiskinit
chmod 0711 /debug_ramdisk/magiskinit
chmod 0750 /debug_ramdisk/magiskinit
copy /dev/debug_ramdisk_mirror/magiskpolicy /debug_ramdisk/magiskpolicy
chmod 0711 /debug_ramdisk/magiskpolicy
chmod 0755 /debug_ramdisk/magiskpolicy
mkdir /debug_ramdisk/.magisk
mkdir /debug_ramdisk/.magisk/mirror 0
mkdir /debug_ramdisk/.magisk/block 0
@ -797,7 +797,7 @@ on post-fs-data
copy /dev/debug_ramdisk_mirror/stub.apk /debug_ramdisk/stub.apk
chmod 0644 /debug_ramdisk/stub.apk
copy /dev/debug_ramdisk_mirror/loadpolicy.sh /debug_ramdisk/loadpolicy.sh
chmod 0711 /debug_ramdisk/loadpolicy.sh
chmod 0755 /debug_ramdisk/loadpolicy.sh
umount /dev/debug_ramdisk_mirror
rmdir /dev/debug_ramdisk_mirror
exec u:r:magisk:s0 0 0 -- /system/bin/sh /debug_ramdisk/loadpolicy.sh
@ -820,6 +820,7 @@ for i in "$NEW_INITRC_DIR"/*; do
if [[ "$i" =~ init.zygote.+\.rc ]]; then
echo "Inject zygote restart $i"
sudo awk -i inplace '{if($0 ~ /service zygote /){print $0;print " exec u:r:magisk:s0 0 0 -- /debug_ramdisk/magisk --zygote-restart";a="";next}} 1' "$i"
sudo setfattr -n security.selinux -v "u:object_r:system_file:s0" "$i" || abort
fi
done
@ -859,7 +860,7 @@ if [ "$GAPPS_BRAND" != 'none' ]; then
fi
sudo cp --preserve=all -r "$WORK_DIR/gapps/product/"* "$PRODUCT_MNT" || abort
find "$WORK_DIR/gapps/product/overlay" -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder sudo find "$PRODUCT_MNT/overlay/placeholder" -type f -exec setfattr -n security.selinux -v "u:object_r:vendor_overlay_file:s0" {} \; || abort
find "$WORK_DIR/gapps/product/overlay" -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder sudo find "$PRODUCT_MNT/overlay/placeholder" -type f -exec setfattr -n security.selinux -v "u:object_r:system_file:s0" {} \; || abort
find "$WORK_DIR/gapps/product/etc/" -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder sudo find "$PRODUCT_MNT/etc/placeholder" -type d -exec setfattr -n security.selinux -v "u:object_r:system_file:s0" {} \; || abort
find "$WORK_DIR/gapps/product/etc/" -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder sudo find "$PRODUCT_MNT/etc/placeholder" -type f -exec setfattr -n security.selinux -v "u:object_r:system_file:s0" {} \; || abort
@ -873,6 +874,7 @@ if [ "$GAPPS_BRAND" != 'none' ]; then
find "$WORK_DIR/gapps/etc/" -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder sudo find "$SYSTEM_MNT/etc/placeholder" -type d -exec setfattr -n security.selinux -v "u:object_r:system_file:s0" {} \; || abort
find "$WORK_DIR/gapps/etc/" -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder sudo find "$SYSTEM_MNT/etc/placeholder" -type f -exec setfattr -n security.selinux -v "u:object_r:system_file:s0" {} \; || abort
else
sudo setfattr -n security.selinux -v "u:object_r:system_file:s0" "$PRODUCT_MNT/framework" || abort
find "$WORK_DIR/gapps/product/app/" -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder sudo find "$PRODUCT_MNT/app/placeholder" -type d -exec setfattr -n security.selinux -v "u:object_r:system_file:s0" {} \; || abort
find "$WORK_DIR/gapps/product/priv-app/" -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder sudo find "$PRODUCT_MNT/priv-app/placeholder" -type d -exec setfattr -n security.selinux -v "u:object_r:system_file:s0" {} \; || abort
find "$WORK_DIR/gapps/product/framework/" -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder sudo find "$PRODUCT_MNT/framework/placeholder" -type d -exec setfattr -n security.selinux -v "u:object_r:system_file:s0" {} \; || abort