]> git.wh0rd.org Git - home.git/commitdiff
custom-chroot: mount /dev/pts as newinstance manually
authorMike Frysinger <vapier@gentoo.org>
Thu, 20 Oct 2016 02:20:23 +0000 (22:20 -0400)
committerMike Frysinger <vapier@gentoo.org>
Thu, 20 Oct 2016 02:20:23 +0000 (22:20 -0400)
.bin/custom-chroot

index 67da2eaa286fedeae1350c457bd906903d347aef..e76d525b53d319bfc6d635d2ca71a8af33aa129f 100755 (executable)
@@ -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