Fix issue with config file saving, fix issue with state file saving, fix issue when merging a uuid into a server without one

This commit is contained in:
Matthew Penner
2020-04-10 17:55:36 -06:00
parent 4ea1b90560
commit 1f4aca8210
5 changed files with 12 additions and 47 deletions

View File

@@ -298,8 +298,7 @@ func (c *Configuration) setSystemUser(u *user.User) error {
c.System.User.Uid = uid
c.System.User.Gid = gid
// return c.WriteToDisk()
return nil
return c.WriteToDisk()
}
// Ensures that the configured data directory has the correct permissions assigned to
@@ -358,12 +357,6 @@ func (c *Configuration) EnsureFilePermissions() error {
// lock on the file. This prevents something else from writing at the exact same time and
// leading to bad data conditions.
func (c *Configuration) WriteToDisk() error {
f, err := os.OpenFile("config.yml", os.O_WRONLY, os.ModeExclusive)
if err != nil {
return err
}
defer f.Close()
ccopy := *c
// If debugging is set with the flag, don't save that to the configuration file, otherwise
// you'll always end up in debug mode.
@@ -376,7 +369,7 @@ func (c *Configuration) WriteToDisk() error {
return err
}
if _, err := f.Write(b); err != nil {
if err := ioutil.WriteFile("config.yml", b, 0644); err != nil {
return err
}