Adding test case for symlink causes infinit loop, reproduces: dotcloud#5370

normally symlinks are created as either
ln -s /path/existing /path/new-name
or
cd /path && ln -s ./existing new-name

but one can create it this way
cd /path && ln -s existing new-name

this drives FollowSymlinkInScope into infinite loop

Docker-DCO-1.1-Signed-off-by: Lajos Papp <lajos.papp@sequenceiq.com> (github: lalyos)
This commit is contained in:
lalyos 2014-05-15 23:52:36 +02:00
parent 9b677d0733
commit 64b6d99e35
2 changed files with 14 additions and 0 deletions

View file

@ -28,6 +28,19 @@ func TestFollowSymLinkNormal(t *testing.T) {
}
}
func TestFollowSymLinkRelativePath(t *testing.T) {
link := "testdata/fs/i"
rewrite, err := FollowSymlinkInScope(link, "testdata")
if err != nil {
t.Fatal(err)
}
if expected := abs(t, "testdata/fs/a"); expected != rewrite {
t.Fatalf("Expected %s got %s", expected, rewrite)
}
}
func TestFollowSymLinkUnderLinkedDir(t *testing.T) {
dir, err := ioutil.TempDir("", "docker-fs-test")
if err != nil {

1
symlink/testdata/fs/i vendored Symbolic link
View file

@ -0,0 +1 @@
a