Bug 92486

Summary: [Install] section missing in systemd service
Product: udisks Reporter: Tom Yan <tom.ty89>
Component: generalAssignee: Martin Pitt <martin.pitt>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Tom Yan 2015-10-15 23:50:59 UTC
http://cgit.freedesktop.org/udisks/commit/?id=0d5aeb6715d981c5344f1f1bb24b02253f3c979b

http://cgit.freedesktop.org/upower/commit/?id=07a6c353a26689e9907788d29d78f8b5c0212b31

udisks2.service should have an [Install] section just like upower.service which would allow users to enable it with systemctl.

I am not even sure why it wasn't there right from the beginning. Possibly because the commit author have only considered GNOME use-case (see the comment of the [Install] section on upower.service).

For example, if you only use a simple wm with xinit/startx, udisks2.service won't be started until you run something like gnome-disks or nautilus which activates the dbus service. This does not make sense when udisksd can be used to restore ATA settings.

FWIW, the service file in "udisks1" does not have an [Install] section either.

P.S. The [Install] section doesn't even have direct relation to "speeding things up".
Comment 1 Martin Pitt 2015-10-16 04:48:35 UTC
Which ATA settings does it restore right now? Do you mean bug 92488?

udisks' only interface to the world is through D-Bus, so the Type=dbus (and thus absent [Install]) is quite on purpose. udisks never had an init.d script either, it has always just been activated through D-Bus (/usr/share/dbus-1/system-services/org.freedesktop.UDisks2.service)
Comment 2 Tom Yan 2015-10-16 09:02:01 UTC
I don't think the [Install] section would have any conflict with Type=dbus. It's just a way for the users to have to a way to have it started with boot if they don't use a Display Manager or a "DE" like gnome-session. Obviously you didn't read the upower commit I pasted.

Actually in Lennart Poettering's original patch a [Install] section is included as well: https://bugs.freedesktop.org/show_bug.cgi?id=29205

It's just somehow the maintainer back then used a patch from someone else instead and obviously that author is only GNOME-awared. (You can see that the two commit I pasted is from the same person)
Comment 3 Tom Yan 2015-10-16 09:41:59 UTC
In case you still have doubt, here are four test cases:

1. both udisks2.service and gdm are not enabled; startx + i3-wm:

[tom@localhost ~]$ journalctl -b -u udisks2
-- No entries --
[tom@localhost ~]$ journalctl -b -u dbus
-- Logs begin at Tue 2015-10-06 07:54:44 HKT, end at Fri 2015-10-16 17:33:23 HKT. --
Oct 16 17:29:11 localhost systemd[1]: Started D-Bus System Message Bus.
Oct 16 17:29:11 localhost dbus[259]: [system] Successfully activated service 'org.freedesktop.systemd1'
Oct 16 17:29:16 localhost dbus[259]: [system] Activating via systemd: service name='org.freedesktop.RealtimeKit1' unit='rtkit-daemon.service'
Oct 16 17:29:16 localhost dbus[259]: [system] Successfully activated service 'org.freedesktop.RealtimeKit1'
Oct 16 17:29:16 localhost dbus[259]: [system] Activating via systemd: service name='org.freedesktop.PolicyKit1' unit='polkit.service'
Oct 16 17:29:16 localhost dbus[259]: [system] Successfully activated service 'org.freedesktop.PolicyKit1'

2. only gdm is enabled, udisks2.service is started through dbus activation:

[tom@localhost ~]$ journalctl -b -1 -u udisks2
-- Logs begin at Tue 2015-10-06 07:54:44 HKT, end at Fri 2015-10-16 17:36:23 HKT. --
Oct 16 17:28:45 localhost systemd[1]: Starting Disk Manager...
Oct 16 17:28:45 localhost udisksd[525]: udisks daemon version 2.1.6 starting
Oct 16 17:28:45 localhost systemd[1]: Started Disk Manager.
Oct 16 17:28:45 localhost udisksd[525]: Acquired the name org.freedesktop.UDisks2 on the system message bus
Oct 16 17:28:55 localhost systemd[1]: Stopping Disk Manager...
Oct 16 17:28:55 localhost systemd[1]: Stopped Disk Manager.
[tom@localhost ~]$ journalctl -b -1 -u dbus | grep -i udi
Oct 16 17:28:45 localhost dbus[249]: [system] Activating via systemd: service name='org.freedesktop.UDisks2' unit='udisks2.service'
Oct 16 17:28:45 localhost dbus[249]: [system] Successfully activated service 'org.freedesktop.UDisks2'

