Browse Source

addonsu: Fix installation on TWRP A/B

* These checks need to be added back otherwise it fails to
  extract files due to 'Too many symbolic links encountered' errors.
* Log:
Installing su addon...
Installing su addon...about to run program [/tmp/mount-system.sh] with 1 args
Extracted file "/system/xbin/su"
Extracted file "/system/addon.d/51-addonsu.sh"
failed to create dir for /system/etc/init/superuser.rc
script aborted: set_metadata: Error on lstat of "/system/etc/init/superuser.rc": Too many symbolic links encountered
set_metadata: Error on lstat of "/system/etc/init/superuser.rc": Too many symbolic links encounterederror: 25
cause: 111
Updater process ended with ERROR: 7

Change-Id: Ibf5082756063f7e703cbc47cf9642677983874ac
LuK1337 1 year ago
parent
commit
2dc0cc9879
2 changed files with 24 additions and 9 deletions
  1. 13
    5
      addonsu/updater-script-install
  2. 11
    4
      addonsu/updater-script-remove

+ 13
- 5
addonsu/updater-script-install View File

@@ -6,11 +6,19 @@ set_metadata("/tmp/mount-system.sh", "uid", 0, "gid", 0, "mode", 0755);
6 6
 set_metadata("/tmp/unmount-system.sh", "uid", 0, "gid", 0, "mode", 0755);
7 7
 run_program("/tmp/mount-system.sh") == 0 || abort("Could not mount /system");
8 8
 
9
-package_extract_dir("system", "/system");
10
-set_metadata("/system/addon.d/51-addonsu.sh", "uid", 0, "gid", 0, "mode", 0755, "selabel", "u:object_r:system_file:s0");
11
-set_metadata("/system/etc/init/superuser.rc", "uid", 0, "gid", 0, "mode", 0644, "selabel", "u:object_r:system_file:s0");
12
-set_metadata("/system/xbin/su", "uid", 0, "gid", 2000, "mode", 0755, "selabel", "u:object_r:su_exec:s0");
13
-symlink("/system/xbin/su", "/system/bin/su");
9
+if getprop("ro.build.system_root_image") != "true" then
10
+  package_extract_dir("system", "/system");
11
+  set_metadata("/system/addon.d/51-addonsu.sh", "uid", 0, "gid", 0, "mode", 0755, "selabel", "u:object_r:system_file:s0");
12
+  set_metadata("/system/etc/init/superuser.rc", "uid", 0, "gid", 0, "mode", 0644, "selabel", "u:object_r:system_file:s0");
13
+  set_metadata("/system/xbin/su", "uid", 0, "gid", 2000, "mode", 0755, "selabel", "u:object_r:su_exec:s0");
14
+  symlink("/system/xbin/su", "/system/bin/su");
15
+else
16
+  package_extract_dir("system", "/system/system");
17
+  set_metadata("/system/system/addon.d/51-addonsu.sh", "uid", 0, "gid", 0, "mode", 0755, "selabel", "u:object_r:system_file:s0");
18
+  set_metadata("/system/system/etc/init/superuser.rc", "uid", 0, "gid", 0, "mode", 0644, "selabel", "u:object_r:system_file:s0");
19
+  set_metadata("/system/system/xbin/su", "uid", 0, "gid", 2000, "mode", 0755, "selabel", "u:object_r:su_exec:s0");
20
+  symlink("/system/xbin/su", "/system/system/bin/su");
21
+endif;
14 22
 
15 23
 run_program("/tmp/unmount-system.sh") == 0 || ui_print("Could not unmount /system");
16 24
 ui_print("Done");

+ 11
- 4
addonsu/updater-script-remove View File

@@ -6,10 +6,17 @@ set_metadata("/tmp/mount-system.sh", "uid", 0, "gid", 0, "mode", 0755);
6 6
 set_metadata("/tmp/unmount-system.sh", "uid", 0, "gid", 0, "mode", 0755);
7 7
 run_program("/tmp/mount-system.sh") == 0 || abort("Could not mount /system");
8 8
 
9
-delete("/system/addon.d/51-addonsu.sh");
10
-delete("/system/bin/su");
11
-delete("/system/etc/init/superuser.rc");
12
-delete("/system/xbin/su");
9
+if getprop("ro.build.system_root_image") != "true" then
10
+  delete("/system/addon.d/51-addonsu.sh");
11
+  delete("/system/bin/su");
12
+  delete("/system/etc/init/superuser.rc");
13
+  delete("/system/xbin/su");
14
+else
15
+  delete("/system/system/addon.d/51-addonsu.sh");
16
+  delete("/system/system/bin/su");
17
+  delete("/system/system/etc/init/superuser.rc");
18
+  delete("/system/system/xbin/su");
19
+endif;
13 20
 
14 21
 run_program("/tmp/unmount-system.sh") == 0 || ui_print("Could not unmount /system");
15 22
 ui_print("Done");