termux / proot

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

bug: Truncate failed permission denied #48

Closed JanuszChmiel closed 3 years ago

JanuszChmiel commented 5 years ago

I would like to kindly ask The core developer of this package for help. If I run 64 bit ARM Linux distribution on ARM 32 bit cpu, I get The following error. Truncatefailed, permission denied. This bug persists while using many C or C++ applications. And I do not know, if it would be possible to solve this by making somechangesto Proot, or if this bug is caused by The fact, that My Android device is not rooted, so there is no access to some protected kernel functions? Proot is ideal project and to be honest, it mean big revolution for all visually impaired users. Because every user can use Orca screen readerwith several Linux distributionsthanks to The rermux. But Proot is really project for experienced absolvent of informatics studies, so I can not play with it and I can not try to repair such complex error myself. Do you think, that you could look at this bug? Debian ARM 64 bit stable report it very often. To test it, install espeak from Debian sudo apt install espeak type espeak hello You will get truncate failed permission denied bug. This bug can have effect on C and C++ applications stability. Ifis it possible to analyse The reasons of this bug and if this bug can be solved with noneed to root Android device, please let Me know.

ghost commented 5 years ago

If I run 64 bit ARM Linux distribution on ARM 32 bit cpu This bug persists while using many C or C++ applications.

If that were a bug... Running 64 bit program on 32 bit CPU, it's unbelievable. You probably want to say that you tried to 32bit on 64, right ?

JanuszChmiel commented 5 years ago

Really, it is possible thanks to special variant of qemu which run in user mode. It can fastly emulate 64 bit ARM instructions, really. I have used several Android apps which have used Proot. And really, my CPu is ARM 32 bit and I Am using 64 bit variant of Linux. I know it thanks to The names of repositories.

ghost commented 5 years ago

@JanuszChmiel Why you didn't mentioned before that you used QEMU ?

If you used qemu-user-aarch64 from my repo, I can check it. Seems more like that issue with qemu, not proot, just haven't tested it well except qemu-user-x86_64.

JanuszChmiel commented 5 years ago

I Am very sorry, may be, that I play on professional and I Am telling you nonsenses. So. I use Termux latest stable from Google Play, And I run Debian which have been setup to termux by using The following script.

https://codeload.github.com/sp4rkie/debian-on-termux/zip/master You can try to install Espeak as test to test truncate fault permission denied. You can even try it from termux by typing pkg install espeak May be, that problem is not related to Proot, that problem resides somewhere else. Thank you very much for yours cooperation.

ghost commented 5 years ago

https://codeload.github.com/sp4rkie/debian-on-termux/zip/master You can try to install Espeak as test to test truncate fault permission denied. You can even try it from termux by typing pkg install espeak

Okay, I downloaded that script. But it doesn't use QEMU. Did you modified it ? If you did, then can you post here changes ?

JanuszChmiel commented 5 years ago

Oh it do not use Qemu? I have made my bad assumption. I must always read The script before making wrong decisions.

Thank you very much for yours time and help.

ghost commented 5 years ago

The script has the following lines:

ARCHITECTURE=$(uname -m)
case $ARCHITECTURE in    # supported architectures include: armel, armhf, arm64, i386, amd64
    aarch64) ARCHITECTURE=arm64 ;;
    x86_64) ARCHITECTURE=amd64 ;;
    armv7l) ARCHITECTURE=armhf ;;
    armel|armhf|arm64|i386|amd64|mips|mips64el|mipsel|ppc64el|s390x) ;; # Officially supported Debian Stretch architectures
    *) echo "Unsupported architecture $ARCHITECTURE"; exit ;;
esac

- this means it always installs correct architecture for your device, i.e. arm installs only on arm, and arm64 only on arm64 (which is aarch64). I will test this script with espeak installation so we will know what actually happens here.

Only https://github.com/xeffyr/termux-builder uses proot + qemu to run Linux chroot'ed ubuntu.

JanuszChmiel commented 5 years ago

Dear Mr Plyush, Thank you very much for yours testsand for yours patience with Me.

ghost commented 5 years ago

I can't reproduce your espeak error. But I got something different:

root@localhost:~# espeak
hs
shared memfd open() failed: Function not implemented
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name

Full log you can find here: https://gist.github.com/xeffyr/6a28b9710be0edd02fe2b629aee19a90


From this log you can see that espeak tries to use shared memory and ALSA - both features that unusable on Android. At least in usual way.


Likely, that's not a proot's issue. But since that you didn't provide any logs, it is not possible to say why you have Permission denied instead of error shown above.

kazz2020 commented 5 years ago

I

JanuszChmiel commented 5 years ago

Yes, but fortunately Espeak can speak even if shared memory is not being supported. It is possible thanks to one trick. Export PULSE_SERVER=127.0.0.1 And it is necessary to start and install Pulseaudio in Termux. By typing special command pkg install pulseaudio

pulseaudio --start --exit-idle-time=-1 pacmd load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1

It is all. It is possible to add this to /etc/profile Bash script so Termux is able to listen for streams from other distribution which uses Proot. It can sound unbelievable but this work and I can even use complex applications such as Firefox or Seamonkey and I can share system resources of Android with Termux and other distribution. It is even possible to use screen reader Orca which uses DBUS and AT-SPI.

ghost commented 5 years ago

This issue is not related to https://github.com/termux/proot/issues/50 ? If related, I hope @michalbednarski will close this and #50 because it is not possible to have chroot'ed environment on typical sdcard file systems.

michalbednarski commented 5 years ago

I also couldn't get "Truncate failed permission denied" when running espeak hello -w hello.wav (writing speech to file as I haven't set up ALSA) in Debian chroot as described above (32bit processor and system)

$ bin/enter_deb 
root@localhost:~# cat /etc/apt/sources.list
deb https://deb.debian.org/debian stable main
root@localhost:~# dpkg --print-architecture
armhf
root@localhost:~# espeak hello -w hello.wav
root@localhost:~# ls -l hello.wav
-rw-------. 1 root root 31640 Nov 10 18:18 hello.wav

@xeffyr I think your comment was meant to be posted on another issue as I don't see this being related to sdcard. Thanks for your help with issues, it's very helpful.

ghost commented 5 years ago

@michalbednarski I just thought that @JanuszChmiel tried something to do on sdcard (as in https://github.com/termux/proot/issues/50). It's very easy to get permission denied or similar here.

I can't reproduce this on arm64 or armhf. Maybe we missed some steps, it's very unclear what's @JanuszChmiel actually installed and what he did to get problem.

Also, I have looked espeak's source code and I can't find any mention of truncate (except comments), so problem may not be related to espeak.

@JanuszChmiel Can you install strace and try to run espeak (or what's causing error) with it ? Then post log here.

JanuszChmiel commented 5 years ago

Yes,you have absolutely right. Error is not only specific for Espeak. Esepak which is The part ot Termux repository do not cause this bug. I will try to find other C or C++ simple app which do not have something to do with sound servers and I will try to use Ubuntu, since installscript for this distro in Termux is The most simplest. I can only confirm very important think. All packages for Termux, which have been specially patched to support modified version of Libc,which is The part of Termux installation do not cause this problem. I think, that those errors are causing because ofThe fact, that it is not standard environment. That when somebody run some Linux distribution in its stricly userspace mode, there will be complex programmers issues related to dependent C libraries. I will accept The fact, that when I will run those Linux distribution by using Proot, I will ignore those bugs, since I Am afraid, that repairing them would require many many hours of debugging may be even Libc library from Debian, Ubuntu, Archlinux. And it would require core developers of all Linux deistribution to make many programmers condition blocks to determine if user runs only userspace variant of Linux or if it is full Linux distribution. I think, that it will also depend on if many developers will officially support to run Linux distribution which will share its system resources with Android kernel. It would be too complex. I Am glad, that I can use Orca, Seamonkey and even Firefox in Debian, Ubuntu and Archlinux withoutsevere dangerous system crashes. Because I do not see at all, I do not have problems, that X session can not support graphics rendering and hardware acceleration. I have also found out, that if somebody would be able to make some Xorg which would allow users to use Xserver without graphics driver, it would be The best possible scenario. Because for visually impaired users, it would not causeproblems if display donot contain some graphical output.

Grimler91 commented 3 years ago

Closing since issue has not been updated in quite a while, and it seems it cannot be reproduced