diff options
author | umohnani8 <umohnani@redhat.com> | 2018-04-29 20:50:04 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-04-30 19:30:57 +0000 |
commit | d1b03f470e8285613ccdf84f00e47143e7361c3b (patch) | |
tree | 4bea046b0e8790fdd2054354a4406832da03a975 | |
parent | 9a2e267637beeb535aac08aee99bcf24db5fce61 (diff) | |
download | podman-d1b03f470e8285613ccdf84f00e47143e7361c3b.tar.gz podman-d1b03f470e8285613ccdf84f00e47143e7361c3b.tar.bz2 podman-d1b03f470e8285613ccdf84f00e47143e7361c3b.zip |
Add more validation to --volume flag for run and create
Return error if the host and container paths is a relative path.
Only absolute paths allowed.
Signed-off-by: umohnani8 <umohnani@redhat.com>
Closes: #695
Approved by: rhatdan
-rw-r--r-- | cmd/podman/create_cli.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/cmd/podman/create_cli.go b/cmd/podman/create_cli.go index 24856feb8..11a5d3533 100644 --- a/cmd/podman/create_cli.go +++ b/cmd/podman/create_cli.go @@ -3,6 +3,7 @@ package main import ( "fmt" "os" + "path/filepath" "strings" "github.com/docker/docker/pkg/sysinfo" @@ -97,6 +98,9 @@ func parseVolumes(volumes []string) error { } func validateVolumeHostDir(hostDir string) error { + if !filepath.IsAbs(hostDir) { + return errors.Errorf("invalid host path, must be an absolute path %q", hostDir) + } if _, err := os.Stat(hostDir); err != nil { return errors.Wrapf(err, "error checking path %q", hostDir) } @@ -104,8 +108,8 @@ func validateVolumeHostDir(hostDir string) error { } func validateVolumeCtrDir(ctrDir string) error { - if ctrDir[0] != '/' { - return errors.Errorf("invalid container directory path %q", ctrDir) + if !filepath.IsAbs(ctrDir) { + return errors.Errorf("invalid container path, must be an absolute path %q", ctrDir) } return nil } |