diff --git a/nsinit/init.go b/nsinit/init.go index 22345f60..a1237577 100644 --- a/nsinit/init.go +++ b/nsinit/init.go @@ -79,7 +79,7 @@ func Init(container *libcontainer.Container, uncleanRootfs, consolePath string, return fmt.Errorf("set process label %s", err) } if container.Context["restrictions"] != "" { - if err := restrict.Restrict(); err != nil { + if err := restrict.Restrict("proc", "sys"); err != nil { return err } } diff --git a/security/restrict/restrict.go b/security/restrict/restrict.go index cfff09f5..e1296b1d 100644 --- a/security/restrict/restrict.go +++ b/security/restrict/restrict.go @@ -11,9 +11,9 @@ import ( // This has to be called while the container still has CAP_SYS_ADMIN (to be able to perform mounts). // However, afterwards, CAP_SYS_ADMIN should be dropped (otherwise the user will be able to revert those changes). -func Restrict() error { +func Restrict(mounts ...string) error { // remount proc and sys as readonly - for _, dest := range []string{"proc", "sys"} { + for _, dest := range mounts { if err := system.Mount("", dest, "", syscall.MS_REMOUNT|syscall.MS_RDONLY, ""); err != nil { return fmt.Errorf("unable to remount %s readonly: %s", dest, err) }