3. both gdm and udisks2.service is enabled, udisks2.service is started by systemd directly, so no d-dbus activation:

[tom@localhost ~]$ journalctl -b -2 -u udisks2
-- Logs begin at Tue 2015-10-06 07:54:44 HKT, end at Fri 2015-10-16 17:36:55 HKT. --
Oct 16 17:27:49 localhost systemd[1]: Starting Disk Manager...
Oct 16 17:27:50 localhost udisksd[244]: udisks daemon version 2.1.6 starting
Oct 16 17:27:50 localhost udisksd[244]: Acquired the name org.freedesktop.UDisks2 on the system message bus
Oct 16 17:27:50 localhost systemd[1]: Started Disk Manager.
Oct 16 17:28:23 localhost systemd[1]: Stopping Disk Manager...
Oct 16 17:28:23 localhost systemd[1]: Stopped Disk Manager.
[tom@localhost ~]$ journalctl -b -2 -u dbus
-- Logs begin at Tue 2015-10-06 07:54:44 HKT, end at Fri 2015-10-16 17:36:55 HKT. --
Oct 16 17:27:49 localhost systemd[1]: Started D-Bus System Message Bus.
Oct 16 17:27:50 localhost dbus[249]: [system] Successfully activated service 'org.freedesktop.systemd1'
Oct 16 17:27:50 localhost dbus[249]: [system] Activating via systemd: service name='org.freedesktop.PolicyKit1' unit='polkit.service'
Oct 16 17:27:50 localhost dbus[249]: [system] Successfully activated service 'org.freedesktop.PolicyKit1'
Oct 16 17:27:50 localhost dbus[249]: [system] Activating via systemd: service name='org.freedesktop.Accounts' unit='accounts-daemon.service'
Oct 16 17:27:50 localhost dbus[249]: [system] Successfully activated service 'org.freedesktop.Accounts'
Oct 16 17:27:50 localhost dbus[249]: [system] Activating via systemd: service name='org.freedesktop.UPower' unit='upower.service'
Oct 16 17:27:50 localhost dbus[249]: [system] Successfully activated service 'org.freedesktop.UPower'
Oct 16 17:27:52 localhost dbus[249]: [system] Activating via systemd: service name='org.freedesktop.ColorManager' unit='colord.service'
Oct 16 17:27:52 localhost dbus[249]: [system] Successfully activated service 'org.freedesktop.ColorManager'
Oct 16 17:27:52 localhost dbus[249]: [system] Activating via systemd: service name='org.freedesktop.RealtimeKit1' unit='rtkit-daemon.service'
Oct 16 17:27:52 localhost dbus[249]: [system] Successfully activated service 'org.freedesktop.RealtimeKit1'
Oct 16 17:27:52 localhost dbus[249]: [system] Activating via systemd: service name='org.freedesktop.locale1' unit='dbus-org.freedesktop.locale1.service'
Oct 16 17:27:52 localhost dbus[249]: [system] Successfully activated service 'org.freedesktop.locale1'
Oct 16 17:27:58 localhost dbus[249]: [system] Activating via systemd: service name='org.freedesktop.GeoClue2' unit='geoclue.service'
Oct 16 17:27:58 localhost dbus[249]: [system] Activating via systemd: service name='fi.w1.wpa_supplicant1' unit='wpa_supplicant.service'
Oct 16 17:27:58 localhost dbus[249]: [system] Successfully activated service 'fi.w1.wpa_supplicant1'
Oct 16 17:27:58 localhost dbus[249]: [system] Activating via systemd: service name='org.freedesktop.Avahi' unit='dbus-org.freedesktop.Avahi.service'
Oct 16 17:27:58 localhost dbus[249]: [system] Successfully activated service 'org.freedesktop.Avahi'
Oct 16 17:27:58 localhost dbus[249]: [system] Successfully activated service 'org.freedesktop.GeoClue2'
Oct 16 17:27:58 localhost dbus[249]: [system] Activating via systemd: service name='org.freedesktop.hostname1' unit='dbus-org.freedesktop.hostname1.service'
Oct 16 17:27:58 localhost dbus[249]: [system] Successfully activated service 'org.freedesktop.hostname1'
Oct 16 17:28:23 localhost dbus[249]: [system] Activating via systemd: service name='org.freedesktop.Accounts' unit='accounts-daemon.service'
Oct 16 17:28:23 localhost dbus[249]: [system] Activation via systemd failed for unit 'accounts-daemon.service': Refusing activation, D-Bus is shutting down.
Oct 16 17:28:23 localhost dbus[249]: [system] Activating via systemd: service name='org.freedesktop.Accounts' unit='accounts-daemon.service'
Oct 16 17:28:23 localhost dbus[249]: [system] Activation via systemd failed for unit 'accounts-daemon.service': Refusing activation, D-Bus is shutting down.
Oct 16 17:28:23 localhost systemd[1]: Stopping D-Bus System Message Bus...
Oct 16 17:28:23 localhost systemd[1]: Stopped D-Bus System Message Bus.

