Systemd – issues with overriding dependencies

It does not appear possible to override dependencies defined through a unit’s .wants or .requires directories.

A unit can declare a ‘want’ or ‘require’ either through directives in its unit file or through links created in a .wants or .requires directory.

You can easily override dependencies specified in a unit’s unit file, by creating a file of the same name in /etc with the offending directives removed. This file is simply used instead of the file in /lib. For example, unit sshd.service might specify that it ‘Wants’ kerberos.service by means of a Wants directive in its unit file /lib/systemd/sshd.service. One can override this by creating an /etc/systemd/sshd.service with the offending Wants directive removed.

One might expect that creating unit’s .wants or .requires directories in /etc would override the equivalent directories in /lib, but that is not the case. For example, ntpd.service may specify that it ‘Requires’ by means of a symlink, in /lib/systemd/ntpd.service.requires, to the unit file. One might expect that you could remove this dependency by creating a directory /etc/systemd/ntpd.service.requires without the offending symlink. Unfortunately this isn’t what happens – instead, systemd uses the union of /etc/systemd/ntpd.service.requires and /lib/systemd/ntpd.service.requires.

This entry was posted in systemd. Bookmark the permalink.

Leave a Reply