Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(RHEL-5956) install: don't translate unit instances to paths when reenabling them #306

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/shared/install.c
Original file line number Diff line number Diff line change
Expand Up @@ -2875,7 +2875,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);
Expand Down
30 changes: 29 additions & 1 deletion test/test-systemctl-enable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ test ! -e "$root/etc/systemd/system/test1-badalias.target"
test ! -e "$root/etc/systemd/system/test1-badalias.socket"
test -h "$root/etc/systemd/system/test1-goodalias2.service"

: '-------aliases in reeanble----------------------------------'
: '-------aliases in reenable----------------------------------'
( ! "$systemctl" --root="$root" reenable test1 )
test -h "$root/etc/systemd/system/default.target.wants/test1.service"
test ! -e "$root/etc/systemd/system/test1-goodalias.service"
Expand Down Expand Up @@ -246,6 +246,29 @@ islink "$root/etc/systemd/system/paths.target.wants/link1.path" "/link1.path"
islink "$root/etc/systemd/system/link1.path" "/link1.path"
islink "$root/etc/systemd/system/paths.target.wants/link1.path" "/link1.path"

: '-------link instance and enable-------------------------------------'
cat >"$root/link-instance@.service" <<EOF
[Service]
ExecStart=true
[Install]
WantedBy=services.target
EOF

"$systemctl" --root="$root" link '/link-instance@.service'
islink "$root/etc/systemd/system/link-instance@.service" "/link-instance@.service"

"$systemctl" --root="$root" enable 'link-instance@first.service'
islink "$root/etc/systemd/system/link-instance@first.service" "/link-instance@.service"
islink "$root/etc/systemd/system/services.target.wants/link-instance@first.service" "/link-instance@.service"

SYSTEMD_LOG_LEVEL=debug "$systemctl" --root="$root" reenable 'link-instance@first.service'
islink "$root/etc/systemd/system/link-instance@first.service" "/link-instance@.service"
islink "$root/etc/systemd/system/services.target.wants/link-instance@first.service" "/link-instance@.service"

"$systemctl" --root="$root" disable 'link-instance@first.service'
test ! -h "$root/etc/systemd/system/link-instance@first.service"
test ! -h "$root/etc/systemd/system/services.target.wants/link-instance@first.service"

: '-------manual link------------------------------------------'
cat >"$root/link3.suffix" <<EOF
[Install]
Expand Down Expand Up @@ -314,6 +337,11 @@ test ! -h "$root/etc/systemd/system/services.target.wants/templ1@.service"
islink "$root/etc/systemd/system/services.target.wants/templ1@one.service" "/etc/systemd/system/templ1@.service"
islink "$root/etc/systemd/system/services.target.wants/templ1@two.service" "/etc/systemd/system/templ1@.service"

"$systemctl" --root="$root" reenable 'templ1@two.service'
test ! -h "$root/etc/systemd/system/services.target.wants/templ1@.service"
islink "$root/etc/systemd/system/services.target.wants/templ1@one.service" "/etc/systemd/system/templ1@.service"
islink "$root/etc/systemd/system/services.target.wants/templ1@two.service" "/etc/systemd/system/templ1@.service"

"$systemctl" --root="$root" disable 'templ1@one.service'
test ! -h "$root/etc/systemd/system/services.target.wants/templ1@.service"
test ! -h "$root/etc/systemd/system/services.target.wants/templ1@one.service"
Expand Down
Loading