summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-06-08 20:08:25 +0200
committerGitHub <noreply@github.com>2021-06-08 20:08:25 +0200
commit9edd08c3f16d5730ac783fde3706bda49401b79f (patch)
treef091eb45d5faad51f73d14e05155220abc1ef243 /libpod
parent3d961acc222b89bca466cfd385e31f8300a3e021 (diff)
parent18fa124dfc5c04cd985446e2e12acc4d1832a45c (diff)
downloadpodman-9edd08c3f16d5730ac783fde3706bda49401b79f.tar.gz
podman-9edd08c3f16d5730ac783fde3706bda49401b79f.tar.bz2
podman-9edd08c3f16d5730ac783fde3706bda49401b79f.zip
Merge pull request #10598 from Luap99/systemd-resolved
Improve systemd-resolved detection
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_internal_linux.go20
1 files changed, 9 insertions, 11 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go
index a3acc3198..94bf7855b 100644
--- a/libpod/container_internal_linux.go
+++ b/libpod/container_internal_linux.go
@@ -1650,22 +1650,20 @@ func (c *Container) generateResolvConf() (string, error) {
}
}
- // Determine the endpoint for resolv.conf in case it is a symlink
- resolvPath, err := filepath.EvalSymlinks(resolvConf)
+ contents, err := ioutil.ReadFile(resolvConf)
// resolv.conf doesn't have to exists
if err != nil && !os.IsNotExist(err) {
return "", err
}
- // Determine if symlink points to any of the systemd-resolved files
- if strings.HasPrefix(resolvPath, "/run/systemd/resolve/") {
- resolvPath = "/run/systemd/resolve/resolv.conf"
- }
-
- contents, err := ioutil.ReadFile(resolvPath)
- // resolv.conf doesn't have to exists
- if err != nil && !os.IsNotExist(err) {
- return "", err
+ ns := resolvconf.GetNameservers(contents)
+ // check if systemd-resolved is used, assume it is used when 127.0.0.53 is the only nameserver
+ if len(ns) == 1 && ns[0] == "127.0.0.53" {
+ // read the actual resolv.conf file for systemd-resolved
+ contents, err = ioutil.ReadFile("/run/systemd/resolve/resolv.conf")
+ if err != nil {
+ return "", errors.Wrapf(err, "detected that systemd-resolved is in use, but could not locate real resolv.conf")
+ }
}
ipv6 := false