Blob Blame History Raw
From 0556c53f7878c9ac2a59100c2752785482e806aa Mon Sep 17 00:00:00 2001
From: James Cammarata <jcammarata@ansibleworks.com>
Date: Tue, 18 Mar 2014 12:22:58 -0500
Subject: [PATCH] Execute commands through accelerate with shell when needed

This fixes an issue related to the new run_command changes, whereby
Popen fails to run a command when an executable is specified + shell=False
and there are multiple positional arguments (see Popen docs for details)
---
 library/utilities/accelerate | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/library/utilities/accelerate b/library/utilities/accelerate
index 6508f14..a61e54e 100644
--- a/library/utilities/accelerate
+++ b/library/utilities/accelerate
@@ -329,11 +329,15 @@ class ThreadedTCPRequestHandler(SocketServer.BaseRequestHandler):
             return dict(failed=True, msg='internal error: cmd is required')
         if 'tmp_path' not in data:
             return dict(failed=True, msg='internal error: tmp_path is required')
-        if 'executable' not in data:
-            return dict(failed=True, msg='internal error: executable is required')
 
         vvvv("executing: %s" % data['cmd'])
-        rc, stdout, stderr = self.server.module.run_command(data['cmd'], executable=data['executable'], close_fds=True)
+
+        use_unsafe_shell = False
+        executable = data.get('executable')
+        if executable:
+            use_unsafe_shell = True
+
+        rc, stdout, stderr = self.server.module.run_command(data['cmd'], executable=executable, use_unsafe_shell=use_unsafe_shell)
         if stdout is None:
             stdout = ''
         if stderr is None:
-- 
1.9.1