a1150245cc
Movified from686be57d0a
, and re-ran gofmt again to address for files not present in 20.10 and vice-versa. Signed-off-by: Sebastiaan van Stijn <github@gone.nl> (cherry picked from commit686be57d0a
) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
32 lines
800 B
Go
32 lines
800 B
Go
//go:build !windows
|
|
// +build !windows
|
|
|
|
package idtools // import "github.com/docker/docker/pkg/idtools"
|
|
|
|
import (
|
|
"fmt"
|
|
"os/exec"
|
|
"path/filepath"
|
|
)
|
|
|
|
func resolveBinary(binname string) (string, error) {
|
|
binaryPath, err := exec.LookPath(binname)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
resolvedPath, err := filepath.EvalSymlinks(binaryPath)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
// only return no error if the final resolved binary basename
|
|
// matches what was searched for
|
|
if filepath.Base(resolvedPath) == binname {
|
|
return resolvedPath, nil
|
|
}
|
|
return "", fmt.Errorf("Binary %q does not resolve to a binary of that name in $PATH (%q)", binname, resolvedPath)
|
|
}
|
|
|
|
func execCmd(cmd string, arg ...string) ([]byte, error) {
|
|
execCmd := exec.Command(cmd, arg...)
|
|
return execCmd.CombinedOutput()
|
|
}
|