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 <aaron@tailscale.com>
(cherry picked from commit f93cf6fa03)
This commit is contained in:
Aaron Klotz 2021-11-30 15:18:42 -07:00 committed by Brad Fitzpatrick
parent 3d9937513b
commit 32210788a2

View File

@ -6,6 +6,7 @@
import ( import (
"bytes" "bytes"
"errors"
"fmt" "fmt"
"os" "os"
"os/exec" "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) { func (fs wslFS) ReadFile(name string) ([]byte, error) {
b, err := wslCombinedOutput(fs.cmd("cat", "--", name)) 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 nil, os.ErrNotExist
} }
return b, err return b, err