mirror of
https://github.com/containers/podman
synced 2024-10-20 17:23:30 +00:00
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>
This commit is contained in:
parent
69c3e32941
commit
2fe6ada854
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue