diff options
author | Giuseppe Scrivano <gscrivan@redhat.com> | 2019-10-21 12:06:46 +0200 |
---|---|---|
committer | Giuseppe Scrivano <gscrivan@redhat.com> | 2019-10-21 12:07:21 +0200 |
commit | fa9982b87ece21baafa08e0c17ca935ce29d7022 (patch) | |
tree | b3fce0c9ba42305fb7dc6824121d43d5935fc61a /libpod | |
parent | b6fdfa041a3e0f0a754c1f3a6edd8bc0be6f6ed8 (diff) | |
download | podman-fa9982b87ece21baafa08e0c17ca935ce29d7022.tar.gz podman-fa9982b87ece21baafa08e0c17ca935ce29d7022.tar.bz2 podman-fa9982b87ece21baafa08e0c17ca935ce29d7022.zip |
rootless: write storage overrides to the conf file
make sure the user overrides are stored in the configuration file when
first created.
Closes: https://github.com/containers/libpod/issues/2659
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/runtime.go | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/libpod/runtime.go b/libpod/runtime.go index a0cf0ad7c..e8c80c67e 100644 --- a/libpod/runtime.go +++ b/libpod/runtime.go @@ -528,6 +528,17 @@ func newRuntimeFromConfig(ctx context.Context, userConfigPath string, options .. return nil, err } + // storage.conf + storageConfFile, err := storage.DefaultConfigFile(rootless.IsRootless()) + if err != nil { + return nil, err + } + + createStorageConfFile := false + if _, err := os.Stat(storageConfFile); os.IsNotExist(err) { + createStorageConfFile = true + } + defRunConf, err := defaultRuntimeConfig() if err != nil { return nil, err @@ -702,27 +713,21 @@ func newRuntimeFromConfig(ctx context.Context, userConfigPath string, options .. } if rootless.IsRootless() && configPath == "" { - configPath, err := getRootlessConfigPath() - if err != nil { - return nil, err - } - - // storage.conf - storageConfFile, err := storage.DefaultConfigFile(rootless.IsRootless()) - if err != nil { - return nil, err - } - if _, err := os.Stat(storageConfFile); os.IsNotExist(err) { + if createStorageConfFile { if err := util.WriteStorageConfigFile(&runtime.config.StorageConfig, storageConfFile); err != nil { return nil, errors.Wrapf(err, "cannot write config file %s", storageConfFile) } } + configPath, err := getRootlessConfigPath() + if err != nil { + return nil, err + } if configPath != "" { - if err := os.MkdirAll(filepath.Dir(configPath), 0755); err != nil { + if err := os.MkdirAll(filepath.Dir(configPath), 0711); err != nil { return nil, err } - file, err := os.OpenFile(configPath, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0666) + file, err := os.OpenFile(configPath, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0600) if err != nil && !os.IsExist(err) { return nil, errors.Wrapf(err, "cannot open file %s", configPath) } |