From 7d6b3d9bdcc1c505c4876dd33f6d85e5f9a5039a Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Mon, 28 Jan 2019 13:37:50 +0100 Subject: [PATCH] rootless: copy some settings from the global configuration if some paths are overriden in the global configuration file, be sure that rootless podman honors them. Closes: https://github.com/containers/libpod/issues/2174 Signed-off-by: Giuseppe Scrivano --- libpod/runtime.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/libpod/runtime.go b/libpod/runtime.go index c7000d84acea..5e4c92e76a82 100644 --- a/libpod/runtime.go +++ b/libpod/runtime.go @@ -385,6 +385,26 @@ func NewRuntime(options ...RuntimeOption) (runtime *Runtime, err error) { if _, err := toml.Decode(string(contents), runtime.config); err != nil { return nil, errors.Wrapf(err, "error decoding configuration file %s", configPath) } + } else if rootless.IsRootless() { + // If the configuration file was not found but we are running in rootless, a subset of the + // global config file is used. + for _, path := range []string{OverrideConfigPath, ConfigPath} { + contents, err := ioutil.ReadFile(OverrideConfigPath) + if err != nil { + // Ignore any error, the file might not be readable by us. + continue + } + tmpConfig := new(RuntimeConfig) + if _, err := toml.Decode(string(contents), tmpConfig); err != nil { + return nil, errors.Wrapf(err, "error decoding configuration file %s", path) + } + + // Cherry pick the settings we want from the global configuration + runtime.config.ConmonPath = tmpConfig.ConmonPath + runtime.config.ConmonEnvVars = tmpConfig.ConmonEnvVars + runtime.config.OCIRuntimes = tmpConfig.OCIRuntimes + break + } } // Overwrite config with user-given configuration options