4. only udisks2 is enabled, X is not started:
[tom@localhost ~]$ journalctl -b -3 -u udisks2
-- Logs begin at Tue 2015-10-06 07:54:44 HKT, end at Fri 2015-10-16 17:38:20 HKT. --
Oct 16 17:27:22 localhost systemd[1]: Starting Disk Manager...
Oct 16 17:27:22 localhost udisksd[248]: udisks daemon version 2.1.6 starting
Oct 16 17:27:23 localhost systemd[1]: Started Disk Manager.
Oct 16 17:27:23 localhost udisksd[248]: Acquired the name org.freedesktop.UDisks2 on the system message bus
Oct 16 17:27:35 localhost systemd[1]: Stopping Disk Manager...
Oct 16 17:27:35 localhost systemd[1]: Stopped Disk Manager.
[tom@localhost ~]$ journalctl -b -3 -u dbus
-- Logs begin at Tue 2015-10-06 07:54:44 HKT, end at Fri 2015-10-16 17:38:20 HKT. --
Oct 16 17:27:22 localhost systemd[1]: Started D-Bus System Message Bus.
Oct 16 17:27:23 localhost dbus[252]: [system] Successfully activated service 'org.freedesktop.systemd1'
Oct 16 17:27:23 localhost dbus[252]: [system] Activating via systemd: service name='org.freedesktop.PolicyKit1' unit='polkit.service'
Oct 16 17:27:23 localhost dbus[252]: [system] Successfully activated service 'org.freedesktop.PolicyKit1'
Oct 16 17:27:27 localhost dbus[252]: [system] Activating via systemd: service name='org.freedesktop.RealtimeKit1' unit='rtkit-daemon.service'
Oct 16 17:27:27 localhost dbus[252]: [system] Successfully activated service 'org.freedesktop.RealtimeKit1'
Oct 16 17:27:35 localhost systemd[1]: Stopping D-Bus System Message Bus...
Oct 16 17:27:35 localhost systemd[1]: Stopped D-Bus System Message Bus.

The point is udisksd shows the following message in all cases except the first one where udisks2.service is not started at all:

Acquired the name org.freedesktop.UDisks2 on the system message bus
Comment 4 Martin Pitt 2015-10-16 09:51:26 UTC
*shrug* okay. I'd still prefer distro packages to not actually systemctl enable this by default, as we'd pointlessly start it on servers, LXC containers, etc then.
Comment 5 Tom Yan 2015-10-16 15:37:32 UTC
an [Install] section does NOT make it enabled by default. It's the way to ALLOW users to enable it.

FWIW, the sane ways to "enable it by default" is either having a static service like the current one AND ALSO a "manual" symlink in a /usr/lib/systemd/system/*.target.wants/ created by upstream, or having a non-static service (i.e. service with an [Install] section) and a post-install script in the distro package to run a `systemctl enable` (so that the package manager won't track the enable/disable status).

And these are NOT what I have been proposing. I am merely asking for the CAPABILITY of enabling it through systemctl.

As I've said, this is mainly useful when udisksd is used to implement persistent ATA settings. However two key factors are STILL broken: one, the systemd service is static; two, udiskd is not sleep-resume aware.

This is all about not limiting users from inherit capabilities in the system and not wasting the efforts which the devs had put into making udisksd the daemon for persistent ATA settings.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.