From 50be74ba1479278cc220633365cdd1c5a21d7cda Mon Sep 17 00:00:00 2001 From: xlgao Date: Mon, 31 Aug 2015 10:48:34 +0800 Subject: [PATCH] just check -v /src:dest and test it Signed-off-by: xlgao --- daemon/volumes_linux_unit_test.go | 1 + daemon/volumes_unit_test.go | 2 +- daemon/volumes_unix.go | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/daemon/volumes_linux_unit_test.go b/daemon/volumes_linux_unit_test.go index 842e101e1e..57c5b6e33f 100644 --- a/daemon/volumes_linux_unit_test.go +++ b/daemon/volumes_linux_unit_test.go @@ -52,6 +52,7 @@ func TestParseBindMount(t *testing.T) { {"name:/tmp", "external", "/tmp", "", "name", "external", "", true, false}, {"name:/tmp:ro", "local", "/tmp", "", "name", "local", "", false, false}, {"local/name:/tmp:rw", "", "/tmp", "", "local/name", "local", "", true, false}, + {"/tmp:tmp", "", "", "", "", "", "", true, true}, } for _, c := range cases { diff --git a/daemon/volumes_unit_test.go b/daemon/volumes_unit_test.go index b1e7f72f89..61b8c8d3b6 100644 --- a/daemon/volumes_unit_test.go +++ b/daemon/volumes_unit_test.go @@ -2,7 +2,7 @@ package daemon import "testing" -func TestParseVolumeFrom(t *testing.T) { +func TestParseVolumesFrom(t *testing.T) { cases := []struct { spec string expId string diff --git a/daemon/volumes_unix.go b/daemon/volumes_unix.go index 80ddcf096d..62fb93242f 100644 --- a/daemon/volumes_unix.go +++ b/daemon/volumes_unix.go @@ -81,6 +81,11 @@ func parseBindMount(spec string, mountLabel string, config *runconfig.Config) (* return nil, fmt.Errorf("Invalid volume specification: %s", spec) } + //validate the volumes destination path + if !filepath.IsAbs(bind.Destination) { + return nil, fmt.Errorf("Invalid volume destination path: %s mount path must be absolute.", bind.Destination) + } + name, source, err := parseVolumeSource(arr[0]) if err != nil { return nil, err