You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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 ...
I've investigated #36, but couldn't comment.
Okular doesn't own
org.kde.okular
(unless started as-unique
), rather it ownsorg.kde.okular-PID
: https://github.com/KDE/okular/blob/master/shell/okular_main.cpp#L104. When opening a file, it scans for already existingorg.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 toflatpak 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 ofinit
, but that kinda defeats the entire point of sandboxing: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.
The text was updated successfully, but these errors were encountered: