From 1a1e533c8b085b20c0de4bda13a66bfd10bda0e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20Mor=C3=A9n?= Date: Tue, 8 Mar 2016 20:06:07 +0100 Subject: [PATCH] Use minijail0 instead of jchroot. Clean environment with env when entering chroot. Use read -r. --- host-bin/enter-chroot | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/host-bin/enter-chroot b/host-bin/enter-chroot index c1da1ce5b..316e32af7 100755 --- a/host-bin/enter-chroot +++ b/host-bin/enter-chroot @@ -684,18 +684,17 @@ if [ -n "$NOLOGIN" ]; then fi elif [ -n "$SYSTEMD" ]; then [ -e "/run/crouton/$NAME.systemd.pid" ] && \ - read SYSTEMD_PID < "/run/crouton/$NAME.systemd.pid" + read -r SYSTEMD_PID < "/run/crouton/$NAME.systemd.pid" if [ -z "SYSTEMD_PID" ] || ! pwdx $SYSTEMD_PID >/dev/null 2>&1; then echo "Starting systemd..." - /usr/local/bin/jchroot "$CHROOT" /bin/systemd & + env -i /sbin/minijail0 -C "$CHROOT" -f "/run/crouton/$NAME.systemd.pid" -i -I /bin/bash -c "exec /lib/systemd/systemd" sleep 1 - pidof -s systemd > "/run/crouton/$NAME.systemd.pid" - read SYSTEMD_PID < "/run/crouton/$NAME.systemd.pid" + read -r SYSTEMD_PID < "/run/crouton/$NAME.systemd.pid" fi if [ -n "$SYSTEMD_PID" ]; then echo "Entering systemd PID $SYSTEMD_PID..." - nsenter -t $SYSTEMD_PID -p -r -w -u -- su - "$USERNAME" + env -i TERM="$TERM" nsenter -t $SYSTEMD_PID -p -r -w -u -- su - "$USERNAME" else echo "Could not start systemd" >&2 fi