From 2a6c237d4cdf50d245ed38a371c3d6b11c981762 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sun, 23 Jul 2023 17:49:20 +0200 Subject: [PATCH] net/dns: overwrite /tmp/resolv.conf on gokrazy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Appliances built using https://gokrazy.org/ have a read-only root file system, including /etc/resolv.conf, which is a symlink to /tmp/resolv.conf. The system’s dhcp client overwrites /tmp/resolv.conf instead, so we need to use this path in Tailscale, too. related to https://github.com/gokrazy/gokrazy/issues/209 fixes https://github.com/tailscale/tailscale/issues/8689 Signed-off-by: Michael Stapelberg --- net/dns/direct.go | 5 ----- net/dns/resolvconfpath_default.go | 11 +++++++++++ net/dns/resolvconfpath_gokrazy.go | 11 +++++++++++ 3 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 net/dns/resolvconfpath_default.go create mode 100644 net/dns/resolvconfpath_gokrazy.go diff --git a/net/dns/direct.go b/net/dns/direct.go index 0cae70d0e..e9279d13a 100644 --- a/net/dns/direct.go +++ b/net/dns/direct.go @@ -27,11 +27,6 @@ import ( "tailscale.com/version/distro" ) -const ( - backupConf = "/etc/resolv.pre-tailscale-backup.conf" - resolvConf = "/etc/resolv.conf" -) - // writeResolvConf writes DNS configuration in resolv.conf format to the given writer. func writeResolvConf(w io.Writer, servers []netip.Addr, domains []dnsname.FQDN) error { c := &resolvconffile.Config{ diff --git a/net/dns/resolvconfpath_default.go b/net/dns/resolvconfpath_default.go new file mode 100644 index 000000000..57e82c4c7 --- /dev/null +++ b/net/dns/resolvconfpath_default.go @@ -0,0 +1,11 @@ +// Copyright (c) Tailscale Inc & AUTHORS +// SPDX-License-Identifier: BSD-3-Clause + +//go:build !gokrazy + +package dns + +const ( + resolvConf = "/etc/resolv.conf" + backupConf = "/etc/resolv.pre-tailscale-backup.conf" +) diff --git a/net/dns/resolvconfpath_gokrazy.go b/net/dns/resolvconfpath_gokrazy.go new file mode 100644 index 000000000..f0759b0e3 --- /dev/null +++ b/net/dns/resolvconfpath_gokrazy.go @@ -0,0 +1,11 @@ +// Copyright (c) Tailscale Inc & AUTHORS +// SPDX-License-Identifier: BSD-3-Clause + +//go:build gokrazy + +package dns + +const ( + resolvConf = "/tmp/resolv.conf" + backupConf = "/tmp/resolv.pre-tailscale-backup.conf" +)