1
0
mirror of https://github.com/docker/cli.git synced 2026-01-15 07:40:57 +03:00

Merge pull request #5673 from tianon/kcore-error

Update restrict.Restrict to both show the error message when failing to mount /dev/null over /proc/kcore, and to ignore "not exists" errors while doing so (for when CONFIG_PROC_KCORE=n in the kernel)
Upstream-commit: 7673e3c58938aa4179f3ec84ed4960b4b6267c14
Component: engine
This commit is contained in:
Michael Crosby
2014-05-08 10:20:19 -07:00

View File

@@ -4,6 +4,7 @@ package restrict
import (
"fmt"
"os"
"syscall"
"github.com/dotcloud/docker/pkg/system"
@@ -18,8 +19,8 @@ func Restrict(mounts ...string) error {
return fmt.Errorf("unable to remount %s readonly: %s", dest, err)
}
}
if err := system.Mount("/dev/null", "/proc/kcore", "", syscall.MS_BIND, ""); err != nil {
return fmt.Errorf("unable to bind-mount /dev/null over /proc/kcore")
if err := system.Mount("/dev/null", "/proc/kcore", "", syscall.MS_BIND, ""); err != nil && !os.IsNotExist(err) {
return fmt.Errorf("unable to bind-mount /dev/null over /proc/kcore: %s", err)
}
return nil
}