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

We have a root argument, let's make sure we honour it
in this case.

(cherry picked from commit b231b43ff0c3a4b951e45567474052885cad52d3)
This commit is contained in:
Daan De Meyer
2026-10-16 11:36:32 +01:00
committed by Luca Boccassi
parent c74e3aa5b7
commit 3d267223ea
2 changed files with 13 additions and 1 deletions
+1 -1
View File
@@ -27,7 +27,7 @@ static int show_installation_targets_client_side(const char *name) {
flags = UNIT_FILE_DRY_RUN |
(arg_runtime ? UNIT_FILE_RUNTIME : 0);
r = unit_file_disable(arg_runtime_scope, flags, NULL, p, &changes, &n_changes);
r = unit_file_disable(arg_runtime_scope, flags, arg_root, p, &changes, &n_changes);
if (r < 0)
return log_error_errno(r, "Failed to get file links for %s: %m", name);
+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