mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
add integration test for --workdir=/
Docker-DCO-1.1-Signed-off-by: Tibor Vass <teabee89@gmail.com> (github: tiborvass)
This commit is contained in:
parent
385c9b1a08
commit
baacc7006b
2 changed files with 16 additions and 3 deletions
|
@ -945,4 +945,18 @@ func TestModeHostname(t *testing.T) {
|
|||
deleteAllContainers()
|
||||
|
||||
logDone("run - hostname and several network modes")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRootWorkdir(t *testing.T) {
|
||||
s, _, err := cmd(t, "run", "--workdir", "/", "busybox", "pwd")
|
||||
if err != nil {
|
||||
t.Fatal(s, err)
|
||||
}
|
||||
if s != "/\n" {
|
||||
t.Fatalf("pwd returned '%s' (expected /\\n)", s)
|
||||
}
|
||||
|
||||
deleteAllContainers()
|
||||
|
||||
logDone("run - workdir /")
|
||||
}
|
||||
|
|
|
@ -27,13 +27,12 @@ func FollowSymlinkInScope(link, root string) (string, error) {
|
|||
return root, nil
|
||||
}
|
||||
|
||||
|
||||
if !strings.HasPrefix(filepath.Dir(link), root) {
|
||||
return "", fmt.Errorf("%s is not within %s", link, root)
|
||||
}
|
||||
|
||||
prev := "/"
|
||||
|
||||
|
||||
for _, p := range strings.Split(link, "/") {
|
||||
prev = filepath.Join(prev, p)
|
||||
prev = filepath.Clean(prev)
|
||||
|
|
Loading…
Reference in a new issue