3

I know that one can override dbus session services in ~/.local/share/dbus-1/services

But it necessarily won't work for system services.

Under openrc, I don't get systemd's systemctl command therefore :

Is the quick and dirty (because service will be restored on next update) way consisting in renaming the associated service file in /usr/share/dbus-1/system-services, the only way to proceed ?

3 Answers 3

2
+50

I just encountered this same problem, and after digging into the dbus code, I think I have a solution:

Files in /usr/local/share/dbus-1/system-services override the files in /usr/share/dbus-1/system-services. So, to prevent a service from autostarting, you can create an empty file. For example, to make sure dbus never starts login1 automatically:

mkdir -p /usr/local/share/dbus-1/system-services
touch /usr/local/share/dbus-1/system-services/org.freedesktop.login1.service

This also allows you to disable user services globally using /usr/local/share/dbus-1/services.

Another effective method to prevent it from launching services by itself is building dbus with -Dtraditional_activation=false. However, this disables all services.

1
  • Whoa ! This just makes sense. So immediately +1 for that info. I was still waiting for an answer to this problem. I make no doubt it should work since I just verified that updates don't touch /usr/local but I'll test your suggestion asap and if OK will accept your answer, say : splendid! and add a +50 bounty for having shared your work. Thanks. Commented Mar 6, 2024 at 20:50
0

Does the D-Bus service have a SystemdService= line pointing to a Systemd unit file, like SystemdService=systemd_unit_name.service?

If yes, you can add a symlink from /etc/systemd/system/systemd_unit_name.service to /dev/null. This is how systemctl mask systemd_unit_name.service works.

Then any attempt to activate the D-Bus service will fail since the linked Systemd service is masked. But you may see some annoying logs in the journal about a failed activation since the service is masked.

If there is no SystemdService= line, you can try adding a symlink from /etc/systemd/system/dbus_unit_name.service to /dev/null (not tested). I assume if there is no alias mapping from a D-Bus unit file named dbus_unit_name.service to a Systemd unit file name systemd_unit_name.service, the D-Bus activation will just look for a Systemd unit file with the same name as the D-Bus unit file, like dbus_unit_name.service.

You can also override D-Bus system services in /etc/dbus-1/system-services/, I believe (again, not tested).

1
  • Thank you for taking car of this problem however you solution presuppose systemd thingies I just do not get since, as stated in OP, I am on an systemd-less (openrc) system. Commented Jan 17, 2023 at 14:11
0

I wanted to disable org.mate.ScreenSaver.service on Ubuntu 24.04, and the solution provided by @mid_kid worked for me, but only after I populated the local service config file with the content copied from the original file, except for the dummy executable:

$ cat /usr/local/share/dbus-1/services/org.mate.ScreenSaver.service 
[D-BUS Service]
Name=org.mate.ScreenSaver
Exec=/bin/false

With this file in place the service was truly disabled.

Here are the contents of the original file for the reference:

$ cat /usr/share/dbus-1/services/org.mate.ScreenSaver.service 
[D-BUS Service]
Name=org.mate.ScreenSaver
Exec=/usr/bin/mate-screensaver --no-daemon
New contributor
Alex Artamonov is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.