config: fix in memory config not saving on the fly backend config

Before this fix, saving a :backend config gave the error

    Can't save config "token" = "XXX" for on the fly backend ":backend"

Even when using the in-memory config `--config ""`

This fixes the problem by
- always using the in memory config if it is configured
- moving the check for a :backend config save to the file config backend

It also removes the contents of the config items being saved from the
log which saves confidential tokens being logged.

Fixes #5451
This commit is contained in:
Nick Craig-Wood
2021-07-13 17:41:28 +01:00
parent da36ce08e4
commit 770b3496a1
3 changed files with 11 additions and 11 deletions

View File

@@ -332,6 +332,10 @@ func SetConfigPath(path string) (err error) {
// SetData sets new config file storage
func SetData(newData Storage) {
// If no config file, use in-memory config (which is the default)
if configPath == "" {
return
}
data = newData
dataLoaded = false
}
@@ -371,10 +375,6 @@ var ErrorConfigFileNotFound = errors.New("config file not found")
// SaveConfig calling function which saves configuration file.
// if SaveConfig returns error trying again after sleep.
func SaveConfig() {
if configPath == "" {
fs.Debugf(nil, "Skipping save for memory-only config")
return
}
ctx := context.Background()
ci := fs.GetConfig(ctx)
var err error