Merge pull request #452 from hqhq/hq_bindmount_whitelist

Add white list for bind mount check
This commit is contained in:
Mrunal Patel 2016-01-06 11:16:10 -08:00
commit 4fda64bc07
1 changed files with 18 additions and 0 deletions

View File

@ -299,6 +299,24 @@ func checkMountDestination(rootfs, dest string) error {
invalidDestinations := []string{ invalidDestinations := []string{
"/proc", "/proc",
} }
// White list, it should be sub directories of invalid destinations
validDestinations := []string{
// These entries can be bind mounted by files emulated by fuse,
// so commands like top, free displays stats in container.
"/proc/cpuinfo",
"/proc/diskstats",
"/proc/meminfo",
"/proc/stats",
}
for _, valid := range validDestinations {
path, err := filepath.Rel(filepath.Join(rootfs, valid), dest)
if err != nil {
return err
}
if path == "." {
return nil
}
}
for _, invalid := range invalidDestinations { for _, invalid := range invalidDestinations {
path, err := filepath.Rel(filepath.Join(rootfs, invalid), dest) path, err := filepath.Rel(filepath.Join(rootfs, invalid), dest)
if err != nil { if err != nil {