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

Emit error when binary file not executable #1769

Open
baude opened this issue Dec 15, 2023 · 1 comment
Open

Emit error when binary file not executable #1769

baude opened this issue Dec 15, 2023 · 1 comment

Comments

@baude
Copy link
Member

baude commented Dec 15, 2023

the FindBinaryHelper should emit an error if it finds the binary but it is not exectable instead of claiming it could not find it.

https://github.com/containers/common/blob/main/pkg/config/config.go#L1110

@giuseppe
Copy link
Member

we'd need to duplicate the code from os/exec.LookPath since it ignores files that are not executable.

Would it help if we improve the error message, something like:

diff --git a/pkg/config/config.go b/pkg/config/config.go
index 2e352db4..318015f1 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -1146,9 +1146,13 @@ func (c *Config) FindHelperBinary(name string, searchPATH bool) (string, error)
                }
        }
        if searchPATH {
-               return exec.LookPath(name)
+               p, err := exec.LookPath(name)
+               if errors.Is(err, exec.ErrNotFound) {
+                       return "", fmt.Errorf("could not find %q in $PATH (the file might be present but not executable): %w", name, err)
+               }
+               return p, err
        }
-       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."
+       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 and make sure the file has the executable bit set."
        if len(c.Engine.HelperBinariesDir.Get()) == 0 {
                return "", fmt.Errorf("could not find %q because there are no helper binary directories configured.  %s", name, configHint)
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants