Commit f50d9bc3 authored by Nolen Johnson's avatar Nolen Johnson Committed by Michael Bestas
Browse files

lineage: Deprecate AddonSU

* We are no longer providing our own root access solution
  as of 17.0, as PermissionHub has largely replaced the
  functionallity of Privacy Guard, which this feature
  was housed in.

* We do still have a baked in ADB root solution that can
  be enabled in developer settings (see topic:ten-adbroot
  on Gerrit).

* This DOES NOT mean we will be providing support for other
  root solutions.

Change-Id: Iecf92e3c8f91304ed998e0260d09a8048dc44d82
parent 8f3d9417
#!/sbin/sh
#
# ADDOND_VERSION=2
#
. /tmp/backuptool.functions
list_files() {
cat <<EOF
bin/su
etc/init/superuser.rc
xbin/su
EOF
}
case "$1" in
backup)
list_files | while read FILE DUMMY; do
backup_file $S/"$FILE"
done
;;
restore)
list_files | while read FILE REPLACEMENT; do
R=""
[ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT"
restore_file $S/"$FILE" "$R"
done
;;
pre-backup)
# Stub
;;
post-backup)
# Stub
;;
pre-restore)
# Stub
;;
post-restore)
# Stub
;;
esac
#!/sbin/sh
# 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
else
block=/dev/block/bootdevice/by-name/system
fi
mkdir -p /system_root
if mount -o rw $block /system_root ||
mount -o rw $block /system_root -t ext4 ||
mount -o rw $block /system_root -t f2fs; 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
exit 1
#!/sbin/sh
# Modern devices use /system as root ("/")
system_as_root=`getprop ro.build.system_root_image`
if [ "$system_as_root" == "true" ]; then
if umount /system_root; then
exit 0
fi
else
if umount /system; then
exit 0
fi
fi
exit 1
ui_print("Installing su addon...");
ifelse(is_mounted("/system"), unmount("/system"));
package_extract_file("mount-system.sh", "/tmp/mount-system.sh");
package_extract_file("unmount-system.sh", "/tmp/unmount-system.sh");
set_metadata("/tmp/mount-system.sh", "uid", 0, "gid", 0, "mode", 0755);
set_metadata("/tmp/unmount-system.sh", "uid", 0, "gid", 0, "mode", 0755);
run_program("/tmp/mount-system.sh") == 0 || abort("Could not mount /system");
if getprop("ro.build.system_root_image") != "true" then
package_extract_dir("system", "/system");
set_metadata("/system/addon.d/51-addonsu.sh", "uid", 0, "gid", 0, "mode", 0755, "selabel", "u:object_r:system_file:s0");
set_metadata("/system/etc/init/superuser.rc", "uid", 0, "gid", 0, "mode", 0644, "selabel", "u:object_r:system_file:s0");
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_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");
ui_print("Done");
set_progress(1.000000);
ui_print("Removing su addon...");
ifelse(is_mounted("/system"), unmount("/system"));
package_extract_file("mount-system.sh", "/tmp/mount-system.sh");
package_extract_file("unmount-system.sh", "/tmp/unmount-system.sh");
set_metadata("/tmp/mount-system.sh", "uid", 0, "gid", 0, "mode", 0755);
set_metadata("/tmp/unmount-system.sh", "uid", 0, "gid", 0, "mode", 0755);
run_program("/tmp/mount-system.sh") == 0 || abort("Could not mount /system");
if getprop("ro.build.system_root_image") != "true" then
delete("/system/addon.d/51-addonsu.sh");
delete("/system/bin/su");
delete("/system/etc/init/superuser.rc");
delete("/system/xbin/su");
else
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");
ui_print("Done");
set_progress(1.000000);
ADDONSU_PREBUILTS_PATH := vendor/lineage/addonsu/
ADDONSU_INSTALL_OUT := $(PRODUCT_OUT)/addonsu-install/
ADDONSU_INSTALL_TARGET := $(PRODUCT_OUT)/addonsu-$(PRODUCT_VERSION_MAJOR).$(PRODUCT_VERSION_MINOR)-$(TARGET_ARCH).zip
$(ADDONSU_INSTALL_TARGET): $(ALL_MODULES.updater.BUILT) \
$(ALL_MODULES.su.BUILT) $(ALL_MODULES.su.PATH)/superuser.rc
$(hide) rm -rf $@ $(ADDONSU_INSTALL_OUT)
$(hide) mkdir -p $(ADDONSU_INSTALL_OUT)/META-INF/com/google/android/
$(hide) mkdir -p $(ADDONSU_INSTALL_OUT)/system/xbin
$(hide) mkdir -p $(ADDONSU_INSTALL_OUT)/system/addon.d
$(hide) mkdir -p $(ADDONSU_INSTALL_OUT)/system/etc/init
$(hide) cp $(ALL_MODULES.su.BUILT) $(ADDONSU_INSTALL_OUT)/system/xbin/
$(hide) cp $(ALL_MODULES.su.PATH)/superuser.rc $(ADDONSU_INSTALL_OUT)/system/etc/init/
$(hide) cp $(ALL_MODULES.updater.BUILT) $(ADDONSU_INSTALL_OUT)/META-INF/com/google/android/update-binary
$(hide) cp $(ADDONSU_PREBUILTS_PATH)/51-addonsu.sh $(ADDONSU_INSTALL_OUT)/system/addon.d/
$(hide) cp $(ADDONSU_PREBUILTS_PATH)/mount-system.sh $(ADDONSU_INSTALL_OUT)/
$(hide) cp $(ADDONSU_PREBUILTS_PATH)/unmount-system.sh $(ADDONSU_INSTALL_OUT)/
$(hide) cp $(ADDONSU_PREBUILTS_PATH)/updater-script-install $(ADDONSU_INSTALL_OUT)/META-INF/com/google/android/updater-script
$(hide) (cd $(ADDONSU_INSTALL_OUT) && zip -qr $@ *)
.PHONY: addonsu
addonsu: $(ADDONSU_INSTALL_TARGET)
@echo "Done: $(ADDONSU_INSTALL_TARGET)"
ADDONSU_REMOVE_OUT := $(PRODUCT_OUT)/addonsu-remove/
ADDONSU_REMOVE_TARGET := $(PRODUCT_OUT)/addonsu-remove-$(PRODUCT_VERSION_MAJOR).$(PRODUCT_VERSION_MINOR)-$(TARGET_ARCH).zip
$(ADDONSU_REMOVE_TARGET): $(ALL_MODULES.updater.BUILT)
$(hide) rm -rf $@ $(ADDONSU_REMOVE_OUT)
$(hide) mkdir -p $(ADDONSU_REMOVE_OUT)/META-INF/com/google/android/
$(hide) cp $(ALL_MODULES.updater.BUILT) $(ADDONSU_REMOVE_OUT)/META-INF/com/google/android/update-binary
$(hide) cp $(ADDONSU_PREBUILTS_PATH)/mount-system.sh $(ADDONSU_REMOVE_OUT)/
$(hide) cp $(ADDONSU_PREBUILTS_PATH)/unmount-system.sh $(ADDONSU_REMOVE_OUT)/
$(hide) cp $(ADDONSU_PREBUILTS_PATH)/updater-script-remove $(ADDONSU_REMOVE_OUT)/META-INF/com/google/android/updater-script
$(hide) (cd $(ADDONSU_REMOVE_OUT) && zip -qr $@ *)
.PHONY: addonsu-remove
addonsu-remove: $(ADDONSU_REMOVE_TARGET)
@echo "Done: $(ADDONSU_REMOVE_TARGET)"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment