tareksander / termux-gui-python-bindings

A Python library to interact with the Termux:GUI plugin
https://tareksander.github.io/termux-gui-python-bindings/index.html
Mozilla Public License 2.0
99 stars 7 forks source link

Compatibility with proot #3

Closed JiriKalvoda closed 1 year ago

JiriKalvoda commented 2 years ago

I would like to use termux-gui from arch linux running in proot in Termux. However there is some problem with UID checking of connection socket.

More precisely. Function _check_user in begin of connection.py file don't working properly. Value of getuid() refer to current user of arch in proot, but socket uid is uid of android user (Termux application). The rest of application (the part I try) work very good even behind proot.

Maybe easy fix of this problem will be adding some possibility how to tell what is right UID of Termmux app (for example thought environment variables).

tareksander commented 2 years ago

As a workaround, you can get the Termux user id by using echo $UID in a normal Termux shell and use proot-distro login with the --user option to essentially pass the UID though into proot. You could even make that one command with proot-distro login --user $(echo $UID).

tareksander commented 2 years ago

I made the branch uid-env to fix this, but I can't test this right now, because I can't get a distro that has a new enough python version to work in my x86_64 android emulator.
You can test it if you want, use python3 -m build to build it.
The env variable TGUI_PY_UID can contain an alternative UID to check against, and the library displays a warning if this is the case. TGUI_PY_UID_NOWARN can be set to any value to suppress the warning.

tareksander commented 2 years ago

I found that alpine also has python 3.10 and tested it, but for me the am command the library uses always segfaults, so the plugin doesn't connect.

JiriKalvoda commented 2 years ago

I have some issues with build the package (but I thing is is bug in proot /tmp dir emulation (or capacity?))

I replace the only edited file direct in /usr/lib/python3.10/site-packages/termuxgui/ and everithing working correctly (as is documented in README) with only one small bug: it pront the warning twice:

jiri@samet:~/termux-gui-python-bindings/tutorial(uid-env)$ TGUI_PY_UID=10343 python helloworld.py
WARNING: Socket UID to check taken from environment variable TGUI_PY_UID
Set TGUI_PY_UID_NOWARN to suppress this message.
WARNING: Socket UID to check taken from environment variable TGUI_PY_UID
Set TGUI_PY_UID_NOWARN to suppress this message.

Than you for very quick fix.

tareksander commented 2 years ago

Ah, it's printed twice because the UID is checked for 2 sockets. But that shouldn't really be a problem. Does suppressing the warning work?

JiriKalvoda commented 2 years ago

But that shouldn't really be a problem.

Yes, it is not problem.

Does suppressing the warning work?

Yes, suppressing is working well.

JiriKalvoda commented 1 year ago

Solved long time ago.