changeset 15504:7ee7b7426aad

posix: fix findexe() to check for file type and access
author Marc-Antoine Ruel <maruel@google.com>
date Thu, 17 Nov 2011 15:44:37 -0600
parents eb5ed02d8743
children 5414b56cfad6
files mercurial/posix.py
diffstat 1 files changed, 2 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/posix.py	Tue Nov 15 02:44:55 2011 +0100
+++ b/mercurial/posix.py	Thu Nov 17 15:44:37 2011 -0600
@@ -258,7 +258,7 @@
 
     def findexisting(executable):
         'Will return executable if existing file'
-        if os.path.exists(executable):
+        if os.path.isfile(executable) and os.access(executable, os.X_OK):
             return executable
         return None
 
@@ -268,9 +268,7 @@
     for path in os.environ.get('PATH', '').split(os.pathsep):
         executable = findexisting(os.path.join(path, command))
         if executable is not None:
-            st = os.stat(executable)
-            if (st.st_mode & (stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)):
-                return executable
+            return executable
     return None
 
 def setsignalhandler():