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