[Magisk] oskaw:
Hi!

My tablet (Lenovo SmartTab, YT-X705F) have a broken screen but adbd is running so I hope I can backup a local database from my App. Unfortunetly my ADB-RSA key is not registered (unauthorized). But the bootloader is unlocked, so I'am able to temporarly boot images. I try to edit the /data/misc/adb/adb_keys file.

And I have the same tablet with the same firmware version.

What I've done:

1. Download stockfirmware YT-X705F_S001135_210909_ROW (I checked. It is the right version)

2. Use Magisk to patch the recovery.img

3. Check if I can boot -> yes fastboot boot magisk_patched_recovery_YT_X705F_S001135_210909.img works

4. Download AIK-Linux and run in a Windows WSL environment

5. Put the magisk_patched_recovery_YT_X705F_S001135_210909.img into the AIK folder

6. Run unpackimg.sh

7. Goto ramdisk/overlay.d

8. Add a file ramdisk/overlay.d/custom.rc (content see below)

9. Add adb_keys files (extracted from another Tablet) -> ramdisk/overlay.d/sbin/adb_keys

10. Add myscript.sh -> ramdisk/overlay.d/sbin/myscript.sh

11. From WSL make sure that is executable by chmod +x ramdisk/overlay.d/sbin/myscript.sh

12. Run AIK repackimg.sh

13. Boot the repacked pathed image with fastboot boot image-new.img

There is a developers guide for the Magisk overlay system: https://topjohnwu.github.io/Magisk/guides.html#root-directory-overlay-system

ramdisk/overlay.d/custom.rc

on early-init
setprop sys.example.foo bar
start myservice

service myservice ${MAGISKTMP}/myscript.sh
oneshot

ramdisk/overlay.d/sbin/myscript.sh

#!/system/bin/sh

touch /sdcard/Download/elvis.lifes.txt
#cp /sbin/adb_keys /data/misc/adb/adb_keys
#chown system:shell /data/misc/adb/adb_keys
#chmod 640 /data/misc/adb/adb_keys

After booting the repacked patched recovery the files put in ramdisk/overlay.d/sbin I can see in the Tablet:

$ adb shell
$ YT-X705F:/sbin $ ls
> adb_keys magisk magisk32 magisk64 magiskhide magiskinit magiskpolicy myscript.sh resetprop su supolicy

And setprop in the custom.rc also worked:

$ YT-X705F:/sbin $ getprop sys.example.foo
> bar

But there is no /sdcard/Download/elvis.lifes.txt file:

$ (ls /sdcard/Download/elvis.lifes.txt && echo yes) || echo no
> no

If I run the script manually, it work:

$ YT-X705F:/sbin $ sh myscript.sh
$ (ls /sdcard/Download/elvis.lifes.txt && echo yes) || echo no
> yes

What I also tried is:

- instead of running a script put write /sdcard/Download/elvis.lifes.txt 123 in the custom.rc

- instead of running a service (myservice) I use exec in custom.rc

- put these things not in early-init but in post-fs-data (not sure, what is the right init stage where /sdcard/Download exists)

- create a ramdisk/overlay.d/data/misc/adb/elvis.lifes.txt

But nothing works. Only setprop is executed from custom.rc and the files are copied from ramdisk/overlay.d/sbin into Tablets /sbin.

Any idea?

Here is the log:

$ YT-X705F:/cache # cat magisk.log
> 05-15 17:58:51.605 530 530 I : Magisk 23.0(23000) daemon started
> 05-15 17:58:51.607 530 530 I : * Device API level: 29
> 05-15 17:58:51.767 530 532 I : ** post-fs-data mode running
> 05-15 17:58:51.767 530 532 I : * Mounting mirrors
> 05-15 17:58:51.767 530 532 I : mount: /sbin/.magisk/mirror/vendor
> 05-15 17:58:51.767 530 532 I : mount: /sbin/.magisk/mirror/data
> 05-15 17:58:51.767 530 532 I : link: /sbin/.magisk/mirror/cache
> 05-15 17:58:51.767 530 532 I : link: /sbin/.magisk/mirror/persist
> 05-15 17:58:51.767 530 532 I : link: /sbin/.magisk/mirror/system
> 05-15 17:58:51.767 530 532 I : mount: /sbin/.magisk/mirror/system_root
> 05-15 17:58:51.767 530 532 I : link: /sbin/.magisk/mirror/product
> 05-15 17:58:51.767 530 532 I : * Initializing Magisk environment
> 05-15 17:58:52.063 530 532 I : * Running post-fs-data.d scripts
> 05-15 17:58:52.086 530 532 I : * Running module post-fs-data scripts
> 05-15 17:58:52.091 530 532 I : * Loading modules
> 05-15 17:58:52.091 530 532 I : sqlite3: loading mount files
> 05-15 17:58:52.091 530 532 I : nano-ndk: loading mount files
> 05-15 17:58:52.091 530 532 I : hosts: loading mount files
> 04-07 12:00:46.606 530 873 I : ** late_start service mode running
> 04-07 12:00:46.607 530 873 I : * Running service.d scripts
> 04-07 12:00:46.617 530 873 I : * Running module service scripts
> 04-07 12:00:46.618 530 873 I : ssh: exec [service.sh]
> 04-07 12:00:58.233 530 2077 I : ** boot_complete triggered