2023-01-27 21:37:20 +00:00
|
|
|
// Copyright (c) Tailscale Inc & AUTHORS
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
2020-07-14 13:12:00 +00:00
|
|
|
|
2021-08-05 22:42:39 +00:00
|
|
|
//go:build linux || freebsd || openbsd
|
2021-04-29 19:34:34 +00:00
|
|
|
|
2020-07-31 20:27:09 +00:00
|
|
|
package dns
|
2020-07-14 13:12:00 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"os/exec"
|
|
|
|
)
|
|
|
|
|
2021-09-05 06:40:48 +00: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 06:31:00 +00:00
|
|
|
if exitErr, ok := err.(*exec.ExitError); ok && exitErr.ExitCode() == 99 {
|
2021-09-05 06:40:48 +00:00
|
|
|
return "debian"
|
2021-04-11 05:37:13 +00:00
|
|
|
}
|
|
|
|
}
|
2021-09-05 06:40:48 +00:00
|
|
|
// Treat everything else as openresolv, by far the more popular implementation.
|
|
|
|
return "openresolv"
|
2020-07-14 13:12:00 +00:00
|
|
|
}
|