summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2019-01-10 13:19:51 -0500
committerMatthew Heon <matthew.heon@pm.me>2019-01-10 13:19:51 -0500
commit2fe6ada8547dd46bdf8f3f1ae10b02c4e903d94b (patch)
treeb240f399350ff03feae27eda352a9809ad92da2f /pkg
parent69c3e329411318f51381649e77df70bbfc3e4b2e (diff)
downloadpodman-2fe6ada8547dd46bdf8f3f1ae10b02c4e903d94b.tar.gz
podman-2fe6ada8547dd46bdf8f3f1ae10b02c4e903d94b.tar.bz2
podman-2fe6ada8547dd46bdf8f3f1ae10b02c4e903d94b.zip
Use defaults if paths are not specified in storage.conf
For rootless Podman, if storage.conf exists but does not specify one or both of RunRoot and GraphRoot, set them to rootless defaults so we don't end up with an unusable configuration. Fixes #2125 Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/util/utils.go12
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)