]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/shared/install.c
shared/install: always overwrite symlinks in .wants and .requires 3084/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 22 Apr 2016 01:11:15 +0000 (21:11 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 22 Apr 2016 02:12:07 +0000 (22:12 -0400)
commit29380daff549b117873f4543a649569be84bd950
tree7d609f4f666c1a2909bd1fdf2d7bf5c9ce1c9b45
parent39207373dd638e548019ddb49929f15795b8b404
shared/install: always overwrite symlinks in .wants and .requires

Before:
$ systemctl preset getty@.service
Failed to preset unit, file /etc/systemd/system/getty.target.wants/getty@tty1.service
already exists and is a symlink to ../../../../usr/lib/systemd/system/getty@.service.

After:
$ systemctl preset getty@.service
Created symlink /etc/systemd/system/getty.target.wants/getty@tty1.service,
pointing to /usr/lib/systemd/system/getty@.service.

We don't really care where the symlink points to. For example, it might point
to /usr/lib or /etc, and systemd will always load the unit from /etc in
preference to /usr/lib. In fact, if we make a symlink like
/etc/systemd/system/multi-user.target.wants/b.service -> ../a.service, pid1
will still start b.service. The name of the symlink is the only thing that
matters, as far as systemd is concerned. For humans it's confusing when the
symlinks points to anything else than the actual unit file. At the very least,
the symlink is supposed to point to a file with the same name in some other
directory. Since we don't care where the symlink points, we can always replace
an existing symlink.

Another option I considered would be to simply leave an existing symlink in
place. That would work too, but replacing the symlink with the expected value
seems more intuitive.

Of course those considerations only apply to .wants and .requires. Symlinks
created with "link" and "alias" are a separate matter.

Fixes #3056.
src/shared/install.c