termux / proot

An chroot-like implementation using ptrace.
https://wiki.termux.com/wiki/PRoot
Other
745 stars 161 forks source link

[Bug]: qemu-x86_64": library "libc.so" not found. #229

Open Anonymous2716 opened 2 years ago

Anonymous2716 commented 2 years ago

Problem description

I extracted the rootfs of alpine-x86_64 after installing from iso with qemu. and here is the script I ran

unset LD_PRELOAD

proot --kill-on-exit -q qemu-x86_64 --link2symlink -0 -r /data/data/com.termux/files/home/q -b $ANDROID_DATA -b /dev/ -b $EXTERNAL_STORAGE -b $HOME -b /proc/ -b /storage/ -b q/root:/dev/shm -b /sys/ -w "$PWD" /usr/bin/env -i HOME=/root TERM=xterm-256color /bin/bash -l

And it got me the error above.

What steps will reproduce the bug?

Descriptions ^

What is the expected behavior?

No response

System information

termux-info:

Termux Variables:
TERMUX_API_VERSION=0.50.1
TERMUX_APK_RELEASE=F_DROID
TERMUX_APP_PID=31471
TERMUX_IS_DEBUGGABLE_BUILD=0
TERMUX_MAIN_PACKAGE_FORMAT=debian
TERMUX_VERSION=0.118.0
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://plug-mirror.rcac.purdue.edu/termux/termux-main/ stable main
# x11-repo (sources.list.d/x11.list)
deb https://packages.termux.org/apt/termux-x11 x11 main
Updatable packages:
All packages up to date
Android version:
9
Kernel build information:
Linux localhost 4.4.146 termux/termux-packages#2 SMP PREEMPT Wed Sep 9 18:47:45 CST 2020 aarch64 Android
Randrianasulu commented 2 years ago

I have this in my proot scripts on Android 10:

$ cat proot.sh
#!/bin/sh
unset LD_PRELOAD
proot -r deb_11 -0 -b /sys -b /proc -b /dev -b /system -b /apex --link2symlink  -q qemu-i386 /bin/bash --login

try to add /system and /apex to your binded dirs?

Anonymous2716 commented 2 years ago

I'm on android 9 so apex doesn't exist right? I added /system and that gave me error while loading /usr/bin/env: Exec format error does that make it a proot issue ? I tried removing this /use/bin/env . then it gave me Error while loading /bin/ash: Exec format error.

Grimler91 commented 2 years ago

Exec format error means that something is run for the wrong architecture, indicating that either /usr/bin/env and /bin/ash are not run under qemu, or that they aren't x86_64 binaries

Anonymous2716 commented 2 years ago
ash: ASCII text, with no line terminators
~/q/bin $ cat ash
/bin/busybox
~/q/bin $ file busybox
busybox: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-x86_64.so.1, stripped
~/q/bin $

~/q/usr/bin $ file env
env: ASCII text, with no line terminators
~/q/usr/bin $ cat env
~/q/usr/bin $ cat env
/bin/busybox
~/q/usr/bin $

Am I doing anything wrong in the script should add something?

michalbednarski commented 2 years ago

Fixed version should soon be available in apt repo as proot-5.1.107-54

After that initial command from initial post should work (after replacing bash -> sh, there's no bash in alpine and trying doing so launches Termux bash which doesn't work in such rootfs configuration)

Only thing remaining will be WARNING: linker: Warning: failed to find generated linker configuration from "/linkerconfig/ld.config.txt", copy that file to guest rootfs to get rid of that warning

Anonymous2716 commented 2 years ago

I maybe figured out the actual issue. After binding /system qemu finds libc.so but ash or env were just text files . they should be symbolic links to busybox . I changed the /use/bin/env and /bin/ash with symbolic links and I was abole to login successfully . maybe it is the issue with extraction. I extracted with 7z from qcow2 image. Now I have to change all the text files with symbolic links . is there any other extractors ?

Anonymous2716 commented 2 years ago

@michalbednarski I installed bash before extracting the rootfs. BTW my issue seems to be solved now. Thanks for the Info's.

Anonymous2716 commented 2 years ago

Can I close this issue? Well I get more weird errors with qemu-aarch64.