summaryrefslogtreecommitdiff
path: root/libpod/healthcheck.go
diff options
context:
space:
mode:
authorStefan Becker <chemobejk@gmail.com>2019-07-11 20:18:56 +0300
committerStefan Becker <chemobejk@gmail.com>2019-07-16 07:01:43 +0300
commit5ed2de158ff8a234f0d5d8380bd44a41c616225c (patch)
treef8fa237b0360cfc22263396bf60b24fa9472e64e /libpod/healthcheck.go
parent5caf218b1162d6b24ac898b0e8ff730f5dcafe23 (diff)
downloadpodman-5ed2de158ff8a234f0d5d8380bd44a41c616225c.tar.gz
podman-5ed2de158ff8a234f0d5d8380bd44a41c616225c.tar.bz2
podman-5ed2de158ff8a234f0d5d8380bd44a41c616225c.zip
healthcheck: reject empty commands
An image with "HEALTHCHECK CMD ['']" is valid but as there is no command defined the healthcheck will fail. Reject such a configuration. Fixes #3507 Signed-off-by: Stefan Becker <chemobejk@gmail.com>
Diffstat (limited to 'libpod/healthcheck.go')
-rw-r--r--libpod/healthcheck.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/libpod/healthcheck.go b/libpod/healthcheck.go
index e9bf984e2..8ed2b12e1 100644
--- a/libpod/healthcheck.go
+++ b/libpod/healthcheck.go
@@ -123,6 +123,9 @@ func (c *Container) runHealthCheck() (HealthCheckStatus, error) {
// command supplied on command line - pass as-is
newCommand = hcCommand
}
+ if len(newCommand) < 1 || newCommand[0] == "" {
+ return HealthCheckNotDefined, errors.Errorf("container %s has no defined healthcheck", c.ID())
+ }
captureBuffer := bufio.NewWriter(&capture)
hcw := hcWriteCloser{
captureBuffer,