aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKoushik Dutta <koushd@gmail.com>2013-07-29 20:10:17 -0700
committerKoushik Dutta <koushd@gmail.com>2013-07-29 20:19:01 -0700
commit912b6d90464adc7065302b33e6fe616771cc5180 (patch)
tree3b1e7336bdfab27b6d89a5b56aebca7da03e2cc1
parentebecbc657e3b8f73f112613a3dfe2eef3078c219 (diff)
downloadbootable_recovery-912b6d90464adc7065302b33e6fe616771cc5180.zip
bootable_recovery-912b6d90464adc7065302b33e6fe616771cc5180.tar.gz
bootable_recovery-912b6d90464adc7065302b33e6fe616771cc5180.tar.bz2
su installation and detection updates for 4.3
Change-Id: Idce9a6d4ca18ddc9b49029024c26bc114f6d3c15
-rw-r--r--extendedcommands.c23
-rw-r--r--su/Android.mk7
-rw-r--r--su/install-su.sh24
3 files changed, 45 insertions, 9 deletions
diff --git a/extendedcommands.c b/extendedcommands.c
index fb64e75..8bf9227 100644
--- a/extendedcommands.c
+++ b/extendedcommands.c
@@ -1588,16 +1588,23 @@ int verify_root_and_recovery() {
int ret = 0;
struct stat st;
- if (0 == lstat("/system/etc/install-recovery.sh", &st)) {
- if (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) {
- ui_show_text(1);
- ret = 1;
- if (confirm_selection("ROM may flash stock recovery on boot. Fix?", "Yes - Disable recovery flash")) {
- __system("chmod -x /system/etc/install-recovery.sh");
+ // check to see if install-recovery.sh is going to clobber recovery
+ // install-recovery.sh is also used to run the su daemon on stock rom for 4.3+
+ // so verify that doesn't exist...
+ if (0 != lstat("/system/etc/.installed_su_daemon", &st)) {
+ // check install-recovery.sh exists and is executable
+ if (0 == lstat("/system/etc/install-recovery.sh", &st)) {
+ if (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) {
+ ui_show_text(1);
+ ret = 1;
+ if (confirm_selection("ROM may flash stock recovery on boot. Fix?", "Yes - Disable recovery flash")) {
+ __system("chmod -x /system/etc/install-recovery.sh");
+ }
}
}
}
+
int exists = 0;
if (0 == lstat("/system/bin/su", &st)) {
exists = 1;
@@ -1629,9 +1636,7 @@ int verify_root_and_recovery() {
ui_show_text(1);
ret = 1;
if (confirm_selection("Root access is missing. Root device?", "Yes - Root device (/system/xbin/su)")) {
- __system("cp /sbin/su.recovery /system/xbin/su");
- __system("chmod 6755 /system/xbin/su");
- __system("ln -sf /system/xbin/su /system/bin/su");
+ __system("/sbin/install-su.sh");
}
}
diff --git a/su/Android.mk b/su/Android.mk
index 8a11752..f086c86 100644
--- a/su/Android.mk
+++ b/su/Android.mk
@@ -17,3 +17,10 @@ LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
include $(BUILD_EXECUTABLE)
+include $(CLEAR_VARS)
+LOCAL_MODULE := install-su.sh
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
+LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
+LOCAL_SRC_FILES := $(LOCAL_MODULE)
+include $(BUILD_PREBUILT)
diff --git a/su/install-su.sh b/su/install-su.sh
new file mode 100644
index 0000000..aad003e
--- /dev/null
+++ b/su/install-su.sh
@@ -0,0 +1,24 @@
+#!/sbin/sh
+cp /sbin/su.recovery /system/xbin/su
+chmod 6755 /system/xbin/su
+ln -sf /system/xbin/su /system/bin/su
+
+# if the system is at least 4.3, and there is no su daemon built in,
+# let's try to install it using install-recovery.sh
+BUILD_RELEASE_VERSION=$(cat /system/build.prop | grep ro\\.build\\.version\\.release)
+IS_43=$(echo $BUILD_RELEASE_VERSION | grep 4\\.3)
+if [ -z "$IS_43" -o "$IS_43" \> "4.3" -o "$IS_43" == "4.3" ]
+then
+ # check for rom su daemon before clobbering install-recovery.sh
+ if [ ! -f "/system/etc/.has_su_daemon" ]
+ then
+ echo -n -e 'ui_print Installing Superuser daemon...\n' > /proc/self/fd/$2
+ echo -n -e 'ui_print\n' > /proc/self/fd/$2
+ cp install-recovery.sh /system/etc/install-recovery.sh
+ chmod 755 /system/etc/install-recovery.sh
+ # note that an post install su daemon was installed
+ # so recovery doesn't freak out and recommend you disable
+ # the install-recovery.sh execute bit.
+ touch /system/etc/.installed_su_daemon
+ fi
+fi