addonsu: Don't mount SAR system to /system
Change-Id: Ic2f0a994477a5bc04b32e24b0bd4baaa2773ff55
diff --git a/addonsu/mount-system.sh b/addonsu/mount-system.sh
index 5886f15..ae2e272 100644
--- a/addonsu/mount-system.sh
+++ b/addonsu/mount-system.sh
@@ -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 @@
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
diff --git a/addonsu/unmount-system.sh b/addonsu/unmount-system.sh
index 60c5e18..19b3431 100644
--- a/addonsu/unmount-system.sh
+++ b/addonsu/unmount-system.sh
@@ -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
diff --git a/addonsu/updater-script-install b/addonsu/updater-script-install
index 6a9d655..996023c 100644
--- a/addonsu/updater-script-install
+++ b/addonsu/updater-script-install
@@ -13,11 +13,11 @@
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");
diff --git a/addonsu/updater-script-remove b/addonsu/updater-script-remove
index bd753a3..6531e55 100644
--- a/addonsu/updater-script-remove
+++ b/addonsu/updater-script-remove
@@ -12,10 +12,10 @@
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");