From: Mike Frysinger Date: Thu, 20 Oct 2016 02:20:23 +0000 (-0400) Subject: custom-chroot: mount /dev/pts as newinstance manually X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=7f47430907b92bf277f3fabb6b4cb569b50ac503;p=home.git custom-chroot: mount /dev/pts as newinstance manually --- diff --git a/.bin/custom-chroot b/.bin/custom-chroot index 67da2ea..e76d525 100755 --- a/.bin/custom-chroot +++ b/.bin/custom-chroot @@ -20,13 +20,18 @@ bootstrap() { unset UNSHARE } +is_mounted() { + local dst=$1 + grep -sq "${dst}" /proc/mounts +} + maybe_mount() { local src=/$1 dst=${chroot}/${2:-$1} [[ -d ${src} ]] || return 0 if ! mkdir -p "${dst}" ; then [[ -w ${chroot} ]] && exit 1 || return 0 fi - grep -sq "${dst}" /proc/mounts || mount ${mount_args} --bind "${src}" "${dst}" + is_mounted "${dst}" || mount ${mount_args} --bind "${src}" "${dst}" } get_type() { @@ -108,7 +113,7 @@ usage() { main() { bootstrap "$@" - local mounts=( proc sys tmp dev dev/pts dev/shm run usr/portage usr/portage/distfiles usr/local/src ) + local mounts=( proc sys tmp dev dev/shm run usr/portage usr/portage/distfiles usr/local/src ) local chroot=${0%/*} case ${chroot} in @@ -138,6 +143,11 @@ main() { for m in "${mounts[@]}" ; do maybe_mount ${m} done + # Handle special mounts that we don't want to just bind mount. + if ! is_mounted "${chroot}/dev/pts" ; then + mount -t devpts devpts "${chroot}/dev/pts" \ + -o nosuid,noexec,newinstance,ptmxmode=0666,mode=0620,gid=5 + fi init_chroot