diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-03-25 15:43:27 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-03-29 16:17:57 +0200 |
commit | 3fc53351dc8f37355f5a4ee8f922d3e13a5182c2 (patch) | |
tree | a0014aa12ea5b21aced961dbe196039302232594 /test | |
parent | test-systemctl-enable: make shellcheck happy (diff) | |
download | systemd-3fc53351dc8f37355f5a4ee8f922d3e13a5182c2.tar.xz systemd-3fc53351dc8f37355f5a4ee8f922d3e13a5182c2.zip |
shared/install: when creating symlinks, accept different but equivalent symlinks
We would only accept "identical" links, but having e.g. a symlink
/usr/lib/systemd/system/foo-alias.service → /usr/lib/systemd/system/foo.service
when we're trying to create /usr/lib/systemd/system/foo-alias.service →
./foo.service is OK. This fixes an issue found in ubuntuautopkg package
installation, where we'd fail when enabling systemd-resolved.service, because
the existing alias was absolute, and (with the recent patches) we were trying
to create a relative one.
A test is added.
(For .wants/.requires symlinks we were already doing OK. A test is also
added, to verify.)
Diffstat (limited to 'test')
-rw-r--r-- | test/test-systemctl-enable.sh | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/test/test-systemctl-enable.sh b/test/test-systemctl-enable.sh index 3b30f090a5..0f66af309a 100644 --- a/test/test-systemctl-enable.sh +++ b/test/test-systemctl-enable.sh @@ -39,8 +39,29 @@ test -h "$root/etc/systemd/system/default.target.wants/test1.service" test -h "$root/etc/systemd/system/special.target.requires/test1.service" "$systemctl" --root="$root" disable test1.service -test ! -e "$root/etc/systemd/system/default.target.wants/test1.service" -test ! -e "$root/etc/systemd/system/special.target.requires/test1.service" +test ! -h "$root/etc/systemd/system/default.target.wants/test1.service" +test ! -h "$root/etc/systemd/system/special.target.requires/test1.service" + +: '------enable when link already exists-----------------------' +# We don't read the symlink target, so it's OK for the symlink to point +# to something else. We should just silently accept this. + +mkdir -p "$root/etc/systemd/system/default.target.wants" +mkdir -p "$root/etc/systemd/system/special.target.requires" +ln -s /usr/lib/systemd/system/test1.service "$root/etc/systemd/system/default.target.wants/test1.service" +ln -s /usr/lib/systemd/system/test1.service "$root/etc/systemd/system/special.target.requires/test1.service" + +"$systemctl" --root="$root" enable test1.service +test -h "$root/etc/systemd/system/default.target.wants/test1.service" +test -h "$root/etc/systemd/system/special.target.requires/test1.service" + +"$systemctl" --root="$root" reenable test1.service +test -h "$root/etc/systemd/system/default.target.wants/test1.service" +test -h "$root/etc/systemd/system/special.target.requires/test1.service" + +"$systemctl" --root="$root" disable test1.service +test ! -h "$root/etc/systemd/system/default.target.wants/test1.service" +test ! -h "$root/etc/systemd/system/special.target.requires/test1.service" : '------suffix guessing---------------------------------------' "$systemctl" --root="$root" enable test1 @@ -90,6 +111,20 @@ test ! -h "$root/etc/systemd/system/default.target.wants/test1.service" test ! -h "$root/etc/systemd/system/special.target.requires/test1.service" test ! -h "$root/etc/systemd/system/test1-goodalias.service" +: '-------aliases when link already exists---------------------' +cat >"$root/etc/systemd/system/test1a.service" <<EOF +[Install] +Alias=test1a-alias.service +EOF + +ln -s /usr/lib/systemd/system/test1a.service "$root/etc/systemd/system/test1a-alias.service" + +"$systemctl" --root="$root" enable test1a.service +test -h "$root/etc/systemd/system/test1a-alias.service" + +"$systemctl" --root="$root" disable test1a.service +test ! -h "$root/etc/systemd/system/test1a-alias.service" + : '-------also units-------------------------------------------' cat >"$root/etc/systemd/system/test2.socket" <<EOF [Install] |