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
dbus-daemon/dbus-broker not told to reload after installing new D-Bus services #3342
Comments
Flatpak isn't what needs to look into the dbus service dirs, instead it is the dbus daemon itself that should do this. In the fedora packages this is done by various config files:
These all try to set the XDG_DATA_DIRS env var which dbus-daemon then uses to locate the service files. I wonder why this is not working though. I mean, a reboot does find it it so it seems the env var is set on the second boot at least. Maybe something about how the service files are changed doesn't cause dbus to detect that a file has changed and it needs to re-read the directory. My guess is that this is related to fedora using dbus-broker, maybe its service-file scanning cache system is different somehow. |
So I tried this with fresh installs:
will try now to do just systemctl reload dbus-broker.service |
Every process has their own set of environment variables. If you change dbus-broker works exactly the same way as dbus-daemon. If that is not the case, it is a bug and I will gladly fix it. However, I do not understand what this bug is about. Can somebody elaborate what exactly is not working? |
Example 1) Example 2)
And how to affect dbus-broker to look inside another directory for service files? (e.g if creating a new flatpak installation, currently this would require a reboot of the system, restarting dbus-broker ends your user session) |
Do you actually share a directory across flatpaks, or do you create a new one for each? If you do the latter, how is dbus supposed to update its environment? How is this supposed to work? |
The feature flatpak-installations does create a new one.
To me it seems currently only after reboot. Is there some way to force dbus broker to look into different directory or something that could achieve that? |
So when that feature was introduced into flatpak, how was this supposed to propagate into dbus-daemon? |
Maybe it was decided that rebooting is fine. |
Surely! The One simple approach would be to place a drop-in configuration into the Please note that environment-variables are not global state, neither do they have a standardized way to update them at runtime. They are built up when starting a session or service etc., but cannot be remotely updated at runtime. |
@dvdhrm Flatpak creates two fixed locations where the service files are put, /var/lib/flatpak/exports/share/dbus-1/services/ for system installed flatpak and ~/.local/share/flatpak/exports/share/dbus-1/services/ for per-user installed ones. There is no real way for flatpak the app to modify the dbus daemon to pick this up, instead it is up to each packager of flatpak to use whatever setup the distro has to add these directories to the XDG_DATA_DIRS env var before the dbus daemon is started. What I think is weird in this report is that installing a flatpak, which created a service file in one of these dirs, didn't cause dbus-broker to find the new service. However, once rebooted it did find it. Assuming flatpak was installed at the time of the last boot, the XDG_DATA_DIRS env var should have been the same in both these runs, so why did it require a reboot to pick up the new service? |
Right. This should just work as expected. And this definitely works with dynamically installed rpms etc. You just need to make sure to use Does anyone have a reproducer for that? |
@
Do we really need to trigger these for session bus services? |
If you do not trigger them, you have a race-condition. There is no guarantee the inotify-event will be handled before anyone starts interacting with the service. Sure, in most cases you do not care, since this is probably user-triggered stuff. But as soon as someone installs something through scripts, you probably want this to be synchronous. Lastly, not all situations use inotify-events. dbus-daemon has some obscure logic where and when to use inotify (and we tried to copy that behavior, but we might have gotten it wrong). In most cases, you are better off just triggering the reload. |
A user of my flatpak app stumbled upon this and after some investigation, I found the following (each tried on a new Fedora VM, installing
So it seems that because the services directories do not exist when the session is started, when they are created when a flatpak is installed, DBus does not react to any changes in them. |
Coming here from #4849... I found #3145 where the issue is fixed in the case where the directory already exists. So we have two remaining problems:
|
Restarting the message bus is not something you can do (it would crash the whole desktop environment). Telling it to reload is OK. The reason why dbus-daemon doesn't detect services in newly-created directories is that you can't put an inotify watch on a directory that doesn't exist yet. The situation for dbus-broker is probably very similar. With hindsight, using inotify to watch for new services on an "if possible" basis was probably a mistake, and always requiring an explicit reload action (like systemd does) would probably have been better, but that ship has sailed. |
I would recommend this as the route to solve this issue, in preference to |
A trigger with |
I don't think the sandbox would allow that. Also, triggers are executed by the system helper for the system installation. |
This is best effort. There is a 2s timeout and if something fails everything continues on. This is called from flatpak_dir_run_triggers because it gets called whenever we might have changes to the exported service files. Fixes flatpak#3342 Signed-off-by: Sebastian Wick <[email protected]>
This is best effort. There is a 2s timeout and if something fails everything continues on. This is called from flatpak_dir_run_triggers because it gets called whenever we might have changes to the exported service files. Fixes flatpak#3342 Signed-off-by: Sebastian Wick <[email protected]>
This is best effort. There is a 2s timeout and if something fails everything continues on. This is called from flatpak_dir_run_triggers because it gets called whenever we might have changes to the exported service files. Fixes flatpak#3342 Signed-off-by: Sebastian Wick <[email protected]> (cherry picked from commit 9532c8d)
This is best effort. There is a 2s timeout and if something fails everything continues on. This is called from flatpak_dir_run_triggers because it gets called whenever we might have changes to the exported service files. Fixes flatpak#3342 Signed-off-by: Sebastian Wick <[email protected]> (cherry picked from commit 9532c8d)
This is best effort. There is a 2s timeout and if something fails everything continues on. This is called from flatpak_dir_run_triggers because it gets called whenever we might have changes to the exported service files. Fixes flatpak#3342 Signed-off-by: Sebastian Wick <[email protected]> (cherry picked from commit 9532c8d)
This is best effort. There is a 2s timeout and if something fails everything continues on. This is called from flatpak_dir_run_triggers because it gets called whenever we might have changes to the exported service files. Fixes flatpak#3342 Signed-off-by: Sebastian Wick <[email protected]> (cherry picked from commit 9532c8d)
This is best effort. There is a 2s timeout and if something fails everything continues on. This is called from flatpak_dir_run_triggers because it gets called whenever we might have changes to the exported service files. Fixes flatpak#3342 Signed-off-by: Sebastian Wick <[email protected]>
Linux distribution and version
Fedora Silverblue 31
Flatpak version
1.6
Description of the problem
Installed dbus.service not found till reboot
Steps to reproduce
Run fails until reboot as above requires a ring dbus service which has been installed in exports but is not launched till reboot.
Does flatpak look in the xdg data sirs for dbus services and these are not updated?
The text was updated successfully, but these errors were encountered: