nix-community / nix-on-droid

Nix-enabled environment for your Android device. [maintainers=@t184256,@Gerschtli]
https://nix-on-droid.unboiled.info
MIT License
1.23k stars 66 forks source link

strace doesn't work #76

Closed deliciouslytyped closed 3 years ago

deliciouslytyped commented 3 years ago

While working on https://github.com/t184256/nix-on-droid/issues/75 , I was unable to debug Xvfb with strace due to the following error:

$ nix-shell -p xorg.xorgserver strace

[nix-shell:~]$ strace Xvfb
proot warning: ptrace request 'PTRACE_???' not supported yet
strace: setreuid: Function not implemented
+++ exited with 1 +++

(I think the proot warning line isn't coming from the child process)

Googling, and the termux IRC suggest it is a proot issue. The only other instance (TODO) f a PTRACE_??? I've been able to find is https://github.com/t184256/nix-on-droid/issues/75 . (TODO:check more thoroughly) but unsurprisingly, the workaround there doesn't help because I find it exceedingly unlikely that random processes are preventing themselves from being inspected.

I got the following input from the termux people, and I'm not sure where to go from here:

Proot possibly interferes with strace because proot is itself an [ab]use of ptrace to try to alter the running process's environment (e.g. to implement certain syscalls, or fake a root directory). So if you are running stuff inside proot, you probably need to strace from "outside" the proot.

Termux doesn't normally use proot, it offers it as a way to run other distros under termux. Proot does have performance implications as well, so termux does not run it by default. Instead, termux builds all packages with paths based on $PREFIX (the app's data directory) instead of / , thus you only need proot to install ubuntu, kali, debian,... inside termux data dir - or other arcane purposes.

I'm guessing nix-on-droid uses proot to try to give the privilege separation nix would give you normally, where the build daemon runs as a separate user from the user; otherwise package builds would be editable by your normal user and thus mutable--like they are in termux.

t184256 commented 3 years ago

That's right, sans for the part why we use ptrace: it's to avoid recompiling the world to move /nix/store, /etc and other stuff into the Nix-on-Droid writable directory.

Fixing strace inside proot is out of the scope of the project, sorry.

And, please, don't bother Termux folks too much with Nix-on-Droid shenanigans, I'm sure they have lots of other stuff to worry about.