Allow to change executable (shell/interpreter) when using raw

This patch adds an optional 'executable=' option to the raw command line to override the default shell (/bin/sh), much like the shell module does.
This commit is contained in:
Dag Wieers 2012-12-23 19:17:07 +01:00
parent 3d3deb9797
commit 846161a1a4
8 changed files with 51 additions and 24 deletions

View file

@ -34,7 +34,15 @@ class ActionModule(object):
self.runner = runner
def run(self, conn, tmp, module_name, module_args, inject):
return ReturnData(conn=conn,
result=self.runner._low_level_exec_command(conn, module_args.encode('utf-8'), tmp, sudoable=True)
)
executable = None
args = []
for arg in module_args.split(' '):
if arg.startswith('executable='):
executable = '='.join(arg.split('=')[1:])
else:
args.append(arg)
module_args = ' '.join(args).encode('utf-8')
return ReturnData(conn=conn,
result=self.runner._low_level_exec_command(conn, module_args, tmp, sudoable=True, executable=executable)
)