Skip to content

Commit

Permalink
Fixed a bug in salt.utils.path.which when a caller hardcodes an execu…
Browse files Browse the repository at this point in the history
…table extension.
  • Loading branch information
arizvisa committed Feb 23, 2019
1 parent 0989551 commit 00f981f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions salt/utils/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,17 @@ def has_executable_ext(path, ext_membership):
pathext = res.split(os.pathsep)
res = {ext.lower() for ext in pathext}

# ...apparently nobody uses operator or functools(?)
is_executable = lambda path, membership=res: is_executable_common(path) and has_executable_ext(path, membership)
# check if our caller already specified a valid extension as then we don't need to match it
_, ext = os.path.splitext(exe)
if ext.lower() in res:
pathext = ['']

is_executable = is_executable_common

# The specified extension isn't valid, so we just assume it's part of the
# filename and proceed to walk the pathext list
else:
is_executable = lambda path, membership=res: is_executable_common(path) and has_executable_ext(path, membership)

else:
# In posix, there's no such thing as file extensions..only zuul
Expand Down

0 comments on commit 00f981f

Please sign in to comment.