From a07fb45f3672167dda329f64618f93ad69851a35 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Tue, 10 Nov 2020 17:17:34 +0100 Subject: conf: move configuration to C:\Program Files\WireGuard\Data It doesn't get wiped out on Windows upgrades. Signed-off-by: Jason A. Donenfeld --- updater/msirunner_windows.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'updater') 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) -- cgit v1.2.3-59-g8ed1b