Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Using termux-wayland without need to compile it with Termux key. #21

Closed
twaik opened this issue Aug 27, 2021 · 9 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@twaik
Copy link
Member

twaik commented Aug 27, 2021

Hi guys! I have no time to help to the project but I have an idea how to use termux wayland without signing it with the key Termux::App is signed.
The idea is to use the same connection mech Termux::API uses. Look:

  1. Small program in Termux fs creates creates connection to Java service the same way Termux API package does (look here: https://github.com/termux/termux-api-package/blob/master/termux-api.c)
  2. The same program creates Xserver well known sockets and sends fds to Java service.
  3. Java service sends these fds to xserver and xserver can make SetNotifyFd to these sockets (look here: https://github.com/freedesktop/xorg-xserver/blob/18d3131f9a332096825c09106a931c427246ddb7/os/connection.c#L282 )
    It will let us use Unix sockets even if application has another keys. And it is compliant with SELinux security restrictions. Also in the future it will let us use android-emugl modified for Termux to let us use fast GLES (it can be modified to use Unix socket). What do you think?
@twaik twaik added the enhancement New feature or request label Aug 27, 2021
@creepy-pasta101
Copy link
Collaborator

creepy-pasta101 commented Aug 27, 2021

Great Idea.. That means even Third party apps can use termux:wayland.. just like VNC in google play since we have allowed users to set XDG_RUNTIME_DIR

@creepy-pasta101 creepy-pasta101 added the help wanted Extra attention is needed label Aug 27, 2021
@twaik
Copy link
Member Author

twaik commented Aug 30, 2021

Sorry, my fault. I forgot that T::X11 uses Xorg on Termux fs side. We can try to provide wayland socket connection through the Java service. I think it will be much easier than modifying Xorg code.

@twaik
Copy link
Member Author

twaik commented Aug 30, 2021

After receiving socket fd in Java service you can push it to wayland server using wl_display_add_socket_fd function on JNI side.

@twaik
Copy link
Member Author

twaik commented Aug 31, 2021

Ok. I was not right. It is impossible to send Unix socket fd the same way Termux::API does. But we can try to send ACTION_VIEW broadcast with URI to temporary Unix socket. T::X11 will be able to open it and there we will be able to send fd to our socket.
T::X11 needs something like TermuxFileReceiverActivity but with reaction only on specific mime type (like "termux/x11"). This way it will receive READ permission on our temporary Unix socket.
That is the simplest way to make it work with Termux without resigning it and without making any change to Termux::App.
I'll try to make a demo this weekend.

@creepy-pasta101
Copy link
Collaborator

Maybe we can make use of this gist?

@twaik
Copy link
Member Author

twaik commented Sep 1, 2021

The problem is SELinux and Android's restrictions. We can not connect to Unix or abstract sockets directly, we will have access denied error. But we can tell Android that there is Uri in private storage that we want to share with other app (send ACTION_VIEW broadcast with mime) and resolve this Uri in another app with ContentResolver. From here we can get it's AssetFileDescriptor, then ParcelFileDescriptor and finally regular file descriptor that can be passed to C. This file descriptor can be used as a transport for initial setup of socket's.

@twaik
Copy link
Member Author

twaik commented Oct 8, 2021

Solved by #31

@twaik twaik closed this as completed Oct 8, 2021
@Reyhank45
Copy link

How do i use Termux Wayland???

@twaik
Copy link
Member Author

twaik commented Jul 10, 2024

You can not.

@termux termux locked as resolved and limited conversation to collaborators Jul 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants