3
0
Fork 0
forked from mirrors/nixpkgs

build-fhs-{chroot,user}env: expose sockets in /tmp

This commit is contained in:
Nikolay Amiantov 2015-08-24 01:42:40 +03:00
parent ff25df9366
commit ec27ba44d0
5 changed files with 16 additions and 2 deletions

View file

@ -3,7 +3,7 @@
chrootenvDest=/run/chrootenv/@name@ chrootenvDest=/run/chrootenv/@name@
# Create some mount points for stuff that must be bind mounted # Create some mount points for stuff that must be bind mounted
mkdir -p $chrootenvDest/{nix/store,dev,proc,sys,host-etc,home,var,run} mkdir -p $chrootenvDest/{nix/store,dev,proc,sys,host-etc,host-tmp,home,var,run}
# Symlink the software that should be part of the chroot system profile # Symlink the software that should be part of the chroot system profile
for i in @chrootEnv@/* for i in @chrootEnv@/*

View file

@ -22,5 +22,13 @@ mount --rbind /run $chrootenvDest/run
# Bind mount the host system's /etc # Bind mount the host system's /etc
mount --bind /etc $chrootenvDest/host-etc mount --bind /etc $chrootenvDest/host-etc
# Bind mount the host system's /tmp
mount --bind /tmp $chrootenvDest/host-tmp
# Bind mount /tmp # Bind mount /tmp
mount --bind /tmp/chrootenv-@name@ $chrootenvDest/tmp mount --bind /tmp/chrootenv-@name@ $chrootenvDest/tmp
# Expose sockets in /tmp
for i in /tmp/.*-unix; do
ln -s "/host-tmp/$(basename "$i")" "$chrootenvDest/$i"
done

View file

@ -3,4 +3,4 @@
chrootenvDest=/run/chrootenv/@name@ chrootenvDest=/run/chrootenv/@name@
# Unmount all (r)bind mounts # Unmount all (r)bind mounts
umount -l $chrootenvDest/{dev/pts,dev/shm,dev,nix/store,proc,sys,host-etc,home,var,tmp,run} umount -l $chrootenvDest/{dev/pts,dev/shm,dev,nix/store,proc,sys,host-etc,host-tmp,home,var,tmp,run}

View file

@ -7,6 +7,7 @@ mounts = [ ['/nix/store', nil],
['/proc', nil], ['/proc', nil],
['/sys', nil], ['/sys', nil],
['/etc', 'host-etc'], ['/etc', 'host-etc'],
['/tmp', 'host-tmp'],
['/home', nil], ['/home', nil],
['/var', nil], ['/var', nil],
['/run', nil], ['/run', nil],

View file

@ -10,6 +10,11 @@ let
''; '';
init = writeText "init" '' init = writeText "init" ''
# Expose sockets in /tmp
for i in /host-tmp/.*-unix; do
ln -s "$i" "/tmp/$(basename "$i")"
done
[ -d "$1" ] && [ -r "$1" ] && cd "$1" [ -d "$1" ] && [ -r "$1" ] && cd "$1"
shift shift
exec "${runScript}" "$@" exec "${runScript}" "$@"