2023-01-28 05:37:20 +08:00
|
|
|
// Copyright (c) Tailscale Inc & AUTHORS
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
2020-07-14 21:12:00 +08:00
|
|
|
|
2021-08-06 06:42:39 +08:00
|
|
|
//go:build linux || freebsd || openbsd
|
2021-04-30 03:34:34 +08:00
|
|
|
|
2020-08-01 04:27:09 +08:00
|
|
|
package dns
|
2020-07-14 21:12:00 +08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"os/exec"
|
|
|
|
)
|
|
|
|
|
2021-09-05 14:40:48 +08:00
|
|
|
func resolvconfStyle() string {
|
|
|
|
if _, err := exec.LookPath("resolvconf"); err != nil {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
if _, err := exec.Command("resolvconf", "--version").CombinedOutput(); err != nil {
|
|
|
|
// Debian resolvconf doesn't understand --version, and
|
|
|
|
// exits with a specific error code.
|
2021-04-11 14:31:00 +08:00
|
|
|
if exitErr, ok := err.(*exec.ExitError); ok && exitErr.ExitCode() == 99 {
|
2021-09-05 14:40:48 +08:00
|
|
|
return "debian"
|
2021-04-11 13:37:13 +08:00
|
|
|
}
|
|
|
|
}
|
2021-09-05 14:40:48 +08:00
|
|
|
// Treat everything else as openresolv, by far the more popular implementation.
|
|
|
|
return "openresolv"
|
2020-07-14 21:12:00 +08:00
|
|
|
}
|