summaryrefslogtreecommitdiff
path: root/pkg/util
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2018-11-21 10:31:12 +0100
committerGiuseppe Scrivano <gscrivan@redhat.com>2018-11-28 10:48:30 +0100
commit078cb630d3959200b4f9a14763714cf77258e8a2 (patch)
tree80133661673510cd13b23735cbcd9dee845c16da /pkg/util
parent6df7409cb5a41c710164c42ed35e33b28f3f7214 (diff)
downloadpodman-078cb630d3959200b4f9a14763714cf77258e8a2.tar.gz
podman-078cb630d3959200b4f9a14763714cf77258e8a2.tar.bz2
podman-078cb630d3959200b4f9a14763714cf77258e8a2.zip
rootless: store only subset of storage.conf
do not store the entire file but only the subset of what we have modified. Also, we were not writing the correct data. Since it is not trivial to serialize storage.conf correctly and all the various supported options, serialize only what we care about. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'pkg/util')
-rw-r--r--pkg/util/utils.go32
1 files changed, 31 insertions, 1 deletions
diff --git a/pkg/util/utils.go b/pkg/util/utils.go
index c5ba38b9f..de29bc5d8 100644
--- a/pkg/util/utils.go
+++ b/pkg/util/utils.go
@@ -284,6 +284,35 @@ func GetRootlessStorageOpts() (storage.StoreOptions, error) {
return opts, nil
}
+type tomlOptionsConfig struct {
+ MountProgram string `toml:"mount_program"`
+}
+
+type tomlConfig struct {
+ Storage struct {
+ Driver string `toml:"driver"`
+ RunRoot string `toml:"runroot"`
+ GraphRoot string `toml:"graphroot"`
+ Options struct{ tomlOptionsConfig } `toml:"options"`
+ } `toml:"storage"`
+}
+
+func getTomlStorage(storeOptions *storage.StoreOptions) *tomlConfig {
+ config := new(tomlConfig)
+
+ config.Storage.Driver = storeOptions.GraphDriverName
+ config.Storage.RunRoot = storeOptions.RunRoot
+ config.Storage.GraphRoot = storeOptions.GraphRoot
+ for _, i := range storeOptions.GraphDriverOptions {
+ s := strings.Split(i, "=")
+ if s[0] == "overlay.mount_program" {
+ config.Storage.Options.MountProgram = s[1]
+ }
+ }
+
+ return config
+}
+
// GetDefaultStoreOptions returns the storage ops for containers
func GetDefaultStoreOptions() (storage.StoreOptions, error) {
storageOpts := storage.DefaultStoreOptions
@@ -304,9 +333,10 @@ func GetDefaultStoreOptions() (storage.StoreOptions, error) {
return storageOpts, errors.Wrapf(err, "cannot open %s", storageConf)
}
+ tomlConfiguration := getTomlStorage(&storageOpts)
defer file.Close()
enc := toml.NewEncoder(file)
- if err := enc.Encode(storageOpts); err != nil {
+ if err := enc.Encode(tomlConfiguration); err != nil {
os.Remove(storageConf)
}
}