diff options
author | TomSweeneyRedHat <tsweeney@redhat.com> | 2019-10-30 19:36:42 -0400 |
---|---|---|
committer | TomSweeneyRedHat <tsweeney@redhat.com> | 2019-11-01 09:57:56 -0400 |
commit | 677a0e5d60c45711cba56032c23783c1d010a49e (patch) | |
tree | eb778d5c58e81cf450b3e7a92482d019241ed15a /cmd/podman/utils.go | |
parent | 69165fa04d9db306809a0b110491f9a572f74431 (diff) | |
download | podman-677a0e5d60c45711cba56032c23783c1d010a49e.tar.gz podman-677a0e5d60c45711cba56032c23783c1d010a49e.tar.bz2 podman-677a0e5d60c45711cba56032c23783c1d010a49e.zip |
Validate contextdir on build
We never verified that the context directory passed into the build
command was a valid directory. When we then slapped a default Containerfile
name onto it, things went south fast if the user had passed us a file and
not a directory.
Fixes: #4383
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
Diffstat (limited to 'cmd/podman/utils.go')
-rw-r--r-- | cmd/podman/utils.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/cmd/podman/utils.go b/cmd/podman/utils.go index c19e6391e..21389b43a 100644 --- a/cmd/podman/utils.go +++ b/cmd/podman/utils.go @@ -74,3 +74,13 @@ func checkIfFileExists(name string) bool { } return !file.IsDir() } + +// Check if a file is or is not a directory +func fileIsDir(name string) bool { + file, err := os.Stat(name) + // All errors return file == nil + if err != nil { + return false + } + return file.IsDir() +} |