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)
| ... | ... |
@@ -28,6 +28,19 @@ func TestFollowSymLinkNormal(t *testing.T) {
|
| 28 | 28 |
} |
| 29 | 29 |
} |
| 30 | 30 |
|
| 31 |
+func TestFollowSymLinkRelativePath(t *testing.T) {
|
|
| 32 |
+ link := "testdata/fs/i" |
|
| 33 |
+ |
|
| 34 |
+ rewrite, err := FollowSymlinkInScope(link, "testdata") |
|
| 35 |
+ if err != nil {
|
|
| 36 |
+ t.Fatal(err) |
|
| 37 |
+ } |
|
| 38 |
+ |
|
| 39 |
+ if expected := abs(t, "testdata/fs/a"); expected != rewrite {
|
|
| 40 |
+ t.Fatalf("Expected %s got %s", expected, rewrite)
|
|
| 41 |
+ } |
|
| 42 |
+} |
|
| 43 |
+ |
|
| 31 | 44 |
func TestFollowSymLinkUnderLinkedDir(t *testing.T) {
|
| 32 | 45 |
dir, err := ioutil.TempDir("", "docker-fs-test")
|
| 33 | 46 |
if err != nil {
|