Quote:
Originally Posted by Renate
Mmm, those scripts are not going to work.
|
Yeah, it's more of a general idea
I'm trying to understand how things work first!
Quote:
Originally Posted by Renate
Getting ADB going is more than just starting the adbd daemon.
Usually setprop sys.usb.config adb is used, but I believe Onyx screwed around with all that.
|
Actually my plan is to run adbd as root but inside a chroot environment, so any kind screwing up of the defaults by Onyx can be easily fixed and I can use any adbd option I like.
I'm thinking about something like:
chroot /system/apex/com.android.adbd /bin/adbd
However, it fails for mysterious reasons while of course the /system/apex/com.android.adbd/bin/adbd file exists:
chroot: exec /bin/adbd: No such file or directory
I think it's due to dynamic linking but it's not clear why yet. More on that below.
I would be a handy magisk module (to always be able to recover from bad things) but if I can't make that approach work, do you know how to make adb execute earlier on the boox, so that messing up with the framework apk can't prevent me from getting adb shell to fix things?
Quote:
Originally Posted by Renate
If you're using Magisk it does the file shadowing/substitution in init. So any changes are not immediately propagated.
|
Oh you mean it will only be done on next boot? So yeah I'd rather have adb working lol. I guess I'm back to the "adbd as root inside a chroot" plan.
Quote:
Originally Posted by Renate
In worst case, you can flash the stock boot image back and there won't be any Magisk. Then you can delete/modify your Magisk module.
Keep it simple, no shell scripts in your Magisk module.
Try something simple like putting system/hello in your module and see if it's visible.
|
Yeah but then no adb if I mess up, unless I flash another boot.img etc. I guess I could fastboot boot an image without the problematic zip but it's not super clear yet, and I prefer to do things more carefully and understand what I'm doing and why.
About the chroot environment: I can't run any binary that's not static - for example, no dynamically linked binaries from even termux work inside the chroot, while they work just fine outside:
#!/bin/sh
cd /data/data/com.termux/files || exit -1
# don't care about bad flags for data
#mount -o remount,dev,suid /data
# create the bind directories if they don't exist
ls ./apex/ > /dev/null || mkdir ./apex
ls ./system/ > /dev/null || mkdir ./system
ls ./dev/ > /dev/null || mkdir ./dev
Ils ./dev/pts > /dev/null || mkdir ./dev/pts
ls ./sys > /dev/null || mkdir ./sys
ls ./proc/ > /dev/null || mkdir ./proc
# bind the true root dirs
mount --bind /dev ./files/dev
mount --bind /dev/pts ./files/dev/pts
mount --bind /sys ./files/sys
mount --bind /proc ./files/proc
mount --bind /apex ./files/apex
chroot /data/data/com.termux/files/ /bin/sh
This works if /data/data/com.termux/files/bin/sh is a static binary, but it doesn't work otherwise say with /usr/bin/bash - or any other dynamic binary actually.
~ # strace-static ./usr/bin/bash
execve("./usr/bin/bash", ["./usr/bin/bash"], [/* 26 vars */]) = -1 ENOENT (No such file or directory)
write(2, "strace-static: exec: No such fil"..., 47strace-static: exec: No such file or directory
) = 47
mprotect(0x78f37e0000, 4096, PROT_READ|PROT_WRITE) = 0
mprotect(0x78f37e0000, 4096, PROT_READ) = 0
mprotect(0x78f37e0000, 4096, PROT_READ|PROT_WRITE) = 0
mprotect(0x78f37e0000, 4096, PROT_READ) = 0
munmap(0x78f37e0000, 4096) = 0
exit_group(1) = ?
+++ exited with 1 +++
To debug the issue and understand more what's happening, I've tried putting all the libs I see with ldd into a directory in case the ld.conf is the problem, but even strace-static can't see the binary (!!) while it's there otherwise md5 wouldn't work:
~ # /bin/ls -la ./test/
total 3459
drwxr-xr-x 2 root root 3488 Oct 30 21:06 .
drwxrwx--x 17 u0_a150 u0_a150 3488 Oct 30 22:07 ..
-rwx--x--x 1 root root 810936 Oct 30 20:55 bash
-rwx--x--x 1 root root 21808 Oct 30 20:55 libandroid-support.so
-rwxr-xr-x 1 root root 978160 Oct 30 20:55 libc.so
-rwxr-xr-x 1 root root 14176 Oct 30 20:55 libdl.so
-rwx--x--x 1 root root 1050584 Oct 30 20:55 libiconv.so
-rwx--x--x 1 root root 339192 Oct 30 20:55 libncursesw.so.6.2
-rwx--x--x 1 root root 311240 Oct 30 20:55 libreadline.so.8.2
~ # /bin/whoami
root
~ # /bin/md5sum ./test/bash
0bcd4b7ec4961d3cf493cb4280c205e7 ./test/bash
~ # /bin/strace-static ./test/bash
execve("./test/bash", ["./test/bash"], [/* 26 vars */]) = -1 ENOENT (No such file or directory)
write(2, "/bin/strace-static: exec: No suc"..., 52/bin/strace-static: exec: No such file or directory
) = 52
mprotect(0x70bb8d5000, 4096, PROT_READ|PROT_WRITE) = 0
mprotect(0x70bb8d5000, 4096, PROT_READ) = 0
mprotect(0x70bb8d5000, 4096, PROT_READ|PROT_WRITE) = 0
mprotect(0x70bb8d5000, 4096, PROT_READ) = 0
munmap(0x70bb8d5000, 4096) = 0
exit_group(1) = ?
+++ exited with 1 +++
I just don't understand, as it's all in test: outside the chroot, I can see which libraries are needed:
1|BOOX:/data/data/com.termux # linker64 --list
/data/data/com.termux/files/test/bash
linux-vdso.so.1 => [vdso] (0x7a59929000)
(null) => /data/data/com.termux/files/usr/lib/libandroid-support.so (0x7a581b8000)
libreadline.so.8 => /data/data/com.termux/files/usr/lib/libreadline.so.8.2 (0x7a58395000)
libiconv.so => /data/data/com.termux/files/usr/lib/libiconv.so (0x7a581e5000)
libdl.so => /apex/com.android.runtime/lib64/bionic/libdl.so (0x7a58422000)
libc.so => /apex/com.android.runtime/lib64/bionic/libc.so (0x7a58444000)
libncursesw.so.6 => /data/data/com.termux/files/usr/lib/libncursesw.so.6.2 (0x7a5832b000)
I'm a bit lost there. I'd rather have a spare adbd working manually on another port at first, then put it inside a magisk module, and only then start messing up with the framework.
Can I please ask for some help?