Skip to content

Commit

Permalink
Use minijail0 instead of jchroot.
Browse files Browse the repository at this point in the history
Clean environment with env when entering chroot.
Use read -r.
  • Loading branch information
mmoren committed Mar 8, 2016
1 parent 56eccfa commit 1a1e533
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions host-bin/enter-chroot
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1a1e533

Please sign in to comment.