]> git.ipfire.org Git - thirdparty/systemd.git/commit
install: don't translate unit instances to paths when reenabling them
authorFrantisek Sumsal <frantisek@sumsal.cz>
Wed, 6 Dec 2023 15:24:21 +0000 (16:24 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 8 Dec 2023 02:20:12 +0000 (11:20 +0900)
commitfe6e0cfa19dd1de4ac599ae207182fd556adcfa7
treef4120d811dfeace9d0758def52e51f37084a2005
parentebc751038018ece35675c04422e03a3685aaf79f
install: don't translate unit instances to paths when reenabling them

For unit instances install_info_discover() returns path to the template,
which then generates confusing errors when passed to
do_unit_file_enable():

~# build/systemctl --root=/tmp/systemctl-test.N9ysbz reenable templ1@two.service
Unit name: templ1@two.service; p: /etc/systemd/system/templ1@.service
Removed "/tmp/systemctl-test.N9ysbz/etc/systemd/system/services.target.wants/templ1@two.service".
Failed to reenable templ1@.service, destination unit services.target is a non-template unit.

This can also be seen with a different reproducer using getty@.service
and a simple bind mount to / - there's no error this time, but it tries
to create a symlink for the default instance (from DefaultInstance=tty1),
which is also incorrect:

~# SYSTEMD_LOG_LEVEL=debug systemctl --root /mnt/bindroot/ reenable getty@test.service
Symlink /mnt/bindroot/etc/systemd/system/getty.target.wants/getty@tty1.service → /usr/lib/systemd/system/getty@.service already exists

Follow-up to: 29a7c59abbe
Resolves: #24740
src/shared/install.c
test/test-systemctl-enable.sh