diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-11-21 14:59:03 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-11-22 22:00:32 +0100 |
commit | 259e2cb5eb2507d0321ceb9f46278df18ebe3066 (patch) | |
tree | 9f210d076e2768378b927440c67904c446d13f33 /conf/store.go | |
parent | manager: move IPC notification to go routine per client (diff) | |
download | wireguard-windows-259e2cb5eb2507d0321ceb9f46278df18ebe3066.tar.xz wireguard-windows-259e2cb5eb2507d0321ceb9f46278df18ebe3066.zip |
conf: allow administrators to add and remove configs easily
We loosen the permissions a little bit while tightening the
restrictions on encrypted files. This should allow administrators to
easily drop unencrypted files into Data\Configurations\ and get them
encrypted and made read-only, while also allowing them to delete
unwanted configurations.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'conf/store.go')
-rw-r--r-- | conf/store.go | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/conf/store.go b/conf/store.go index 21bd3a22..e79e24b8 100644 --- a/conf/store.go +++ b/conf/store.go @@ -103,7 +103,7 @@ func MigrateUnencryptedConfigs() (int, []error) { e++ continue } - err = ioutil.WriteFile(dstFile, bytes, 0600) + err = writeEncryptedFile(dstFile, bytes) if err != nil { errs[e] = err e++ @@ -185,16 +185,7 @@ func (config *Config) Save() error { if err != nil { return err } - err = ioutil.WriteFile(filename+".tmp", bytes, 0600) - if err != nil { - return err - } - err = os.Rename(filename+".tmp", filename) - if err != nil { - os.Remove(filename + ".tmp") - return err - } - return nil + return writeEncryptedFile(filename, bytes) } func (config *Config) Path() (string, error) { |