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: 29a7c59abb
Resolves: #24740
This commit is contained in:
committed by
Yu Watanabe
parent
ebc7510380
commit
fe6e0cfa19
@@ -2894,7 +2894,7 @@ static int normalize_linked_files(
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EISDIR),
|
||||
"Unexpected path to a directory \"%s\", refusing.", *a);
|
||||
|
||||
if (!is_path(*a)) {
|
||||
if (!is_path(*a) && !unit_name_is_valid(*a, UNIT_NAME_INSTANCE)) {
|
||||
r = install_info_discover(&ctx, lp, n, SEARCH_LOAD|SEARCH_FOLLOW_CONFIG_SYMLINKS, &i, NULL, NULL);
|
||||
if (r < 0)
|
||||
log_debug_errno(r, "Failed to discover unit \"%s\", operating on name: %m", n);
|
||||
|
||||
Reference in New Issue
Block a user