aboutsummaryrefslogtreecommitdiff
path: root/pkg/util
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2019-02-05 12:08:24 -0500
committerMatthew Heon <matthew.heon@pm.me>2019-02-06 10:01:43 -0500
commit33845f8a0f6160f24f298d81863292ad37e59c4d (patch)
treea0135a26e18aefdfc667defdfd89c610f0e69307 /pkg/util
parent3554bfce98bc643bd4724340bf2abbaa6373e70c (diff)
downloadpodman-33845f8a0f6160f24f298d81863292ad37e59c4d.tar.gz
podman-33845f8a0f6160f24f298d81863292ad37e59c4d.tar.bz2
podman-33845f8a0f6160f24f298d81863292ad37e59c4d.zip
Unconditionally refresh storage options from config
Due to our unconditionally setting some storage options, we are not always reading storage options from storage.conf. This can lead to some fields in the storage config (most notably extra storage options) being ignored, despite being set in storage.conf. Resolve this by unconditionally refreshing our storage config from storage.conf (this was previously only done for rootless Podman) Fixes #2217 Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'pkg/util')
-rw-r--r--pkg/util/utils.go44
1 files changed, 27 insertions, 17 deletions
diff --git a/pkg/util/utils.go b/pkg/util/utils.go
index e0b94b011..52f431881 100644
--- a/pkg/util/utils.go
+++ b/pkg/util/utils.go
@@ -301,36 +301,36 @@ func getTomlStorage(storeOptions *storage.StoreOptions) *tomlConfig {
// for the volume API
// It also returns the path where all named volumes will be created using the volume API
func GetDefaultStoreOptions() (storage.StoreOptions, string, error) {
+ var (
+ defaultRootlessRunRoot string
+ defaultRootlessGraphRoot string
+ err error
+ )
storageOpts := storage.DefaultStoreOptions
volumePath := "/var/lib/containers/storage"
+
if rootless.IsRootless() {
- var err error
storageOpts, err = GetRootlessStorageOpts()
if err != nil {
return storageOpts, volumePath, err
}
+
volumePath, err = GetRootlessVolumeInfo()
if err != nil {
return storageOpts, volumePath, err
}
+ }
- storageConf := StorageConfigFile()
- if _, err := os.Stat(storageConf); err == nil {
- defaultRootlessRunRoot := storageOpts.RunRoot
- defaultRootlessGraphRoot := storageOpts.GraphRoot
- storageOpts = storage.StoreOptions{}
- storage.ReloadConfigurationFile(storageConf, &storageOpts)
+ 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) {
+ if rootless.IsRootless() {
+ 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)
if err != nil {
@@ -343,6 +343,16 @@ func GetDefaultStoreOptions() (storage.StoreOptions, string, error) {
if err := enc.Encode(tomlConfiguration); err != nil {
os.Remove(storageConf)
}
+ } else if err == nil {
+ // 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
+ }
}
}
return storageOpts, volumePath, nil