summaryrefslogtreecommitdiffhomepage
path: root/runsc/specutils/specutils.go
diff options
context:
space:
mode:
authorNicolas Lacasse <nlacasse@google.com>2018-09-05 13:00:08 -0700
committerShentubot <shentubot@google.com>2018-09-05 13:01:21 -0700
commitf96b33c73c2150632a8a1ba22b1a420ec1f1214d (patch)
tree207ebf5d6495f53715d6d52fb5809ba8c647dfbf /runsc/specutils/specutils.go
parentbc5e18c9d1004ee324a794446416a6b108999b9c (diff)
runsc: Promote getExecutablePathInternal to getExecutablePath.
Remove GetExecutablePath (the non-internal version). This makes path handling more consistent between exec, root, and child containers. The new getExecutablePath now uses MountNamespace.FindInode, which is more robust than Walking the Dirent tree ourselves. This also removes the last use of lstat(2) in the sentry, so that can be removed from the filters. PiperOrigin-RevId: 211683110 Change-Id: Ic8ec960fc1c267aa7d310b8efe6e900c88a9207a
Diffstat (limited to 'runsc/specutils/specutils.go')
-rw-r--r--runsc/specutils/specutils.go31
1 files changed, 0 insertions, 31 deletions
diff --git a/runsc/specutils/specutils.go b/runsc/specutils/specutils.go
index 3234cc088..551718e9a 100644
--- a/runsc/specutils/specutils.go
+++ b/runsc/specutils/specutils.go
@@ -163,37 +163,6 @@ func ReadSpecFromFile(bundleDir string, specFile *os.File) (*specs.Spec, error)
return &spec, nil
}
-// GetExecutablePath returns the absolute path to the executable, relative to
-// the root. It searches the environment PATH for the first file that exists
-// with the given name.
-// TODO: Remove this in favor of finding executables via
-// boot.GetExecutablePathInternal.
-func GetExecutablePath(exec, root string, env []string) (string, error) {
- exec = filepath.Clean(exec)
-
- // Don't search PATH if exec is a path to a file (absolute or relative).
- if strings.IndexByte(exec, '/') >= 0 {
- return exec, nil
- }
-
- // Search the PATH for a file whose name matches the one we are looking
- // for.
- path := GetPath(env)
- for _, p := range path {
- abs := filepath.Join(root, p, exec)
- // Do not follow symlink link because the target is in the container
- // root filesystem.
- if _, err := os.Lstat(abs); err == nil {
- // We found it! Return the path relative to the root.
- return filepath.Join("/", p, exec), nil
- }
- }
-
- // Could not find a suitable path, just return the original string.
- log.Warningf("could not find executable %s in path %s", exec, path)
- return exec, nil
-}
-
// GetPath returns the PATH as a slice of strings given the environemnt
// variables.
func GetPath(env []string) []string {