rootless cni: resolve absolute symlinks correctly

When /etc/resolv.conf is a symlink to an absolute path use it and not
join it the the previous path.

[NO TESTS NEEDED] This depends on the host layout.

Fixes #11358

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2021-08-30 16:49:02 +02:00
parent a2acd04447
commit 06f94dd09e

View File

@ -185,7 +185,13 @@ func (r *RootlessCNI) Do(toRun func() error) error {
// if there is no symlink exit
break
}
resolvePath = filepath.Join(filepath.Dir(resolvePath), link)
if filepath.IsAbs(link) {
// link is as an absolute path
resolvePath = link
} else {
// link is as a relative, join it with the previous path
resolvePath = filepath.Join(filepath.Dir(resolvePath), link)
}
if strings.HasPrefix(resolvePath, "/run/") {
break
}