diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-01-10 11:58:13 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-10 11:58:13 -0800 |
commit | 36d96c19f947aeac2675afe64a3b482e54f9e4c4 (patch) | |
tree | 854dc78eb7237a0f9507b82f2f8e7f42d6b13ae0 /pkg | |
parent | 7d2632872a875ad0baca0f812e0f8d9d97617977 (diff) | |
parent | 2fe6ada8547dd46bdf8f3f1ae10b02c4e903d94b (diff) | |
download | podman-36d96c19f947aeac2675afe64a3b482e54f9e4c4.tar.gz podman-36d96c19f947aeac2675afe64a3b482e54f9e4c4.tar.bz2 podman-36d96c19f947aeac2675afe64a3b482e54f9e4c4.zip |
Merge pull request #2131 from mheon/restore_storage_defaults
Use defaults if paths are not specified in storage.conf
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/util/utils.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/pkg/util/utils.go b/pkg/util/utils.go index 2b752afe1..e0b94b011 100644 --- a/pkg/util/utils.go +++ b/pkg/util/utils.go @@ -316,8 +316,20 @@ func GetDefaultStoreOptions() (storage.StoreOptions, string, error) { storageConf := StorageConfigFile() if _, err := os.Stat(storageConf); err == nil { + defaultRootlessRunRoot := storageOpts.RunRoot + defaultRootlessGraphRoot := storageOpts.GraphRoot storageOpts = storage.StoreOptions{} storage.ReloadConfigurationFile(storageConf, &storageOpts) + + // If the file did not specify a graphroot or runroot, + // set sane defaults so we don't try and use root-owned + // directories + if storageOpts.RunRoot == "" { + storageOpts.RunRoot = defaultRootlessRunRoot + } + if storageOpts.GraphRoot == "" { + storageOpts.GraphRoot = defaultRootlessGraphRoot + } } else if os.IsNotExist(err) { os.MkdirAll(filepath.Dir(storageConf), 0755) file, err := os.OpenFile(storageConf, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0666) |