From 9dce713f28f08e1b4edd3ead524580c944b79326 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Mon, 30 Aug 2021 16:49:02 +0200 Subject: [PATCH] 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 --- libpod/networking_linux.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libpod/networking_linux.go b/libpod/networking_linux.go index 7eef04ddf1..e41aebb4a8 100644 --- a/libpod/networking_linux.go +++ b/libpod/networking_linux.go @@ -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 }