summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Goltzsche <max.goltzsche@gmail.com>2021-06-19 23:34:25 +0200
committerMatthew Heon <mheon@redhat.com>2021-06-24 13:43:40 -0400
commite5c939183a709f4c6c1fd22df17cf641f78069da (patch)
treee6982f5abcfb956dd50a1b600f623b684b09504e
parent613f427a03d9a4ea29e32b9c2089d93b0866af29 (diff)
downloadpodman-e5c939183a709f4c6c1fd22df17cf641f78069da.tar.gz
podman-e5c939183a709f4c6c1fd22df17cf641f78069da.tar.bz2
podman-e5c939183a709f4c6c1fd22df17cf641f78069da.zip
Fix systemd-resolved detection.
Previously podman failed when run in an environment where 127.0.0.53 is the only nameserver but systemd-resolved is not used directly. In practice this happened when podman was run within an alpine container that used the host's network and the host was running systemd-resolved. This fix makes podman ignore a file not found error when reading /run/systemd/resolve/resolv.conf. Closes #10733 [NO TESTS NEEDED] Signed-off-by: Max Goltzsche <max.goltzsche@gmail.com>
-rw-r--r--libpod/container_internal_linux.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go
index be59e3b54..5f6493743 100644
--- a/libpod/container_internal_linux.go
+++ b/libpod/container_internal_linux.go
@@ -1659,9 +1659,13 @@ func (c *Container) generateResolvConf() (string, error) {
// 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")
+ resolvedContents, 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")
+ if !os.IsNotExist(err) {
+ return "", errors.Wrapf(err, "detected that systemd-resolved is in use, but could not locate real resolv.conf")
+ }
+ } else {
+ contents = resolvedContents
}
}