Skip to content

Commit

Permalink
rootless: copy some settings from the global configuration
Browse files Browse the repository at this point in the history
if some paths are overriden in the global configuration file, be sure
that rootless podman honors them.

Closes: containers#2174

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
  • Loading branch information
giuseppe committed Jan 29, 2019
1 parent c9e1f36 commit 552e15d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions libpod/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,28 @@ 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
runtime.config.CNIPluginDir = tmpConfig.CNIPluginDir
runtime.config.NoPivotRoot = tmpConfig.NoPivotRoot
break
}
}

// Overwrite config with user-given configuration options
Expand Down

0 comments on commit 552e15d

Please sign in to comment.