From 32210788a24525f579ad48185175e971c2d047ba Mon Sep 17 00:00:00 2001 From: Aaron Klotz Date: Tue, 30 Nov 2021 15:18:42 -0700 Subject: [PATCH] net/dns: fix checking for wrapped error when attempting to read wsl.conf for Windows WSL2 Fixes https://github.com/tailscale/tailscale/issues/3437 Signed-off-by: Aaron Klotz (cherry picked from commit f93cf6fa03b40b0f18d86ece74df98837716d234) --- net/dns/wsl_windows.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/dns/wsl_windows.go b/net/dns/wsl_windows.go index 9706af04a..c846c2ffa 100644 --- a/net/dns/wsl_windows.go +++ b/net/dns/wsl_windows.go @@ -6,6 +6,7 @@ import ( "bytes" + "errors" "fmt" "os" "os/exec" @@ -193,7 +194,8 @@ func (fs wslFS) Truncate(name string) error { return fs.WriteFile(name, nil, 064 func (fs wslFS) ReadFile(name string) ([]byte, error) { b, err := wslCombinedOutput(fs.cmd("cat", "--", name)) - if ee, _ := err.(*exec.ExitError); ee != nil && ee.ExitCode() == 1 { + var ee *exec.ExitError + if errors.As(err, &ee) && ee.ExitCode() == 1 { return nil, os.ErrNotExist } return b, err