aboutsummaryrefslogtreecommitdiff
path: root/libpod/runtime.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-10-21 22:02:57 +0200
committerGitHub <noreply@github.com>2019-10-21 22:02:57 +0200
commitd2591a54335424263374a919d485712e5b8aa093 (patch)
tree342678abd4e02bee73a987017e1acfe04fb0d41e /libpod/runtime.go
parentd3520de6338dd1bce2dd1d51847e064e5299f63e (diff)
parentfa9982b87ece21baafa08e0c17ca935ce29d7022 (diff)
downloadpodman-d2591a54335424263374a919d485712e5b8aa093.tar.gz
podman-d2591a54335424263374a919d485712e5b8aa093.tar.bz2
podman-d2591a54335424263374a919d485712e5b8aa093.zip
Merge pull request #4309 from giuseppe/write-storage-overrides
rootless: write storage overrides to the conf file
Diffstat (limited to 'libpod/runtime.go')
-rw-r--r--libpod/runtime.go31
1 files changed, 18 insertions, 13 deletions
diff --git a/libpod/runtime.go b/libpod/runtime.go
index 107e8e3d0..8f145a809 100644
--- a/libpod/runtime.go
+++ b/libpod/runtime.go
@@ -509,6 +509,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
@@ -683,27 +694,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)
}