2
0
mirror of https://gitlab.com/ita1024/waf.git synced 2024-11-29 13:30:32 +01:00

Only detect binaries with execution permission

If for instance a program was in PATH and the file was marked
non-executable (`chmod -x`), `find_binary` it would still pick it up as
executable.
This commit is contained in:
Dan Church 2022-12-21 13:19:00 -06:00
parent c6b190734f
commit 78a1de612e
No known key found for this signature in database
GPG Key ID: EA2BF379CD2CDBD0

View File

@ -496,12 +496,12 @@ def find_binary(self, filenames, exts, paths):
for ext in exts:
exe_name = f + ext
if os.path.isabs(exe_name):
if os.path.isfile(exe_name):
if os.path.isfile(exe_name) and os.access(x, os.X_OK):
return exe_name
else:
for path in paths:
x = os.path.expanduser(os.path.join(path, exe_name))
if os.path.isfile(x):
if os.path.isfile(x) and os.access(x, os.X_OK):
return x
return None