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] Move single-instance socket into dedicated directory #25353

Closed
WhyNotHugo opened this issue Nov 15, 2022 · 10 comments
Closed

Comments

@WhyNotHugo
Copy link
Contributor

Is your feature request related to a problem?

Sandboxing mechanism can expose parts of the host filesystem into a sandbox by bind-mounting them. For example, one can mount ~/.local/share/TelegramDesktop into the same path in a sandbox and Telegram works (assuming the path to the binary and required libraries have been mounted too).

Generally, it is possible can bind-mount any type of file, but it MUST exist on the host.

Telegram Desktop creates its single-instance directory inside $XDG_RUNTIME_DIR, with a non-obvious filename. There's no way for sand-boxing mechanism to ensure that the socket is visible to a second process of telegram-desktop without exposing other sensitive files in $XDG_RUNTIME_DIR. (more on this on "Describe alternatives you've considered" below).

Describe the solution you'd like

A common pattern is to use a dedicated directory. For example, KeePassXC creates its browser-integration socket in a dedicated directory ($XDG_RUNTIME_DIR/app/org.keepassxc.KeePassXC/). This ensures the same directory can be mounted on multiple sandboxes, and the same socket is visible to all of them (in this particular case the same directory is also mounted into the brower's sandbox, but that's beside the point here).

I'd like to propose moving the single-instance sockets into the $XDG_RUNTIME_DIR/app/org.telegram.desktop/ directory, with the filename remaining the same as it is now (or whatever you want it to be).

Describe alternatives you've considered

Exposing all of $XDG_RUNTIME_DIR exposes a lot of sensitive sockets into the sandbox (e.g.: docker control socket, ssh-agent socket, and a few others).

Hardcoding the filename is not an option; it's impossible to mount the socket if it doesn't exist first. However the socket will be created by telegram after it starts up, but telegram can only run after all the mounting has been completed.

Additional context

A vaguely similar issue for keepasxc: keepassxreboot/keepassxc#8018

I've seen #16349 and #16350. The intent seemed to have been similar.

Currently, with firejail, telegram will just spawn a second instance. I'm using my own sandboxing with bubblewrap, and the same issue occurs.

@ilya-fedin
Copy link
Contributor

ilya-fedin commented Nov 15, 2022

The socket is in /tmp and it works just fine with flatpak and snap. Ask firejail to have a shared /tmp, this won't be changed, sorry.

@WhyNotHugo
Copy link
Contributor Author

The socket is in /tmp

When I run telegram without any sandbox, it ends up in $XDG_RUNTIME_DIR/. But yeah, the sandboxed version uses /tmp.

What causes the change in behaviour?

Ask firejail to have a shared /tmp, this won't be changed, sorry.

No worries, I can share a /tmp between sandboxes belonging to telegram, I won't need any change from your side. Thanks for the hint!

@WhyNotHugo
Copy link
Contributor Author

What causes the change in behaviour?

Still curious about this tho.

@ilya-fedin
Copy link
Contributor

When I run telegram without any sandbox, it ends up in $XDG_RUNTIME_DIR/

There's no any condition to use $XDG_RUNTIME_DIR, so that's strange, it shouldn't do that

@ilya-fedin
Copy link
Contributor

Unless Qt does some smart voo-doo magic, of course

@WhyNotHugo
Copy link
Contributor Author

When I run telegram-desktop with no sandbox, it creates bb3944ec2f90eae3b5fc14280f1c52ac-{87A94AB0-E370-4cde-98D3-ACC110C5967D} in $XDG_RUNTIME_DIR.

@ilya-fedin
Copy link
Contributor

apparently QDir::tempPath decides so

@ilya-fedin
Copy link
Contributor

I can't reproduce, btw

@WhyNotHugo
Copy link
Contributor Author

WhyNotHugo commented Nov 15, 2022 via email

@ilya-fedin
Copy link
Contributor

Are you sure it's not RuntimeLocation?

In 1.9.7..4.3.0 it's RuntimeLocation. In older and newer versions it's QDir::tempPath.

Is $XDR_RUNTIME_DIR set for you?

Yes

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 31, 2022
ilya-fedin referenced this issue in flathub/org.telegram.desktop Apr 12, 2023
Since migration to Qt 6, people periodically creating issues about incorrect single instance check in flatpak. This goes from the fact Qt 6 does permission checks on the XDG_RUNTIME_DIR and there's no easy way to work around that, so declare we don't support those flatpak versions. Specifying the version that added shared /tmp support.
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants