1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2024-09-19 23:03:53 -04:00

Set up a private /dev/pts in the chroot

This commit is contained in:
Eelco Dolstra 2014-02-27 23:25:03 +01:00
parent 3fd01b171a
commit 1017bd68ea
2 changed files with 14 additions and 2 deletions

View file

@ -2017,11 +2017,11 @@ void DerivationGoal::initChild()
bind-mount the host /dev. */ bind-mount the host /dev. */
if (dirsInChroot.find("/dev") == dirsInChroot.end()) { if (dirsInChroot.find("/dev") == dirsInChroot.end()) {
createDirs(chrootRootDir + "/dev/shm"); createDirs(chrootRootDir + "/dev/shm");
createDirs(chrootRootDir + "/dev/pts");
Strings ss; Strings ss;
ss.push_back("/dev/full"); ss.push_back("/dev/full");
ss.push_back("/dev/kvm"); ss.push_back("/dev/kvm");
ss.push_back("/dev/null"); ss.push_back("/dev/null");
ss.push_back("/dev/ptmx");
ss.push_back("/dev/random"); ss.push_back("/dev/random");
ss.push_back("/dev/tty"); ss.push_back("/dev/tty");
ss.push_back("/dev/urandom"); 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) if (pathExists("/dev/shm") && mount("none", (chrootRootDir + "/dev/shm").c_str(), "tmpfs", 0, 0) == -1)
throw SysError("mounting /dev/shm"); 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 /* Do the chroot(). Below we do a chdir() to the
temporary build directory to make sure the current temporary build directory to make sure the current
directory is in the chroot. (Actually the order directory is in the chroot. (Actually the order

View file

@ -42,7 +42,6 @@ Settings::Settings()
useSubstitutes = true; useSubstitutes = true;
useChroot = false; useChroot = false;
useSshSubstituter = false; useSshSubstituter = false;
dirsInChroot.insert("/dev/pts");
impersonateLinux26 = false; impersonateLinux26 = false;
keepLog = true; keepLog = true;
compressLog = true; compressLog = true;