lang-bootstrap/06/helpers/chroot
2025-04-19 08:57:21 +01:00

18 lines
721 B
Bash
Executable file

#!/usr/bin/env bash
# Run a command chrooted inside $DESTDIR w/o network, with /dev/null, outline:
#
# [helpers/chroot, outer script]
# / unshare
# | -n # without network
# | -r # with EUID=EGID=0
# \ -m # separate mount namespace
# [helpers/chroot-inner, this script]
# mount --bind /dev/null $DESTDIR/dev/null # unprivileged /dev/null!
# &&
# env -i # with env unset
# chroot $DESTDIR # unprivileged chroot!
set -uex
exec unshare -nrm helpers/chroot-inner "$@"