Skip to content
Snippets Groups Projects
Commit 7ee7b7426aad authored by Marc-Antoine Ruel's avatar Marc-Antoine Ruel
Browse files

posix: fix findexe() to check for file type and access

parent eb5ed02d8743
No related branches found
No related tags found
No related merge requests found
......@@ -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():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment