aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/build.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-02-27 23:25:03 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-02-27 23:35:23 +0100
commit1017bd68ea9264afe8b9d672653ca8c6271611d5 (patch)
tree9ae3c85642d5d2167675f5746649c27a9881f71e /src/libstore/build.cc
parent3fd01b171a74d28dc8e48b9ee5f2d0e9a3915fb8 (diff)
Set up a private /dev/pts in the chroot
Diffstat (limited to 'src/libstore/build.cc')
-rw-r--r--src/libstore/build.cc15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index 7a78d5557..973e7a122 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -2017,11 +2017,11 @@ void DerivationGoal::initChild()
bind-mount the host /dev. */
if (dirsInChroot.find("/dev") == dirsInChroot.end()) {
createDirs(chrootRootDir + "/dev/shm");
+ createDirs(chrootRootDir + "/dev/pts");
Strings ss;
ss.push_back("/dev/full");
ss.push_back("/dev/kvm");
ss.push_back("/dev/null");
- ss.push_back("/dev/ptmx");
ss.push_back("/dev/random");
ss.push_back("/dev/tty");
ss.push_back("/dev/urandom");
@@ -2065,6 +2065,19 @@ void DerivationGoal::initChild()
if (pathExists("/dev/shm") && mount("none", (chrootRootDir + "/dev/shm").c_str(), "tmpfs", 0, 0) == -1)
throw SysError("mounting /dev/shm");
+ /* Mount a new devpts on /dev/pts. Note that this
+ requires the kernel to be compiled with
+ CONFIG_DEVPTS_MULTIPLE_INSTANCES=y (which is the case
+ if /dev/ptx/ptmx exists). */
+ if (pathExists("/dev/pts/ptmx") &&
+ !pathExists(chrootRootDir + "/dev/ptmx")
+ && dirsInChroot.find("/dev/pts") == dirsInChroot.end())
+ {
+ if (mount("none", (chrootRootDir + "/dev/pts").c_str(), "devpts", 0, "newinstance,mode=0620") == -1)
+ throw SysError("mounting /dev/pts");
+ createSymlink("/dev/pts/ptmx", chrootRootDir + "/dev/ptmx");
+ }
+
/* Do the chroot(). Below we do a chdir() to the
temporary build directory to make sure the current
directory is in the chroot. (Actually the order