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/units/TEST-74-AUX-UTILS.detect-virt.sh | |
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 '')
-rwxr-xr-x | test/units/TEST-74-AUX-UTILS.detect-virt.sh | 7 |
1 files changed, 7 insertions, 0 deletions
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) |