-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-implemented salt.utils.path.which to properly define executable semantics on both the windows and posix platforms. #51785
Conversation
…mantics on both the windows and posix platforms.
…utils.path.which, and removed spaces from a set comprehension that the saltstack's linter didn't like.
…et synchronized via the remote-minion and master-minion-sync states.
Some of these tests need to be punted as they're dying due to a |
Still something to fix... just a moment here. |
…et synchronized via the remote-minion and master-minion-sync states.
…to get synchronized via the remote-minion and master-minion-sync states.
Force-pushed as the commit specified the wrong module path. |
…y can short-circuit the system_path search.
Hmm..why is
|
…plementation had an unncessary check.
…iginal author is assuming that ';' is being used.
Bah, this one also needs its tests punted as they're having that I patched the unit-tests to include an assignment to os.pathsep since it's ':' on linux, and also changed some of the side-effects of os.access since the original implementation had one more syscall than was necessary. |
…aths in case the PATH is non-existent.
… trying to simulate the existence of a file and not whether its executable or not.
Wow, am I reading this right? All the tests passed, yay. |
Thx @twangboy |
[master] Porting #51785 to master
What does this PR do?
The original
salt.utils.path.which()
function had a number of issues, one of which resulted in #51784. The original implementation did not appear to properly isolate windows and posix semantics which is why the issue came into existence. Another probably non-important issue is that memoization is attempted to be used, but on a function with no arguments which results in the performance benefit not being able to be taken advantage of. I assume the original author intended to use memoization to improve the peformance of the regular expression.In essence, this PR is the same as the following code but with the ability to follow links.
What issues does this PR fix or reference?
This fixes issue #51784, and also re-implements some of the optimizations that the original author desired.
Previous Behavior
In some instances (see #51784), the
salt.utils.path.which()
function would return non-(shell)-executable programs on the Windows platform, and also not benefit from memoization used to reduce the number of times a regular expression is matched (which it appears that the original author considered expensive)New Behavior
Now it splits up the posix and windows logic so that the windows implementation properly searches the path for executables according to the PATHEXT environment variable, posix version will follow links in order to identify whether the link is executable, and the matching of PATHEXT is done in constant-time without using regexes.
Tests written?
No
Commits signed with GPG?
No