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.
This commit is contained in:
@@ -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}
|
||||
|
||||
Executable
+7
@@ -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)
|
||||
Reference in New Issue
Block a user