1// +build !windows
2
3package idtools // import "github.com/docker/docker/pkg/idtools"
4
5import (
6	"fmt"
7	"os/exec"
8	"path/filepath"
9	"strings"
10)
11
12func resolveBinary(binname string) (string, error) {
13	binaryPath, err := exec.LookPath(binname)
14	if err != nil {
15		return "", err
16	}
17	resolvedPath, err := filepath.EvalSymlinks(binaryPath)
18	if err != nil {
19		return "", err
20	}
21	//only return no error if the final resolved binary basename
22	//matches what was searched for
23	if filepath.Base(resolvedPath) == binname {
24		return resolvedPath, nil
25	}
26	return "", fmt.Errorf("Binary %q does not resolve to a binary of that name in $PATH (%q)", binname, resolvedPath)
27}
28
29func execCmd(cmd, args string) ([]byte, error) {
30	execCmd := exec.Command(cmd, strings.Split(args, " ")...)
31	return execCmd.CombinedOutput()
32}
33