From 244544b735a8dbac0e14e7ee85e12a39780cbbb9 Mon Sep 17 00:00:00 2001 From: Mahmood Ali Date: Tue, 2 Apr 2019 20:00:54 -0400 Subject: [PATCH] an alternative order --- drivers/shared/executor/executor.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/shared/executor/executor.go b/drivers/shared/executor/executor.go index 7eea886a8fe4..699d3247ae65 100644 --- a/drivers/shared/executor/executor.go +++ b/drivers/shared/executor/executor.go @@ -561,6 +561,14 @@ func lookupBin(taskDir string, bin string) (string, error) { return root, nil } + // when checking host paths, check with Stat first if path is absolute + // as exec.LookPath only considers files already marked as executable + // and only consider this for absolute paths to avoid depending on + // current directory of nomad which may cause unexpected behavior + if _, err := os.Stat(bin); err == nil && filepath.IsAbs(bin) { + return bin, nil + } + // Check the $PATH if host, err := exec.LookPath(bin); err == nil { return host, nil