aboutsummaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2019-02-15 11:41:14 +0100
committerGiuseppe Scrivano <gscrivan@redhat.com>2019-02-15 11:41:17 +0100
commit8aa9b85fa7b5abd79826ec1229902eb8e19b4193 (patch)
tree4441942ab83a446463d363b5133c612b76b159ac /libpod
parent71782812fef6cc8ce97aeefaecb3468597c840b9 (diff)
downloadpodman-8aa9b85fa7b5abd79826ec1229902eb8e19b4193.tar.gz
podman-8aa9b85fa7b5abd79826ec1229902eb8e19b4193.tar.bz2
podman-8aa9b85fa7b5abd79826ec1229902eb8e19b4193.zip
libpod: honor runtime_path from libpod.conf
Add backward compatibility for `runtime_path` that was used by older versions of Podman. The issue was introduced with: 650cf122e1b33f4d8f4426ee1cc1a4bf00c14798 If `runtime_path` is specified, it overrides any other configuration and a warning is printed. It should be considered deprecated and will be removed in future. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/runtime.go24
1 files changed, 23 insertions, 1 deletions
diff --git a/libpod/runtime.go b/libpod/runtime.go
index b01674be0..4f5d1e292 100644
--- a/libpod/runtime.go
+++ b/libpod/runtime.go
@@ -130,6 +130,12 @@ type RuntimeConfig struct {
OCIRuntime string `toml:"runtime"`
// OCIRuntimes are the set of configured OCI runtimes (default is runc)
OCIRuntimes map[string][]string `toml:"runtimes"`
+ // RuntimePath is the path to OCI runtime binary for launching
+ // containers.
+ // The first path pointing to a valid file will be used
+ // This is used only when there are no OCIRuntime/OCIRuntimes defined. It
+ // is used only to be backward compatible with older versions of Podman.
+ RuntimePath []string `toml:"runtime_path"`
// ConmonPath is the path to the Conmon binary used for managing
// containers
// The first path pointing to a valid file will be used
@@ -403,6 +409,7 @@ func NewRuntime(options ...RuntimeOption) (runtime *Runtime, err error) {
runtime.config.ConmonPath = tmpConfig.ConmonPath
runtime.config.ConmonEnvVars = tmpConfig.ConmonEnvVars
runtime.config.OCIRuntimes = tmpConfig.OCIRuntimes
+ runtime.config.RuntimePath = tmpConfig.RuntimePath
runtime.config.CNIPluginDir = tmpConfig.CNIPluginDir
runtime.config.NoPivotRoot = tmpConfig.NoPivotRoot
break
@@ -485,10 +492,25 @@ func NewRuntimeFromConfig(configPath string, options ...RuntimeOption) (runtime
// Make a new runtime based on the given configuration
// Sets up containers/storage, state store, OCI runtime
func makeRuntime(runtime *Runtime) (err error) {
+
+ // Backward compatibility for `runtime_path`
+ if runtime.config.RuntimePath != nil {
+ // Don't print twice in rootless mode.
+ if os.Geteuid() == 0 {
+ logrus.Warningf("The configuration is using `runtime_path`, which is deprecated and will be removed in future. Please use `runtimes` and `runtime`")
+ logrus.Warningf("If you are using both `runtime_path` and `runtime`, the configuration from `runtime_path` is used")
+ }
+
+ // Transform `runtime_path` into `runtimes` and `runtime`.
+ name := filepath.Base(runtime.config.RuntimePath[0])
+ runtime.config.OCIRuntime = name
+ runtime.config.OCIRuntimes = map[string][]string{name: runtime.config.RuntimePath}
+ }
+
// Find a working OCI runtime binary
foundRuntime := false
// If runtime is an absolute path, then use it as it is.
- if runtime.config.OCIRuntime[0] == '/' {
+ if runtime.config.OCIRuntime != "" && runtime.config.OCIRuntime[0] == '/' {
foundRuntime = true
runtime.ociRuntimePath = OCIRuntimePath{Name: filepath.Base(runtime.config.OCIRuntime), Paths: []string{runtime.config.OCIRuntime}}
} else {