Follow symlinks inside container root for build's ADD

Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Upstream-commit: 0fb01fd8fe376a3518b1050ab62f2b3370d62535
Component: engine
This commit is contained in:
Michael Crosby
2014-03-27 02:07:35 +00:00
parent aa3273eb2a
commit 1c550a00a4
2 changed files with 27 additions and 0 deletions
+9
View File
@@ -395,9 +395,18 @@ func (b *buildFile) checkPathForAddition(orig string) error {
func (b *buildFile) addContext(container *runtime.Container, orig, dest string, remote bool) error {
var (
err error
origPath = path.Join(b.contextPath, orig)
destPath = path.Join(container.RootfsPath(), dest)
)
if destPath != container.RootfsPath() {
destPath, err = utils.FollowSymlinkInScope(destPath, container.RootfsPath())
if err != nil {
return err
}
}
// Preserve the trailing '/'
if strings.HasSuffix(dest, "/") {
destPath = destPath + "/"