diff options
author | Daan De Meyer <daan.j.demeyer@gmail.com> | 2024-08-14 12:43:05 +0200 |
---|---|---|
committer | Mike Yuan <me@yhndnzj.com> | 2024-08-16 10:11:29 +0200 |
commit | 2701c2f67de592fe2565b084cfaec1667767dbaf (patch) | |
tree | a3b63bc8394abcdffdb5b2d36f83a83883376617 /test | |
parent | test: fix typo (diff) | |
download | systemd-2701c2f67de592fe2565b084cfaec1667767dbaf.tar.xz systemd-2701c2f67de592fe2565b084cfaec1667767dbaf.zip |
Add $SYSTEMD_IN_CHROOT to override chroot detection
When running unprivileged, checking /proc/1/root doesn't work because
it requires privileges. Instead, let's add an environment variable so
the process that chroot's can tell (systemd) subprocesses whether
they're running in a chroot or not.
Diffstat (limited to '')
-rw-r--r-- | test/test-systemctl-enable.sh | 2 | ||||
-rwxr-xr-x | test/units/TEST-74-AUX-UTILS.detect-virt.sh | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/test/test-systemctl-enable.sh b/test/test-systemctl-enable.sh index 5615c900f4..3fc59f6f9e 100644 --- a/test/test-systemctl-enable.sh +++ b/test/test-systemctl-enable.sh @@ -3,7 +3,7 @@ set -ex # Silence warning from running_in_chroot_or_offline() -export SYSTEMD_IGNORE_CHROOT=1 +export SYSTEMD_IN_CHROOT=0 systemctl=${1:-systemctl} systemd_id128=${2:-systemd-id128} diff --git a/test/units/TEST-74-AUX-UTILS.detect-virt.sh b/test/units/TEST-74-AUX-UTILS.detect-virt.sh new file mode 100755 index 0000000000..fe1db4d2aa --- /dev/null +++ b/test/units/TEST-74-AUX-UTILS.detect-virt.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: LGPL-2.1-or-later +set -eux +set -o pipefail + +SYSTEMD_IN_CHROOT=1 systemd-detect-virt --chroot +(! SYSTEMD_IN_CHROOT=0 systemd-detect-virt --chroot) |