addonsu: Don't mount SAR system to /system

Change-Id: Ic2f0a994477a5bc04b32e24b0bd4baaa2773ff55
gugelfrei
Michael Bestas 5 years ago committed by Paul Keith
parent 9717ee7b80
commit 79e91fe4ca

@ -1,18 +1,12 @@
#!/sbin/sh
if mount /system; then
exit 0
fi
# Try to get the block from /etc/recovery.fstab
block=`cat /etc/recovery.fstab | cut -d '#' -f 1 | grep /system | grep -o '/dev/[^ ]*' | head -1`
if [ -n "$block" ] && mount $block /system; then
exit 0
fi
# Modern devices use /system as root ("/")
system_as_root=`getprop ro.build.system_root_image`
if [ "$system_as_root" == "true" ]; then
if mount /system_root; then
exit 0
fi
active_slot=`getprop ro.boot.slot_suffix`
if [ ! -z "$active_slot" ]; then
block=/dev/block/bootdevice/by-name/system$active_slot
@ -20,7 +14,17 @@ if [ "$system_as_root" == "true" ]; then
block=/dev/block/bootdevice/by-name/system
fi
mkdir -p /system_root
if mount -o rw $block /system_root && mount /system_root/system /system; then
if mount -o rw $block /system_root; then
exit 0
fi
else
if mount /system; then
exit 0
fi
# Try to get the block from /etc/recovery.fstab
block=`cat /etc/recovery.fstab | cut -d '#' -f 1 | grep /system | grep -o '/dev/[^ ]*' | head -1`
if [ -n "$block" ] && mount $block /system; then
exit 0
fi
fi

@ -3,13 +3,13 @@
# Modern devices use /system as root ("/")
system_as_root=`getprop ro.build.system_root_image`
if [ "$system_as_root" == "true" ]; then
if umount /system && umount /system_root; then
if umount /system_root; then
exit 0
fi
fi
if umount /system; then
else
if umount /system; then
exit 0
fi
fi
exit 1

@ -13,11 +13,11 @@ if getprop("ro.build.system_root_image") != "true" then
set_metadata("/system/xbin/su", "uid", 0, "gid", 2000, "mode", 0755, "selabel", "u:object_r:su_exec:s0");
symlink("/system/xbin/su", "/system/bin/su");
else
package_extract_dir("system", "/system/system");
set_metadata("/system/system/addon.d/51-addonsu.sh", "uid", 0, "gid", 0, "mode", 0755, "selabel", "u:object_r:system_file:s0");
set_metadata("/system/system/etc/init/superuser.rc", "uid", 0, "gid", 0, "mode", 0644, "selabel", "u:object_r:system_file:s0");
set_metadata("/system/system/xbin/su", "uid", 0, "gid", 2000, "mode", 0755, "selabel", "u:object_r:su_exec:s0");
symlink("/system/xbin/su", "/system/system/bin/su");
package_extract_dir("system", "/system_root/system");
set_metadata("/system_root/system/addon.d/51-addonsu.sh", "uid", 0, "gid", 0, "mode", 0755, "selabel", "u:object_r:system_file:s0");
set_metadata("/system_root/system/etc/init/superuser.rc", "uid", 0, "gid", 0, "mode", 0644, "selabel", "u:object_r:system_file:s0");
set_metadata("/system_root/system/xbin/su", "uid", 0, "gid", 2000, "mode", 0755, "selabel", "u:object_r:su_exec:s0");
symlink("/system/xbin/su", "/system_root/system/bin/su");
endif;
run_program("/tmp/unmount-system.sh") == 0 || ui_print("Could not unmount /system");

@ -12,10 +12,10 @@ if getprop("ro.build.system_root_image") != "true" then
delete("/system/etc/init/superuser.rc");
delete("/system/xbin/su");
else
delete("/system/system/addon.d/51-addonsu.sh");
delete("/system/system/bin/su");
delete("/system/system/etc/init/superuser.rc");
delete("/system/system/xbin/su");
delete("/system_root/system/addon.d/51-addonsu.sh");
delete("/system_root/system/bin/su");
delete("/system_root/system/etc/init/superuser.rc");
delete("/system_root/system/xbin/su");
endif;
run_program("/tmp/unmount-system.sh") == 0 || ui_print("Could not unmount /system");

Loading…
Cancel
Save