mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
go back to defaulting wrapping commands in shell
this was taken out in an effort to default to the user's shell but creates issues as this is not known ahead of time and its painful to set executable and shell_type for all servers, it should only be needed for those that restrict the user to specific shells and when /bin/sh is not available. raw and command may still bypass this by explicitly passing None. fixes #13882 still conditional
This commit is contained in:
parent
3750af45d4
commit
c09c01a1f5
2 changed files with 4 additions and 5 deletions
|
@ -481,8 +481,7 @@ class ActionBase(with_metaclass(ABCMeta, object)):
|
||||||
display.debug("done with _execute_module (%s, %s)" % (module_name, module_args))
|
display.debug("done with _execute_module (%s, %s)" % (module_name, module_args))
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def _low_level_execute_command(self, cmd, sudoable=True, in_data=None,
|
def _low_level_execute_command(self, cmd, sudoable=True, in_data=None, executable=C.DEFAULT_EXECUTABLE, encoding_errors='replace'):
|
||||||
executable=None, encoding_errors='replace'):
|
|
||||||
'''
|
'''
|
||||||
This is the function which executes the low level shell command, which
|
This is the function which executes the low level shell command, which
|
||||||
may be commands to create/remove directories for temporary files, or to
|
may be commands to create/remove directories for temporary files, or to
|
||||||
|
@ -498,7 +497,7 @@ class ActionBase(with_metaclass(ABCMeta, object)):
|
||||||
'''
|
'''
|
||||||
|
|
||||||
if executable is not None:
|
if executable is not None:
|
||||||
cmd = executable + ' -c ' + cmd
|
cmd = executable + ' -c ' + pipes.quote(cmd)
|
||||||
|
|
||||||
display.debug("_low_level_execute_command(): starting")
|
display.debug("_low_level_execute_command(): starting")
|
||||||
if not cmd:
|
if not cmd:
|
||||||
|
|
|
@ -49,7 +49,7 @@ class TestActionBase(unittest.TestCase):
|
||||||
|
|
||||||
play_context.remote_user = 'apo'
|
play_context.remote_user = 'apo'
|
||||||
action_base._low_level_execute_command('ECHO', sudoable=True)
|
action_base._low_level_execute_command('ECHO', sudoable=True)
|
||||||
play_context.make_become_cmd.assert_called_once_with('ECHO', executable=None)
|
play_context.make_become_cmd.assert_called_once_with("/bin/sh -c ECHO", executable='/bin/sh')
|
||||||
|
|
||||||
play_context.make_become_cmd.reset_mock()
|
play_context.make_become_cmd.reset_mock()
|
||||||
|
|
||||||
|
@ -58,6 +58,6 @@ class TestActionBase(unittest.TestCase):
|
||||||
try:
|
try:
|
||||||
play_context.remote_user = 'root'
|
play_context.remote_user = 'root'
|
||||||
action_base._low_level_execute_command('ECHO SAME', sudoable=True)
|
action_base._low_level_execute_command('ECHO SAME', sudoable=True)
|
||||||
play_context.make_become_cmd.assert_called_once_with('ECHO SAME', executable=None)
|
play_context.make_become_cmd.assert_called_once_with("/bin/sh -c 'ECHO SAME'", executable='/bin/sh')
|
||||||
finally:
|
finally:
|
||||||
C.BECOME_ALLOW_SAME_USER = become_allow_same_user
|
C.BECOME_ALLOW_SAME_USER = become_allow_same_user
|
||||||
|
|
Loading…
Reference in a new issue