-
Notifications
You must be signed in to change notification settings - Fork 23.8k
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
Assign executable in popen only if it is explicitly set #31347
Conversation
* As default executable is None assign executable value only if it set explicitly.
lib/ansible/module_utils/basic.py
Outdated
if executable: | ||
args = [executable, '-c', args] | ||
else: | ||
shell = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is incorrect, the caller is specifically asking to use shell
lib/ansible/module_utils/basic.py
Outdated
if use_unsafe_shell: | ||
if executable is None: | ||
executable = os.environ.get('SHELL') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure why you are removing this, i can see issues with invalid shell/blocker shells set (nologin, /bin/false) but we can work around that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so reread what $SHELL means .. seems i made a mistake, i assumed it was 'current shell' but it is the 'default shell', probably removing these 2 lines will fix most issues, the else: shell = True
below should stay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing these lines will re-break: #24169
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OTOH, we might need to find a new fix for #24169 as bcoca is quoting the POSIX definition of SHELL above and the POSIX definition of popen http://pubs.opengroup.org/onlinepubs/9699919799/ seems to be why this is hardcoded to sh in the first place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not really, this works 'by accident', only when default shell matches the executable requested, as my previous comment states, i misinterpreted what the value of $SHELL
represents
After rereading, actual fix of the ticket would require we pass ansible_shell_executable information to all modules and fallback to that
lib/ansible/module_utils/basic.py
Outdated
@@ -2621,14 +2622,9 @@ def run_command(self, args, check_rc=False, close_fds=True, executable=None, dat | |||
msg = "Argument 'args' to run_command must be list or string" | |||
self.fail_json(rc=257, cmd=args, msg=msg) | |||
|
|||
shell = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not move this. You may want to remove setting shell = True in the above conditional block, though.
Another note, when you cherry-pick this you'll probably want to cherry pick 5f22b4f as well (it wasn't deemed important enough to backport but it shouldn't change any behaviour so it should be safe to do so.) |
Closing this as we will need something like #31361 to fix both bugs. The ios_command bug has been fixed in 2.4.1 by reverting the original commit. |
SUMMARY
Fixes #30836
only if it set explicitly.
ISSUE TYPE
COMPONENT NAME
module_utils/basic.py
ANSIBLE VERSION
ADDITIONAL INFORMATION
Playbook:
Before:
After