diff options
author | baude <bbaude@redhat.com> | 2018-08-28 10:51:21 -0500 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-08-28 17:03:19 +0000 |
commit | 822c327997213f36f19936e54923b7c2776248b0 (patch) | |
tree | c3580ffeec9e840eef639c95f512c8da58e49ebb | |
parent | 14d567deae518878d529a437ce882393e00cc3c9 (diff) | |
download | podman-822c327997213f36f19936e54923b7c2776248b0.tar.gz podman-822c327997213f36f19936e54923b7c2776248b0.tar.bz2 podman-822c327997213f36f19936e54923b7c2776248b0.zip |
Resolve /etc/resolv.conf before reading
In some cases, /etc/resolv.conf can be a symlink to something like
/run/systemd/resolve/resolv.conf. We currently check for that file
and if it exists, use it instead of /etc/resolv.conf. However, we are
no seeing cases where the systemd resolv.conf exists but /etc/resolv.conf
is NOT a symlink.
Therefore, we now obtain the endpoint for /etc/resolv.conf whether it is a
symlink or not. That endpoint is now what is read to generate a container's
resolv.conf.
Signed-off-by: baude <bbaude@redhat.com>
Closes: #1368
Approved by: rhatdan
-rw-r--r-- | libpod/container_internal.go | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go index e276e0194..1c6143cd2 100644 --- a/libpod/container_internal.go +++ b/libpod/container_internal.go @@ -1007,13 +1007,10 @@ type resolvConf struct { // generateResolvConf generates a containers resolv.conf func (c *Container) generateResolvConf() (string, error) { - // Copy /etc/resolv.conf to the container's rundir - resolvPath := "/etc/resolv.conf" - - // Check if the host system is using system resolve and if so - // copy its resolv.conf - if _, err := os.Stat("/run/systemd/resolve/resolv.conf"); err == nil { - resolvPath = "/run/systemd/resolve/resolv.conf" + // Determine the endpoint for resolv.conf in case it is a symlink + resolvPath, err := filepath.EvalSymlinks("/etc/resolv.conf") + if err != nil { + return "", err } orig, err := ioutil.ReadFile(resolvPath) if err != nil { |