From e178f59d16f6ae3cb763d25db7cf86f5b10458b4 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Mon, 1 Dec 2014 14:54:14 -0500 Subject: [PATCH] Label standard mounts within loop Signed-off-by: Michael Crosby Upstream-commit: 305e9cd2fab974c38064a1acd2ef1f552a3a1357 Component: engine --- components/engine/daemon/volumes.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/components/engine/daemon/volumes.go b/components/engine/daemon/volumes.go index 54cc0369dc..46ae5588af 100644 --- a/components/engine/daemon/volumes.go +++ b/components/engine/daemon/volumes.go @@ -236,25 +236,22 @@ func validMountMode(mode string) bool { } func (container *Container) setupMounts() error { - if err := label.SetFileLabel(container.ResolvConfPath, container.MountLabel); err != nil { - return err - } mounts := []execdriver.Mount{ {Source: container.ResolvConfPath, Destination: "/etc/resolv.conf", Writable: true, Private: true}, } if container.HostnamePath != "" { - if err := label.SetFileLabel(container.HostnamePath, container.MountLabel); err != nil { - return err - } mounts = append(mounts, execdriver.Mount{Source: container.HostnamePath, Destination: "/etc/hostname", Writable: true, Private: true}) } if container.HostsPath != "" { - if err := label.SetFileLabel(container.HostsPath, container.MountLabel); err != nil { + mounts = append(mounts, execdriver.Mount{Source: container.HostsPath, Destination: "/etc/hosts", Writable: true, Private: true}) + } + + for _, m := range mounts { + if err := label.SetFileLabel(m.Source, container.MountLabel); err != nil { return err } - mounts = append(mounts, execdriver.Mount{Source: container.HostsPath, Destination: "/etc/hosts", Writable: true, Private: true}) } // Mount user specified volumes