Skip to content

Commit

Permalink
rootless cni: resolve absolute symlinks correctly
Browse files Browse the repository at this point in the history
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 containers#11358

Signed-off-by: Paul Holzinger <[email protected]>
  • Loading branch information
Luap99 committed Aug 30, 2021
1 parent a2acd04 commit 06f94dd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion libpod/networking_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 06f94dd

Please sign in to comment.