Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve symlinks in config.FindHelperBinary #1303

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,14 @@ func (c *Config) FindHelperBinary(name string, searchPATH bool) (string, error)
bindirPath := ""
bindirSearched := false

tryResolveSymlink := func(path string) string {
symlinkedPath, err := filepath.EvalSymlinks(path)
if err != nil {
return path
}
return symlinkedPath
}

// If set, search this directory first. This is used in testing.
if dir, found := os.LookupEnv("CONTAINERS_HELPER_BINARY_DIR"); found {
dirList = append([]string{dir}, dirList...)
Expand All @@ -1332,11 +1340,15 @@ func (c *Config) FindHelperBinary(name string, searchPATH bool) (string, error)
}
fullpath := filepath.Join(path, name)
if fi, err := os.Stat(fullpath); err == nil && fi.Mode().IsRegular() {
return fullpath, nil
return tryResolveSymlink(fullpath), nil
}
}
if searchPATH {
return exec.LookPath(name)
path, err := exec.LookPath(name)
if err != nil {
return path, err
}
return tryResolveSymlink(path), nil
}
configHint := "To resolve this error, set the helper_binaries_dir key in the `[engine]` section of containers.conf to the directory containing your helper binaries."
if len(c.Engine.HelperBinariesDir) == 0 {
Expand Down