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

Flathub's Okular should use non-PID identifier on D-Bus or share a PID namespace for all instances #374

Open
nihil-admirari opened this issue Oct 14, 2024 · 2 comments

Comments

@nihil-admirari
Copy link
Contributor

I've investigated #36, but couldn't comment.

Okular doesn't own org.kde.okular (unless started as -unique), rather it owns org.kde.okular-PID: https://github.com/KDE/okular/blob/master/shell/okular_main.cpp#L104. When opening a file, it scans for already existing org.kde.okular-NOT_MY_PID buses and then tries to attach to them.

The problem is that in Flatpak all PIDs are sandboxed, which can be verified by running

flatpak run --command=bash org.kde.okular -c 'echo "$$" && read tmp'

simultaneously in two terminals (both will print the PID of 2). Since Okular always gets a PID of 2, and since it always filters out buses with its own PID, it never finds a previous instance and always starts a new one.

There are two possible solutions that I can think of. The first one is to replace PID with e.g. a static QUuid in https://github.com/KDE/okular/blob/master/shell/shell.cpp#L292 and https://github.com/KDE/okular/blob/master/shell/okular_main.cpp#L104.

The second one relies on Flatpak's --parent-pid and --parent-share-pids: https://docs.flatpak.org/en/latest/flatpak-command-reference.html. When starting Okular in a Flatpak, an already running Flatpak instance should be detected and its PID passed to flatpak run of the new instance. I've no idea how it can be implemented in practice. I've tested it by running multiple Okular's in the PID namespace of init, but that kinda defeats the entire point of sandboxing:

flatpak run --parent-pid=1 --parent-share-pids org.kde.okular --command=okular ...

Also, Flatpak doesn't allow wildcard D-Bus permissions (https://docs.flatpak.org/en/latest/sandbox-permissions.html) unless it's a subname, and Okular's D-Bus name is not a subname. The entire session D-Bus needs to be exposed.

@travier
Copy link
Member

travier commented Oct 14, 2024

Maybe we can use org.kde.okular.* instead?

@nihil-admirari
Copy link
Contributor Author

Did that in #375. Now it uses org.kde.okular.Instance_ + hex representation of a UUID for D-Bus names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants