systemctl: honour --root= in "is-enabled --full"

We have a root argument, let's make sure we honour it
in this case.
This commit is contained in:
Daan De Meyer authored and Daan De Meyer committed 2026-10-02 23:23:17 +02:00
1 parent 0a4491ef3f
commit b231b43ff0
2 files changed
+13 -1

No files matched your search

+12
View File
@@ -754,3 +754,15 @@ ID='the-id2'
EOF
SYSTEMD_OS_RELEASE="/etc/os-release2" check_alias o 'the-id2'
: '-------is-enabled --full is relative to --root=-----------------'
mkdir -p "$root/usr/lib/systemd/system"
cat >"$root/usr/lib/systemd/system/rooted.service" <<EOF
[Install]
WantedBy=multi-user.target
EOF
"$systemctl" --root="$root" enable rooted.service
# Without --root= being passed on this inspects the host, which knows nothing about this unit.
"$systemctl" --root="$root" is-enabled --full rooted.service |
grep "^ $root/etc/systemd/system/multi-user.target.wants/rooted.service\$" >/dev/null