From 633ac50f03586326ec8f70a2a2c34b9e167f4bf0 Mon Sep 17 00:00:00 2001
From: "Paolo G. Giarrusso"
Date: Sun, 14 Aug 2016 13:05:19 +0200
Subject: [PATCH] Check executability in exec lookup (#2489)
Fix #2489. Nothing guarantees that files in the PATH are executable, and
Unix utilities handle this just fine.
---
src/System/Process/Read.hs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/System/Process/Read.hs b/src/System/Process/Read.hs
index 56630b88a1..5c76d8f87e 100644
--- a/src/System/Process/Read.hs
+++ b/src/System/Process/Read.hs
@@ -345,7 +345,8 @@ findExecutable eo name = liftIO $ do
testFPs [] = loop dirs
testFPs (fp:fps) = do
exists <- D.doesFileExist fp
- if exists
+ existsExec <- if exists then liftM D.executable $ D.getPermissions fp else return False
+ if existsExec
then do
fp' <- D.makeAbsolute fp >>= parseAbsFile
return $ return fp'