From 9f60678e039e7c51d83712df95b7b2396c12e00f Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sun, 22 Nov 2020 21:37:41 +0100 Subject: tunnel: set %WIREGUARD_INTERFACE_NAME% instead of expanding %i While this diverges from wg-quick(8), it's also much more Windows-friendly, considering that % is the prefix for expanding environment variables in cmd.exe. Signed-off-by: Jason A. Donenfeld --- tunnel/scriptrunner.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'tunnel') diff --git a/tunnel/scriptrunner.go b/tunnel/scriptrunner.go index ba6aec9b..670bb2a1 100644 --- a/tunnel/scriptrunner.go +++ b/tunnel/scriptrunner.go @@ -11,7 +11,6 @@ import ( "log" "os" "path/filepath" - "strings" "syscall" "golang.org/x/sys/windows" @@ -27,7 +26,6 @@ func runScriptCommand(command, interfaceName string) error { log.Printf("Skipping execution of script, because dangerous script execution is safely disabled: %#q", command) return nil } - command = strings.ReplaceAll(command, "%i", interfaceName) log.Printf("Executing: %#q", command) comspec, _ := os.LookupEnv("COMSPEC") if len(comspec) == 0 { @@ -49,6 +47,7 @@ func runScriptCommand(command, interfaceName string) error { } process, err := os.StartProcess(comspec, nil /* CmdLine below */, &os.ProcAttr{ Files: []*os.File{devNull, writer, writer}, + Env: append(os.Environ(), "WIREGUARD_TUNNEL_NAME="+interfaceName), Sys: &syscall.SysProcAttr{ HideWindow: true, CmdLine: fmt.Sprintf("cmd /c %s", command), -- cgit v1.2.3-59-g8ed1b