Moved tmp and shm creation insize ozinit where it belongs

master
xSmurf 10 years ago
parent d1d1a9ae43
commit a5ddbf0166

@ -30,14 +30,19 @@ func (fs *Filesystem) ozinitMountDev() error {
fs.log.Warning("Failed to mount devtmpfs: %v", err)
return err
}
}
if err := mountSpecial("/dev/shm", "tmpfs"); err != nil {
if err := mountSpecial("/dev/shm", "tmpfs", true); err != nil {
fs.log.Warning("Failed to mount shm directory: %v", err)
return err
}
if err := mountSpecial("/tmp", "tmpfs", true); err != nil {
fs.log.Warning("Failed to mount shm directory: %v", err)
return err
}
if err := mountSpecial("/dev/pts", "devpts"); err != nil {
if err := mountSpecial("/dev/pts", "devpts", false); err != nil {
fs.log.Warning("Failed to mount pts directory: %v", err)
return err
}
@ -45,8 +50,11 @@ func (fs *Filesystem) ozinitMountDev() error {
return nil
}
func mountSpecial(path, mtype string) error {
func mountSpecial(path, mtype string, nodevs bool) error {
flags := uintptr(syscall.MS_NOSUID | syscall.MS_REC | syscall.MS_NOEXEC)
if nodevs {
flags = flags | syscall.MS_NODEV
}
if err := os.MkdirAll(path, 0755); err != nil {
return err
}

@ -179,14 +179,17 @@ func (fs *Filesystem) setupChroot() error {
if err != nil {
return err
}
return setupTmp(fs.root)
return nil
}
func (fs *Filesystem) setupDev() error {
devPath := path.Join(fs.root, "dev")
flags := uintptr(syscall.MS_NOSUID | syscall.MS_NOEXEC)
if err := syscall.Mount("none", devPath, "tmpfs", flags, ""); err != nil {
fs.log.Warning("Failed to mount devtmpfs: %v", err)
fs.log.Warning("Failed to mount new tmpfs: %s (%v)", devPath, err)
return err
}
if err := os.Chmod(devPath, 0755); err != nil {
return err
}
@ -200,12 +203,6 @@ func (fs *Filesystem) setupDev() error {
}
}
shmPath := path.Join(devPath, "shm")
if err := mountSpecial(shmPath, "tmpfs"); err != nil {
fs.log.Warning("Failed to mount shm directory: %v", err)
return err
}
return nil
}

Loading…
Cancel
Save