Parcourir la source

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)
lalyos il y a 11 ans
Parent
commit
8b77a5b7ae
2 fichiers modifiés avec 14 ajouts et 0 suppressions
  1. 13 0
      pkg/symlink/fs_test.go
  2. 1 0
      pkg/symlink/testdata/fs/i

+ 13 - 0
pkg/symlink/fs_test.go

@@ -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 - 0
pkg/symlink/testdata/fs/i

@@ -0,0 +1 @@
+a