aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/updater
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-11-10 17:17:34 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2020-11-16 19:03:37 +0100
commita07fb45f3672167dda329f64618f93ad69851a35 (patch)
tree2b60fae6cd8d7715829e57da758056589e591e9d /updater
parentfetcher: introduce downloader utility (diff)
downloadwireguard-windows-a07fb45f3672167dda329f64618f93ad69851a35.tar.xz
wireguard-windows-a07fb45f3672167dda329f64618f93ad69851a35.zip
conf: move configuration to C:\Program Files\WireGuard\Data
It doesn't get wiped out on Windows upgrades. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'updater')
-rw-r--r--updater/msirunner_windows.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/updater/msirunner_windows.go b/updater/msirunner_windows.go
index c11d4db9..f7ee35a2 100644
--- a/updater/msirunner_windows.go
+++ b/updater/msirunner_windows.go
@@ -68,9 +68,11 @@ func msiTempFile() (*os.File, error) {
Length: uint32(unsafe.Sizeof(windows.SecurityAttributes{})),
SecurityDescriptor: sd,
}
- // TODO: os.TempDir() returns C:\windows\temp when calling from this context. Supposedly this is mostly secure
- // against TOCTOU, but who knows! Look into this!
- name := filepath.Join(os.TempDir(), hex.EncodeToString(randBytes[:]))
+ windir, err := windows.GetWindowsDirectory()
+ if err != nil {
+ return nil, err
+ }
+ name := filepath.Join(windir, "Temp", hex.EncodeToString(randBytes[:]))
name16 := windows.StringToUTF16Ptr(name)
// TODO: it would be nice to specify delete_on_close, but msiexec.exe doesn't open its files with read sharing.
fileHandle, err := windows.CreateFile(name16, windows.GENERIC_WRITE, windows.FILE_SHARE_READ, sa, windows.CREATE_NEW, windows.FILE_ATTRIBUTE_NORMAL, 0)