aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-12-13 10:23:22 -0600
committerbaude <bbaude@redhat.com>2018-12-13 10:23:22 -0600
commit0c3501acb53e5a860c104cae6e0fa885f398fe8a (patch)
tree980e4d1c50d7c157c6593aaa4984f1da15d80f57
parente3a1a7efca7f64b125fcd4f627a871bc699b5888 (diff)
downloadpodman-0c3501acb53e5a860c104cae6e0fa885f398fe8a.tar.gz
podman-0c3501acb53e5a860c104cae6e0fa885f398fe8a.tar.bz2
podman-0c3501acb53e5a860c104cae6e0fa885f398fe8a.zip
runlabel should sub podman for docker|/usr/bin/docker
Many RH images use a fully-qualified path to docker in their RUN labels. While initially we wanted an exact match for substituting commands, docker is a good exception. Bug #1623282 Signed-off-by: baude <bbaude@redhat.com>
-rw-r--r--cmd/podman/shared/funcs.go28
1 files changed, 16 insertions, 12 deletions
diff --git a/cmd/podman/shared/funcs.go b/cmd/podman/shared/funcs.go
index 8520c0616..8770b8ec0 100644
--- a/cmd/podman/shared/funcs.go
+++ b/cmd/podman/shared/funcs.go
@@ -10,10 +10,23 @@ import (
)
func substituteCommand(cmd string) (string, error) {
+ var (
+ newCommand string
+ )
+
+ // Replace cmd with "/proc/self/exe" if "podman" or "docker" is being
+ // used. If "/usr/bin/docker" is provided, we also sub in podman.
+ // Otherwise, leave the command unchanged.
+ if cmd == "podman" || filepath.Base(cmd) == "docker" {
+ newCommand = "/proc/self/exe"
+ } else {
+ newCommand = cmd
+ }
+
// If cmd is an absolute or relative path, check if the file exists.
// Throw an error if it doesn't exist.
- if strings.Contains(cmd, "/") || strings.HasPrefix(cmd, ".") {
- res, err := filepath.Abs(cmd)
+ if strings.Contains(newCommand, "/") || strings.HasPrefix(newCommand, ".") {
+ res, err := filepath.Abs(newCommand)
if err != nil {
return "", err
}
@@ -24,16 +37,7 @@ func substituteCommand(cmd string) (string, error) {
}
}
- // Replace cmd with "/proc/self/exe" if "podman" or "docker" is being
- // used. Otherwise, leave the command unchanged.
- switch cmd {
- case "podman":
- fallthrough
- case "docker":
- return "/proc/self/exe", nil
- default:
- return cmd, nil
- }
+ return newCommand, nil
}
// GenerateCommand takes a label (string) and converts it to an executable command