From 7f6a141839212c0d4d50324a726c5477817c8887 Mon Sep 17 00:00:00 2001 From: baude Date: Wed, 31 Jan 2018 12:27:50 -0600 Subject: libpod/runtime.go: Stick paths in arrays To account for more path possibilities, we now iterate a string array of possible paths to try and find paths to runc and conmon. Signed-off-by: baude Closes: #278 Approved by: baude --- libpod/runtime.go | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/libpod/runtime.go b/libpod/runtime.go index afde03904..cce396764 100644 --- a/libpod/runtime.go +++ b/libpod/runtime.go @@ -93,21 +93,22 @@ var ( ) func findConmonPath() string { - path := "/usr/local/libexec/crio/conmon" - _, err := os.Stat(path) - if err != nil { - path = "/usr/libexec/crio/conmon" - } - return path + paths := []string{"/usr/libexec/crio/conmon", "/usr/local/libexec/crio/conmon", "/usr/bin/conmon", "/usr/sbin/conmon"} + return pathHelper(paths) } func findRuncPath() string { - path := "/usr/bin/runc" - _, err := os.Stat(path) - if err != nil { - path = "/usr/sbin/runc" + paths := []string{"/usr/bin/runc", "/usr/sbin/runc", "/sbin/runc", "/bin/runc"} + return pathHelper(paths) +} + +func pathHelper(paths []string) string { + for _, path := range paths { + if _, err := os.Stat(path); err == nil { + return path + } } - return path + return paths[0] } // NewRuntime creates a new container runtime -- cgit v1.2.3-54-g00ecf