diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-05-25 02:23:34 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-05-25 02:23:34 +0200 |
commit | b33299a29713f2d87fba572010f87f1361480cba (patch) | |
tree | 432899e15da424b1a2c28041190db3144c94480c | |
parent | build: opt in to walk cgo (diff) | |
download | wireguard-windows-b33299a29713f2d87fba572010f87f1361480cba.tar.xz wireguard-windows-b33299a29713f2d87fba572010f87f1361480cba.zip |
global: use filepath.Join uniformly
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r-- | ringlogger/dump_windows.go | 10 | ||||
-rw-r--r-- | ringlogger/global.go | 4 | ||||
-rw-r--r-- | tunnel/winipcfg/netsh.go | 3 | ||||
-rw-r--r-- | updater/msirunner_windows.go | 10 |
4 files changed, 14 insertions, 13 deletions
diff --git a/ringlogger/dump_windows.go b/ringlogger/dump_windows.go index 7faf8ffc..552410e5 100644 --- a/ringlogger/dump_windows.go +++ b/ringlogger/dump_windows.go @@ -8,7 +8,7 @@ package ringlogger import ( "io" "os" - "path" + "path/filepath" "golang.org/x/sys/windows" "golang.org/x/sys/windows/registry" @@ -16,13 +16,13 @@ import ( ) func DumpTo(out io.Writer, localSystem bool) error { - var filepath string + var path string if !localSystem { root, err := conf.RootDirectory() if err != nil { return err } - filepath = path.Join(root, "log.bin") + path = filepath.Join(root, "log.bin") } else { k, err := registry.OpenKey(registry.LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\S-1-5-18", registry.QUERY_VALUE) if err != nil { @@ -38,9 +38,9 @@ func DumpTo(out io.Writer, localSystem bool) error { if err != nil { return err } - filepath = path.Join(systemprofile, "AppData", "Local", "WireGuard", "log.bin") + path = filepath.Join(systemprofile, "AppData", "Local", "WireGuard", "log.bin") } - file, err := os.Open(filepath) + file, err := os.Open(path) if err != nil { return err } diff --git a/ringlogger/global.go b/ringlogger/global.go index 8d8f8ec8..60e750a5 100644 --- a/ringlogger/global.go +++ b/ringlogger/global.go @@ -7,7 +7,7 @@ package ringlogger import ( "log" - "path" + "path/filepath" "golang.zx2c4.com/wireguard/windows/conf" ) @@ -22,7 +22,7 @@ func InitGlobalLogger(tag string) error { if err != nil { return err } - Global, err = NewRinglogger(path.Join(root, "log.bin"), tag) + Global, err = NewRinglogger(filepath.Join(root, "log.bin"), tag) if err != nil { return err } diff --git a/tunnel/winipcfg/netsh.go b/tunnel/winipcfg/netsh.go index 4cff5de8..4714c520 100644 --- a/tunnel/winipcfg/netsh.go +++ b/tunnel/winipcfg/netsh.go @@ -10,6 +10,7 @@ import ( "fmt" "io" "os/exec" + "path/filepath" "strings" "golang.org/x/sys/windows" @@ -23,7 +24,7 @@ func runNetsh(cmds []string) error { if err != nil { return err } - cmd := exec.Command(system32 + "\\netsh.exe") // I wish we could append (, "-f", "CONIN$") but Go sets up the process context wrong. + cmd := exec.Command(filepath.Join(system32, "netsh.exe")) // I wish we could append (, "-f", "CONIN$") but Go sets up the process context wrong. stdin, err := cmd.StdinPipe() if err != nil { return fmt.Errorf("runNetsh stdin pipe - %v", err) diff --git a/updater/msirunner_windows.go b/updater/msirunner_windows.go index 38acc0ac..84ddde28 100644 --- a/updater/msirunner_windows.go +++ b/updater/msirunner_windows.go @@ -11,7 +11,7 @@ import ( "errors" "os" "os/exec" - "path" + "path/filepath" "runtime" "syscall" "unsafe" @@ -35,10 +35,10 @@ func runMsi(msiPath string, userToken uintptr) error { Token: syscall.Token(userToken), }, Files: []*os.File{devNull, devNull, devNull}, - Dir: path.Dir(msiPath), + Dir: filepath.Dir(msiPath), } - msiexec := path.Join(system32, "msiexec.exe") - proc, err := os.StartProcess(msiexec, []string{msiexec, "/qb!-", "/i", path.Base(msiPath)}, attr) + msiexec := filepath.Join(system32, "msiexec.exe") + proc, err := os.StartProcess(msiexec, []string{msiexec, "/qb!-", "/i", filepath.Base(msiPath)}, attr) if err != nil { return err } @@ -71,7 +71,7 @@ func msiTempFile() (*os.File, error) { } //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 := path.Join(os.TempDir(), hex.EncodeToString(randBytes[:])) + name := filepath.Join(os.TempDir(), 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) |