summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
Diffstat (limited to 'libpod')
-rw-r--r--libpod/boltdb_state_internal.go30
-rw-r--r--libpod/runtime.go6
2 files changed, 25 insertions, 11 deletions
diff --git a/libpod/boltdb_state_internal.go b/libpod/boltdb_state_internal.go
index 9be753d26..e195ca314 100644
--- a/libpod/boltdb_state_internal.go
+++ b/libpod/boltdb_state_internal.go
@@ -2,7 +2,7 @@ package libpod
import (
"bytes"
- "path/filepath"
+ "os"
"runtime"
"strings"
@@ -400,14 +400,30 @@ func (s *BoltState) getContainerFromDB(id []byte, ctr *Container, ctrsBkt *bolt.
// Handle legacy containers which might use a literal path for
// their OCI runtime name.
runtimeName := ctr.config.OCIRuntime
- if strings.HasPrefix(runtimeName, "/") {
- runtimeName = filepath.Base(runtimeName)
- }
-
ociRuntime, ok := s.runtime.ociRuntimes[runtimeName]
if !ok {
- // Use a MissingRuntime implementation
- ociRuntime = getMissingRuntime(runtimeName, s.runtime)
+ runtimeSet := false
+
+ // If the path starts with a / and exists, make a new
+ // OCI runtime for it using the full path.
+ if strings.HasPrefix(runtimeName, "/") {
+ if stat, err := os.Stat(runtimeName); err == nil && !stat.IsDir() {
+ newOCIRuntime, err := newConmonOCIRuntime(runtimeName, []string{runtimeName}, s.runtime.conmonPath, s.runtime.runtimeFlags, s.runtime.config)
+ if err == nil {
+ // The runtime lock should
+ // protect against concurrent
+ // modification of the map.
+ ociRuntime = newOCIRuntime
+ s.runtime.ociRuntimes[runtimeName] = ociRuntime
+ runtimeSet = true
+ }
+ }
+ }
+
+ if !runtimeSet {
+ // Use a MissingRuntime implementation
+ ociRuntime = getMissingRuntime(runtimeName, s.runtime)
+ }
}
ctr.ociRuntime = ociRuntime
}
diff --git a/libpod/runtime.go b/libpod/runtime.go
index ccd920ab0..792492db6 100644
--- a/libpod/runtime.go
+++ b/libpod/runtime.go
@@ -396,14 +396,12 @@ func makeRuntime(ctx context.Context, runtime *Runtime) (retErr error) {
// If the string starts with / it's a path to a runtime
// executable.
if strings.HasPrefix(runtime.config.Engine.OCIRuntime, "/") {
- name := filepath.Base(runtime.config.Engine.OCIRuntime)
-
- ociRuntime, err := newConmonOCIRuntime(name, []string{runtime.config.Engine.OCIRuntime}, runtime.conmonPath, runtime.runtimeFlags, runtime.config)
+ ociRuntime, err := newConmonOCIRuntime(runtime.config.Engine.OCIRuntime, []string{runtime.config.Engine.OCIRuntime}, runtime.conmonPath, runtime.runtimeFlags, runtime.config)
if err != nil {
return err
}
- runtime.ociRuntimes[name] = ociRuntime
+ runtime.ociRuntimes[runtime.config.Engine.OCIRuntime] = ociRuntime
runtime.defaultOCIRuntime = ociRuntime
} else {
ociRuntime, ok := runtime.ociRuntimes[runtime.config.Engine.OCIRuntime]