소스 검색

expose unresolved path for volumes and resolve symlink in container.getResourcePath

Docker-DCO-1.1-Signed-off-by: Tibor Vass <teabee89@gmail.com> (github: tiborvass)
Tibor Vass 11 년 전
부모
커밋
65d4047cb6
2개의 변경된 파일7개의 추가작업 그리고 3개의 파일을 삭제
  1. 5 1
      daemon/container.go
  2. 2 2
      daemon/volumes.go

+ 5 - 1
daemon/container.go

@@ -139,7 +139,11 @@ func (container *Container) WriteHostConfig() (err error) {
 
 func (container *Container) getResourcePath(path string) string {
 	cleanPath := filepath.Join("/", path)
-	return filepath.Join(container.basefs, cleanPath)
+	result, err := symlink.FollowSymlinkInScope(filepath.Join(container.basefs, cleanPath), container.basefs)
+	if err != nil {
+		utils.Errorf("getResourcePath failed: %v", err)
+	}
+	return result
 }
 
 func (container *Container) getRootResourcePath(path string) string {

+ 2 - 2
daemon/volumes.go

@@ -280,8 +280,8 @@ func initializeVolume(container *Container, volPath string, binds map[string]Bin
 		delete(container.VolumesRW, volPath)
 	}
 
-	container.Volumes[newVolPath] = destination
-	container.VolumesRW[newVolPath] = srcRW
+	container.Volumes[volPath] = destination
+	container.VolumesRW[volPath] = srcRW
 
 	if err := createIfNotExists(source, volIsDir); err != nil {
 		return err